Tizen 2.1 base tizen_2.1 2.1b_release 2.2_release accepted/tizen_2.1/20130425.024326 submit/tizen_2.1/20130424.224356 submit/tizen_2.2/20130714.134603 submit/tizen_2.2/20130714.143236
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:39:37 +0000 (01:39 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:39:37 +0000 (01:39 +0900)
912 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
HACKING [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
Makefile.inc [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
acinclude.m4 [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
augeas.pc.in [new file with mode: 0644]
augeas.spec [new file with mode: 0644]
augeas.spec.in [new file with mode: 0644]
build/aux/arg-nonnull.h [new file with mode: 0644]
build/aux/c++defs.h [new file with mode: 0644]
build/aux/config.guess [new file with mode: 0755]
build/aux/config.rpath [new file with mode: 0755]
build/aux/config.sub [new file with mode: 0755]
build/aux/depcomp [new file with mode: 0755]
build/aux/gitlog-to-changelog [new file with mode: 0755]
build/aux/install-sh [new file with mode: 0755]
build/aux/ltmain.sh [new file with mode: 0755]
build/aux/missing [new file with mode: 0755]
build/aux/move-if-change [new file with mode: 0755]
build/aux/unused-parameter.h [new file with mode: 0644]
build/aux/warn-on-use.h [new file with mode: 0644]
build/aux/ylwrap [new file with mode: 0755]
config.h.in [new file with mode: 0644]
configure [new file with mode: 0755]
configure.ac [new file with mode: 0644]
doc/Makefile.am [new file with mode: 0644]
doc/Makefile.in [new file with mode: 0644]
doc/bcprules.sty [new file with mode: 0644]
doc/ftdetect/augeas.vim [new file with mode: 0644]
doc/lenses.tex [new file with mode: 0644]
doc/naturaldocs/Makefile.am [new file with mode: 0644]
doc/naturaldocs/Makefile.in [new file with mode: 0644]
doc/naturaldocs/Modules/NaturalDocs/Languages/Augeas.pm [new file with mode: 0644]
doc/naturaldocs/conf/Augeas.css [new file with mode: 0644]
doc/naturaldocs/conf/c_api/Languages.txt [new file with mode: 0644]
doc/naturaldocs/conf/c_api/Menu.txt [new file with mode: 0644]
doc/naturaldocs/conf/c_api/Topics.txt [new file with mode: 0644]
doc/naturaldocs/conf/lenses/Languages.txt [new file with mode: 0644]
doc/naturaldocs/conf/lenses/Menu.txt [new file with mode: 0644]
doc/naturaldocs/conf/lenses/Topics.txt [new file with mode: 0644]
doc/syntax/augeas.vim [new file with mode: 0644]
doc/unambig.tex [new file with mode: 0644]
doc/xpath.txt [new file with mode: 0644]
examples/Makefile.am [new file with mode: 0644]
examples/Makefile.in [new file with mode: 0644]
examples/fadot.c [new file with mode: 0644]
gnulib/lib/Makefile.am [new file with mode: 0644]
gnulib/lib/Makefile.in [new file with mode: 0644]
gnulib/lib/alloca.c [new file with mode: 0644]
gnulib/lib/alloca.in.h [new file with mode: 0644]
gnulib/lib/argz.c [new file with mode: 0644]
gnulib/lib/argz.in.h [new file with mode: 0644]
gnulib/lib/asnprintf.c [new file with mode: 0644]
gnulib/lib/asprintf.c [new file with mode: 0644]
gnulib/lib/btowc.c [new file with mode: 0644]
gnulib/lib/canonicalize-lgpl.c [new file with mode: 0644]
gnulib/lib/config.charset [new file with mode: 0644]
gnulib/lib/ctype.in.h [new file with mode: 0644]
gnulib/lib/dosname.h [new file with mode: 0644]
gnulib/lib/errno.in.h [new file with mode: 0644]
gnulib/lib/float+.h [new file with mode: 0644]
gnulib/lib/float.in.h [new file with mode: 0644]
gnulib/lib/fnmatch.c [new file with mode: 0644]
gnulib/lib/fnmatch.in.h [new file with mode: 0644]
gnulib/lib/fnmatch_loop.c [new file with mode: 0644]
gnulib/lib/getdelim.c [new file with mode: 0644]
gnulib/lib/getfilecon.c [new file with mode: 0644]
gnulib/lib/getline.c [new file with mode: 0644]
gnulib/lib/getopt.c [new file with mode: 0644]
gnulib/lib/getopt.in.h [new file with mode: 0644]
gnulib/lib/getopt1.c [new file with mode: 0644]
gnulib/lib/getopt_int.h [new file with mode: 0644]
gnulib/lib/gettext.h [new file with mode: 0644]
gnulib/lib/isblank.c [new file with mode: 0644]
gnulib/lib/langinfo.in.h [new file with mode: 0644]
gnulib/lib/localcharset.c [new file with mode: 0644]
gnulib/lib/localcharset.h [new file with mode: 0644]
gnulib/lib/locale.in.h [new file with mode: 0644]
gnulib/lib/lstat.c [new file with mode: 0644]
gnulib/lib/malloc.c [new file with mode: 0644]
gnulib/lib/malloca.c [new file with mode: 0644]
gnulib/lib/malloca.h [new file with mode: 0644]
gnulib/lib/malloca.valgrind [new file with mode: 0644]
gnulib/lib/mbrtowc.c [new file with mode: 0644]
gnulib/lib/mbsinit.c [new file with mode: 0644]
gnulib/lib/mbsrtowcs-impl.h [new file with mode: 0644]
gnulib/lib/mbsrtowcs-state.c [new file with mode: 0644]
gnulib/lib/mbsrtowcs.c [new file with mode: 0644]
gnulib/lib/mbtowc-impl.h [new file with mode: 0644]
gnulib/lib/mbtowc.c [new file with mode: 0644]
gnulib/lib/memchr.c [new file with mode: 0644]
gnulib/lib/memchr.valgrind [new file with mode: 0644]
gnulib/lib/mempcpy.c [new file with mode: 0644]
gnulib/lib/nl_langinfo.c [new file with mode: 0644]
gnulib/lib/pathmax.h [new file with mode: 0644]
gnulib/lib/printf-args.c [new file with mode: 0644]
gnulib/lib/printf-args.h [new file with mode: 0644]
gnulib/lib/printf-parse.c [new file with mode: 0644]
gnulib/lib/printf-parse.h [new file with mode: 0644]
gnulib/lib/readlink.c [new file with mode: 0644]
gnulib/lib/realloc.c [new file with mode: 0644]
gnulib/lib/ref-add.sin [new file with mode: 0644]
gnulib/lib/ref-del.sin [new file with mode: 0644]
gnulib/lib/regcomp.c [new file with mode: 0644]
gnulib/lib/regex.c [new file with mode: 0644]
gnulib/lib/regex.h [new file with mode: 0644]
gnulib/lib/regex_internal.c [new file with mode: 0644]
gnulib/lib/regex_internal.h [new file with mode: 0644]
gnulib/lib/regexec.c [new file with mode: 0644]
gnulib/lib/safe-alloc.c [new file with mode: 0644]
gnulib/lib/safe-alloc.h [new file with mode: 0644]
gnulib/lib/se-context.in.h [new file with mode: 0644]
gnulib/lib/se-selinux.in.h [new file with mode: 0644]
gnulib/lib/size_max.h [new file with mode: 0644]
gnulib/lib/stat.c [new file with mode: 0644]
gnulib/lib/stdbool.in.h [new file with mode: 0644]
gnulib/lib/stddef.in.h [new file with mode: 0644]
gnulib/lib/stdint.in.h [new file with mode: 0644]
gnulib/lib/stdio.in.h [new file with mode: 0644]
gnulib/lib/stdlib.in.h [new file with mode: 0644]
gnulib/lib/stpcpy.c [new file with mode: 0644]
gnulib/lib/stpncpy.c [new file with mode: 0644]
gnulib/lib/str-two-way.h [new file with mode: 0644]
gnulib/lib/streq.h [new file with mode: 0644]
gnulib/lib/string.in.h [new file with mode: 0644]
gnulib/lib/strndup.c [new file with mode: 0644]
gnulib/lib/strnlen.c [new file with mode: 0644]
gnulib/lib/strnlen1.c [new file with mode: 0644]
gnulib/lib/strnlen1.h [new file with mode: 0644]
gnulib/lib/strstr.c [new file with mode: 0644]
gnulib/lib/sys_stat.in.h [new file with mode: 0644]
gnulib/lib/sys_wait.in.h [new file with mode: 0644]
gnulib/lib/time.in.h [new file with mode: 0644]
gnulib/lib/unistd.in.h [new file with mode: 0644]
gnulib/lib/vasnprintf.c [new file with mode: 0644]
gnulib/lib/vasnprintf.h [new file with mode: 0644]
gnulib/lib/vasprintf.c [new file with mode: 0644]
gnulib/lib/verify.h [new file with mode: 0644]
gnulib/lib/wchar.in.h [new file with mode: 0644]
gnulib/lib/wcrtomb.c [new file with mode: 0644]
gnulib/lib/wctype.in.h [new file with mode: 0644]
gnulib/lib/xsize.h [new file with mode: 0644]
gnulib/m4/00gnulib.m4 [new file with mode: 0644]
gnulib/m4/alloca.m4 [new file with mode: 0644]
gnulib/m4/argz.m4 [new file with mode: 0644]
gnulib/m4/btowc.m4 [new file with mode: 0644]
gnulib/m4/canonicalize.m4 [new file with mode: 0644]
gnulib/m4/codeset.m4 [new file with mode: 0644]
gnulib/m4/configmake.m4 [new file with mode: 0644]
gnulib/m4/ctype.m4 [new file with mode: 0644]
gnulib/m4/double-slash-root.m4 [new file with mode: 0644]
gnulib/m4/dup2.m4 [new file with mode: 0644]
gnulib/m4/eealloc.m4 [new file with mode: 0644]
gnulib/m4/environ.m4 [new file with mode: 0644]
gnulib/m4/errno_h.m4 [new file with mode: 0644]
gnulib/m4/extensions.m4 [new file with mode: 0644]
gnulib/m4/fcntl-o.m4 [new file with mode: 0644]
gnulib/m4/fcntl_h.m4 [new file with mode: 0644]
gnulib/m4/float_h.m4 [new file with mode: 0644]
gnulib/m4/fnmatch.m4 [new file with mode: 0644]
gnulib/m4/getdelim.m4 [new file with mode: 0644]
gnulib/m4/getline.m4 [new file with mode: 0644]
gnulib/m4/getopt.m4 [new file with mode: 0644]
gnulib/m4/getpagesize.m4 [new file with mode: 0644]
gnulib/m4/glibc21.m4 [new file with mode: 0644]
gnulib/m4/gnulib-common.m4 [new file with mode: 0644]
gnulib/m4/gnulib-comp.m4 [new file with mode: 0644]
gnulib/m4/include_next.m4 [new file with mode: 0644]
gnulib/m4/intlmacosx.m4 [new file with mode: 0644]
gnulib/m4/intmax_t.m4 [new file with mode: 0644]
gnulib/m4/inttypes_h.m4 [new file with mode: 0644]
gnulib/m4/isblank.m4 [new file with mode: 0644]
gnulib/m4/langinfo_h.m4 [new file with mode: 0644]
gnulib/m4/lcmessage.m4 [new file with mode: 0644]
gnulib/m4/lib-ld.m4 [new file with mode: 0644]
gnulib/m4/lib-link.m4 [new file with mode: 0644]
gnulib/m4/lib-prefix.m4 [new file with mode: 0644]
gnulib/m4/libtool.m4 [new file with mode: 0644]
gnulib/m4/localcharset.m4 [new file with mode: 0644]
gnulib/m4/locale-fr.m4 [new file with mode: 0644]
gnulib/m4/locale-ja.m4 [new file with mode: 0644]
gnulib/m4/locale-tr.m4 [new file with mode: 0644]
gnulib/m4/locale-zh.m4 [new file with mode: 0644]
gnulib/m4/locale_h.m4 [new file with mode: 0644]
gnulib/m4/localename.m4 [new file with mode: 0644]
gnulib/m4/lock.m4 [new file with mode: 0644]
gnulib/m4/longlong.m4 [new file with mode: 0644]
gnulib/m4/lstat.m4 [new file with mode: 0644]
gnulib/m4/ltoptions.m4 [new file with mode: 0644]
gnulib/m4/ltsugar.m4 [new file with mode: 0644]
gnulib/m4/ltversion.m4 [new file with mode: 0644]
gnulib/m4/lt~obsolete.m4 [new file with mode: 0644]
gnulib/m4/malloc.m4 [new file with mode: 0644]
gnulib/m4/malloca.m4 [new file with mode: 0644]
gnulib/m4/mbrtowc.m4 [new file with mode: 0644]
gnulib/m4/mbsinit.m4 [new file with mode: 0644]
gnulib/m4/mbsrtowcs.m4 [new file with mode: 0644]
gnulib/m4/mbstate_t.m4 [new file with mode: 0644]
gnulib/m4/mbtowc.m4 [new file with mode: 0644]
gnulib/m4/memchr.m4 [new file with mode: 0644]
gnulib/m4/mempcpy.m4 [new file with mode: 0644]
gnulib/m4/mmap-anon.m4 [new file with mode: 0644]
gnulib/m4/mode_t.m4 [new file with mode: 0644]
gnulib/m4/multiarch.m4 [new file with mode: 0644]
gnulib/m4/nl_langinfo.m4 [new file with mode: 0644]
gnulib/m4/onceonly.m4 [new file with mode: 0644]
gnulib/m4/open.m4 [new file with mode: 0644]
gnulib/m4/pathmax.m4 [new file with mode: 0644]
gnulib/m4/printf.m4 [new file with mode: 0644]
gnulib/m4/putenv.m4 [new file with mode: 0644]
gnulib/m4/readlink.m4 [new file with mode: 0644]
gnulib/m4/realloc.m4 [new file with mode: 0644]
gnulib/m4/regex.m4 [new file with mode: 0644]
gnulib/m4/safe-alloc.m4 [new file with mode: 0644]
gnulib/m4/selinux-context-h.m4 [new file with mode: 0644]
gnulib/m4/selinux-selinux-h.m4 [new file with mode: 0644]
gnulib/m4/setenv.m4 [new file with mode: 0644]
gnulib/m4/setlocale.m4 [new file with mode: 0644]
gnulib/m4/size_max.m4 [new file with mode: 0644]
gnulib/m4/ssize_t.m4 [new file with mode: 0644]
gnulib/m4/stat.m4 [new file with mode: 0644]
gnulib/m4/stdbool.m4 [new file with mode: 0644]
gnulib/m4/stddef_h.m4 [new file with mode: 0644]
gnulib/m4/stdint.m4 [new file with mode: 0644]
gnulib/m4/stdint_h.m4 [new file with mode: 0644]
gnulib/m4/stdio_h.m4 [new file with mode: 0644]
gnulib/m4/stdlib_h.m4 [new file with mode: 0644]
gnulib/m4/stpcpy.m4 [new file with mode: 0644]
gnulib/m4/stpncpy.m4 [new file with mode: 0644]
gnulib/m4/string_h.m4 [new file with mode: 0644]
gnulib/m4/strndup.m4 [new file with mode: 0644]
gnulib/m4/strnlen.m4 [new file with mode: 0644]
gnulib/m4/strstr.m4 [new file with mode: 0644]
gnulib/m4/symlink.m4 [new file with mode: 0644]
gnulib/m4/sys_stat_h.m4 [new file with mode: 0644]
gnulib/m4/sys_wait_h.m4 [new file with mode: 0644]
gnulib/m4/thread.m4 [new file with mode: 0644]
gnulib/m4/threadlib.m4 [new file with mode: 0644]
gnulib/m4/time_h.m4 [new file with mode: 0644]
gnulib/m4/unistd_h.m4 [new file with mode: 0644]
gnulib/m4/vasnprintf.m4 [new file with mode: 0644]
gnulib/m4/vasprintf.m4 [new file with mode: 0644]
gnulib/m4/warn-on-use.m4 [new file with mode: 0644]
gnulib/m4/wchar_h.m4 [new file with mode: 0644]
gnulib/m4/wchar_t.m4 [new file with mode: 0644]
gnulib/m4/wcrtomb.m4 [new file with mode: 0644]
gnulib/m4/wctob.m4 [new file with mode: 0644]
gnulib/m4/wctomb.m4 [new file with mode: 0644]
gnulib/m4/wctype_h.m4 [new file with mode: 0644]
gnulib/m4/wint_t.m4 [new file with mode: 0644]
gnulib/m4/xsize.m4 [new file with mode: 0644]
gnulib/m4/yield.m4 [new file with mode: 0644]
gnulib/tests/Makefile.am [new file with mode: 0644]
gnulib/tests/Makefile.in [new file with mode: 0644]
gnulib/tests/binary-io.h [new file with mode: 0644]
gnulib/tests/c-ctype.c [new file with mode: 0644]
gnulib/tests/c-ctype.h [new file with mode: 0644]
gnulib/tests/c-strcase.h [new file with mode: 0644]
gnulib/tests/c-strcasecmp.c [new file with mode: 0644]
gnulib/tests/c-strncasecmp.c [new file with mode: 0644]
gnulib/tests/dup2.c [new file with mode: 0644]
gnulib/tests/fcntl.in.h [new file with mode: 0644]
gnulib/tests/getpagesize.c [new file with mode: 0644]
gnulib/tests/glthread/lock.c [new file with mode: 0644]
gnulib/tests/glthread/lock.h [new file with mode: 0644]
gnulib/tests/glthread/thread.c [new file with mode: 0644]
gnulib/tests/glthread/thread.h [new file with mode: 0644]
gnulib/tests/glthread/threadlib.c [new file with mode: 0644]
gnulib/tests/glthread/yield.h [new file with mode: 0644]
gnulib/tests/ignore-value.h [new file with mode: 0644]
gnulib/tests/init.sh [new file with mode: 0644]
gnulib/tests/intprops.h [new file with mode: 0644]
gnulib/tests/localename.c [new file with mode: 0644]
gnulib/tests/localename.h [new file with mode: 0644]
gnulib/tests/macros.h [new file with mode: 0644]
gnulib/tests/open.c [new file with mode: 0644]
gnulib/tests/putenv.c [new file with mode: 0644]
gnulib/tests/same-inode.h [new file with mode: 0644]
gnulib/tests/setenv.c [new file with mode: 0644]
gnulib/tests/setlocale.c [new file with mode: 0644]
gnulib/tests/signature.h [new file with mode: 0644]
gnulib/tests/symlink.c [new file with mode: 0644]
gnulib/tests/test-alloca-opt.c [new file with mode: 0644]
gnulib/tests/test-binary-io.c [new file with mode: 0644]
gnulib/tests/test-binary-io.sh [new file with mode: 0755]
gnulib/tests/test-btowc.c [new file with mode: 0644]
gnulib/tests/test-btowc1.sh [new file with mode: 0755]
gnulib/tests/test-btowc2.sh [new file with mode: 0755]
gnulib/tests/test-c-ctype.c [new file with mode: 0644]
gnulib/tests/test-c-strcase.sh [new file with mode: 0755]
gnulib/tests/test-c-strcasecmp.c [new file with mode: 0644]
gnulib/tests/test-c-strncasecmp.c [new file with mode: 0644]
gnulib/tests/test-canonicalize-lgpl.c [new file with mode: 0644]
gnulib/tests/test-ctype.c [new file with mode: 0644]
gnulib/tests/test-dup2.c [new file with mode: 0644]
gnulib/tests/test-environ.c [new file with mode: 0644]
gnulib/tests/test-errno.c [new file with mode: 0644]
gnulib/tests/test-fcntl-h.c [new file with mode: 0644]
gnulib/tests/test-fnmatch.c [new file with mode: 0644]
gnulib/tests/test-getdelim.c [new file with mode: 0644]
gnulib/tests/test-getline.c [new file with mode: 0644]
gnulib/tests/test-getopt.c [new file with mode: 0644]
gnulib/tests/test-getopt.h [new file with mode: 0644]
gnulib/tests/test-getopt_long.h [new file with mode: 0644]
gnulib/tests/test-ignore-value.c [new file with mode: 0644]
gnulib/tests/test-isblank.c [new file with mode: 0644]
gnulib/tests/test-langinfo.c [new file with mode: 0644]
gnulib/tests/test-locale.c [new file with mode: 0644]
gnulib/tests/test-localename.c [new file with mode: 0644]
gnulib/tests/test-lock.c [new file with mode: 0644]
gnulib/tests/test-lstat.c [new file with mode: 0644]
gnulib/tests/test-lstat.h [new file with mode: 0644]
gnulib/tests/test-malloc-gnu.c [new file with mode: 0644]
gnulib/tests/test-malloca.c [new file with mode: 0644]
gnulib/tests/test-mbrtowc-w32-1.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc-w32-2.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc-w32-3.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc-w32-4.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc-w32-5.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc-w32.c [new file with mode: 0644]
gnulib/tests/test-mbrtowc.c [new file with mode: 0644]
gnulib/tests/test-mbrtowc1.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc2.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc3.sh [new file with mode: 0755]
gnulib/tests/test-mbrtowc4.sh [new file with mode: 0755]
gnulib/tests/test-mbsinit.c [new file with mode: 0644]
gnulib/tests/test-mbsinit.sh [new file with mode: 0755]
gnulib/tests/test-mbsrtowcs.c [new file with mode: 0644]
gnulib/tests/test-mbsrtowcs1.sh [new file with mode: 0755]
gnulib/tests/test-mbsrtowcs2.sh [new file with mode: 0755]
gnulib/tests/test-mbsrtowcs3.sh [new file with mode: 0755]
gnulib/tests/test-mbsrtowcs4.sh [new file with mode: 0755]
gnulib/tests/test-memchr.c [new file with mode: 0644]
gnulib/tests/test-nl_langinfo.c [new file with mode: 0644]
gnulib/tests/test-nl_langinfo.sh [new file with mode: 0755]
gnulib/tests/test-open.c [new file with mode: 0644]
gnulib/tests/test-open.h [new file with mode: 0644]
gnulib/tests/test-readlink.c [new file with mode: 0644]
gnulib/tests/test-readlink.h [new file with mode: 0644]
gnulib/tests/test-safe-alloc.c [new file with mode: 0644]
gnulib/tests/test-setenv.c [new file with mode: 0644]
gnulib/tests/test-setlocale1.c [new file with mode: 0644]
gnulib/tests/test-setlocale1.sh [new file with mode: 0755]
gnulib/tests/test-setlocale2.c [new file with mode: 0644]
gnulib/tests/test-setlocale2.sh [new file with mode: 0755]
gnulib/tests/test-stat.c [new file with mode: 0644]
gnulib/tests/test-stat.h [new file with mode: 0644]
gnulib/tests/test-stdbool.c [new file with mode: 0644]
gnulib/tests/test-stddef.c [new file with mode: 0644]
gnulib/tests/test-stdint.c [new file with mode: 0644]
gnulib/tests/test-stdio.c [new file with mode: 0644]
gnulib/tests/test-stdlib.c [new file with mode: 0644]
gnulib/tests/test-string.c [new file with mode: 0644]
gnulib/tests/test-strnlen.c [new file with mode: 0644]
gnulib/tests/test-strstr.c [new file with mode: 0644]
gnulib/tests/test-symlink.c [new file with mode: 0644]
gnulib/tests/test-symlink.h [new file with mode: 0644]
gnulib/tests/test-sys_stat.c [new file with mode: 0644]
gnulib/tests/test-sys_wait.c [new file with mode: 0644]
gnulib/tests/test-sys_wait.h [new file with mode: 0644]
gnulib/tests/test-time.c [new file with mode: 0644]
gnulib/tests/test-unistd.c [new file with mode: 0644]
gnulib/tests/test-unsetenv.c [new file with mode: 0644]
gnulib/tests/test-vasnprintf.c [new file with mode: 0644]
gnulib/tests/test-vasprintf.c [new file with mode: 0644]
gnulib/tests/test-verify.c [new file with mode: 0644]
gnulib/tests/test-verify.sh [new file with mode: 0755]
gnulib/tests/test-wchar.c [new file with mode: 0644]
gnulib/tests/test-wcrtomb-w32-1.sh [new file with mode: 0755]
gnulib/tests/test-wcrtomb-w32-2.sh [new file with mode: 0755]
gnulib/tests/test-wcrtomb-w32-3.sh [new file with mode: 0755]
gnulib/tests/test-wcrtomb-w32-4.sh [new file with mode: 0755]
gnulib/tests/test-wcrtomb-w32-5.sh [new file with mode: 0755]
gnulib/tests/test-wcrtomb-w32.c [new file with mode: 0644]
gnulib/tests/test-wcrtomb.c [new file with mode: 0644]
gnulib/tests/test-wcrtomb.sh [new file with mode: 0755]
gnulib/tests/test-wctype-h.c [new file with mode: 0644]
gnulib/tests/unsetenv.c [new file with mode: 0644]
gnulib/tests/wctob.c [new file with mode: 0644]
gnulib/tests/wctomb-impl.h [new file with mode: 0644]
gnulib/tests/wctomb.c [new file with mode: 0644]
gnulib/tests/zerosize-ptr.h [new file with mode: 0644]
lenses/access.aug [new file with mode: 0644]
lenses/aliases.aug [new file with mode: 0644]
lenses/approx.aug [new file with mode: 0644]
lenses/aptpreferences.aug [new file with mode: 0644]
lenses/aptsources.aug [new file with mode: 0644]
lenses/bbhosts.aug [new file with mode: 0644]
lenses/build.aug [new file with mode: 0644]
lenses/cgconfig.aug [new file with mode: 0644]
lenses/cgrules.aug [new file with mode: 0644]
lenses/cobblermodules.aug [new file with mode: 0644]
lenses/cobblersettings.aug [new file with mode: 0644]
lenses/cron.aug [new file with mode: 0644]
lenses/crypttab.aug [new file with mode: 0644]
lenses/darkice.aug [new file with mode: 0644]
lenses/debctrl.aug [new file with mode: 0644]
lenses/device_map.aug [new file with mode: 0644]
lenses/dhclient.aug [new file with mode: 0644]
lenses/dhcpd.aug [new file with mode: 0644]
lenses/dnsmasq.aug [new file with mode: 0644]
lenses/dpkg.aug [new file with mode: 0644]
lenses/dput.aug [new file with mode: 0644]
lenses/ethers.aug [new file with mode: 0644]
lenses/exports.aug [new file with mode: 0644]
lenses/fstab.aug [new file with mode: 0644]
lenses/gdm.aug [new file with mode: 0644]
lenses/group.aug [new file with mode: 0644]
lenses/grub.aug [new file with mode: 0644]
lenses/hosts.aug [new file with mode: 0644]
lenses/httpd.aug [new file with mode: 0644]
lenses/inetd.aug [new file with mode: 0644]
lenses/inifile.aug [new file with mode: 0644]
lenses/inittab.aug [new file with mode: 0644]
lenses/interfaces.aug [new file with mode: 0644]
lenses/iptables.aug [new file with mode: 0644]
lenses/json.aug [new file with mode: 0644]
lenses/keepalived.aug [new file with mode: 0644]
lenses/krb5.aug [new file with mode: 0644]
lenses/limits.aug [new file with mode: 0644]
lenses/login_defs.aug [new file with mode: 0644]
lenses/logrotate.aug [new file with mode: 0644]
lenses/lokkit.aug [new file with mode: 0644]
lenses/mke2fs.aug [new file with mode: 0644]
lenses/modprobe.aug [new file with mode: 0644]
lenses/modules_conf.aug [new file with mode: 0644]
lenses/monit.aug [new file with mode: 0644]
lenses/multipath.aug [new file with mode: 0644]
lenses/mysql.aug [new file with mode: 0644]
lenses/nagioscfg.aug [new file with mode: 0644]
lenses/nagiosobjects.aug [new file with mode: 0644]
lenses/nrpe.aug [new file with mode: 0644]
lenses/nsswitch.aug [new file with mode: 0644]
lenses/ntp.aug [new file with mode: 0644]
lenses/odbc.aug [new file with mode: 0644]
lenses/openvpn.aug [new file with mode: 0644]
lenses/pam.aug [new file with mode: 0644]
lenses/passwd.aug [new file with mode: 0644]
lenses/pbuilder.aug [new file with mode: 0644]
lenses/pg_hba.aug [new file with mode: 0644]
lenses/php.aug [new file with mode: 0644]
lenses/phpvars.aug [new file with mode: 0644]
lenses/postfix_access.aug [new file with mode: 0644]
lenses/postfix_main.aug [new file with mode: 0644]
lenses/postfix_master.aug [new file with mode: 0644]
lenses/puppet.aug [new file with mode: 0644]
lenses/puppetfileserver.aug [new file with mode: 0644]
lenses/resolv.aug [new file with mode: 0644]
lenses/rsyncd.aug [new file with mode: 0644]
lenses/rx.aug [new file with mode: 0644]
lenses/samba.aug [new file with mode: 0644]
lenses/securetty.aug [new file with mode: 0644]
lenses/sep.aug [new file with mode: 0644]
lenses/services.aug [new file with mode: 0644]
lenses/shells.aug [new file with mode: 0644]
lenses/shellvars.aug [new file with mode: 0644]
lenses/shellvars_list.aug [new file with mode: 0644]
lenses/slapd.aug [new file with mode: 0644]
lenses/solaris_system.aug [new file with mode: 0644]
lenses/soma.aug [new file with mode: 0644]
lenses/spacevars.aug [new file with mode: 0644]
lenses/squid.aug [new file with mode: 0644]
lenses/sshd.aug [new file with mode: 0644]
lenses/sudoers.aug [new file with mode: 0644]
lenses/sysconfig.aug [new file with mode: 0644]
lenses/sysctl.aug [new file with mode: 0644]
lenses/syslog.aug [new file with mode: 0644]
lenses/tests/test_access.aug [new file with mode: 0644]
lenses/tests/test_aliases.aug [new file with mode: 0644]
lenses/tests/test_approx.aug [new file with mode: 0644]
lenses/tests/test_aptpreferences.aug [new file with mode: 0644]
lenses/tests/test_aptsource.aug [new file with mode: 0644]
lenses/tests/test_bbhosts.aug [new file with mode: 0644]
lenses/tests/test_cgconfig.aug [new file with mode: 0644]
lenses/tests/test_cgrules.aug [new file with mode: 0644]
lenses/tests/test_cobblermodules.aug [new file with mode: 0644]
lenses/tests/test_cobblersettings.aug [new file with mode: 0644]
lenses/tests/test_cron.aug [new file with mode: 0644]
lenses/tests/test_crypttab.aug [new file with mode: 0644]
lenses/tests/test_darkice.aug [new file with mode: 0644]
lenses/tests/test_debctrl.aug [new file with mode: 0644]
lenses/tests/test_device_map.aug [new file with mode: 0644]
lenses/tests/test_dhclient.aug [new file with mode: 0644]
lenses/tests/test_dhcpd.aug [new file with mode: 0644]
lenses/tests/test_dnsmasq.aug [new file with mode: 0644]
lenses/tests/test_dpkg.aug [new file with mode: 0644]
lenses/tests/test_dput.aug [new file with mode: 0644]
lenses/tests/test_ethers.aug [new file with mode: 0644]
lenses/tests/test_exports.aug [new file with mode: 0644]
lenses/tests/test_fstab.aug [new file with mode: 0644]
lenses/tests/test_gdm.aug [new file with mode: 0644]
lenses/tests/test_group.aug [new file with mode: 0644]
lenses/tests/test_grub.aug [new file with mode: 0644]
lenses/tests/test_hosts.aug [new file with mode: 0644]
lenses/tests/test_httpd.aug [new file with mode: 0644]
lenses/tests/test_inetd.aug [new file with mode: 0644]
lenses/tests/test_inifile.aug [new file with mode: 0644]
lenses/tests/test_inittab.aug [new file with mode: 0644]
lenses/tests/test_interfaces.aug [new file with mode: 0644]
lenses/tests/test_iptables.aug [new file with mode: 0644]
lenses/tests/test_json.aug [new file with mode: 0644]
lenses/tests/test_keepalived.aug [new file with mode: 0644]
lenses/tests/test_krb5.aug [new file with mode: 0644]
lenses/tests/test_ldap.aug [new file with mode: 0644]
lenses/tests/test_limits.aug [new file with mode: 0644]
lenses/tests/test_login_defs.aug [new file with mode: 0644]
lenses/tests/test_logrotate.aug [new file with mode: 0644]
lenses/tests/test_lokkit.aug [new file with mode: 0644]
lenses/tests/test_mke2fs.aug [new file with mode: 0644]
lenses/tests/test_modprobe.aug [new file with mode: 0644]
lenses/tests/test_modules_conf.aug [new file with mode: 0644]
lenses/tests/test_monit.aug [new file with mode: 0644]
lenses/tests/test_multipath.aug [new file with mode: 0644]
lenses/tests/test_mysql.aug [new file with mode: 0644]
lenses/tests/test_nagioscfg.aug [new file with mode: 0644]
lenses/tests/test_nagiosobjects.aug [new file with mode: 0644]
lenses/tests/test_nrpe.aug [new file with mode: 0644]
lenses/tests/test_nsswitch.aug [new file with mode: 0644]
lenses/tests/test_ntp.aug [new file with mode: 0644]
lenses/tests/test_odbc.aug [new file with mode: 0644]
lenses/tests/test_openvpn.aug [new file with mode: 0644]
lenses/tests/test_pam.aug [new file with mode: 0644]
lenses/tests/test_passwd.aug [new file with mode: 0644]
lenses/tests/test_pbuilder.aug [new file with mode: 0644]
lenses/tests/test_pg_hba.aug [new file with mode: 0644]
lenses/tests/test_php.aug [new file with mode: 0644]
lenses/tests/test_phpvars.aug [new file with mode: 0644]
lenses/tests/test_postfix_access.aug [new file with mode: 0644]
lenses/tests/test_postfix_main.aug [new file with mode: 0644]
lenses/tests/test_postfix_master.aug [new file with mode: 0644]
lenses/tests/test_puppet.aug [new file with mode: 0644]
lenses/tests/test_puppetfileserver.aug [new file with mode: 0644]
lenses/tests/test_resolv.aug [new file with mode: 0644]
lenses/tests/test_rsyncd.aug [new file with mode: 0644]
lenses/tests/test_rx.aug [new file with mode: 0644]
lenses/tests/test_samba.aug [new file with mode: 0644]
lenses/tests/test_securetty.aug [new file with mode: 0644]
lenses/tests/test_services.aug [new file with mode: 0644]
lenses/tests/test_shells.aug [new file with mode: 0644]
lenses/tests/test_shellvars.aug [new file with mode: 0644]
lenses/tests/test_shellvars_list.aug [new file with mode: 0644]
lenses/tests/test_slapd.aug [new file with mode: 0644]
lenses/tests/test_solaris_system.aug [new file with mode: 0644]
lenses/tests/test_soma.aug [new file with mode: 0644]
lenses/tests/test_spacevars.aug [new file with mode: 0644]
lenses/tests/test_squid.aug [new file with mode: 0644]
lenses/tests/test_sshd.aug [new file with mode: 0644]
lenses/tests/test_sudoers.aug [new file with mode: 0644]
lenses/tests/test_sysconfig.aug [new file with mode: 0644]
lenses/tests/test_sysctl.aug [new file with mode: 0644]
lenses/tests/test_syslog.aug [new file with mode: 0644]
lenses/tests/test_vsftpd.aug [new file with mode: 0644]
lenses/tests/test_webmin.aug [new file with mode: 0644]
lenses/tests/test_wine.aug [new file with mode: 0644]
lenses/tests/test_xinetd.aug [new file with mode: 0644]
lenses/tests/test_xml.aug [new file with mode: 0644]
lenses/tests/test_xorg.aug [new file with mode: 0644]
lenses/tests/test_yum.aug [new file with mode: 0644]
lenses/util.aug [new file with mode: 0644]
lenses/vsftpd.aug [new file with mode: 0644]
lenses/webmin.aug [new file with mode: 0644]
lenses/wine.aug [new file with mode: 0644]
lenses/xinetd.aug [new file with mode: 0644]
lenses/xml.aug [new file with mode: 0644]
lenses/xorg.aug [new file with mode: 0644]
lenses/yum.aug [new file with mode: 0644]
man/Makefile.am [new file with mode: 0644]
man/Makefile.in [new file with mode: 0644]
man/augparse.1 [new file with mode: 0644]
man/augparse.pod [new file with mode: 0644]
man/augtool.1 [new file with mode: 0644]
man/augtool.pod [new file with mode: 0644]
packaging/augeas.changes [new file with mode: 0644]
packaging/augeas.spec [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/Makefile.in [new file with mode: 0644]
src/ast.c [new file with mode: 0644]
src/augeas.c [new file with mode: 0644]
src/augeas.h [new file with mode: 0644]
src/augeas_sym.version [new file with mode: 0644]
src/augparse.c [new file with mode: 0644]
src/augtool.c [new file with mode: 0644]
src/builtin.c [new file with mode: 0644]
src/errcode.c [new file with mode: 0644]
src/errcode.h [new file with mode: 0644]
src/fa.c [new file with mode: 0644]
src/fa.h [new file with mode: 0644]
src/fa_sym.version [new file with mode: 0644]
src/get.c [new file with mode: 0644]
src/hash.c [new file with mode: 0644]
src/hash.h [new file with mode: 0644]
src/info.c [new file with mode: 0644]
src/info.h [new file with mode: 0644]
src/internal.c [new file with mode: 0644]
src/internal.h [new file with mode: 0644]
src/jmt.c [new file with mode: 0644]
src/jmt.h [new file with mode: 0644]
src/lens.c [new file with mode: 0644]
src/lens.h [new file with mode: 0644]
src/lexer.c [new file with mode: 0644]
src/lexer.l [new file with mode: 0644]
src/list.h [new file with mode: 0644]
src/memory.c [new file with mode: 0644]
src/memory.h [new file with mode: 0644]
src/parser.c [new file with mode: 0644]
src/parser.h [new file with mode: 0644]
src/parser.y [new file with mode: 0644]
src/pathx.c [new file with mode: 0644]
src/put.c [new file with mode: 0644]
src/ref.c [new file with mode: 0644]
src/ref.h [new file with mode: 0644]
src/regexp.c [new file with mode: 0644]
src/regexp.h [new file with mode: 0644]
src/syntax.c [new file with mode: 0644]
src/syntax.h [new file with mode: 0644]
src/transform.c [new file with mode: 0644]
src/transform.h [new file with mode: 0644]
src/try [new file with mode: 0755]
tests/Makefile.am [new file with mode: 0644]
tests/Makefile.in [new file with mode: 0644]
tests/cutest.c [new file with mode: 0644]
tests/cutest.h [new file with mode: 0644]
tests/fatest.c [new file with mode: 0644]
tests/lens-access.sh [new file with mode: 0755]
tests/lens-aliases.sh [new file with mode: 0755]
tests/lens-approx.sh [new file with mode: 0755]
tests/lens-aptpreferences.sh [new file with mode: 0755]
tests/lens-aptsource.sh [new file with mode: 0755]
tests/lens-bbhosts.sh [new file with mode: 0755]
tests/lens-cgconfig.sh [new file with mode: 0755]
tests/lens-cgrules.sh [new file with mode: 0755]
tests/lens-cobblermodules.sh [new file with mode: 0755]
tests/lens-cobblersettings.sh [new file with mode: 0755]
tests/lens-cron.sh [new file with mode: 0755]
tests/lens-crypttab.sh [new file with mode: 0755]
tests/lens-darkice.sh [new file with mode: 0755]
tests/lens-debctrl.sh [new file with mode: 0755]
tests/lens-device_map.sh [new file with mode: 0755]
tests/lens-dhclient.sh [new file with mode: 0755]
tests/lens-dhcpd.sh [new file with mode: 0755]
tests/lens-dnsmasq.sh [new file with mode: 0755]
tests/lens-dpkg.sh [new file with mode: 0755]
tests/lens-dput.sh [new file with mode: 0755]
tests/lens-ethers.sh [new file with mode: 0755]
tests/lens-exports.sh [new file with mode: 0755]
tests/lens-fstab.sh [new file with mode: 0755]
tests/lens-gdm.sh [new file with mode: 0755]
tests/lens-group.sh [new file with mode: 0755]
tests/lens-grub.sh [new file with mode: 0755]
tests/lens-hosts.sh [new file with mode: 0755]
tests/lens-httpd.sh [new file with mode: 0755]
tests/lens-inetd.sh [new file with mode: 0755]
tests/lens-inifile.sh [new file with mode: 0755]
tests/lens-inittab.sh [new file with mode: 0755]
tests/lens-interfaces.sh [new file with mode: 0755]
tests/lens-iptables.sh [new file with mode: 0755]
tests/lens-json.sh [new file with mode: 0755]
tests/lens-keepalived.sh [new file with mode: 0755]
tests/lens-krb5.sh [new file with mode: 0755]
tests/lens-ldap.sh [new file with mode: 0755]
tests/lens-limits.sh [new file with mode: 0755]
tests/lens-login_defs.sh [new file with mode: 0755]
tests/lens-logrotate.sh [new file with mode: 0755]
tests/lens-lokkit.sh [new file with mode: 0755]
tests/lens-mke2fs.sh [new file with mode: 0755]
tests/lens-modprobe.sh [new file with mode: 0755]
tests/lens-modules_conf.sh [new file with mode: 0755]
tests/lens-monit.sh [new file with mode: 0755]
tests/lens-multipath.sh [new file with mode: 0755]
tests/lens-mysql.sh [new file with mode: 0755]
tests/lens-nagioscfg.sh [new file with mode: 0755]
tests/lens-nagiosobjects.sh [new file with mode: 0755]
tests/lens-nrpe.sh [new file with mode: 0755]
tests/lens-nsswitch.sh [new file with mode: 0755]
tests/lens-ntp.sh [new file with mode: 0755]
tests/lens-odbc.sh [new file with mode: 0755]
tests/lens-openvpn.sh [new file with mode: 0755]
tests/lens-pam.sh [new file with mode: 0755]
tests/lens-passwd.sh [new file with mode: 0755]
tests/lens-pbuilder.sh [new file with mode: 0755]
tests/lens-pg_hba.sh [new file with mode: 0755]
tests/lens-php.sh [new file with mode: 0755]
tests/lens-phpvars.sh [new file with mode: 0755]
tests/lens-postfix_access.sh [new file with mode: 0755]
tests/lens-postfix_main.sh [new file with mode: 0755]
tests/lens-postfix_master.sh [new file with mode: 0755]
tests/lens-puppet.sh [new file with mode: 0755]
tests/lens-puppetfileserver.sh [new file with mode: 0755]
tests/lens-resolv.sh [new file with mode: 0755]
tests/lens-rsyncd.sh [new file with mode: 0755]
tests/lens-rx.sh [new file with mode: 0755]
tests/lens-samba.sh [new file with mode: 0755]
tests/lens-securetty.sh [new file with mode: 0755]
tests/lens-services.sh [new file with mode: 0755]
tests/lens-shells.sh [new file with mode: 0755]
tests/lens-shellvars.sh [new file with mode: 0755]
tests/lens-shellvars_list.sh [new file with mode: 0755]
tests/lens-slapd.sh [new file with mode: 0755]
tests/lens-solaris_system.sh [new file with mode: 0755]
tests/lens-soma.sh [new file with mode: 0755]
tests/lens-spacevars.sh [new file with mode: 0755]
tests/lens-squid.sh [new file with mode: 0755]
tests/lens-sshd.sh [new file with mode: 0755]
tests/lens-sudoers.sh [new file with mode: 0755]
tests/lens-sysconfig.sh [new file with mode: 0755]
tests/lens-sysctl.sh [new file with mode: 0755]
tests/lens-syslog.sh [new file with mode: 0755]
tests/lens-test-1 [new file with mode: 0755]
tests/lens-vsftpd.sh [new file with mode: 0755]
tests/lens-webmin.sh [new file with mode: 0755]
tests/lens-wine.sh [new file with mode: 0755]
tests/lens-xinetd.sh [new file with mode: 0755]
tests/lens-xml.sh [new file with mode: 0755]
tests/lens-xorg.sh [new file with mode: 0755]
tests/lens-yum.sh [new file with mode: 0755]
tests/modules/fail_cf_two_nullable.aug [new file with mode: 0644]
tests/modules/fail_concat_ctype.aug [new file with mode: 0644]
tests/modules/fail_del_default_check.aug [new file with mode: 0644]
tests/modules/fail_del_maybe.aug [new file with mode: 0644]
tests/modules/fail_double_maybe.aug [new file with mode: 0644]
tests/modules/fail_empty_module.aug [new file with mode: 0644]
tests/modules/fail_key_slash.aug [new file with mode: 0644]
tests/modules/fail_label_slash.aug [new file with mode: 0644]
tests/modules/fail_let_no_exp.aug [new file with mode: 0644]
tests/modules/fail_multi_key_concat.aug [new file with mode: 0644]
tests/modules/fail_multi_key_iter.aug [new file with mode: 0644]
tests/modules/fail_multi_store_concat.aug [new file with mode: 0644]
tests/modules/fail_multi_store_iter.aug [new file with mode: 0644]
tests/modules/fail_nocase_union.aug [new file with mode: 0644]
tests/modules/fail_put_bad_value.aug [new file with mode: 0644]
tests/modules/fail_recursion_multi_keys.aug [new file with mode: 0644]
tests/modules/fail_regexp_minus_empty.aug [new file with mode: 0644]
tests/modules/fail_regexp_range_end.aug [new file with mode: 0644]
tests/modules/fail_self_ref_module.aug [new file with mode: 0644]
tests/modules/fail_shadow_union.aug [new file with mode: 0644]
tests/modules/fail_xform_orphan_value.aug [new file with mode: 0644]
tests/modules/pass_array.aug [new file with mode: 0644]
tests/modules/pass_bad_tests.aug [new file with mode: 0644]
tests/modules/pass_concat_atype.aug [new file with mode: 0644]
tests/modules/pass_cont_line.aug [new file with mode: 0644]
tests/modules/pass_empty_put.aug [new file with mode: 0644]
tests/modules/pass_empty_regexp.aug [new file with mode: 0644]
tests/modules/pass_ins_test.aug [new file with mode: 0644]
tests/modules/pass_iter_atype.aug [new file with mode: 0644]
tests/modules/pass_iter_key_union.aug [new file with mode: 0644]
tests/modules/pass_label_value.aug [new file with mode: 0644]
tests/modules/pass_lens_plus.aug [new file with mode: 0644]
tests/modules/pass_let_exp.aug [new file with mode: 0644]
tests/modules/pass_mixed_recursion.aug [new file with mode: 0644]
tests/modules/pass_nested_sections.aug [new file with mode: 0644]
tests/modules/pass_nocase.aug [new file with mode: 0644]
tests/modules/pass_prefix_union.aug [new file with mode: 0644]
tests/modules/pass_put_bad_label.aug [new file with mode: 0644]
tests/modules/pass_put_invalid_star.aug [new file with mode: 0644]
tests/modules/pass_quote_quote.aug [new file with mode: 0644]
tests/modules/pass_read_file.aug [new file with mode: 0644]
tests/modules/pass_regexp_minus.aug [new file with mode: 0644]
tests/modules/pass_self_ref_module.aug [new file with mode: 0644]
tests/modules/pass_simple_recursion.aug [new file with mode: 0644]
tests/modules/pass_square.aug [new file with mode: 0644]
tests/modules/pass_store_maybe.aug [new file with mode: 0644]
tests/modules/pass_strip_quotes.aug [new file with mode: 0644]
tests/modules/pass_subtree_growth.aug [new file with mode: 0644]
tests/modules/pass_switch_value_regexp.aug [new file with mode: 0644]
tests/modules/pass_union_atype.aug [new file with mode: 0644]
tests/modules/pass_union_atype_298.aug [new file with mode: 0644]
tests/modules/pass_union_nokey.aug [new file with mode: 0644]
tests/modules/pass_union_select_star.aug [new file with mode: 0644]
tests/modules/pass_unit.aug [new file with mode: 0644]
tests/root/boot/grub/grub.conf [new file with mode: 0644]
tests/root/boot/grub/menu.lst [new file with mode: 0644]
tests/root/etc/aliases [new file with mode: 0644]
tests/root/etc/apt/sources.list [new file with mode: 0644]
tests/root/etc/dput.cf [new file with mode: 0644]
tests/root/etc/exports [new file with mode: 0644]
tests/root/etc/fstab [new file with mode: 0644]
tests/root/etc/group [new file with mode: 0644]
tests/root/etc/grub.conf [new file with mode: 0644]
tests/root/etc/hosts [new file with mode: 0644]
tests/root/etc/inittab [new file with mode: 0644]
tests/root/etc/krb5.conf [new file with mode: 0644]
tests/root/etc/logrotate.d/acpid [new file with mode: 0644]
tests/root/etc/logrotate.d/rpm [new file with mode: 0644]
tests/root/etc/modules.conf [new file with mode: 0644]
tests/root/etc/multipath.conf [new file with mode: 0644]
tests/root/etc/network/interfaces [new file with mode: 0644]
tests/root/etc/nrpe.cfg [new file with mode: 0644]
tests/root/etc/ntp.conf [new file with mode: 0644]
tests/root/etc/pam.d/login [new file with mode: 0644]
tests/root/etc/pam.d/newrole [new file with mode: 0644]
tests/root/etc/pam.d/postgresql [new file with mode: 0644]
tests/root/etc/pam.d/sshd~ [new file with mode: 0644]
tests/root/etc/passwd [new file with mode: 0644]
tests/root/etc/php.ini [new file with mode: 0644]
tests/root/etc/puppet/puppet.conf [new file with mode: 0644]
tests/root/etc/samba/smb.conf [new file with mode: 0644]
tests/root/etc/security/limits.conf [new file with mode: 0644]
tests/root/etc/services [new file with mode: 0644]
tests/root/etc/squid/squid.conf [new file with mode: 0644]
tests/root/etc/ssh/sshd_config [new file with mode: 0644]
tests/root/etc/sudoers [new file with mode: 0644]
tests/root/etc/sysconfig/atd [new file with mode: 0644]
tests/root/etc/sysconfig/authconfig [new file with mode: 0644]
tests/root/etc/sysconfig/autofs [new file with mode: 0644]
tests/root/etc/sysconfig/clock [new file with mode: 0644]
tests/root/etc/sysconfig/cpuspeed [new file with mode: 0644]
tests/root/etc/sysconfig/crond [new file with mode: 0644]
tests/root/etc/sysconfig/crontab [new file with mode: 0644]
tests/root/etc/sysconfig/firstboot [new file with mode: 0644]
tests/root/etc/sysconfig/grub [new file with mode: 0644]
tests/root/etc/sysconfig/hsqldb [new file with mode: 0644]
tests/root/etc/sysconfig/httpd [new file with mode: 0644]
tests/root/etc/sysconfig/hw-uuid [new file with mode: 0644]
tests/root/etc/sysconfig/hwconf [new file with mode: 0644]
tests/root/etc/sysconfig/i18n [new file with mode: 0644]
tests/root/etc/sysconfig/init [new file with mode: 0644]
tests/root/etc/sysconfig/iptables [new file with mode: 0644]
tests/root/etc/sysconfig/iptables-config [new file with mode: 0644]
tests/root/etc/sysconfig/irda [new file with mode: 0644]
tests/root/etc/sysconfig/irqbalance [new file with mode: 0644]
tests/root/etc/sysconfig/kdump [new file with mode: 0644]
tests/root/etc/sysconfig/kernel [new file with mode: 0644]
tests/root/etc/sysconfig/keyboard [new file with mode: 0644]
tests/root/etc/sysconfig/kudzu [new file with mode: 0644]
tests/root/etc/sysconfig/libvirtd [new file with mode: 0644]
tests/root/etc/sysconfig/lircd [new file with mode: 0644]
tests/root/etc/sysconfig/lm_sensors [new file with mode: 0644]
tests/root/etc/sysconfig/nasd [new file with mode: 0644]
tests/root/etc/sysconfig/netconsole [new file with mode: 0644]
tests/root/etc/sysconfig/netdump_id_dsa.pub [new file with mode: 0644]
tests/root/etc/sysconfig/network [new file with mode: 0644]
tests/root/etc/sysconfig/network-scripts/ifcfg-br0 [new file with mode: 0644]
tests/root/etc/sysconfig/network-scripts/ifcfg-eth0 [new file with mode: 0644]
tests/root/etc/sysconfig/network-scripts/ifcfg-lo [new file with mode: 0644]
tests/root/etc/sysconfig/network-scripts/ifcfg-wlan0 [new file with mode: 0644]
tests/root/etc/sysconfig/nfs [new file with mode: 0644]
tests/root/etc/sysconfig/ntpd [new file with mode: 0644]
tests/root/etc/sysconfig/prelink [new file with mode: 0644]
tests/root/etc/sysconfig/puppet [new file with mode: 0644]
tests/root/etc/sysconfig/readonly-root [new file with mode: 0644]
tests/root/etc/sysconfig/rsyslog [new file with mode: 0644]
tests/root/etc/sysconfig/samba [new file with mode: 0644]
tests/root/etc/sysconfig/saslauthd [new file with mode: 0644]
tests/root/etc/sysconfig/smartmontools [new file with mode: 0644]
tests/root/etc/sysconfig/spamassassin [new file with mode: 0644]
tests/root/etc/sysconfig/sysstat [new file with mode: 0644]
tests/root/etc/sysconfig/sysstat.ioconf [new file with mode: 0644]
tests/root/etc/sysconfig/system-config-firewall [new file with mode: 0644]
tests/root/etc/sysconfig/system-config-securitylevel [new file with mode: 0644]
tests/root/etc/sysconfig/system-config-users [new file with mode: 0644]
tests/root/etc/sysconfig/vncservers [new file with mode: 0644]
tests/root/etc/sysconfig/wpa_supplicant [new file with mode: 0644]
tests/root/etc/sysconfig/xend [new file with mode: 0644]
tests/root/etc/sysconfig/xendomains [new file with mode: 0644]
tests/root/etc/sysctl.conf [new file with mode: 0644]
tests/root/etc/vsftpd.conf [new file with mode: 0644]
tests/root/etc/xinetd.conf [new file with mode: 0644]
tests/root/etc/xinetd.d/cvs [new file with mode: 0644]
tests/root/etc/xinetd.d/rsync [new file with mode: 0644]
tests/root/etc/yum.conf [new file with mode: 0644]
tests/root/etc/yum.repos.d/fedora-updates.repo [new file with mode: 0644]
tests/root/etc/yum.repos.d/fedora.repo [new file with mode: 0644]
tests/root/etc/yum.repos.d/remi.repo [new file with mode: 0644]
tests/root/pairs.txt [new file with mode: 0644]
tests/test-api.c [new file with mode: 0644]
tests/test-augtool-empty-line.sh [new file with mode: 0755]
tests/test-augtool-modify-root.sh [new file with mode: 0755]
tests/test-augtool.sh [new file with mode: 0755]
tests/test-augtool/aliases-add-value.sh [new file with mode: 0644]
tests/test-augtool/aliases-change-value.sh [new file with mode: 0644]
tests/test-augtool/grub-change-default.sh [new file with mode: 0644]
tests/test-augtool/grub-rm-entry.sh [new file with mode: 0644]
tests/test-augtool/grub-setm-newvalues.sh [new file with mode: 0644]
tests/test-augtool/ini-yum-change.sh [new file with mode: 0644]
tests/test-augtool/ini-yum-newkey.sh [new file with mode: 0644]
tests/test-augtool/ini-yum-newsec.sh [new file with mode: 0644]
tests/test-augtool/ini-yum-rmkey.sh [new file with mode: 0644]
tests/test-augtool/rec-append-record.sh [new file with mode: 0644]
tests/test-augtool/rec-hosts-add.sh [new file with mode: 0644]
tests/test-augtool/rec-hosts-reorder-new.sh [new file with mode: 0644]
tests/test-augtool/rec-hosts-reorder.sh [new file with mode: 0644]
tests/test-augtool/rec-hosts-rm-hosts.sh [new file with mode: 0644]
tests/test-augtool/rec-initdefault.sh [new file with mode: 0644]
tests/test-augtool/rec-ins-record.sh [new file with mode: 0644]
tests/test-augtool/rec-mod-field.sh [new file with mode: 0644]
tests/test-augtool/rec-rm-inner-field.sh [new file with mode: 0644]
tests/test-augtool/rec-rm-record.sh [new file with mode: 0644]
tests/test-augtool/rec-rm-tail-field.sh [new file with mode: 0644]
tests/test-augtool/sshd-add-acceptenv.sh [new file with mode: 0644]
tests/test-augtool/yum.repos-setm-enabled.sh [new file with mode: 0644]
tests/test-bug-1.sh [new file with mode: 0755]
tests/test-events-saved.sh [new file with mode: 0755]
tests/test-get.sh [new file with mode: 0755]
tests/test-idempotent.sh [new file with mode: 0755]
tests/test-interpreter.sh [new file with mode: 0755]
tests/test-load.c [new file with mode: 0644]
tests/test-mv.sh [new file with mode: 0755]
tests/test-preserve.sh [new file with mode: 0755]
tests/test-put-symlink.sh [new file with mode: 0755]
tests/test-save-empty.sh [new file with mode: 0755]
tests/test-save-mode.sh [new file with mode: 0755]
tests/test-save.c [new file with mode: 0644]
tests/test-unlink-error.sh [new file with mode: 0755]
tests/test-xpath.c [new file with mode: 0644]
tests/xpath.tests [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..da54c9e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,49 @@
+-*- coding: utf-8 -*-
+
+Written by:
+
+  David Lutterkort <lutter@redhat.com>
+
+Committers:
+
+  Francis Giraldeau           <francis.giraldeau@revolutionlinux.com>
+  Raphael Pinson              <raphink@gmail.com>
+
+Contributions by:
+
+  Partha Aji                  <paji@redhat.com>
+  Sebastien Aperghis-Tramoni  <sebastien@aperghis.net>
+  Mathieu Arnold              <mat@FreeBSD.org>
+  Sergio Ballestrero
+  Sylvain Baubeau             <bob@glumol.com>
+  Anders F Björklund          <afb@users.sourceforge.net>
+  Aurelien Bompard            <aurelien@bompard.org>
+  Matthew Booth               <mbooth@redhat.com>
+  Dominic Cleal               <dcleal@redhat.com>
+  Lorenzo Dalrio              <lorenzo.dalrio@gmail.com>
+  Francois Deppierraz         <francois.deppierraz@camptocamp.com>
+  Dominique Dumont            <dominique.dumont@hp.com>
+  Free Ekanayaka              <free@64studio.com>
+  Marc Fournier               <marc.fournier@camptocamp.com>
+  Harald Hoyer                <harald@redhat.com>
+  Shannon Hughes              <shughes@redhat.com>
+  Richard W.M. Jones          <rjones@redhat.com>
+  Simon Josi                  <josi@puzzle.ch>
+  Bryan Kearney               <bkearney@redhat.com>
+  Frédéric Lespez             <frederic.lespez@free.fr>
+  Erinn Looney-Triggs         <erinn.looneytriggs@gmail.com>
+  Jim Meyering                <meyering@redhat.com>
+  Sean Millichamp             <sean@bruenor.org>
+  Joel Nimety                 <jnimety@perimeterusa.com>
+  Matt Palmer                 <matt@anchor.net.au>
+  Bill Pemberton              <wfp5p@virginia.edu>
+  Alan Pevec                  <apevec@redhat.com>
+  Robin Lee Powell            <rlpowell@digitalkingdom.org>
+  Satoru SATOH                <satoru.satoh@gmail.com>
+  Nicolas Valcárcel Scerpella <nvalcarcel@ubuntu.com>
+  Nahum Shalman               <nshalman elys com>
+  Tim Stoop                   <tim.stoop@gmail.com>
+  Laine Stump                 <laine@laine.org>
+  Ivana Hutarova Varekova     <varekova@redhat.com>
+  Frederik Wagner             <wagner@lrz.de>
+  Dean Wilson                 <dwilson@blueowl.it>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..cf9b6b9
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,510 @@
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard.  To achieve this, non-free programs must
+be allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+^L
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at least
+    three years, to give the same user the materials specified in
+    Subsection 6a, above, for a charge no more than the cost of
+    performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+^L
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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 library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James
+  Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..603dcb5
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,6289 @@
+2011-04-15  David Lutterkort  <lutter@redhat.com>
+
+       Iptables: handle --tcp-flags
+       Fixes bug #157
+
+2011-04-14  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c: respect autosave flag when executing a single command
+       Fixes bug #193
+
+2011-04-13  Erinn Looney-Triggs  <erinn.looneytriggs@gmail.com>
+
+       Grub: support the 'device' directive for UEFI boot
+       Fixes bug #189
+
+2011-04-13  David Lutterkort  <lutter@redhat.com>
+
+       Access: support the format @netgroup@@nisdomain
+       Fixes bug #190
+
+       * lenses/tests/test_fstab.aug: test that we parse SELinux context correctly
+
+2011-03-25  David Lutterkort  <lutter@redhat.com>
+
+       Httpd: remove duplicate inclusion of /etc/httpd/conf/httpd.conf
+
+2011-03-25  Bill Pemberton  <wfp5p@virginia.edu>
+
+       Deal with continuation lines in httpd.aug
+       Apache allows config lines to be continued with a backslash, but the
+       lens couldn't deal with it.  Change the value sep_spc to deal with
+       continuation lines as found in interfaces.aug
+
+       Enable the test for continuation lines in test_httpd.aug
+
+       Add /etc/httpd/conf/httpd.conf to the filter list for httpd.aug
+
+       Allow blank and comment lines throughout config file in iptables
+
+       Exclude /etc/yum/pluginconf.d/versionlock.list from yum.aug
+       The versionlock plugin puts a file in /etc/yum/pluginconf.d that is
+       not a yum config file so yum.aug shouldn't try to parse it.
+
+2011-03-23  David Lutterkort  <lutter@redhat.com>
+
+       Mysql: include /etc/my.cnf used on Fedora/RHEL
+       Fixes https://bugzilla.redhat.com/show_bug.cgi?id=688053
+
+       Httpd: include /etc/httpd/conf/httpd.conf used on Fedora/RHEL
+       Fixes https://bugzilla.redhat.com/show_bug.cgi?id=688149
+
+2011-03-22  David Lutterkort  <lutter@redhat.com>
+
+       * src/lexer.l: fix a few compilation warnings
+
+       Eliminate global variable 'comment_depth' in lexer
+
+2011-03-19  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Add support for configfile and background in grub
+       Test for the new configuration directives are also provided.
+
+       Thanks to Onur Küçük for the patch.
+
+2011-03-18  Raphaël Pinson  <raphink@gmail.com>
+
+       #include is also valid in sudoers.aug
+
+       Add support for #includedir in sudoers.aug and test (ticket #188)
+
+2011-03-17  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Support sudoers in nsswitch.aug
+       nsswitch.conf support a configuration item to specify database backend, this
+       commit adds the support for it.
+
+       Fix bug #187
+
+       Thanks to thefoxbox for the enhancement
+
+       Fix unmatch bracket causes segfault in augtool.c
+       When command is parsed in augtool, function nexttoken verify that path has
+       valid and matching brackets and return NULL if not. The function cleanpath that
+       follows was not handling the NULL case, leading to a segmentation fault. By
+       checking for NULL value, the error is thrown adequately.
+
+       Fix bug #186
+
+       Thanks to spamaps for the help to resolve this issue.
+
+2011-03-16  David Lutterkort  <lutter@redhat.com>
+
+       * src/lexer.l (augl_init_lexer): really close the input file on error
+
+2011-03-16  Richard W.M. Jones  <rjones@redhat.com>
+
+       Add FreeBSD /etc/rc.conf file to Shellvars lens.
+
+2011-03-15  David Lutterkort  <lutter@redhat.com>
+
+       Replace erroneous assert(0) with proper error report
+         * src/put.c (create_union): report an error to the user if none of the
+           alternatives match
+         * lenses/tests/test_shellvars.aug: add a test to trigger that code path
+           in create_union
+
+       Fixes bug #183
+
+2011-03-10  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c (aug_init): check return value of argz_* for ENOMEM
+
+2011-03-10  Matthew Booth  <mbooth@redhat.com>
+
+       Fix parsing of fstab entries containing fscontext SELinux option
+       Systems using SELinux can contain an fstab option like:
+       fscontext=system_u:object_r:removable_t
+
+       The fstab lens is currently too strict, and doesn't allow colons in the value.
+       This patch relaxes the parsing to make it as lax as possible within the
+       constraints of the syntax.
+
+2011-03-08  David Lutterkort  <lutter@redhat.com>
+
+       Be more defensive about closing input files for the lexer
+
+2011-03-04  David Lutterkort  <lutter@redhat.com>
+
+       Explain using ./src/try
+         * HACKING: document the various modes of using ./src/try
+         * src/try: read commands from build/augcmds.txt rather than /tmp; use a
+           more sensible default if augcmds.txt does not exist
+
+2011-03-03  Matthew Booth  <mbooth@redhat.com>
+
+       Use getopt-gnu from gnulib for AIX support
+
+       Update to gnulib commit c2090a8
+       Required for updated getopt-gnu license.
+
+2011-03-03  Raphaël Pinson  <raphink@gmail.com>
+
+       Remove trailing spaces in lenses/tests/test_nagiosobjects.aug
+
+       Add nagiosobjects.aug based on Sebastien Aperghis' work.
+
+       Remove trailing spaces in nagioscfg.aug
+
+       Improve nagioscfg.aug as per Sebastien Aperghis' work.
+
+2011-03-02  Raphaël Pinson  <raphink@gmail.com>
+
+       Fix single quotes support in httpd.aug.
+
+       Support single quotes in httpd.aug. Add unit test for it in test_httpd.aug.
+
+2011-03-02  David Lutterkort  <lutter@redhat.com>
+
+       * tests/fatest.c (testManualAmbig): don't use '$' in variable names
+       Breaks on, at least, AIX
+
+2011-03-02  Raphaël Pinson  <raphink@gmail.com>
+
+       Add Sep.equal, used in nrpe.aug
+
+       Changes in nrpe.aug Remove wrong ^ in comment regex Use Util.comment_generic Use generic modules Improve NaturalDocs documentation
+
+2011-02-23  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.8.0
+
+       Fix compile errors found by gcc 4.6.0
+       There were several places that caused the new 'variable assigned but not
+       used' warning.
+
+       The struct lens also contained the member jmt twice; it is now only
+       available for L_REC lenses.
+
+       * src/info.h: include stdlib so we can use uint
+
+       * tests/Makefile.am: distribute the test data in test-augtool/
+
+2011-02-23  Dominic Cleal  <dcleal@redhat.com>
+
+       Split Solaris multiboot argument for the kernel path into @path node (ticket #158)
+
+2011-02-22  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Add aug_span API function V2
+       aug_span API function provides information about the node of the specified
+       path. It sets the absolute path of the file name and spans of label, value
+       and span inside the node. The span includes all matching chars of the actual
+       lens and it's descendant. Hence, the top level node will span the entire file.
+       It returns 0 in case of success and -1 if the node is not associated to a file
+       or if the path is invalid.  The main use case is to make possible to display
+       the related file with the node elements hightlighted in a UI.
+
+       The API option AUG_NO_NODE_SPAN provided to aug_init disable the allocation
+       structures to keep node spans. It saves about 5% of memory for a typical
+       tree.
+
+         * src/augeas.c : add aug_span implementation and option handling to aug_in
+           according to the option /augeas/span in the tree
+         * src/augeas.h : add declaration of aug_span and constants for option
+         * src/augeas_sym.version : make the new function visible in libaugeas
+         * src/augtool.c : add the "nodepos" command to augtool
+         * src/get.c : gather filename, label, value and span spans if any
+         * src/info.c : create and release functions for struct node_span
+         * src/info.h : add definition of struct node_info
+         * src/internal.h : add node_info to struct tree
+         * src/transform.c : duplicate filename string
+         * tests/test-load.c : 3 basic unit tests for general correct behavior
+
+2011-02-22  Raphaël Pinson  <raphink@gmail.com>
+
+       Add short options for --nostdinc, --noload and --noautoload Update manpage and pod accordingly
+
+       Distribute bcprules.sty and xpath.txt
+
+2011-02-19  Raphaël Pinson  <raphink@gmail.com>
+
+       Add indented_title_label in inifile.aug Use indented_title_label in mysql.aug Adjust test for mysql.aug accordingly
+
+2011-02-18  Raphaël Pinson  <raphink@gmail.com>
+
+       Allow indentation for "iface" entries in interfaces.aug (Fix ticket #182) Add unit test for "iface" indentation
+
+2011-02-16  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Minor code format cleanup
+         * Cut long lines to 80 chars
+         * Indentation fix
+
+       Fix memory leak with recursive square lens
+
+2011-02-16  Raphaël Pinson  <raphink@gmail.com>
+
+       Remove trailing whitespaces in util.aug
+
+       Add comment_c_style and comment_multiline Add empty_generic and make empty a call to it Add empty_c_style to complement comment_c_style
+
+2011-02-15  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Fix segfault in get.c with L_MAYBE lens (bug#180)
+       When a L_MAYBE lens was the last child of a L_CONCAT inside a L_SUBTREE, then
+       the match in visit_exit top_frame(rec_state)->lens == lens->child was true,
+       causing combine of a frame when it shouldn't. This test is true because there
+       is no other lens following in the concat in this special case, hence the top
+       frame matched the child of the L_MAYBE.
+
+       To avoid this special case, we propose to push L_MAYBE lens on the frames
+       stack. If L_MAYBE is encountered in visit_exit, we pop at least one frame and
+       two if the child match. This way, the stack is always valid.
+
+       Closes trac ticket #180.
+
+2011-02-15  Raphaël Pinson  <raphink@gmail.com>
+
+       Improve vim syntax file
+
+2011-02-14  David Lutterkort  <lutter@redhat.com>
+
+       man pages: update man page for augtool
+
+2011-02-14  Raphaël Pinson  <raphink@gmail.com>
+
+       augtool: add --interactive option
+       This option runs an interactive shell after evaluating STDIN or an explicit
+       inputfile
+
+2011-02-14  David Lutterkort  <lutter@redhat.com>
+
+       Mysql: change default comment delimiter from ';' to '#'
+       Fixes bug #181 reported by devzero
+
+2011-02-06  Francis Giraldeau  <francis.giraldeau@usherbrooke.ca>
+
+       Add Dhcpd lens
+         * Support unquoting for allow/deny statements
+         * Append new line to block statement braces by default
+         * Add missing string and integer statements according to man dhcpd.conf
+         * Remove trailing white space from the lens file
+
+       Replace seq by label in option list
+
+         The counter/seq doesn't garantee that node label "1" will get at the first
+         position. Positional arguments are ordered, hence the sequence may be
+         misleading. This is why a fixed label for sequence nodes are better.
+
+2011-01-28  Raphaël Pinson  <raphink@gmail.com>
+
+       Support directives without arg in httpd.aug
+       * Use sep.aug in httpd.aug Modify Sep.opt_space to make it fit the
+         definition in httpd.aug (it's only used here)
+       * Allow directives without arguments in httpd.aug
+       * Adjust test_httpd.aug to test argument-less directives
+
+2011-01-25  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Fix httpd.aug doc, filter and add to checks
+         * Added other contributors to authors
+         * Changed the licence to LGPLv2+
+         * Fix copy/paste error about config files
+         * Added filters for Fedora and RHEL
+
+       Add Httpd lens
+       The Httpd lens parses Apache Web server configuration according to the manual.
+
+         * Generic sections with square lens
+         * Generic directives
+         * Arguments of sections and directives are handled as list
+
+       The lens doesn't support automatic quoting of string values, because arguments
+       are separated by spaces and it raises ambiguity when using unquoting. The lens
+       doesn't support either long lines splitted by backslash.
+
+2011-01-25  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c (store_error): make sure pos_str is always NUL terminated
+       Fixes bug #178
+
+2011-01-19  Fred  <frederic.lespez@free.fr>
+
+       PuppetFileserver: new lens for Puppet's fileserver.conf
+
+2011-01-19  David Lutterkort  <lutter@redhat.com>
+
+       * man/augtool.pod: fix typos
+       Fixes https://bugzilla.redhat.com/show_bug.cgi?id=628502
+
+2011-01-14  David Lutterkort  <lutter@redhat.com>
+
+       Allow compiling with NDEBUG defined
+         * src/errcode.h (ensure0): do not mention 'error' label when NDEBUG is
+           defined
+         * src/pathx.c (coerce_to_bool, eval_pred): make sure we return something
+           when assert(0) is compiled away
+
+2011-01-13  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Fix a small bashism from test script
+
+2011-01-13  David Lutterkort  <lutter@redhat.com>
+
+       Xorg: "position" in "screen" section is optional; allow "Extensions" section
+       Patch by omzzk
+
+       Fixes bug #175
+
+2011-01-11  David Lutterkort  <lutter@redhat.com>
+
+       Replace augtest by test-augtool.sh
+       This removes the silly dependency on Ruby, since augtest was the only
+       Ruby script in the whole source tree.
+
+       The test files for test-augtool.sh live in tests/test-augtool, and are
+       functionally identical to the Ruby test files tests/*.rb. The only
+       exception is that test-root.rb has been removed - it tested something that
+       is better tested in test-xpath.c
+
+       The new test-augtool.sh test is also a little more efficient in that it
+       only copies the file needed by a test into the root, and only sets the lens
+       for that file up for loading. This reduces the runtime of the tests from ~
+       30s on my machine to under 2s.
+
+       Test that getting and setting the root node works
+       This tests the same thing that test-get.sh tests, but in a much more
+       reliable fashion
+
+       * src/pathx.c (store_error): never append to an uninitialized string
+
+       * src/augtool.c: be a little more quiet
+       Some of the commands used to print unconditionally; we now only print if we
+       should be echoing (i.e., if --echo is given on the command line or if stdin
+       is a tty)
+
+2011-01-11  Fred  <frederic.lespez@free.fr>
+
+       Crypttab: new lens for /etc/crypttab
+
+2011-01-11  Raphaël Pinson  <raphink@gmail.com>
+
+       In autosave mode, print "save" when in echo or interactive mode. Remove comma at the end of enum list.
+
+2011-01-10  Raphaël Pinson  <raphink@gmail.com>
+
+       Refactor augtool.c to use only readline
+
+       augtool: add --autosave option
+       Additional changes to augtool:
+         * Define AUGTOOL_PROMPT as a constant
+         * Do not print (null) lines when using --echo
+         * Add test for --autosave in test-save-mode.sh
+
+       Fixes ticket #172
+
+2011-01-07  David Lutterkort  <lutter@redhat.com>
+
+       bootstrap: add sys_wait module
+       Fixes bug #164
+
+2011-01-07  Dominic Cleal  <dcleal@redhat.com>
+
+       Add support for Solaris multiboot kernels with slashes in the first kernel argument (Fix ticket #158)
+
+       Allow kernel$ and module$ extensions to GRUB for Solaris (Fix ticket #158)
+
+2011-01-07  David Lutterkort  <lutter@redhat.com>
+
+       Shellvars: read various snmpd config files
+       Patch by erinn
+
+       Fixes ticket #170
+
+2011-01-07  Dominic Cleal  <dcleal@redhat.com>
+
+       Solaris_system: new lens for /etc/system (Solaris)
+       File is used to configure the kernel, module loading and parameters. The
+       system(4) man page gives a good overview of the commands and a sample file:
+       http://docs.sun.com/app/docs/doc/816-5174/system-4?l=en&n=1&a=view
+
+       It supports moddir, rootdev, rootfs, exclude, include, forceload and set.
+       The set tree is broken down quite a lot as the operator can vary (equals,
+       bitwise AND and OR).
+
+2011-01-07  David Lutterkort  <lutter@redhat.com>
+
+       Resolv: allow comments starting with semicolon
+       Patch by erinn
+
+       Fixes bug #173
+
+2011-01-03  Raphaël Pinson  <raphink@gmail.com>
+
+       Add automount, netmasks and sendmailvars keywords for databases in nsswitch.aug
+
+       Add bootparams as database keyword (Fix ticket #171) Update test file accordingly
+
+2010-12-29  Raphaël Pinson  <raphink@gmail.com>
+
+       Rename "host" nodes as "origin" (breaks compatibility) Implement "except" keyword as a subtree Make origin_re less strict to fix comment #6 in ticket #166 Implement multiple users and netgroups Improve test file
+
+2010-12-28  Francis Giraldeau  <francis.giraldeau@usherbrooke.ca>
+
+       Add xml lens
+       The XML lens parse arbitrary XML documents. Most, but not all features of XML
+       standard are implemented, partially because the nature of augeas. Tests comes
+       from OASIS test suite.
+
+       Supported:
+         * Document type declaration: elements, attlist, entity
+         * XML Prolog
+         * XML comments
+         * XML processing instructions
+         * Neested elements, including empty elements
+         * Element attributes
+         * Mixed content, text and elements
+         * CDATA sections
+
+       Not supported:
+         * Single quotes attributes: double quotes is mandatory
+         * External entity reference, because augeas can't load a related file within a lens
+         * Document validation: augeas don't enforce DTD
+
+       This lens doesn't respect the PutGet law, becuse of an ambiguity in union.put
+       with text nodes. If a text node is created as a sibling of another text node, a
+       put and a get will merge those two nodes. In practice, no error occur and this
+       is a desirable behavior.
+
+2010-12-22  Raphaël Pinson  <raphink@gmail.com>
+
+       Fix ticket #169 and add unit tests by Sergio Ballestrero.
+
+2010-12-20  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c (func_regexp): do not SEGV on error; provide better error msg
+       Fixes bug 168
+
+         * when the passed in regexp had a syntax error, we would leave the
+           interpreter variable at VIND uninitialised, but tagged as a regexp. As
+           a result, we'd SEGV when that slot in the variable table is
+           freed. Properly initialize slots in the variable table to NULL, and
+           store the regexp as soon as it has been built (before compilation)
+           there to address that.
+         * when a regexp had a syntax error, we would just drop the details of the
+           syntax error on the floor. We now include that in the error details so
+           that the user has some hint to how the regexp is foobared
+
+       # Please enter the commit message for your changes. Lines starting
+       # with '#' will be ignored, and an empty message aborts the commit.
+       # On branch master
+       # Changes to be committed:
+       #   (use "git reset HEAD <file>..." to unstage)
+       #
+       #       modified:   src/pathx.c
+       #
+       # Untracked files:
+       #   (use "git add <file>..." to include in what will be committed)
+       #
+       #       doc/cfg.txt
+       #       doc/naturaldocs/conf/lenses/Menu_Backup.txt
+       #       doc/naturaldocs/conf/lenses/Menu_Backup_2.txt
+       #       p/
+       #       site.orig/
+       #       tests/root-small/
+       #       tests/root/etc/network/
+       #       tests/root/etc/samba/
+       #       tests/root/etc/sysconfig/system-config-firewall
+
+2010-12-10  Francis Giraldeau  <francis.giraldeau@usherbrooke.ca>
+
+       Enable square lens in dump_lens
+
+       Add square lens to language
+       The new primitive square lens allows to handle XML like open and close tags.
+       It takes 2 arguments, a regexp for the tag and a lens for the content. The
+       square lens verify that open and close tags are matched in the get direction,
+       and put direction handles the close tag by copying the key.
+
+         * src/builtin.c: add "square" keyword to language
+         * src/lens.c: lns_make_square to compile the lens from actual simpler
+           lenses
+         * src/lens.h: append L_SQUARE to lens_tag enum to identify the square lens
+           type object
+         * src/jmt.c: handle square lens in parser
+         * src/get.c: add char* square to state struct to hold the last L_DEL in
+           square to perform syntax check, and add all get handling functions for
+           L_SQUARE
+         * src/put.c: modify create_del to render current key when default string is
+           NULL and add all put handling functions
+         * tests/modules/pass_square.aug: unit tests to validate the square lens,
+           regular and recursives
+
+2010-12-09  Francis Giraldeau  <francis.giraldeau@usherbrooke.ca>
+
+       Add test for lens-access.sh in Makefile
+
+2010-12-02  Raphaël Pinson  <raphink@gmail.com>
+
+       Relicense pg_hba.aug as LGPLv2+ as the rest of Augeas.
+
+2010-12-02  Lorenzo Dalrio  <lorenzo.dalrio@gmail.com>
+
+       Add access.aug and associated test file
+
+2010-12-02  Raphaël Pinson  <raphink@gmail.com>
+
+       Fix GPL into LGPLv2+ for a series of lenses.
+
+2010-11-24  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Ignore eclipse project files
+
+2010-11-22  Raphael Pinson  <raphink@gmail.com>
+
+       Add support for "map" entries in grub.aug and adapt test accordingly (Fix ticket #148)
+
+2010-11-19  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.7.4
+
+2010-11-19  Raphaël Pinson  <raphink@gmail.com>
+
+       * lenses/util.aug: improve management of eol comments
+         - add comment_generic
+         - use comment_generic in comment
+         - add comment_eol
+         - add comment_or_eol
+
+       Use comment_eol and comment_or_eol in some lenses to fix default eol
+       comment entries.  Adapt tests for shellvars and services to take this new
+       behaviour in consideration.
+
+       Add "indomU" Debian setting to grub.aug (Fix ticket #162)
+
+       Allow "\" style newlines in syslog.aug and add corresponding test (Fix ticket #161).
+
+2010-11-18  Raphael Pinson  <raphink@gmail.com>
+
+       Make filter a View in sudoers.aug to make it appear properly in doc
+
+       Improve doc on services.aug
+
+       Add some doc to pg_hba.aug
+
+       Add a bit of doc to pbuilder.aug
+
+       Add all missing lenses to Menu.txt
+
+2010-11-18  Mathieu Arnold  <mat@FreeBSD.org>
+
+       Add syslog.aug and associated test file
+
+2010-11-18  Raphaël Pinson  <raphink@gmail.com>
+
+       resolve refresh_pattern into fields Parse "extension_methods" into a list break entries upgrade_http0.9 and broken_vary_encoding down similar to what http_access does
+       Fix ticket #46
+
+2010-11-18  Mathieu Arnold  <mat@FreeBSD.org>
+
+       On FreeBSD (at least) the sudoers file is in /usr/local/etc/.
+
+2010-11-18  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Parse ulimit builtin in shellvars.aug (fix ticket #73).
+
+       Accept double quotes in arguments in postfix_master.aug, fix bug# 69
+
+2010-11-18  David Lutterkort  <lutter@redhat.com>
+
+       * tests/Makefile.am (lens_tests): add tests for new lenses
+
+       Krb5 (realm_re, app_re): allow digits in realm names
+       Still makes the incorrect assumption that realm names start with an upper
+       case letter, and app names with a lower case one, but it's an improvement
+       over the current restrictions.
+
+       Fixes bug https://fedorahosted.org/augeas/ticket/139
+
+2010-11-18  Matthew Booth  <mbooth@redhat.com>
+
+       Fix crasher in ast.c:dict_pos on i686 with gcc 4.5 and -O2
+       This patch works around what appears to be an optimization bug in gcc 4.5. The
+       symptom of the bug is that dict_pos, called from dict_lookup, receives an
+       invalid value when accessing dict->used. The following ticket describes the bug,
+       and includes a simple test case:
+
+       https://fedorahosted.org/augeas/ticket/149
+
+       Adding a printf to dict_lookup immediately before the dict_pos call reveals that
+       dict->used has a value of 30 in the crashing case on my F14 system. A printf
+       added to the first line of dict_pos shows dict->used has an apparent value of
+       16777246. This causes an invalid array lookup shortly afterwards, which causes
+       the crash. 16777246, interestingly, is 2^24 + 30, where 24 is the size of the
+       dict->used bitfield. This should obviously not be possible, suggesting either a
+       compiler bug or undefined behaviour due in incorrect use of the language. Having
+       re-read the relevant section of K&R, I can't see anything about this use of
+       bitfields which might be a problem, except that: 'Fields may be declared only as
+       ints; for portability, specify signed or unsigned explicitly.' uint32_t resolves
+       to 'unsigned int' on i686, and in any case, replacing it with 'unsigned int'
+       does not solve the problem. As it stands, I believe this is a bug in the
+       optimizer.
+
+       The above ticket contains an alternate patch which copies dict in dict_pos,
+       which also prevents the crash. However, adding anything to dict_pos which
+       prevents the compiler from optimising dict away achieves the same result. For
+       example:
+
+       printf("%p", dict);
+
+       This patch instead removes the bitfields in struct dict. While this is a
+       workaround, these bitfields save at most 1 word of memory per struct, but at the
+       cost of mis-aligned access. The patch does not increase the size of
+       dict_max_size to UINT32_MAX, as the lower maximum serves as a better guard
+       against runaway memory allocation.
+
+2010-11-17  Raphael Pinson  <raphink@gmail.com>
+
+       Allow underscore in chain_name for iptables.aug and adjust test accordingly.
+
+2010-11-17  Erinn Looney-Triggs  <erinn.looneytriggs@gmail.com>
+
+       Add login_defs.aug and associated test file.
+
+2010-11-14  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       pg_hba: added debian systems path to filter - fixes #154.
+
+       util.aug: exclude unneeded files on debian systems (fix ticket #153)
+
+2010-11-05  Raphael Pinson  <raphink@gmail.com>
+
+       Map comments and use Util.comment and Util.empty in order to full fix ticket #151. Adapt test accordingly.
+
+       Allow indented lines in aptsources.aug (Fix ticket #151) and add associated test
+
+       Allow "=" as a separator for title in grub.aug (Fix ticket #150) and adapt test accordingly.
+
+2010-11-04  Raphael Pinson  <raphink@gmail.com>
+
+       Fix example in lens
+
+2010-11-02  Raphael Pinson  <raphink@gmail.com>
+
+       Add a few lenses to Menu.txt
+
+       Add shells.aug and associated test
+
+2010-11-01  Raphael Pinson  <raphink@gmail.com>
+
+       Add mke2fs.aug and associated test
+
+2010-10-31  Raphael Pinson  <raphink@gmail.com>
+
+       Add support for rpc services in inetd.aug, rework lens to allow it and add tests accordingly.
+
+       Parse option values in fstab.aug, adapt test file accordingly.
+
+       Map service names in node values instead of node names to prevent variable node names.
+
+2010-10-29  Raphael Pinson  <raphink@gmail.com>
+
+       Add /etc/mtab to known files
+
+2010-10-28  Raphael Pinson  <raphink@gmail.com>
+
+       Fix paramater into parameter in ND comment
+
+2010-10-27  Raphael Pinson  <raphink@gmail.com>
+
+       Use generic modules in bbhosts.aug
+
+2010-10-26  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Fixes bug #144: wrong behavior of iter concat
+       This patch fix the list_tail_cons macro to fastforward the tail list when
+       the first item is added to the list, otherwise if the first item added when
+       the list is NULL has two item, the tail points the the first item.
+
+2010-10-26  Raphael Pinson  <raphink@gmail.com>
+
+       Fix filter to use proper file
+
+       Remove trailing whitespace
+
+       Add nsswitch.aug and associated test
+
+2010-10-26  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Add debugging information about lens hierarchy
+       When compiled with --enable-debug, will compile a function to output the lens
+       hierarchy in dot files. Enable this specific debug info with
+       AUGEAS_DEBUG=lenses
+
+2010-10-26  David Lutterkort  <lutter@redhat.com>
+
+       Sudoers: allow 'visiblepw' parameter flag
+       Fix provided by christj. Fixes bug #143
+
+2010-10-26  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Add clearm command to augtool
+       The clearm command is the same as setm, but sets the node value to
+       NULL in place of a string, suitable in some use case. 
+
+       Fix ticket #146
+
+2010-10-26  Raphael Pinson  <raphink@gmail.com>
+
+       /etc/sudoers.d is now supported (at least in Debian and Ubuntu)
+
+       Add resolv.aug and test
+
+2010-10-14  Aurelien Bompard  <aurelien@bompard.org>
+
+       Pg_hba: new lens and test
+       Fixes bug #140
+
+2010-09-30  Raphaël Pinson  <raphink@gmail.com>
+
+       Add a few lenses to Menu.txt
+
+       Use Rx.ipv4 and Rx.integer in openvpn.aug
+
+       Use generic modules Rx, Sep and Build in keepalived.aug
+
+       Add email_addr to rx.aug
+
+       Improve build.aug
+
+       Improve documentation of build.aug
+
+2010-09-29  Raphaël Pinson  <raphink@gmail.com>
+
+       Move Build, Rx and Sep into Generic Modules, add Keepalived
+
+2010-09-24  Raphaël Pinson  <raphink@gmail.com>
+
+       Improve keepalived.aug
+
+2010-09-23  Raphaël Pinson  <raphink@gmail.com>
+
+       Add a lens for keepalived.conf and associated test
+
+2010-09-23  David Lutterkort  <lutter@redhat.com>
+
+       Preserve parse errors under /augeas//error
+       With the changes in commit 5ee81630, a subtree in /augeas/files that is
+       dirty after trying to load all files indicates a file that was loaded
+       before, but is not loaded anymore (e.g., because the set of lenses changed
+       since the last time we loaded) In that situation, both the subtree in
+       /augeas/files as well as the corresponding subtree in /files is deleted.
+
+       The code in store_error, which is called by load_file when a parse error
+       happens, would leave that subtree in /augeas/files dirty. This commit fixes
+       that by making sure we mark the error entries as clean. It also revamps
+       store_error to use the lighter-weight tree_xxx functions instead of the
+       aug_xxx functions.
+
+       Fixes bug #138
+
+2010-09-21  Raphaël Pinson  <raphink@gmail.com>
+
+       * src/augtool.c: add -f|--file option to get commands from an input file
+
+2010-09-21  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       Nrpe: new lens and tests.
+
+       Odbc: new lens and tests.
+
+2010-09-15  David Lutterkort  <lutter@redhat.com>
+
+       When setting a tree node to the value it already has, do not modify the tree
+
+2010-09-09  David Lutterkort  <lutter@redhat.com>
+
+       * src/try: add an optioj to strace augtool
+
+       Properly record the new mtime of a saved file in the tree
+       transform_save used to pass an incorrect file name to add_file_info (the
+       name was missing the root prefix), leading to an mitme of 0 for all saved
+       files. That in turn causes freshly saved files to be unnecessarily reloaded
+       on the next aug_load.
+
+         * src/transform.c (mtime_as_string): tolerate a NULL filename, and return
+           an mtime of 0; (transform_save): pass the full file name, including the
+           root to add_file_info
+         * tests/test-load.c (testReloadDeletedMeta): the test is now
+           time-sensitive; to work around that, set the mtime of the changed tree
+           to the original mtime of the file
+         * tests/test-save.c (testMtime): verify that we record the actual mtime
+           and not just 0 in the tree after a save.
+
+       Thanks to Laine Stump for spotting this
+
+2010-08-27  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Fix yum tests
+         * Modify separator for list values to accept simple spaces
+         * Add all alternatives for baseurl and gpgkey
+         * Add tests to verify the correct behavior
+
+2010-08-27  David Lutterkort  <lutter@redhat.com>
+
+       * bootstrap: add locale module from gnulib
+       Fixes bug #137
+
+2010-08-16  David Lutterkort  <lutter@redhat.com>
+
+       Yum: accept continuation lines for gpgkey
+       Fixes bug #132
+
+2010-08-16  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       * src/get.c (visit_exit): fix segfault from empty stack for L_MAYBE
+       Fixes bug #136
+
+2010-08-06  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.7.3
+
+       Fix behavior of aug_defnode
+         (1) Make sure that the definition of the variable is recorded under
+             /augeas/variables
+         (2) Do not report an error if the expression evaluates to a non-empty
+             nodeset
+
+         * src/augeas.c (aug_defvar): split creating metadata under
+           /augeas/variables into record_var_meta; (aug_defnode): do not return an
+           error when expr evaluates to nonempty node set; record variable
+           definition
+         * tests/test-api.c: add tests for defvar and defnode behavior
+
+2010-08-05  David Lutterkort  <lutter@redhat.com>
+
+       Use pathx_aug_parse rather than pathx_parse in various places
+       Since pathx_aug_parse makes sure the symbol table stays updated, use
+       pathx_aug_parse whereever that makes sense.
+
+       Rename parse_user_pathx to pathx_aug_parse
+         * internal.h (pathx_aug_parse): new protoype
+         * augeas.c (pathx_aug_parse): renamed, add optional arg for a different
+           root
+
+       Fix BZ 613967 - memory corruption on reloading externally modified file
+       The problem was that when we replaced the old tree for a file with the new
+       one we just read from the file, the replace operation did not update
+       nodesets in variables, since we did not pass the global symtab into
+       tree_replace.
+
+         * src/internal.h (tree_replace): pass in struct augeas, so that we have
+           access to the global symtab
+         * src/augeas.c (tree_replace): make sure we create the pathx with the
+           global symtab
+         * src/transform.c (load_file): adapt to new prototype for tree_replace
+         * tests/test-load.c (testReloadExternalMod): test that we do not segfault
+           when a file was modified externally
+
+       Test root: mimick the setup of grub config files on Fedora more closely
+         * root/etc/grub.conf: symlink to root/boot/grub/grub.conf
+         * root/boot/grub/grub.conf: new file with contents of /etc/grub.conf
+         * root/boot/grub/menu.lst: symlink to grub.conf
+
+2010-08-03  Raphael Pinson  <raphink@gmail.com>
+
+       Sudoers: allow escaped spaces in user/group names
+       Fixes bug #124
+
+2010-07-26  David Lutterkort  <lutter@redhat.com>
+
+       Limits: also look for files in /etc/security/limits.d
+       Suggested by David Timms
+
+2010-07-23  Tim Stoop  <tim.stoop@gmail.com>
+
+       Mysql: lens for MySQL's *.cnf files
+
+2010-07-23  David Lutterkort  <lutter@redhat.com>
+
+       Sysconfig: new lens for a subdialect of shell
+       Using shell files with simple variable assignments is a very popular config
+       file format. The Shellvars lens doesn't serve those files perfectly well,
+       since it tries to preserve details important for general shell scripts that
+       are ignored by sysconfig files.
+
+       This lens is a variation on Shellvars that changes a few important aspects
+       of it:
+
+         * Strip quotes from values when reading a file, and restore quotes as
+           needed upon writing
+         * Pretend there's no difference between single and double quotes (this
+           assumption makes it possible to add quotes as needed solely based on
+           syntax)
+         * Do not support shell arrays or backticks; support for these could be
+           restored by somebody sufficiently motivated, though neither of them
+           should be used in a sysconfig file
+
+       The lens doesn't autoload any files yet, though we should consider moving
+       most of the files that Shellvars loads over to this lens.
+
+       * src/lens.c (lns_check_rec): allow 'let rec' with regular RHS
+       If the user writes 'let rec l = rhs' and the RHS does not mention l, just
+       mark the lens as regular and carry on.
+
+2010-07-21  David Lutterkort  <lutter@redhat.com>
+
+       * src/syntax.c (load_module_file): make sure we report an error
+
+       Fix segfault in glue routines; add test for the fix
+       The tree_*_glue functions did not set the error struct when parsing a path;
+       this caused a segfault when trying to insert before/after a non-existant
+       node, since tree_insert tried to report the error into a struct error that
+       was NULL.
+
+       Fixes bug #129
+
+       * src/syntax.c (compile_test): reset errors at the end of the test
+       Otherwise, we can't have tests succeed after tests failed intentionally (by
+       making their result '= *')
+
+       * src/errcode.h (reset_error): new function
+         * src/augeas.c (api_entry): use reset_error
+         * src/errcode.c (reset_error): new function, with code from api_entry
+         * src/errcode.h (reset_error): add prototype
+
+2010-07-20  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       * src/put.c (split_concat): fix memory leak when split doesn't match
+
+2010-07-19  David Lutterkort  <lutter@redhat.com>
+
+       Use gnulib from a submodule
+       This allows us to record the exact changeset from gnulib that everybody
+       should be using.
+
+2010-07-19  Frederik Wagner  <fnerdwq@googlemail.com>
+
+       Added /etc/sysconfig/suseconfig to shellvars lens.
+
+2010-07-08  Francis Giraldeau  <francis.giraldeau@gmail.com>
+
+       Adding is_scan in the condition to accept an item
+
+2010-06-30  Matthew Booth  <mbooth@redhat.com>
+
+       Device_map: new lens for grub's device.map
+
+2010-06-29  David Lutterkort  <lutter@redhat.com>
+
+       Avoid unnecessary file parsing when reloading the tree
+       We used to reparse every file we knew about upon aug_load. Now, we only
+       reparse files if the file has changed on disk.
+
+       We test a few scenarios to make sure aug_load retains its behavior of
+       obliterating the tree and filling it with the latest from disk. This
+       includes throwing away unsaved changes or trees that have been deleted.
+
+       Add utility tree_store_value to avoid unnecessary strdup's
+         * src/internal.h (tree_store_value): add prototype
+         * src/augeas.c (tree_store_value): new function; (tree_set_value): use
+           tree_store_value
+
+       Make tree_clean available outside of augeas.c
+         * src/augeas.c (tree_clean): remove 'static'
+         * src/internal.h (tree_clean): add prototype
+
+       Add xstrtoint64 to internal.[ch]
+       The implementation is directly from libvirt
+
+         * src/internal.h (xstrtoint64): add prototype
+         * src/internal.c (xstrtoint64): add impl
+
+       * src/test-load.c (testLoadSave): work off a writable /etc/hosts
+       This addresses a FIXME that could lead to use not detecting incorrect behavior
+
+       Move 'run' test utility to cutest.[ch]
+         * tests/cutest.h (run): add prototype
+         * tests/cutest.c (run): add impl
+         * tests/test-save.c (run): remove
+
+       Redefine all variables upon load
+       This is a slight change in behavior: before, we used to just discard the
+       contents of all variables upon load. Now, we redefine variables by
+       evaluating the expression with which they were defined initially again.
+
+       The change in behavior is backwards compatible, since at worst, users will
+       redefine variables themselves after an aug_load
+
+       * src/augeas.c (aug_init): create /augeas/variables on startup
+
+       * src/augeas.c (aug_defvar): use constants to create /augeas/variables
+
+2010-06-22  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.7.2
+
+       * augeas.spec.in: fix ownership of /usr/share/augeas
+       fixes BZ 569393
+
+2010-06-17  David Lutterkort  <lutter@redhat.com>
+
+       Test behavior of aug_setm
+         * src/augeas.c (aug_setm): return number of modified nodes
+         * tests/test-api.c (testSetM): compliance tests for aug_setm
+
+       * src/augeas.c (aug_setm): do not segfault when sub is NULL
+
+2010-06-17  Frederik Wagner  <fnerdwq@gmail.com>
+
+       Tests for new aug_setm function
+       Test through augtool calls.
+
+       Exposed aug_setm to augtool.
+
+2010-06-17  David Lutterkort  <lutter@redhat.com>
+
+       Add aug_setm to API
+         * src/augeas.h (aug_setm): new public API call
+         * src/augeas.c (aug_setm): implement setting multiple nodes
+         * src/augeas_sym.version: export symbol aug_setm
+
+2010-05-24  Frederik Wagner  <fnerdwq@googlemail.com>
+
+       Shellvars: added SuSE sysconfig puppet files
+       For SuSE systems, added /etc/sysconfig/{puppet,puppetmaster} to lens.
+
+2010-05-18  Frederik Wagner  <fnerdwq@googlemail.com>
+
+       List handling shellvars_list lens added.
+       Lens shellvars_list has been added to treat variables in specific files
+       as lists of words, e.g. in /etc/sysconfig/ 'kernel' and 'bootloader'.
+
+       * lenses/shellvars.aug: removed include for /etc/sysconfig/kernel
+       * lenses/shellvars_array.aug: new lens
+       * lenses/tests/test_shellvars_array.aug: test for new lens
+
+2010-05-13  David Lutterkort  <lutter@redhat.com>
+
+       Add modules_conf to naturaldocs Menu
+
+       Add /etc/modules.conf from hell
+       Actually, from http://www.janerob.com/rob/ts5100/modules.conf
+
+2010-05-13  Matthew Booth  <mbooth@redhat.com>
+
+       Modules_conf: new lens for modules.conf and conf.modules
+
+       Modprobe: Refactor to make re-use easier
+
+2010-05-11  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c: record expression for defvar in /augeas/variables
+
+2010-05-07  David Lutterkort  <lutter@redhat.com>
+
+       * Grub: handle comments within a boot stanza
+       Fixes RH BZ 590067
+
+       Adjust copyright notices
+         - copyright is from creation of file through 2010
+         - adjust copyright owner according to Red Hat's policy
+
+2010-05-04  Raphael Pinson  <raphink@gmail.com>
+
+       Group: add test for disabled account ('!' in password field)
+
+2010-04-27  seph  <seph@directionless.org>
+
+       Shellvars: process /etc/environment
+
+2010-04-26  Nicolas Valcárcel Scerpella  <nvalcarcel@ubuntu.com>
+
+       Iptables: also look for /etc/iptables-save
+       This is where Debian keeps iptables rules
+
+2010-04-26  Frederik Wagner  <fnerdwq@googlemail.com>
+
+       securetty: added handling of emtpy lines/comments
+       * lenses/securetty.aug:
+               added handling of comments and empty lines
+       * lenses/tests/test_securetty.aug:
+               added test for enhanced lens
+
+2010-04-21  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.7.1
+
+2010-04-21  Simon Josi  <josi@puzzle.ch>
+
+       Securetty: new lens and test for /etc/securetty
+
+2010-04-21  David Lutterkort  <lutter@redhat.com>
+
+       Sudoers: use example file from Fedora 13
+       This is causing trouble with release-0.7.0, but not this revision.
+
+       File was reported in bug #122
+
+       tests: make most tests work on Solaris
+       The test scripts are full of bashisms; removed some of them, though for
+       most, just changed the shell from /bin/sh to /bin/bash; removing bashisms
+       will need to be addressed.
+
+       Tests now mostly pass (82/85) on the OpenCSW Solaris 5.10 build machine
+
+       * tests/test-save.c: use proper includes for WIFEXITED
+       Without them, the build fails on FreeBSD
+
+2010-04-20  David Lutterkort  <lutter@redhat.com>
+
+       Debctrl (multi_line_entry): fix bad regexp
+       The lens 'del /^ / " "' is not valid, since we do not allow '^' as a meta
+       character. Changing that to 'del / / " "' exposed a typecheck problem in
+       lns: both multi_line_entry and eol match blank lines. Fixed this by
+       requiring that a multi_line_entry has to have at least one non-blank
+       character.
+
+       Debctrl: whitespace cleanup, no functional change
+
+       * src/fa.c (re_iter_as_string): escape literal '|'
+       When turning a FA back to a string, a literal '|' needs to be output as '\|'
+
+         * tests/fatest.c (testExpandCharRanges): test escaping of literal '|'
+
+2010-04-19  David Lutterkort  <lutter@redhat.com>
+
+       * tests/fatest.c (print_regerror): do not use alloca
+
+       * bootstrap: pull in isblank explicitly
+       Fixes bug #111
+
+       * src/lens.c (lns_check_rec): fix refcounting mistake on error path
+       Fixes bug #120
+
+       * src/augtool.c: report an error when 'get' fails
+
+       aug_get: return -1 when multiple nodes match
+       This fixes breakage in the API contract for aug_get, introduced in commit
+       e80494a6. Also adds a test to ensure we do not break API for aug_get again.
+
+       Fixes bug #121
+
+2010-04-16  David Lutterkort  <lutter@redhat.com>
+
+       jmt: distinguish between successful parse and syntax error at end of input
+       If a syntax error happened after the last character of the input string
+       (e.g., becuase the input was incomplete), rec_process would think the parse
+       was successful, and then notice that there was no parse result. That would
+       lead to an incorrect error message hinting at an internal error, when it
+       was really a syntax error.
+
+       By changing the return value for jmt_visit, it's now possible to
+       distinguish between internal errors, syntax errors and successful parses
+       properly.
+
+       * src/get.c (visit_exit): handle L_MAYBE
+       Added test to tests/modules/pass_simple_recursion.aug, lens 'maybe'
+
+       Fixes bug #119
+
+       * src/jmt.c (build_tree): print debug output for build_nullable
+
+2010-03-12  David Lutterkort  <lutter@redhat.com>
+
+       * lenses/tests/test_logrotate.aug: add test for files separated by newlines
+       This test the fix for bug #104, commit fe0453ce.
+
+2010-03-11  David Lutterkort  <lutter@redhat.com>
+
+       * lenses/group.aug (password): remove backslashes
+       Backslashes in char classes are taken literally, they do not escape a
+       character.
+
+2010-03-11  root  <root@lx200.costest.lrz.de>
+
+       Group: Added disabled password support
+       * lenses/group.aug: '*' and '!' are allowed chars for disabled password
+       * lenses/tests/test_group.aug: added test for lens change
+
+2010-03-11  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (lns_check_rec): avoid use of uninitialized 'result'
+       The ensures can fail, and we check whether result is NULL in the error
+       path.
+
+2010-03-05  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (lns_format_atype): format L_REC lenses
+
+       * src/lens.c: remove asserts; better error for missed tag in switch
+
+       Shellvars: handle a bare 'export VAR'
+
+       Inittab: allow ':' in the process field
+       Fixes part of bug #109
+
+2010-03-05  Tim Stoop  <tim.stoop@gmail.com>
+
+       Approx: allow keywords starting with '$'
+
+2010-03-04  David Lutterkort  <lutter@redhat.com>
+
+       Approx: lens and test for the approx proxy server
+
+       Produce a better error when iteration stops prematurely during put/create
+       We now try to include the name of the child node that caused us to stop in
+       the error message.
+
+2010-03-03  David Lutterkort  <lutter@redhat.com>
+
+       * src/fa.c: allow the strange regexp syntax '(a|)'
+       POSIX allows it, and so do we now
+
+       Fixes bug #113
+
+2010-03-02  David Lutterkort  <lutter@redhat.com>
+
+       Passwd: parse NIS entries on Solaris
+       Based on a fix by Stuart Sears
+
+2010-02-26  David Lutterkort  <lutter@redhat.com>
+
+       * src/fa.c: clean up error macros
+       The error macros _E, _F, and _N use names reserved for system libraries;
+       this leads to compile errors at least on Solaris (as reported by lanky).
+
+       Rename _E and _F to E and F, and eliminate _N.
+
+2010-02-26  Frederik Wagner  <wagner@lrz.de>
+
+       Modprobe: Suse includes
+       * lenses/modprobe.aug: included /etc/modprobe.conf.local
+
+       Shellvars: Suse includes
+       * lenses/shellvars.aug:
+           added include for /etc/sysconfig/network/ifcfg-
+
+       Grub: support empty kernel parameters, Suse incl.s
+       * lenses/grub.aug:
+         - added support for kernel parameters of the form "parameter="
+           w/o given value
+         - included /boot/grub/menu.lst
+         - changed default for delimiter in kw_menu_arg to " "
+       * lenses/tests/test_grub.aug: changes corresponding to lens change
+
+2010-02-26  Dominique Dumont  <domi.dumont@free.fr>
+
+       Debctrl: new lens and test
+
+2010-02-23  David Lutterkort  <lutter@redhat.com>
+
+       Ntp: add 'tinker' directive
+       Fixes bug #103
+
+       Logrotate: tolerate whitespace at the end of a line
+       Fixes bug #101
+
+2010-02-23  Raphael Pinson  <raphink@gmail.com>
+
+       Dhclient: add rfc code parsing
+       Fixes bug #107
+
+       Sudoers: allow del_negate even if no negate_node is found
+       Fixes bug #106
+
+       Logrotate: files can be separated by newlines
+       Fixes bug #104
+
+       Dput: add 'allow_dcut' parameter
+       Fixes bug #105
+
+2010-02-22  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c: ignore empty lines from stdin
+       We still complain about the nonsensical 'augtool ""'.
+
+       Fixes BZ 566844 reported by Mike Burns
+
+2010-02-22  Stuart Sears  <ssears@redhat.com>
+
+       Sudoers (parameter_string_nobool_kw): accept "secure_path "
+       Fixes BX 566134
+
+2010-02-19  Tim Stoop  <tim.stoop@gmail.com>
+
+       Nagisocfg: lens and test for /etc/nagios3/nagios.cfg
+
+2010-02-12  Ivana Hutarova Varekova  <varekova@redhat.com>
+
+       Cgrules: new lens and test
+       See cgrules.conf for http://libcg.sourceforge.net/
+
+2010-02-11  Ivana Hutarova Varekova  <varekova@redhat.com>
+
+       Cgconfig: lens and tests for libcgroup config
+       See http://libcg.sourceforge.net/
+
+2010-02-11  Laine Stump  <laine@laine.org>
+
+       * src/transform.c (file_info): fix memory leak
+
+2010-02-09  David Lutterkort  <lutter@redhat.com>
+
+       * lens.c (ambig_check): pretty print tree type errors
+       Instead of dumping raw regular expressions for the tree encoding, print out
+       something resembling our tree notation.
+
+2010-02-08  David Lutterkort  <lutter@redhat.com>
+
+       libfa: handle the syntax r{min,} properly
+         * src/fa.c (parse_repeated_regexp): set max = -1 when we see r{min,};
+           (re_iter_as_string): when max == -1, print r{min,}
+         * tests/fatext.c (testExample): add a few tests for this syntax
+
+       * src/fa.c (parse_int): flag not parsing anything as an error
+
+       * src/jmt.c: add caller filtering
+       Caller filtering is needed to weed out seemingly ambiguous parse trees (see
+       Section 5.3 of Jim/Mandelbaum's paper)
+
+       Also adds two pathological lenses and tests to
+       pass_simple_recursion.aug. Those tests fail without caller filtering.
+
+       * AUTHORS: reformatted
+
+       * tests/Makefile.am: add test for cobblermodules.aug
+
+2010-02-08  Shannon Hughes  <shughes@redhat.com>
+
+       Cobblermodules: lens + tests for cobbler's modules.conf
+
+2010-02-02  David Lutterkort  <lutter@redhat.com>
+
+       Shellvars: allow spaces after/before opening/closing parens for array
+       Bug reported by Doug Warner
+
+2010-02-01  Matthew Palmer  <matt@anchor.net.au>
+
+       Sshd: allow optional arguments in subsystem commands
+
+2010-01-27  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c (tree_replace): don't bother marking the new parent as dirty
+       We call tree_rm on it earlier, which already marks it as dirty.
+
+       This line also triggered a SEGV when sub == NULL; this happened, for
+       example, when /etc/apt/preferences was an empty file.
+
+       Bug reported by Matt Palmer
+
+       * src/get.c (no_match_error): initialize lname
+       Otherwise, gcc complains about a possibly uninitialized value with -O2
+
+2010-01-25  David Lutterkort  <lutter@redhat.com>
+
+       Test for using a recursive lens inside other lenses
+
+       * src/get.c: handle recursive lenses that are not L_REC
+       Since any lens that uses an L_REC is itself recursive, the distinction
+       whether to use get_rec or get_lens can be made in lns_get
+
+       rec_process will also build the jmt if it does not exist yet
+
+       Fixes ticket #100
+
+       Properly handle lenses that use L_REC lenses
+       In constructs involving a recursive lens, we need to take the body of the
+       recursive lens into consideration. We avoid infinite recursion by stopping
+       when we see an L_REC that is marked as rec_internal, since that's the
+       struct lens that points back to the top of the lens from within it.
+
+       jmt_build now expects to be handed a properly set up recursive lens, which
+       means that for an L_REC both the internal and external instances have to
+       exist and be connected
+
+         * src/lens.c (lns_check_rec): defer building the jmt until the end
+         * src/jmt.c: when building the jmt, consider L_REC as long as it's not
+           internal
+
+       * src/jmt.c (print_grammar): recurse into L_REC if they are not rec_internal
+
+       * src/jmt.c (jmt_visit): allow for toplevel lenses that are not L_REC
+       To reconstruct the parse of a lens that is not L_REC, but uses L_REC,
+       e.g. l* where l is L_REC, we can not assume any longer that the root of the
+       parse tree has only one child. Consequently, we need to start
+       reconstruction with listing all the children of the root node.
+
+       Split build_tree into build_children (collects a list of child nodes) and
+       build_tree which creates the tree for a nonterminal.
+
+       To start reconstruction, we now start with collecting the list of children
+       of the root of the parse tree; the Earley graph does not contain an item
+       for that, which makes this operation slightly special.
+
+       * src/lens.c: propagate rec_internal in the body of an L_REC
+
+       * src/lens.c: don't short-circuit typechecking for recursive lenses explicitly
+       The typecheck helpers are all smart enough to not run checks when one of
+       the types is NULL, as is the case for recursive lenses.
+
+       * src/lens.h (struct lens): explain better how we handle recursive lenses
+
+       * src/jmt.c (build_trace): allow passing in a NULL item
+
+       * src/lens.c (tags): add name for value primitive
+
+       * src/get.c: replace assert's by ensure's
+       assert aborts, which a library shouldn't do
+
+       * src/errcode.h (ensure0): convenience version of ensure
+
+       * src/get.c (find_seq): properly report OOM, do not call abort
+
+       Remove assert_error_at
+       This function was dangerous, since it does not jump, and therefore users
+       will continue doing what they were doing, even if an assertion failed. Use
+       BUG_ON instead.
+
+       * src/get.c (struct state): make info a pointer
+
+2010-01-23  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (restrict_regexp): properly report OOM
+
+2010-01-20  David Lutterkort  <lutter@redhat.com>
+
+       Document the basics of building from git
+
+2010-01-15  David Lutterkort  <lutter@redhat.com>
+
+       * src/builtin.c: builtins for printing and inspecting lenses
+
+       Add a unit type
+       The literal '()' is the only member of the unit type. Composition is now
+       allowed if the first expression is of type unit, i.e. '() ; something' is
+       legal.
+
+       Language: allow '_' as an identifier that is never bound
+         The expression
+           let _ = something
+         will evaluate something and then immediately forget it
+
+         * src/lexer.l (LID): allow leading underscore
+         * src/syntax.c (bind, bind_type): do not bind '_'
+
+       New primitive lens 'value'
+       In analogy to 'label', this lens allows setting the value of a tree node to
+       a fixed string
+
+2010-01-14  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.7.0
+
+       Json: lens and tests for generic Json files
+
+       Tests for recursive (context free) lenses
+
+       Syntax for recursive lenses
+       Add a 'let rec' construct; the syntax should be considered experimental and
+       might be changed to some other form of expressing recursion.
+
+       With recursive lenses, we can't do the bottom-up typechecking that we do
+       for regular lenses; we need to consider the whole lens at once. This is
+       achieved by inserting a callback to lns_check_rec when we parse 'let rec
+       ident = exp'.
+
+         * src/builtin.c (lns_check_rec_glue): new function
+         * src/lexer.l: new token LETREC
+         * src/parser.y: add syntax rule for LETREC and desugar it into a call to
+           lns_check_rec
+         * src/syntax.h: make free_term available, constant for name
+           of let_check_rec within the interpreter
+         * src/syntax.c (free_term): now extern, not static
+
+       * src/get.c (get_rec, parse_rec): get/parse for recursive lenses
+
+       * src/put.c: put/create for recursive lenses
+
+       Remember the jmt in the lens and free it when it is no loner needed
+
+       Earley parser based on Jim/Mandelbaum's transducers
+
+       Calculate if a lens's ctype is nullable
+
+       Add a typechecker and constructor for recursive lenses
+         * src/lens.h (lns_make_rec, lns_check_rec): new functions
+         * src/lens.c (lns_make_rec, lns_check_rec): new functions
+
+       Suppress buildtime typechecks for L_REC; propagate recursive flag
+
+       * src/lens.c (free_lens): free recursive lenses
+
+       * src/lens.h: add a recursive lens combinator
+
+       A simple debug facility
+       Debugging is disabled by default. When configured with --enable-debug=yes,
+       Augeas will look at runtime at the environment variable AUGEAS_DEBUG, which
+       should contain a colon-separated list of categories. Besides printing
+       various thigs on stdout, some debug output is also left in files in the
+       directory set by the environment variable AUGEAS_DEBUG_DIR, e.g., dot
+       graphs of various internal data structures.
+
+         * configure.ac: add --enable-debug option
+         * src/internal.h (debugging, debug_file): new functions
+         * src/internal.c (debugging, debug_file): new functions
+
+       struct error: add pointer back to struct augeas
+
+       * src/errcode.h: more usable BUG_ON and BUG_FMT
+
+       * src/lens.c (ambig_check): report OOM from fa_ambig_example
+
+       * src/fa.c (fa_ambig_example): getting a NULL example is not an error
+
+       * src/syntax.c (compile): give up after the first error
+       We have no error recovery to speak off; if we keep going, we most of the
+       time carpet-bomb the user with error messages that are simple follow-ons to
+       the first error.
+
+       * TODO: deleted, that list is in Trac now
+
+       * src/fa.c (fa_intersect): initialize vars that could be used on error
+
+       * src/fa.c (fa_as_regexp): convert strings more efficiently
+       Since we are building the transitive closure of the FA, cut down the size
+       of the FA by first extracting strings and removing their internal states.
+
+       * src/fa.c (fa_as_regexp): fin only accepting state, no trans fin->fin
+
+       Indicate whether an FA uses character ranges or regexps on transitions
+         * src/fa.c (struct fa): new field trans_re; (fa_as_regexp): set trans_re;
+           (fa_dot): print regexp rather than char range if trans_re is set
+
+2010-01-13  David Lutterkort  <lutter@redhat.com>
+
+       Add syntax for case-insensitive regexps
+       A regexp literal /regexp/i will be converted to a case-insensitive regexp.
+
+       * src/regexp.c (regexp_minus): respect nocase flags
+
+       * src/lens.c (str_to_fa): compile nocase fa when needed
+
+       * src/lens.c (str_to_fa): remove FIXME's and use proper error reporting
+
+       Support for case-insensitive regexps
+       Add nocase argument to make_regexp, and adjust all uses of make_regexp to
+       pass that in. For concatenation and union of regexps we have to expand
+       case-insensitive regexps when they are mixed with case-sensitive regexps.
+
+       Adjust all uses of make_regexp.
+
+       Add fa_expand_nocase to libfa
+
+       Support for case-insensitive operations in libfa
+         * src/fa.h (fa_nocase, fa_is_nocase): new functions
+         * src/fa.c (struct fa): new field nocase; (fa_is_basic): a total FA has
+           two transitions under nocase; (fa_clone): preserve nocase flag;
+           (union_in_place, concat_in_place, fa_intersect): if one operand is
+           nocase, and the other isn't, expand the nocase FA to a case-sensitive
+           one; (totalize): do not add transitions on [A-Z]; (fa_nocase,
+           fa_is_nocase): new functions; (case_expand): new function
+         * tests/fatest.c (assertExample): also test against a nocase FA;
+           (testNoCase): test concat etc. on nocase FA's
+
+       * src/lens.c (subtree_atype): new function
+
+2010-01-07  David Lutterkort  <lutter@redhat.com>
+
+       Facelift for augtool
+       This makes augtool somewhat friendlier, mostly because
+
+         - help is organized better: typing 'help' produces a list of commands and
+           a brief synopsis for each, typing 'help command' prints detailed help
+           about a command
+         - augtool now knows about path expressions, so that they do not need to
+           be enclosed in quotes if they have spaces with predicates, e.g. you can
+           now type 'get /foo[ last() ]'
+
+       Record an error if more than one lens tries to load a file
+         * src/transform.c (file_info): new function; (transform_load): detect if
+           more than one lens tries to load a file and record error in
+           /augeas/files/PATH/error
+
+       Pull computing a path underneath /files from a filename into a function
+         * src/transform.c (file_name_path): new function; (load_file): use
+           file_name_path
+
+       Change the metadata for individual files
+       Record the name of the lens used to load the file in the lens node
+       underneath /augeas/files/$PATH; the location info of the lens is kept in
+       lens/info
+
+         * src/transform.c (add_file_info): change what we keep underneath the
+           lens node
+         * tests/xpath.tests (lircd-ancestor): adapt to metadata change
+
+       * src/transform.c (add_file_info): manipulate tree directly
+       Going through public functions like aug_set is silly, and causes all kinds
+       of string munging.
+
+       Produce better error message for multiple matching transforms in save
+         * src/augeas.h (aug_errcode_t): new error code AUG_EMXFM
+         * src/augeas.c (errcodes): new error string for AUG_EMXFM; (tree_save):
+           report multiple transforms as proper error
+         * tests/test-save.c (testMultipleXfm): new test
+
+       New function transform_file_error
+         * src/transfrom.h (transform_file_error): add prototype
+         * src/transform.c (transform_file_error): new function
+
+       New function xfm_lens_name
+         * src/transfrom.h (xfm_lens_name): add prototype
+         * src/transform.c (xfm_lens_name): new function
+
+       Tree functions to find/create a node with a path expression
+       Internal counterparts to aug_get and aug_set
+
+         * src/internal.h (tree_find, tree_find_cr): new prototypes
+         * src/augeas.c (tree_find, tree_find_cr): new functions
+
+       * src/internal.h: make various tree management functions available
+
+2010-01-06  David Lutterkort  <lutter@redhat.com>
+
+       Xinetd (name): fix bad '-' in character class
+
+2010-01-05  David Lutterkort  <lutter@redhat.com>
+
+       Do not choke on non-existing lens during save
+         * src/transform.c (add_file_info): check that lens is non-NULL;
+           (lens_from_name): provide detailed error message when lens lookup
+           failed; (transform_validate): copy error from lens_from_name into tree
+         * tests/test-save.c (testNonExistentLens): new test
+
+       Fixes bug #98
+
+       New error code AUG_ENOLENS
+       Indicates failure to look a lens up by name from /augeas/load/*/lens
+
+         * src/augeas.h (aug_errcode_t): new value AUG_ENOLENS
+         * src/augeas.c (errcodes): new entry for AUG_ENOLENS
+
+       * src/lens.c (lens_release): tolerate a NULL lens
+
+2010-01-04  Bryan Kearney  <bkearney@localhost.localdomain>
+
+       Cobblersettings: new lens and test
+
+2010-01-04  David Lutterkort  <lutter@redhat.com>
+
+       Rename read_file to xread_file
+
+2009-12-23  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (lns_make_union, lns_make_concat): do not access free'd memory
+       make_lens_binop may free one of the lenses it gets passed. We can therefore
+       not reference them after a call to make_lens_binop.
+
+       * src/lens.c (format_lens): minimalistic pretty-printing of a lens
+
+       * src/regexp.c (print_regexp): clean the regexp with fa_restrict_alphabet
+
+2009-12-18  David Lutterkort  <lutter@redhat.com>
+
+       * src/builtin.c (lens_get, lens_put): propagate errors as exceptions
+
+       More convenience macros for errors
+       Add BUG_ON and ERR_RET macros for reporting internal errors
+
+         * src/errcode.h (BUG_ON, ERR_RET, HAS_ERR): new macros
+         * src/errcode.c (bug_on): implementation for BUG_ON
+
+2009-12-17  David Lutterkort  <lutter@redhat.com>
+
+       Lokkit: allow '-' in arguments
+
+       Iptables: handle both negation syntaxes
+       Options can be negated either with '! --option arg' or with '--option !
+       arg'. We now handle both, though they lead to slightly different trees
+
+2009-12-14  David Lutterkort  <lutter@redhat.com>
+
+       * doc/ftdetect/augeas.vim: fix syntax
+
+2009-12-09  Partha Aji  <paji@redhat.com>
+
+       Made samba aug accept entry keys with ':' in them
+
+2009-12-09  David Lutterkort  <lutter@redhat.com>
+
+       Shellvars: allow arrays that span multiple lines
+
+2009-12-07  David Lutterkort  <lutter@redhat.com>
+
+       Iptables: allow quoted strings as arguments
+
+2009-11-30  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.6.0
+
+       Distribute and install vim syntax files
+       Fixes ticket #97
+
+       * Makefile.maint: sign tags
+
+       Krb5: allow v4_name_convert in libdefaults section
+       Fixes part of ticket #95
+
+       Fstab: allow # in the spec
+       Fixes part of ticket #95
+
+       Group: allow empty password field
+       Fixes part of ticket #95
+
+       * src/parser.y: properly initialize yylloc
+       Fixes ticket #96
+
+2009-11-25  David Lutterkort  <lutter@redhat.com>
+
+       Properly check regexp literals for syntax errors
+         * src/regexp.h (regexp_check): new function
+         * src/regexp.c (regexp_compile_internal): new function to base both
+           regexp_compile and regexp_check off
+         * src/syntax.c (check_value): produce a syntax error if regexp does not
+           pass regexp_check; (check_exp): make sure we do check values
+
+       Fixes ticket #93
+
+       * src/lexer.l: include errcode.h; fix bad use of report_error
+
+       * src/errcode.c: include stdarg.h
+
+       Cron: variable names can contain '_' etc.
+       Use Shellvars.key_re for consistency.
+
+       Fixes ticket #94
+
+2009-11-25  Matt Palmer  <mpalmer@hezmatt.org>
+
+       AptPreferences: add a put test
+       Make sure we handle an empty file properly, and cleanup the resulting
+       hassle
+
+2009-11-24  Matt Palmer  <mpalmer@hezmatt.org>
+
+       Normalise records so that empty lines (which are a required part of the syntax) don't creep into the tree
+
+       Support version pins in apt_preferences
+
+2009-11-23  David Lutterkort  <lutter@redhat.com>
+
+       * tests/Makefile.am (lens_tests): run postfix_access tests
+
+2009-11-16  Partha Aji  <paji@redhat.com>
+
+       Added a Post Fix Access lens along with the unit tests
+
+2009-11-13  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (ambig_check): distinguish error between concat and iteration
+
+       * src/regexp.c (regexp_escape): treat NULL regexps as the empty regexp
+
+       * src/regexp.c (regexp_escape): fix stripping of enclosing parens
+       Only strip them if they belong together, and not for something like /(a)(b)/
+
+       * src/syntax.c: spew exceptions less often
+         print_value: only print exceptions that haven't been seen
+         compile_test: only print the exception for a test when it hasn't
+                       been seen
+
+       * src/get.c: never try to process a string that doesn't match
+       When a string during init_regs doesn't match at all, there's nothing useful
+       we can do. Immediately return an error from lns_get.
+
+       * src/syntax.h (exn_error): produce an exception to indicate an error
+       exn_error returns a special exception that indicates that an error has
+       happened (e.g., out-of-memory) that has already been reported in the
+       central augeas->error instance.
+
+2009-11-12  David Lutterkort  <lutter@redhat.com>
+
+       * src/info.c (print_info): do not choke on NULL info
+
+       * src/internal.h: new macros MEMCMP and MEMMOVE
+
+       * src/lens.c (lns_make_subtype): explain type derivation
+
+       * examples/fadot.c: by default, print minimized regexp
+
+       * examples/fadot.c: fix formatting, no functional changes
+
+2009-11-10  David Lutterkort  <lutter@redhat.com>
+
+       Make augparse and augtool use user's locale
+
+       * test/Makefile.am (TEST_ENVIRONMENT): set LANG to a non-C locale
+
+       Remove character ranges from regexps if we are not in the C locale
+       Since re_compile_pattern uses the current locale when expanding character
+       ranges like [a-z], we need to be careful that such ranges are expanded in
+       the C locale.
+
+         * configure.ac: check for uselocale
+         * src/internal.[ch] (regexp_c_locale): new function
+         * src/lens.c (digits_string): spell out the digits
+         * src/lens.c (restrict_regexp): expand char ranges in restricted regexp
+         * src/lexer.l (regexp_literal): run regexp literals through
+           regexp_c_locale
+         * src/regexp.c (regexp_escape): compress character ranges for printing
+         * src/regexp.c (regexp_minus): expand charcter ranges
+
+       Fixes ticket #35 for systems that do not have uselocale (for systems with
+       uselocale, the fix is commit 07b6a880)
+
+       libfa: new function fa_expand_char_ranges
+
+       Calls to __aug_load_module need to go through api_entry/api_exit
+
+       Switch to C locale on API entry on systems that have uselocale
+       Since we need to do all our operations (especially regexp matching) in the
+       C locale, we switch to that on API entry, and switch back to the user's
+       locale on API exit.
+
+       That also makes it necessary that aug_init wraps the bulk of its work
+       inside an api_entry/api_exit.
+
+       Fixes ticket #35 for systems that have uselocale
+
+2009-10-26  David Lutterkort  <lutter@redhat.com>
+
+       Inittab: parse end-of-line comments into a #comment
+
+2009-10-23  David Lutterkort  <lutter@redhat.com>
+
+       * src/lens.c (lns_make_subtree): parenthesize key and value patterns
+       These patterns may be a union not enclosed in parens
+
+       * src/regexp.c (regexp_escape): don't clobber last character
+
+       * src/lens.c: use regexp_escape to print regexps in error messages
+
+       * src/fa.c (fa_restrict_alphabet): initialize parse
+
+       * src/fa.c (special_chars): treat $ and ^ as special
+       They are special when they are at the beginning resp. the end of a regular
+       expression. Making them special (i.e., escaping them with '\') everywhere
+       doesn't hurt.
+
+       * src/fa.c (re_needs_parens_in_concat): ITER doesn't need parens in concat
+
+       * src/fa.c (re_cset_as_string): work properly with negated cset
+       We did not take re->negate into account, and always acted as if the cset
+       was not negated. Introduce helper function cset_contains to both fix that
+       and make the code a little clearer.
+
+2009-10-22  David Lutterkort  <lutter@redhat.com>
+
+       bootstrap: use stpcpy and stpncpy from gnulib
+
+       Makefiles: gnulib now requires linking against libselinux
+         * src/Makefile.am (libfa_la_LIBADD): add LIB_SELINUX
+         * examples/Makefile.am (fadot_LDADD): remove GNULIB
+
+2009-10-21  David Lutterkort  <lutter@redhat.com>
+
+       Path expressions: add union operator
+       Nodesets can now be unioned with the '|' operator
+
+       Fixes ticket #89
+
+       * src/pathx.c (clone_nodeset): properly set size of the clone
+       The size of the clone is the number of nodes in the original nodeset, not
+       the size of the original nodeset.
+
+       * src/regexp.c (regexp_union_n): insert '|' after the first non-NULL regexp
+       We can not blindly insert a '|' after the first passed-in regexp since that
+       (and any number of regexps at the beginning) might be NULL. We only insert
+       '|' after actually copying a regexp into the result.
+
+2009-10-20  David Lutterkort  <lutter@redhat.com>
+
+       Wine: new lens and test
+       Lens for parsing textual Windows registry files
+
+       Pam: allow '-' before type
+       The type field in a pam.d file can start with a '-' to indicate that
+       missing the module should not cause an error. The '-' is now mapped into
+       the tree as a separate node 'optional'
+
+       Bug reported by Shannon Hughes
+
+       * test/Makefile.am (lens_tests): add lens-ethers.sh
+
+       * src/internal.c (escape): convert char to unsigned when printing as octal
+       Without that, there's no guarantee that the char will be printed as three
+       octal digits and not more
+
+       Report line/column number when get/put test fails
+         * src/builtin.c (make_exn_lns_error): add line/column number in error
+           message
+         * src/internal.c (calc_line_ofs): moved here from transform.c
+         * src/internal.h (calc_line_ofs): declare prototype
+         * src/transform.c (calc_line_ofs): moved to internal.c
+
+       * src/get.c (get_error): use end of last match as error position
+
+       * man/augtool.1: regenerate
+
+2009-10-19  David Lutterkort  <lutter@redhat.com>
+
+       Krb5: support a [kdc] section
+       The only entry it can have so far is 'profile' - no idea what else can go
+       there since it's not documented in krb5.conf(5), but used, e.g. on Fedora
+       11
+
+2009-10-12  David Lutterkort  <lutter@redhat.com>
+
+       Rx (device_name): allow '!' in device name
+
+2009-10-09  David Lutterkort  <lutter@redhat.com>
+
+       Lokkit: make argument for --trust more permissive
+       The --trust option takes an interface name, whcih can be more than what
+       token accepts.
+
+         * lenses/lokkit.aug (trust): new lens; (entry): use trust
+         * lenses/rx.aug (device_name): new regexp
+         * lenses/tests/test_lokkit.aug: new test for more permissive device names
+
+       Lokkit.forward_port: add missing eol
+       Also adjust test_lokkit.aug since we're not getting a spurious empty entry
+       anymore
+
+2009-10-06  Satoru SATOH  <satoru.satoh@gmail.com>
+
+       /etc/ethers: new lens and test
+       The followings adds a new lens for /etc/ethers and associated test.
+
+2009-09-30  David Lutterkort  <lutter@redhat.com>
+
+       * src/augparse.c: get error details from error API
+
+       interpreter: do not abort() on fatal errors or print on stderr
+       Use the error reporting infrastructure for most errors. Fatal errors (bugs)
+       in the interpreter now lead to an error code AUG_EINTERNAL, and not an
+       abort()
+
+       * src/parser.y: do not print to stderr
+
+       * src/lexer.l: print into struct error instead of stderr
+
+       New error code AUG_ESYNTAX
+
+       * src/info.c (format_info): minor fixes
+         - append a ':' after the location
+         - produce a result even when line numbers are invalid
+         - use xasprintf, not asprintf
+
+       * src/lexer.l (to_int): unused, remove
+
+       Make struct error available in struct info
+       This makes it much easier to report errors into the central struct error
+       instance hanging off the Augeas instance.
+
+       Put struct error and report_error into its own file
+       Also, make the struct error in struct augeas a pointer
+
+       * src/info.h: optimize layout of struct info
+
+       *src/syntax.c: catch some allocation errors
+
+       * src/ref.h (make_ref_err): convenience macro
+
+       * tests/fatest.c (print_regerror): only print first 40 chars of regexp
+
+       libfa: handle allocation failures gracefully
+
+       parser: report some allocation failures
+
+       * src/fatest.c: make testable with failmalloc
+         - when FAILMALLOC_INTERVAL is set, report success, no matter
+           how many tests failed (presumably because of memory starvation)
+         - abort with die_oom() if crucial internal checks can't be performed
+           because of allocation failures
+
+       cutest: fortify against allocation failures
+         - new function die_oom which sets exit status to 2 when
+           we die from an oom condition
+         - use the safe-alloc macros for allocations
+         - abort the test when internal allocations fail
+
+       * src/hash.c (hash_alloc_insert): return 0/-1 for success/error
+
+       Use a proper function for make_ref
+       That allows us to require that callers check the return value
+
+       Handle allocation failures from define_native_intl
+
+       build: support for running with libfailmalloc preloaded
+       Add --with-failmalloc=LIB configure option and failmalloc targets to run
+       select programs with failing allocations.
+
+2009-09-24  David Lutterkort  <lutter@redhat.com>
+
+       * src/transform.c: do not include canonicalize.h anymore
+       The canonicalize-lgpl gnulib module doesn't require that anymore
+
+2009-09-21  David Lutterkort  <lutter@redhat.com>
+
+       Path expressions: add regexp matching
+       Add a function regexp : string -> regexp and an operator
+        =~ : string|nodeset -> regexp -> boolean to the language for
+       path expressions.
+
+       * src/regexp.c (regexp_compile): do not print anything on error
+
+       Split regexps, info and strings out of syntax.[ch]
+         * Move struct string and struct info and related functions into info.[ch]
+         * Move headers for regexp.c into new file regexp.h
+
+       This makes it easier to reuse these outside of syntax.[ch] - including
+       syntax.h in get.c and put.c was way too much anyway.
+
+       aug_match, aug_mv: return -1 when pathx evaluation fails
+
+       Report errors when exactly one match is expected
+       aug_mv and aug_insert expect that exactly one node matches the path
+       expressions they are given. Report new errors if none or more than one node
+       match.
+
+       * src/augtool.c: use new error API
+       Call into the error API after each aug_* call and print error details
+
+       Propagate pathx errors during evalutaion
+       We did not report errors from pathx evaluation functions, only from the
+       parser/typechecker. Now functions like pathx_first etc. report errors
+       properly.
+
+       Store pathx parse errors in internal error struct
+       The pathx_parse function will now store error information in a struct
+       error; we pass the one from struct augeas in and save it in the pathx.
+
+       Reset old error messages on each entry through the API from the outside
+
+       * src/syntax.c (interpreter_init): report errors
+
+       Error reporting API and infrastructure
+       Only reporting errors in the tree makes the API much harder to use; the
+       aug_error* functions make it easier to inquire about errors
+       programmatically.
+
+       * src/pathx.c (pathx_symtab_init): unused, remove
+
+2009-09-18  David Lutterkort  <lutter@redhat.com>
+
+       * src/syntax.c (interpreter_init): fix potential leak
+       If globbuf has entries in it when we encounter an error, we need to
+       globfree it.
+
+2009-09-17  Matt Palmer  <mpalmer@hezmatt.org>
+
+       Sudoers: allow certain backslash-quoted characters in a command
+       Commands may contain backslashes by themselves and the two-char sequences
+       \\[=:,\\]
+
+2009-09-14  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.5.3
+
+2009-09-11  David Lutterkort  <lutter@redhat.com>
+
+       Man pages: update to match current augtool and augparse
+
+       Add --version option to augtool and augparse
+       Fixes bug #88
+
+       A couple more files for the test root
+
+       Add preceding-sibling and following-sibling axes to path expressions
+
+2009-09-10  David Lutterkort  <lutter@redhat.com>
+
+       Better error message for too many args in a path expression
+
+2009-09-09  David Lutterkort  <lutter@redhat.com>
+
+       Slapd: include /etc/openldap/slapd.conf
+       This is the default location in Fedora.
+
+       Fixes bug #85
+
+2009-09-04  David Lutterkort  <lutter@redhat.com>
+
+       Multipath: new lens for /etc/multipath.conf
+
+       * src/try: fix 'set annotate' for gdb
+
+2009-09-03  David Lutterkort  <lutter@redhat.com>
+
+       Transparent save of cross-device links
+       When saving to a file, we first write to a file with extension .augnew and
+       then rename that file to the actual file. This fails when the original is a
+       symlink to a file on another device.
+
+       We now write the .augnew file next to the canonicalized original file to
+       avoid that headache. There are still situations where the rename fails,
+       e.g. when the original file is bindmounted - in that situation, we have to
+       copy.
+
+       * src/syntax.c (print_value): use print_tree instead of dump_tree
+
+2009-09-02  David Lutterkort  <lutter@redhat.com>
+
+       * lenses/rx.aug (fspath): simplistic regex for filesystem paths
+
+       * src/lens.c (disjoint_check): print example as tree for put
+       When the typechecker finds lens overlap in a union's put direction, format
+       the generated example as a tree to make it more readable.
+
+       * src/lens.c(enc_format): remove extraneous quote
+
+       Make fa_example work for strings with embedded NUL's
+
+2009-09-01  Matt Palmer  <mpalmer@hezmatt.org>
+
+       Inetd: new lens and test
+
+2009-08-31  David Lutterkort  <lutter@redhat.com>
+
+       Pretty-print lens atypes and use that for errors during put
+       * src/lens.c (lns_format_atype): new function
+       * src/lens.h (lns_format_atype): new prototype
+       * src/put.c (regexp_match_error): use lns_format_atype for errors
+
+       * tests/modules/pass_strip_quotes.aug: test quote stripping
+       The tests strips optional quotes and puts them back (or creates them) as
+       needed, only depending on the value of the tree node.
+
+       Match trees on label and value, not just label
+       We still only use one level in the tree for matching in the put direction,
+       but take the values of nodes into account.
+
+       We had fail_ tests in place to document the deficiency of the tree matcher,
+       but with that deficiency gone, these now become passing tests.
+
+       Restrict the alphabet of a regexp
+
+       Use offsets for various lens types
+
+       Carry the key type explicitly in lenses
+       Instead of computing the key type recursively, store it in lens->ktype. The
+       key type becomes the new abstract type (atype) when a lens is used inside a
+       subtree combinator.
+
+       Allow NULLS in regexp_(union|concat)_n
+       It's sometimes useful to union/concat N regexps even if some of them are
+       NULL. regexp_(union|concat)_n will ignore them.
+
+       libfa: handle regexps with embedded NUL characters
+       So far, the API promised that we could do that, but that wasn't implemented.
+
+       fa_compile: accept regexps with embedded NUL's
+
+       Make regexp_escape strip enclosing parens; make API const correct
+         * src/syntax.h (regexp_escape): make const correct
+         * src/regexp.h (regexp_escape): strip '(...)' enclosing entire regexp
+
+       * src/builtin.c (tree_clear_glue): primitive clear function for use in tests
+
+       Utility function xasprintf
+       Like asprintf, but don't leave first arg in limbo on error
+
+       *  src/internal.h (xasprintf): new prototype
+       *  src/internal.c (xasprintf): new function
+
+       regexp_release: allow NULL regexp
+
+       * src/augeas.c: do not read past the end of the load path
+
+2009-08-14  David Lutterkort  <lutter@redhat.com>
+
+       Only read regular files
+         * src/transform.c (is_regular_file): new function
+         * src/transform.c (filter_generate): do not include non-regular files
+
+       Fixes bug #68
+
+2009-08-12  David Lutterkort  <lutter@redhat.com>
+
+       Do not assume how glob allocates gl_pathv
+       We assumed that the gl_pathv in a glob_t was allocated in a particular
+       manner.
+
+         * src/transform.c (filter_generate): make a copy of gl_pathv
+
+2009-08-10  David Lutterkort  <lutter@redhat.com>
+
+       aug_load: cleanup variables when deleting /files
+       The first thing aug_load does is delete /augeas/files and /files. We need
+       to make sure that any variables that contain references to nodes in those
+       subtrees are cleaned up properly, i.e. that we remove such nodes from
+       nodesets in the variables.
+
+         * src/augeas.c (tree_unlink_children): remove descendants of the tree we
+           are deleting from variables.
+         * tests/test-load.c (testLoadDefined): verify fix
+
+       Fixes bug #79
+
+       Pass symtab explicitly into pathx_symtab_remove_descendants
+
+2009-08-06  David Lutterkort  <lutter@redhat.com>
+
+       Record new files under /augeas/files when they are saved
+         * src/transform.c (transform_save): add file info with add_file_info
+         * tests/test-save.c: test that file info is added for a new file
+         * tests/Makefile.am: build and run test-save
+         * .gitignore: ignore tests/test-save
+
+       Fixes bug #78
+
+       * src/transform.c (add_file_info): change what we store about a file
+       For a file FILE, we now only record the path and the info for the lens;
+       instead of
+
+         /augeas/files/FILE/path      = /files/FILE
+         /augeas/files/FILE/lens/info = ...
+         /augeas/files/FILE/lens/id = 0x...
+
+       we only record
+
+         /augeas/files/FILE/path  = /files/FILE
+         /augeas/files/FILE/lens  = ...
+
+       The id wasn't useful to anybody, and the lens info is useful for debugging
+       at best
+
+       * src/transform.c (add_file_info): minor cleanup
+         - Rename add_load_info to add_file_info
+         - Eliminate filename argument, since it's redundant
+
+       defnode: when creating new node, put it in the nodeset
+       When a new node is created, e.g. with 'defnode x "/foo[0 = 1]"' we used to
+       assign an empty nodeset to x. Now x will hold a reference to the newly
+       created node, even though the initial path expression would never match any
+       nodes.
+
+         * src/augeas.c (aug_defnode): call pathx_symtab_assign_tree after
+           creating a node
+         * src/pathx.c (pathx_symtab_assign_tree): new function to assign a single
+           tree node to a variable
+         * src/internal.h: declare pathx_symtab_assign_tree
+         * tests/test-xpath.c (test_defnode_nonexistent): test new behavior
+
+2009-08-05  David Lutterkort  <lutter@redhat.com>
+
+       * src/lexer.l: allow DOS line endings
+       Accept \r\n as a line ending in addition to \n
+
+       Fixes RH Bugzilla 514712
+
+2009-08-04  Matthew Booth  <mbooth@redhat.com>
+
+       Require quotes around strings in xorg.conf
+       man xorg.conf appears to support this:
+                  String      a string enclosed in double quote marks (")
+
+       This change means that explicitly parsed values will remove quotes in the
+       get directory and insert them in the put direction.
+
+       Currently, only the following entries are explicitly parsed:
+       * Option
+       * Screen
+       * InputDevice
+       * Driver
+       * SubSection
+       * Identifier
+       * VideoRam
+       * DefaultDepth
+       * Device
+       * All entries in the Display Subsection
+
+       The lens will also accept any other entry name not in this list. However,
+       as it does not know what types to expect, it stores a bare string. This
+       will include quote marks.
+
+       Add more specific entry handlers to xorg.conf
+       Additionally handle:
+       * Driver
+       * Identifier
+       * VideoRam
+       * DefaultDepth
+
+       This covers all entries in the default configuration.
+
+       The advantage of having a specific handler is that it knows more about what
+       values are valid. For example, with this patch Driver will not accept an
+       unquoted value, which would cause the X server not to start.
+
+       Parse more directives in xorg.conf
+       The default xorg.conf generated by pyxf86config on Red Hat/Fedora systems
+       is not parsed by the current xorg.conf. Specifically it does not
+       understand:
+
+       * Screen, in ServerLayout
+       * InputDevice, in ServerLayout
+       * SubSection "Display" ..., in Screen
+
+       This patch adds support for those values, so that the default xorg.conf on
+       Red Hat/Fedora systems now parses.
+
+       It should also add support for all directives in the Display subsection,
+       however they are not covered by the test.
+
+2009-07-31  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       vim: extra carriage return caused a parse error
+
+2009-07-23  Jim Meyering  <meyering@redhat.com>
+
+       tests: extract SELinux context more portably
+       * test-preserve.sh: Use stat --format=%C $hosts ... rather than
+       ls -lZ $hosts | cut -d ' ' -f 5.  The latter fails with some
+       combinations of ls and SELinux.
+
+2009-07-16  David Lutterkort  <lutter@redhat.com>
+
+       * src/Makefile.am: link libfa with gnulib, needed on AIX
+
+2009-07-14  Bruno Cornec  <Bruno.Cornec@hp.com>
+
+       * doc/augeas.vim: vi syntax highlighting for .aug files
+
+2009-07-13  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.5.2
+
+2009-07-09  David Lutterkort  <lutter@redhat.com>
+
+       tree handling: propagate dirty flag into root
+       We had an off-by-one error in tree_mark_dirty that lead to the root of the
+       tree not being marked as dirty. As a consequence, performing a tree_clean
+       on such a tree would not mark the tree as clean; that caused an aug_load
+       directly followed by aug_save to write to disk, even though the tree was
+       unchanged.
+
+         * src/augeas.c (tree_mark_dirty): propagate dirty flag to the root
+         * tests/test-load.c (testLoadSave): test that simple load + save
+           does not touch the filesystem
+
+       This bug was introduced in commit 7278965b
+
+2009-07-08  David Lutterkort  <lutter@redhat.com>
+
+       Ntp: allow additional options for server etc.
+       Allow options listed on http://doc.ntp.org/4.2.4/confopt.html
+
+       Fixes bug #72 reported by Micah
+
+       Shellvars: allow backticks as quote characters
+         * lenses/shellvars.aug (simple_value): allow backticks as quotes
+         * lenses/tests/test_shellvars.aug: add tests
+
+       Fixes bug #74 reported by Micah
+
+2009-07-08  Jim Meyering  <meyering@redhat.com>
+
+       build: ignore generated test files
+       * tests/.gitignore: Remove file.
+       * .gitignore: ignore tests/lens-*.sh
+
+2009-07-08  David Lutterkort  <lutter@redhat.com>
+
+       Logrotate: allow filenames to be indented
+         * lenses/logrotate.aug (rule): allow indentation at start of rule
+         * lenses/tests/test_logrotate.aug: add tests
+
+       Fixes part of bug #67 reported by Micah
+
+       Logrotate: make owner/group in create statement optional
+         * lenses/logrotate.aug (create): make mode/owner/group optional
+         * lenses/test/test_logrotate.aug: add tests
+
+       Fixes part of bug #67 reported by Micah
+
+       * configure.ac: use AC_SYS_LARGEFILE
+       Suggested by Jeff Johnson <n3npq@mac.com>
+
+       * src/augeas.c (init_root): when root0 == "", use "/" as root
+       When an empty string is passed as root0, make sure we do not make an
+       invalid memory access when we look for the trailing slash.
+
+       Reported and fix suggested by Jeff Johnson <n3npq@mac.com>
+
+2009-06-26  Jim Meyering  <meyering@redhat.com>
+
+       tests: divide test-lenses.sh into its 54 independent tests
+       This permits these tests to be run in parallel.
+       * tests/lens-test-1: New file.
+       * tests/Makefile.am (lens_tests): Define.
+       (check-lens-tests): New rule, to ensure that the above stays in
+       sync with reality.
+       (check): Depend on check-lens-tests.
+       ($(lens_tests)): New rule.  Generate these files.
+       (check_SCRIPTS): Remove test-lenses.sh.  Add $(lens_tests).
+       (EXTRA_DIST): Add lens-test-1.
+       * tests/test-lenses.sh: Remove file.
+       * tests/.gitignore: suppress lens-*.sh files
+
+       enable automake-1.11 features: colorized and parallel tests, etc.
+       Also enable automake's new "silent-rules" feature.
+       Use "make V=1" to see the usual, verbose-mode commands.
+       * configure.ac: Require automake-1.11.
+       Enable color-tests parallel-tests.  Use AM_SILENT_RULES([yes])
+
+2009-06-26  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       Yum: also read files in /etc/yum/pluginconf.d
+
+2009-06-16  David Lutterkort  <lutter@redhat.com>
+
+       Inittab: clean up formatting some
+
+2009-06-16  Matt Palmer  <matt@anchor.net.au>
+
+       Inittab: simplified schema, map comments
+       Change the structure of the inittab lens so that the 'id' field is used
+       as the name of the subtree for that line in /etc/inittab.
+
+       Map comments as '#comment' nodes
+
+2009-06-16  David Lutterkort  <lutter@redhat.com>
+
+       augtool: add --echo option
+         * src/augtool.c: add --echo option to print commands when reading
+                          from a file via stdin
+         * man/augtool.pod: document --echo option
+         * man/augtool.1: regenerated
+
+2009-06-15  Jim Meyering  <meyering@redhat.com>
+
+       build: fix "make distcheck" failure
+       * src/Makefile.am (EXTRA_DIST): Add fa_sym.version.
+
+2009-06-12  Anders F Bjorklund  <afb@users.sourceforge.net>
+
+       * tests/augtest: convert darwin's double slashes to single slash
+
+       * test-test-preserve.sh: work with BSD ls, as well as GNU ls
+       Needed to make the test pass on OS/X
+
+2009-06-11  David Lutterkort  <lutter@redhat.com>
+
+       libfa: use linker script to only export public symbols
+       libfa was exporting all kinds of symbols that were meant to be internal;
+       now it only exports what's in fa.h
+
+2009-06-11  Anders F Björklund  <afb@users.sourceforge.net>
+
+       configure: do not use version script if the linker doesn't support it
+       That is the case on OS X
+
+       Fixes part of ticket #66
+
+       configuration: check whether rl_completion_matches is available
+       That function is missing on OS/X; we substitute it with a dummy if readline
+       does not provide it.
+
+       Fixes part of ticket #66
+
+       * src/augtool.c: add missing include for ctype.h
+       Part of fix for ticket #66
+
+2009-06-09  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.5.1
+
+       * tests/test-put-symlink.sh: fix broken test
+       - use lenses in ../lenses
+       - fix typo: HOSTS_AUGSAVE, not HOSTS_AGSAVE
+
+       * bootstrap: use getline module from gnulib
+
+       * src/augtool.c: initialize 'line' to NULL
+
+2009-06-05  David Lutterkort  <lutter@redhat.com>
+
+       Logrotate (hooks): simplify to speed up typechecker
+
+       Logrotate: make newline at end of script optional
+
+       * src/put.c (put_store): escape regexp before printing
+
+       * src/pathx.c: coerce the operands of 'and'/'or' to boolean
+       Fixes bug #44
+
+       * src/lexer.l: allow empty regexps
+       Fixes bug #34
+
+       Dnsmasq: process files in /etc/dnsmasq.d/*
+       Fixes bug #65 reported by abnormaliti
+
+2009-06-01  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c: allow comments starting with '#'
+
+2009-05-29  David Lutterkort  <lutter@redhat.com>
+
+       Whitespace cleanup (no functional change)
+       Remove trailing whitespace
+
+       Ntp: support more commands
+       * process 'broadcastdelay'
+       * process enable/disable flags
+       * process leapfile
+
+       Minor amount of code cleanup
+
+       Fixes bug #62, reported by Frank Sweetser
+
+       Fix grammar docs (production for PrimaryExpr was wrong)
+
+       * tests/root/etc/: add group and passwd files
+
+2009-05-28  Matt Palmer  <matt@anchor.net.au>
+
+       Interfaces: various bug fixes
+       * disallow end-of-line comments
+       * support generic allow-* stanzas
+
+       Interfaces: accept options containing '_'
+       Bug reported by Jonas Eriksson
+
+2009-05-28  David Lutterkort  <lutter@redhat.com>
+
+       * tests/grub-rm-entry.rb: 'savedefault' indented by '\t', not ''
+
+2009-05-14  David Lutterkort  <lutter@redhat.com>
+
+       Modprobe: handle comments at the end of a line
+
+2009-04-13  David Lutterkort  <lutter@redhat.com>
+
+       Grub: allow optional argument for savedefault command
+
+       Grub: parse arguments to chainloader command
+
+       Grub: parse arguments for terminal command
+
+       Grub: parse individual arguments for serial command
+
+       Grub: parse kernel and module arguments
+
+       Grub: simplify comment_re to speed up typecheck
+
+2009-04-13  Raphael Pinson  <raphink@gmail.com>
+
+       Cron: add a "time" node
+
+2009-04-13  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.h: improve some comments
+
+2009-04-09  David Lutterkort  <lutter@redhat.com>
+
+       * src/augparse.c: add --notypecheck option
+
+2009-04-08  Raphael Pinson  <raphink@gmail.com>
+
+       Pbuilder: lens and tests for Debian's personal builder
+
+       Shellvars: map comments with Util.comment and Util.empty
+
+       Shellvars: parse 'export' and 'unset' commands
+
+2009-04-08  David Lutterkort  <lutter@redhat.com>
+
+       Add Cron to the dosumentation menu
+
+2009-04-08  Raphael Pinson  <raphink@gmail.com>
+
+       Cron: new lens and test
+       Parses /etc/crontab and /etc/cron.d
+
+       Sudoers: allow backslashes inside sto_to_com and sto_to_com_user
+       This patch fixes ticket #60 which reports the possible usage of
+       backslashes in sudoers aliases (for use with e.g. Windows resources).
+
+       Backslashes are now allowed only in the middle of sto_to_com and
+       sto_to_com_cmnd.
+
+       Additionally, add a line with backslashes in test_sudoers to prevent
+       regressions.
+
+       Xinetd: map comments using Util.comment
+
+       Squid: allow indentation of entries
+
+2009-04-07  Raphael Pinson  <raphink@gmail.com>
+
+       Logrotate: allow = as a separator for value_to_eol
+       Fix ticket #61 by allowing "=" as a valid separator in value_to_eol.
+       "word" may not contain "=" anymore in this case.  Note that this is not
+       documented in "man logrotate" but is shipped by default in CentOS (cf
+       ticket #61).
+
+2009-04-07  David Lutterkort  <lutter@redhat.com>
+
+       Ntp: fixes to make the default Fedora config work
+       Now enough of ntp.conf is understood so that the config from Fedora 10 with
+       all directives uncommented can be processed.
+
+2009-04-07  Raphael Pinson  <raphink@gmail.com>
+
+       Ntp: add fudge directive
+       Fixes ticket #59
+
+2009-04-07  David Lutterkort  <lutter@redhat.com>
+
+       * src/transform.c (transform_save): append newline to old text
+       If we appended a newline to initially load the file, we also need to do
+       that when we parse the file again during save.
+
+       Bug reported by Michael Conigliaro <mike@conigliaro.org>
+
+2009-04-03  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c: new option --noautoload
+
+       * src/augeas.h: expose flag to suppress module autoload
+       With AUG_NO_MODL_AUTOLOAD, modules are only loaded when they are needed.
+
+       * src/transform.c (filter_generate): avoid segfault if we never call glob
+
+       Php: some more tests, sample php.ini in test root
+
+       Rx: remove \b and \d escapes
+
+2009-04-03  Raphael Pinson  <raphink@gmail.com>
+
+       Modify some existing lenses to use new utility modules
+       Changes Aliases, Exports, Fstab, Group, and Monit
+
+       Also exposes comments in /etc/aliases as #comment nodes
+
+       New utility modules Build, Rx, and Sep
+
+2009-04-03  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       Php: added default path on redhat
+
+2009-04-02  Raphael Pinson  <raphink@gmail.com>
+
+       Use readline only when stdin is a tty, use getline otherwise
+
+2009-04-01  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       Vsftpd: several fixes
+       * map comments as #comment
+       * handle empty lines
+       * find vsftpd.conf on Fedora/RHEL
+
+2009-03-27  David Lutterkort  <lutter@redhat.com>
+
+       Iptables: fix ticket #51
+        * allow more characters in chain names
+        * allow comments mixed in with chains and rules
+
+       * augeas.spec.in: fadot is not installed yet
+
+       Version 0.5.0
+
+       Fix build problems uncovered by distcheck
+
+       * src/get.c (get_quant_star): do not leak registers
+
+       Some more test files
+
+       Fix uninitialized variables found by optimizer
+
+       * src/hash.c (hash_free_nodes): simplify and accelerate
+       Reduces time to typecheck grub.aug from 9.8s to 8.5s on my machine.
+
+       * src/hash.c: mark some asserts as expensive
+
+       * tests/root/etc/krb5.conf: simple example file
+
+       Krb5: lens and tests for /etc/krb5.conf
+
+2009-03-25  Raphael Pinson  <raphink@gmail.com>
+
+       Grub: add support for Debian's update-grub (ticket #50)
+       Bug reported by Micah Anderson
+
+2009-03-25  David Lutterkort  <lutter@redhat.com>
+
+       * src/fa.c (fa_ambig_example): use heuristic for fast checking
+       This avoids a lot of intersections in the Augeas typechecker, and speeds
+       typechecking up by between 5% and 20%, depending on the lens.
+
+       Thanks to Nate Foster for the inspiration of this
+
+       Sudoers: produce at most one negate node
+       Even if there are multiple '!' signs, only produce one negate node.
+
+2009-03-25  Raphael Pinson  <raphink@gmail.com>
+
+       Sudoers: fix ticket #48
+       * make a difference between boolean and non boolean values for integers and
+         strings
+       * allow multiple negate flags (odd/even numbers change the behaviour)
+       * add optional double quotes to integer and string field
+
+       Bug reported by Frank Sweetser
+
+2009-03-25  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c: make second argument for 'set' optional
+       This makes it possible to set a tree node's value to the empty string
+       with
+         set /foo ""
+       and
+         set /foo
+
+2009-03-24  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c (aug_init): make it easier to override distributed lenses
+       Make the default load path
+
+          $(datadir)/augeas/lenses:$(datadir)/augeas/lenses/dist
+
+       and instal the lenses we distribute into the dist/ subdir. That makes it
+       easy for other packages to override lenses we ship: when they are installed
+       into $(datadir)/augeas/lenses, they are automatically preferred over the
+       ones we ship.
+
+       New API call aug_defnode and augtool command defnode
+       It's common that we want to define a variable to reference /foo/bar, and
+       create that node if it does not exist yet. aug_defnode bundles that
+       together into one convenient call.
+
+       * src/pathx.c (eval_filter): correctly hande realloc of value_pool
+
+       * src/pathx.c (expand_tree): ensure we start with a nonempty lp_trace
+
+       * src/augtool.c: new 'defvar' command
+
+       Add variables for path expressions
+       The new API call aug_defvar allows defining variables that can later be
+       used in path expressions.
+
+2009-03-22  David Lutterkort  <lutter@redhat.com>
+
+       Add FilterExpr to path expression grammar
+       This allows using constructs like $foo/some/path and $foo[2]
+
+       * src/augeas.c (parse_user_pathx): new parameter need_nodeset
+
+       * src/pathx.c (pathx_parse): new parameter need_nodeset
+
+       * src/pathx.c (ns_filter): new function
+
+       * src/pathx.c: rename E_LOCPATH to E_FILTER
+
+       * src/pathx.c (clone_value): new function
+
+2009-03-21  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c (release_value): factor logic into separate function
+
+       * src/pathx.c: remove assumption that toplevel expression is a locpath
+       We can't assume that anymore when we have variables. That requires some
+       headache for pathx_expand_tree, since that needs a full trace of evaluating
+       a locpath against the tree.
+
+       * src/pathx.c (pathx_eval): factor eval into a function
+
+       * examples/fadot: remove, checked in by mistake
+
+2009-03-20  David Lutterkort  <lutter@redhat.com>
+
+       * .gitignore: ignore examples/fadot
+
+       * src/get.c: rename 'Short iteration' to a more helpful message
+
+       * src/transform.c (store_error): report which lens failed
+
+       * src/transform.c (store_error): ignore errors from err_set
+
+       * src/transform.c (store_error): calculate line number/ofs for error
+
+       * src/transform.c (err_set): new function
+
+2009-03-20  Francis Giraldeau  <francis.giraldeau@revolutionlinux.com>
+
+       * examples/fadot.c: tool to generate dot graphs of FA's
+       The fadot tool produces dot graphs of finite automata, and allows certain
+       operations on FA's from the command line, like intersection and complement
+       of FA's.
+
+2009-03-19  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c: call make_value before pop_value
+       Since make_value might realloc, pointers retrieved with pop_value may
+       become invalid across make_value calls.
+
+       * src/augeas.c: remove some internal uses of pathx_parse
+
+       * src/augeas.c: create various /augeas nodes when they go missing
+
+       * src/put.c (create_concat): fix goofy error message
+
+       Update and refresh man pages
+
+       * src/augtool.c: add --noload option
+
+       Validate trees representing a transform before using them
+
+       * tests/test-load.c: new test for aug_load
+
+       * src/augeas.h (aug_init): make loading the tree optional
+       The new flag AUG_NO_LOAD can be used to keep aug_init from loading any
+       files. This gives the user a chance to modify /augeas/load and then call
+       aug_load.
+
+       * src/augtool.c: new 'load' command
+
+       * src/augeas.h (aug_load): new public function
+
+       * src/transform.h: use tree encoded transforms
+
+       * src/lens.c (lens_release): allow NULL lens to be passed in
+
+       * src/syntax.h (lens_lookup): new function
+
+       * src/augeas.c: report transforms under /augeas/load
+
+       Rename AUG_NO_DEFAULT_LOAD to AUG_NO_MODL_AUTOLOAD
+
+       Limits (filter): no need to exclude anything
+
+2009-03-19  Raphael Pinson  <raphink@gmail.com>
+
+       Limits: map domain into the value of domain node (schema change)
+       Mapping the domain as the label of a node leads to difficulties since '*'
+       is a valid domain name.
+
+       Problem reported by Mark Drayton (ticket #47)
+
+2009-03-19  David Lutterkort  <lutter@redhat.com>
+
+       Lokkit: new lens and test
+
+2009-03-17  David Lutterkort  <lutter@redhat.com>
+
+       Iptables: new lens and test
+       A fairly basic parse of the iptables config file. It should accept any
+       legal iptables config file; what makes it basic is that it doesn't break
+       some of the values down as fine-grained as I would like to have them
+
+2009-03-13  David Lutterkort  <lutter@redhat.com>
+
+       * configure.ac: bump major version of libfa
+
+       * src/fa.h (fa_as_regexp): cleaner prototype
+
+       * src/fa.h (fa_ambig_example): cleaner prototype
+
+       * src/fa.h (fa_example): cleaner prototype
+
+       * src/fa.h (fa_compile): pass in size of regexp
+
+       * src/fa.h: use 'struct fa *' instead of fa_t
+
+       * src/augeas.c: fix handling of dirty flag
+       Under some circumstances, we did not properly propagate the dirty flag up
+       the tree, leading to files that were not saved even though they should have
+       been.
+
+       This also removes two full sweeps over the tree for dirty handling, and now
+       only touches nodes that are/need to be marked dirty.
+
+       * Makefile.maint: different setup at home
+
+2009-03-12  David Lutterkort  <lutter@redhat.com>
+
+       * src/transform.c (transform_save): properly sync data to disk
+       Make sure the data we write into the .augnew file hits the disk before
+       renaming to the proper name
+
+       Modprobe: lens and tests for modprobe.conf
+
+       * src/fa.c (re_cset_as_string): turn '[^\n]' into '.'
+
+       Place Sudoers and Util under LGPLv2+
+       Raphael Pinson agreed to changing the license for these to LGPLv2+ like the
+       rest of Augeas.
+
+2009-03-09  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.4.2
+
+       Logrotate: process 'minsize 1M' rule
+       logrotate allows unit suffixes 'k', 'M' and 'G' for 'size' and 'minsize'
+
+       Squid: add squid.conf from Fedora 11 rawhide
+
+       * src/builtin.c: new builtins Sys.getenv and Sys.read_file
+
+       * src/syntax.h (dup_string): duplicate a string
+
+       * src/internal.h (xstrerror): new function
+
+2009-03-09  Francois Deppierraz  <francois.deppierraz@camptocamp.com>
+
+       Test the Debian Lenny sample squid.conf
+
+       Add a bunch of keywords available on squid-2.7-STABLE6 or squid-3.HEAD-20090308.
+       The keywords list was generated by the following command:
+
+       fgrep TAG squid-2.7.STABLE6/src/squid.conf.default  | awk '{ print "                | \""$3"\"" }' | sort > /tmp/squid2.7
+
+       fgrep TAG squid-3.HEAD-20090308/src/squid.conf.documented | awk '{ print "                | \""$3"\"" }' | sort > /tmp/squid3-HEAD
+
+       cat /tmp/squid2.7 /tmp/squid3-HEAD | sort | uniq
+
+2009-03-08  David Lutterkort  <lutter@redhat.com>
+
+       * tests/xpath.tests: Hosts lens puts comments into #comment nodes
+
+       * augeas.spec.in: BR for libselinux-devel (bug #26)
+       Without the BR, the Fedora and EPEL builds are done without SELinux
+       support, resulting in a binary that does not preserve SELinux contexts
+
+2009-03-06  David Lutterkort  <lutter@redhat.com>
+
+       Sshd: map comments as '#comment' nodes
+
+       Change the label for comment nodes to '#comment'
+
+       Do not delete files that had an error upon parsing
+       When we can't read a file, we create an entry for it under /augeas, but
+       there won't be anything for it under /files. That looks a lot like a file
+       whose entire subtree was deleted; but since we failed reading the file, we
+       should not delete it either.
+
+       * src/augeas.c (aug_init): always create /files
+
+       Sshd: add test showing how to add a Subsystem
+
+2009-03-03  David Lutterkort  <lutter@redhat.com>
+
+       * Makefile.maint: add autogen target
+
+       * src/pathx.c (eval_rel): for numbers, '<' and '<=' were reversed
+
+       Postfix_main: handle continuation lines
+
+       * src/pathx.c: fix some comments
+
+2009-03-02  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.4.1
+
+       * configure.ac: make default warning level 'maximum'
+       Using 'error' here is too unfriendly on weird platforms, since builds can
+       fail, e.g. because of broken system headers. When doing actual development,
+       set this to 'error'.
+
+       * src/pathx.c: function label() returning the label of the ctx node
+
+       * src/pathx.c: make sure ['foo' != 'foo'] is false
+
+       * src/pathx.c: handle names with '.' properly
+       Make sure that a component ina path expression like '.bar' is parsed as a
+       single step (name), and not as the self axis '.' followed by some
+       garbage.
+
+       Bug reported by Jan Kupec
+
+       * src/pathx.c: it is an error if we don't consume the whole expression
+
+2009-02-27  David Lutterkort  <lutter@redhat.com>
+
+       * tests/test-event-saved.sh: make sure fuiles are writable by owner
+
+2009-02-25  David Lutterkort  <lutter@redhat.com>
+
+       Plug a few memory leaks
+
+       Remove files whose tree under /files was deleted
+       When doing rm /files/etc/hosts, we now delete the file /etc/hosts
+       on save
+
+       Move path formatting functions around
+       Move path_expand and format_path to internal.c
+       Rename format_path to path_of_tree
+
+       * src/augeas.c (tree_find): helper for getting a tree node
+
+2009-02-24  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c: erase /augeas/events/saved only once
+       tree_save is called recursively; /augeas/events/saved must be reset
+       in aug_save, not tree_save
+
+       Record saved files in transform_save, not tree_save
+
+       * src/augeas.c (tree_unlink): remove and free a subtree
+
+       * src/transform.h: move transform decls out of syntax.h
+
+       Util.stdexcl: exclude .augsave and .augnew files
+
+2009-02-20  David Lutterkort  <lutter@redhat.com>
+
+       * src/lexer.l: correct location info for strings and regexps
+
+       * src/get.c: check for valid match before calling token()
+
+2009-02-19  David Lutterkort  <lutter@redhat.com>
+
+       * src/parser.y: do not allow epsilon as a tree constant
+       This grammar mistake made epsilon a valid expression
+
+       * src/fa.c: cache hash values in the state
+       This gives about a 15% performance improvement in typechecking
+       the logrotate lens
+
+2009-02-18  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c: allow '(' Expr ')'
+
+       * src/pathx.c: add 'and' and 'or' operators
+
+       * src/pathx.c: add relational expressions '>', '<', '>=', '<='
+
+       * src/pathx.c: add count() function
+
+       * src/pathx.c (parse_name): do not allow ')' in names
+       Names can not contain ')', otherwise we will run beyond the end of
+       arguments in a function call like 'f(name)'
+
+       * src/pathx.c: add position() function
+
+       * src/pathx.c: allow '=' and '!=' of numbers
+
+       * src/pathx.c: fix matching multiple predicates
+       We used to evaluate /path[pred1][last()] wrong - last() must match the last
+       node in the nodeset /path[pred1], not the last node in the nodeset /path.
+
+       This requires that we compute nodesets explicitly.
+
+       Logrotate: small fixes
+       * recognize 'yearly' schedule
+       * allow whitespaces around { and }
+
+2009-02-17  David Lutterkort  <lutter@redhat.com>
+
+       * src/get.c: speed up initial match
+       Avoid matching the entire input string, since it can be _very_ slow.
+       Since it is very common that the toplevel lens is (l)*, optimize for
+       that.
+
+       * src/get.c: reduce the number of calls to regexp_match
+       Only call the regexp matcher at the very beginning of get/parse, and once
+       for every match inside an iteration. Use re_registers to keep track of the
+       substrings being worked on in favor of 'struct split'
+
+       Always do REGS_REALLOCATE for regexp match registers
+
+       * src/regexp.c: clean up syntax options
+
+       * src/put.c: remove outdated debug msgs and comments
+
+       * src/internal.h: Remove bogus DEBUG define
+
+       Ntp: enhance lens
+       These enhancements are needed to make the Ntp.lns process the default
+       /etc/ntp.conf on Fedora
+
+2009-02-16  David Lutterkort  <lutter@redhat.com>
+
+       * src/syntax.c: print tests results in the same form we read them
+
+2009-02-13  David Lutterkort  <lutter@redhat.com>
+
+       Allow passing NULL regexps in some regexp routines
+
+2009-02-13  Raphael Pinson  <raphink@gmail.com>
+
+       Xorg: new lens and tests
+
+2009-02-11  David Lutterkort  <lutter@redhat.com>
+
+       Test that an invalid regexp makes module loading fail
+
+       Services: various small fixes to process Fedora's /etc/services
+
+       * tests/test-get.sh: print all error info on failure
+
+       Better error mesages when re match fails during get/put
+
+       * src/lens.c: throw exception on regexp syntax errors
+
+       * src/fa.c: test for invalid ranges like [z-a]
+
+2009-02-11  Raphael Pinson  <raphink@gmail.com>
+
+       Lens and test for /etc/services
+
+2009-02-11  David Lutterkort  <lutter@redhat.com>
+
+       * src/augtool.c (cmd_match): check return from aug_match more defensively
+
+2009-02-06  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.4.0
+
+       Use printf instead of 'echo -e' in tests
+       Printf is more portable
+
+       Fix compilation on OpenSolaris
+       * src/pathx.c (position): assert not marked as noreturn
+
+       * tests/test-xpath.c (run_one_test): allow results in   arbitrary order. Files on Fedora and Debian are enumerated   in different order, leading to spurious test failures
+
+       * src/pathx.c: remove the value() function, it's redundant with '.'
+
+       * pathx.c: when comparing strings consider NULL == ""
+
+       Change how names are parsed in path expressions
+       Names can not contain any of the characters [][=/ \t\n] - to include
+       them in a name, they need to be escaped with a '\', so that 'foo\=bar'
+       matches a node with literal label 'foo=bar'.
+
+       * tests/grub-rm-entry.rb: fix test failure
+
+       * tests/augtest: do not typecheck everything
+       The typecheck is redundant (we already do that when running lens tests) and
+       really slow
+
+       Grub: process 'savedefault' in boot stanza
+       Also, allow keywords to be preceded by whitespace
+
+       Fixes ticket #36
+
+       Minor whitespace cleanup
+
+2009-02-02  Free Ekanayaka  <free@64studio.com>
+
+       Lens and tests for DarkIce
+       See http://darkice.tyrell.hu/
+
+2009-02-01  David Lutterkort  <lutter@redhat.com>
+
+       * src/augeas.c: use ALLOC instead of CALLOC
+
+       * augeas.c (aug_init): check an allocation failure
+
+       * src/internal.c (escape, unescape): check allocation failures
+
+       * src/pathx.c (free_state): allow NULL state
+
+       * src/augeas.c (init_root): check for failure of strdup
+
+2009-01-30  David Lutterkort  <lutter@redhat.com>
+
+       * src/pathx.c: factor test if a step matches into step_matches
+       This also fixes a problem matching, test also included
+
+       * src/pathx.c: use bool for boolean values
+
+       Build changes so that 'make' on Opensolaris 5.11 works
+       The tests ('make check') still fail, because of trouble with
+       some of the shell scripts
+
+       * src/transform.c: use POSIX conform FNM_PATHNAME, nut GNU alias
+
+       * src/get.c: remove braindead use of alloca
+
+       * tests/test-get.sh: use new descendant syntax to find errors
+
+       Remove unneeded call to pathx_parse in aug_match
+
+       Introduce parse_user_pathx to report errors
+       If user-supplied path expressions have errors, report them in
+       /augeas/pathx/error
+
+       Move parsing of path expressions into public API methods
+       For path expressions that are passed through the API, we need to report
+       errors. This change lays the groundwork, so that we can distinguish between
+       parsing user-supplied path expressions and internally generated path
+       expressions.
+
+       Rename aug_tree_replace to tree_replace
+       We reserve the aug_ prefix for public functions. There is also no need to
+       pass struct augeas here, a tree root is enough.
+
+       More xpath tests; allow ... in tests
+
+       Simplify internal API's
+       * pass origin, not root to pathx_parse
+       * pathx_next does not need an explicit argument for the current
+         tree node any more
+
+       Expand the grammar for path expressions
+       * add predicates based on labels and values
+       * allow path expressions in predicates, e.g. '/foo/bar[../baz = "7"]'
+       * add explicit axes and some abbreviations thereof
+
+       This requires a rewrite of the interpreter of path expressions; the
+       interpreter is now based on a more explicit representation of the abstract
+       syntax of the path expression and is statically type checked.
+
+       Also add tests to check path expression evaluation
+
+       Use absolute paths in lens tests when manipulating the tree
+       Paths that start with a number (like '1/ipaddr') are ambiguous in the new
+       path expression grammar and will confuse the parser; to make it clear that
+       they are paths, and not just a number, use absolute paths.
+
+       Notes on new XPath grammar
+
+       Rename struct path to struct pathx
+       Also rename path_* functions to pathx_*; rename make_pathx to pathx_parse
+       and change its signature to allow cleaner error reporting
+
+2009-01-29  David Lutterkort  <lutter@redhat.com>
+
+       Grub: support color directive
+
+2009-01-26  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.3.6
+
+2009-01-26  Dominique Dumont  <dominique.dumont@hp.com>
+
+       Sshd: add documentation on usage
+
+2009-01-25  David Lutterkort  <lutter@redhat.com>
+
+       Add indented puppet.conf to test root
+
+2009-01-22  David Lutterkort  <lutter@redhat.com>
+
+       Fix bug #25 - allow indented entries in puppet.conf
+       * lenses/inifile.aug: add new indented_entry and indented_title
+         lenses
+       * lenses/puppet.aug: use the indented_* lenses
+       * lenses/tests/test_puppet.aug: test with indented entries
+
+2009-01-19  David Lutterkort  <lutter@redhat.com>
+
+       Report version and legal save modes in /augeas/version
+
+2009-01-17  David Lutterkort  <lutter@redhat.com>
+
+       * ref.h: include limits.h, since we use UINT_MAX
+
+2009-01-16  David Lutterkort  <lutter@redhat.com>
+
+       Mark up code in documentation comments for Dpkg and Exports
+
+2009-01-16  Robin Lee Powell  <rlpowell@digitalkingdom.org>
+
+       Documentation for Exports and Dpkg
+
+2009-01-13  David Lutterkort  <lutter@redhat.com>
+
+       Minor changes to handling of save flag
+       * complain if /augeas/save is missing or has an invalid value
+       * do not clobber non-save flags when updating from /augeas/save
+       * add a test
+
+2009-01-13  Bryan Kearney  <bkearney@redhat.com>
+
+       Dynamically change behavior of aug_save; add noop save mode
+       * control behavior of aug_save through changing /augeas/save
+       * noop mode allows checking if changes will be written, without
+         changing file system
+
+2009-01-08  Jim Meyering  <meyering@redhat.com>
+
+       comment typos
+
+       plug a leak
+       24 bytes in 1 blocks are definitely lost in loss record 1 of 1
+          at 0x4021BDE: calloc (vg_replace_malloc.c:397)
+          by 0x4029379: make_tree (augeas.c:316)
+          by 0x403AC70: get_lens (get.c:592)
+          by 0x403ACB6: get_lens (get.c:523)
+          by 0x403AB4F: get_lens (get.c:474)
+          by 0x403ACDE: get_lens (get.c:523)
+          by 0x403AB4F: get_lens (get.c:474)
+          by 0x403AF20: lns_get (get.c:684)
+          by 0x4034E81: lens_get (builtin.c:124)
+          by 0x402CDC7: native_call (syntax.c:967)
+          by 0x402F4C9: compile_exp (syntax.c:1574)
+          by 0x402EF17: compile_exp (syntax.c:1487)
+          by 0x402FEEC: __aug_load_module_file (syntax.c:1600)
+          by 0x80489AE: main (augparse.c:86)
+
+       test ls output more portably in face of SELinux differences
+       * test-preserve.sh: Use cut -b1-10 to get mode from ls -l output.
+       Use ls -lZ (not ls -Z, which is not portable) to get SELinux context.
+
+2009-01-04  Arnaud Gomes-do-Vale  <arnaud.gomes@ircam.fr>
+
+       * src/Makefile.am: fix bz #478619 - do not use abspath
+
+2009-01-03  Robin Lee Powell  <rlpowell@digitalkingdom.org>
+
+       Dpkg: new lens and test
+
+2009-01-03  David Lutterkort  <lutter@redhat.com>
+
+       Php: expand filter slightly
+       Suggested by Robin Lee Powell <rlpowell@digitalkingdom.org>
+
+2008-12-29  David Lutterkort  <lutter@redhat.com>
+
+       Fix segfault when branch in a union does not have a ktype
+       * src/lens.c (lns_key_regexp): check for NULL ktype of branch
+       * tests/modules/pass_union_nokey.aug: test the fix
+
+       Bug reported by Robin Lee Powell <rlpowell@digitalkingdom.org>
+
+2008-12-27  Free Ekanayaka  <free@64studio.com>
+
+       Add soma lens and test
+
+       Add limits lens and test
+
+2008-12-24  David Lutterkort  <lutter@redhat.com>
+
+       * autogen.sh: remove bogus argument to configure
+
+2008-12-24  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       Php, Gdm: exclude literal ".anon" from title, not regexp /.anon/
+
+2008-12-24  Free Ekanayaka  <free@64studio.com>
+
+       Phpvars: allow whitespaces before the \n in the <?php head line
+
+2008-12-23  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.3.5
+
+       * transform.c (transfer_file_attrs): ignore SELinux failures if filesystem   does not support extended attributes
+
+       * transform.c (clone_file): fix #32; only copy if   /augeas/save/copy_if_rename_fails exists
+
+       Group: split list of users, make it optional
+       The list of users in a group is now split into individual 'user/'
+       nodes. If a group has no members, no user/ nodes are produced.
+
+2008-12-23  Free Ekanayaka  <free@64studio.com>
+
+       Add lens and test for /etc/group
+
+2008-12-23  David Lutterkort  <lutter@redhat.com>
+
+       Simpler interface and implementation for path_find_one
+
+       Add path_expand_tree
+       Instead of calling path_find_one/tree_create
+
+       Move implementation dealing with path expressions into separate file
+
+       Simplify searching in the tree by using parent pointers
+       Segments do not need to track the tree node where they matched anymore,
+       since we can get the same information by following parent pointers.
+
+       Make finding the parent and siblings of a node uniform
+       All nodes (including the root) now have a parent node, so
+       that the start of the list of siblings can be found as
+       tree->parent->children for any node.
+
+       All 'standalone' trees now have a fake root, called 'origin' whose
+       children are the real root nodes. Another way to look at this is
+       that the tree is now edge-labeled.
+
+       Rename seg_siblings to tree_siblings
+
+       Add an explicit parent pointer to the tree
+
+2008-12-23  Free Ekanayaka  <free@64studio.com>
+
+       Lens and test for config files using PHP-style variables
+       Process /etc/squirrelmail/config.php
+
+2008-12-23  Marc Fournier  <marc.fournier@camptocamp.com>
+
+       New lens and tests for /etc/rsyncd.conf
+       rsyncd.conf is an ini file which allows indented
+       parameters (like smb.conf) as well as entries outside
+       any section (like php.ini).
+
+2008-12-23  David Lutterkort  <lutter@redhat.com>
+
+       * fa.c: mark '.' as a special character that needs to be escaped
+
+2008-12-22  David Lutterkort  <lutter@redhat.com>
+
+       Notes on the expanded XPath notation
+
+2008-12-22  Free Ekanayaka  <free@64studio.com>
+
+       Add lens and test for /etc/passwd
+
+       Shellvars: process two more files on Debian
+       Add /etc/arno-iptables-firewall/debconf.cfg and /etc/cron-apt/config
+
+       Add lenses and tests for postfix's main.cf and master.cf
+
+       Squid: new lens for squid.conf
+
+       Webmin: new lens
+
+2008-12-16  David Lutterkort  <lutter@redhat.com>
+
+       Shellvars: load /etc/sysconfig/sendmail
+
+2008-12-03  David Lutterkort  <lutter@redhat.com>
+
+       Xinetd: make sure equal sign is surrounded by spaces
+       Fix ticket #30
+
+       * lenses/xinetd.aug: make sure new equal signs have a space before
+         and after them; indent attributes with a tab by default
+       * lenses/tests/test_xinetd.aug: add test
+
+2008-11-20  David Lutterkort  <lutter@redhat.com>
+
+       Sshd: change the structure of Condition subtrees
+       The conditions for a match block are now a single subtree, instead of
+       one subtree per condition.
+
+2008-11-19  David Lutterkort  <lutter@redhat.com>
+
+       Only try to save backup file if original exists
+       * transform.c (transform_save): check that original exists before
+       creating backup
+
+       Fix saving of files where backup/new and target are on different devices
+       * transform.c (clone_file): new function
+       * transform.c (transform_save): if rename fails because new/backup file
+         and target file are on different devices, copy the files
+
+2008-11-05  David Lutterkort  <lutter@redhat.com>
+
+       * Makefile.maint: add target tag-release
+
+       Version 0.3.4
+
+       * test-preserve.sh: check that augtool -b produces a backup
+
+2008-10-30  David Lutterkort  <lutter@redhat.com>
+
+       Fix problem with transferring file attributes during save
+       * src/transform.c(transform_save): transfer attributes from the original to
+         the new file as soon as the new file is created; create a .augsave file
+         as a hardlink, not by renaming
+       * src/transform.c(file_replace): pull out the code to transfer attributes
+         into new function transfer_file_attrs; rename of new file to original is
+         now done in transform_save
+
+2008-10-24  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.3.3
+
+       * Makefile.maint: add upload target
+
+       Modest beginnings of a maiintainer Makefile
+       * Makefile.maint: new file
+
+       Undo API breakage introduced in commit 48c285c
+       * src/augeas.c (aug_save): return 0 on success, instead of the number of
+         files changed
+       * src/augtool.c (cmd_save): get the number of files changed from aug_match
+
+       build: use LIB_SELINUX as set by gnulib
+       * configure.ac: do not set up LIB_SELINUX, gnulib does that
+
+2008-10-22  Sylvain Baubeau  <bob@glumol.com>
+
+       Grub: support "rootnoverify" and "chainloader" directives
+
+2008-10-21  David Lutterkort  <lutter@redhat.com>
+
+       Version 0.3.2
+
+       test-preserve.sh: do not check SELinux context on non-SELinux systems
+
+       test-events-saved.sh: sort the list of saved files
+
+       aug_save: report saved files in /augeas/events/saved
+       aug_save now reports which files were changed on disk underneath
+       /augeas/events/saved; if multiple files are changed in one save operation,
+       there will be multiple /augeas/events/saved entries in the tree. The value
+       of each is the path to the file prefixed with /files.
+
+       Generate ChangeLog from git history
+
+       file_replace: preserve SELinux context
+       Copy the SELinux context from the existing file.
+
+       transform_save: preserve file owner/group and mode when saving
+       Take the file owner/group and mode from the existing file and set it on the
+       newly created file during save. When a file is created from scratch, we
+       still create the file with whatever default user/group/mode the current
+       user has set.
+
+2008-10-20  David Lutterkort  <lutter@redhat.com>
+
+       aug_save: report the number of files that were changed
+       When the tree is saved, keep track of the number of files that were
+       actually changed and return that number.
+
+       transform_save: make saving idempotent
+       When a file needs to be saved, its contents are first generated in a temp
+       file which is then moved over the original file. Between generating the
+       temp file and moving it in its final place, read its contents back in and
+       compare with the contents of the original file. Only move the tempfile over
+       the original if the contents do indeed differ. This avoids spurious changes
+       in mtime.
+
+       Formatting changes
+
+2008-10-16  Jim Meyering  <jim@meyering.net>
+
+       Include <config.h> early, so its _GNU_SOURCE definition takes effect.
+       * src/lexer.l (%top{...}): Include <config.h> here, not in %{...}.
+       Otherwise, the flex-emitted inclusion of <string.h> would
+       precede the definition of _GNU_SOURCE, rendering it useless.
+       This also avoids warnings about strndup being undeclared.
+       Don't include <string.h> explicitly, since flex already does that.
+
+2008-10-13  Joel Nimety  <jnimety@perimeterusa.com>
+
+       Grub: add support for password directive
+
+2008-10-06  Free Ekanayaka  <free@64studio.com>
+
+       Samba: Change default indentation and separation
+       Match indentation of the example configuration file shipped by the upstream
+       authors
+
+       Add gdm lens and associated test
+
+2008-10-02  David Lutterkort  <lutter@redhat.com>
+
+       Ignore files based on .hgignore
+
+2008-10-01  David Lutterkort  <lutter@redhat.com>
+
+       Complain when nodes in the tree can not be put
+       When nodes are added to the tree that do not match the appropriate
+       key/label lens, we used to silently drop them if the key/label was inside a
+       repetition inside a concat.
+
+       Now, we check when we split the tree for a concat that we have used all the
+       nodes in the tree that we were supposed to, and complain otherwise.
+
+       This also uncovered that the test rec-hosts-add.rb was broken, but still
+       passed.
+
+2008-10-01  David Lutterkort  <dlutter@redhat.com>
+
+       Pass --nostdinc properly when running under gdb
+
+       Logrotate: parse tabooext into list; add processing of a number of options
+       Patch by Sean E. Millichamp
+
+2008-09-22  David Lutterkort  <dlutter@redhat.com>
+
+       Grub: add support for 'serial' and 'terminal'
+       Patch by Sean E. Millichamp
+
+       Add backlinks to main site
+
+       Remove some italics
+
+       Logrotate: add dateext flag
+       Patch by Sean E. Millichamp
+
+       Various changes to the NaturalDocs support
+       This patch changes a few things around in the NaturalDocs support:
+
+       - There is no explicit --with-naturaldocs option anymore; instead,
+         configure.ac looks for a program that's either called 'naturaldocs' or
+         'NaturalDocs' and enables support for doc generation depending on whether
+         that program is found or not.
+
+         This works in any of the following situations:
+         (1) NaturalDocs is installed from an RPM, and therefore on the default
+             PATH, with its Perl modules installed on the standard Perl library
+             path
+         (2) NaturalDocs is installed in a random directory, and both PATH and
+             PERL5LIB are set accordingly
+         (3) A wrapper script that sets the path is on PATH
+
+       - Various fixes to make 'make distcheck' work
+
+2008-09-12  David Lutterkort  <dlutter@redhat.com>
+
+       Properly include test modules
+
+2008-09-11  Raphael Pinson  <raphink@gmail.com>
+
+       Add naturaldocs support Build pdf docs
+
+2008-09-09  Raphael Pinson  <raphink@gmail.com>
+
+       Adapt comments for NaturalDocs parsing
+
+       Add comments for NaturalDocs parsing
+
+       Add comments for NaturalDocs parsing
+
+       Add comments for NaturalDocs parsing Reorganize a bit
+
+       Adapt sudoers.aug for NaturalDocs parsing
+
+       Adapt augeas.h for NaturalDocs parsing
+
+2008-09-08  David Lutterkort  <dlutter@redhat.com>
+
+       Sshd: better handling of match blocks
+       Split match conditions into individual 'Condition' entries. Store the
+       settings for a match block inside 'Settings' entries.
+
+2008-09-08  Free Ekanayaka  <free@64studio.com>
+
+       Add monit lens and test
+
+2008-09-06  Free Ekanayaka  <free@64studio.com>
+
+       Ldap: merge with Spacevars. Spacevars: process havp.config
+       Adapt Test_ldap, since there is no Ldap.lns anymore
+
+2008-09-08  David Lutterkort  <dlutter@redhat.com>
+
+       Use --nostdinc in tests
+       We never want to use installed lenses in the tests; they should only be
+       read from the directories that are specified explicitly
+
+       augtool, augparse: add --nostdinc option
+
+       augtool, augparse: allow long options
+
+2008-09-06  Free Ekanayaka  <free@64studio.com>
+
+       Shellvars: merge Sysconfig, Ifcfg; support /etc/default
+       Merge Sysconfig and Ifcfg into Shellvars
+
+       Add /etc/default/* to the list of supported configuration files
+
+2008-09-05  David Lutterkort  <dlutter@redhat.com>
+
+       transform: append missing newlines
+       If a file does not end with a newline, append one automatically. Most
+       lenses require that a file ends with a newline, and files that are missing
+       them are quite common.
+
+       Shellvars: use Util.eol for eol
+
+       test/modules: only distribute .aug files
+
+       Shellvars: handle space at the end of a line
+
+2008-09-04  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.3.1 for changeset 803c17b1833a
+
+       Release 0.3.1
+
+       Sysctl: lens for sysctl.conf
+       Contributed by Sean Millichamp
+
+2008-09-04  Free Ekanayaka  <free@64studio.com>
+
+       Add lens and test for dnsmasq.conf
+
+2008-09-02  Free Ekanayaka  <free@64studio.com>
+
+       Add slapd.aug and test modules
+
+       Spacevars: Allow passing the entry keyword as a parameter
+       Modify Ldap.lns and Test_spacevars accordingly
+
+2008-08-30  Free Ekanayaka  <free@64studio.com>
+
+       Add samba.aug and associated test
+
+2008-08-27  Free Ekanayaka  <free@64studio.com>
+
+       Inifile: support empty comments
+       Empty comments are lines beginning with ";" or "#" but without any more text
+
+2008-08-29  Raphael Pinson  <raphink@gmail.com>
+
+       Map entries outside of sections inside a ".anon" section
+       Clean regexp for entry key
+       Remove /.anon/ from record key regexp
+       Modify test_php.aug according to new mapping policy
+       entry_re is standard in php.aug
+
+2008-09-03  David Lutterkort  <dlutter@redhat.com>
+
+       typecheck_maybe: less convoluted check for empty match
+       There's no need to construct an FA to check if a regular expression matches
+       the empty string.
+
+       Properly typecheck the '?' operator
+       The '?' operator was completely missing a typecheck for the atype. The
+       check must make sure that neither the ctype nor the atype match the empty
+       word.
+
+       To allow constructs like (store re)?, we allow the atype to match the empty
+       word, as long as the lens inside the '?' consumes the value of the current
+       node, since that also tells as whether to use the inner lens or not.
+
+       Various existing lenses failed to typecheck after this change and have been
+       adapted; this also fixes a bug in the Fstab.lns where existing whitespace
+       was being replaced with a default tab. The Interfaces.lns needed a fairly
+       invasive change, and as a consequence produces way more (too many?)
+       anonymous tree nodes.
+
+       Added tests to verify the typechecking of '?'
+
+2008-09-02  David Lutterkort  <dlutter@redhat.com>
+
+       Minor error message improvements
+       - Include information about the lens that produced the error if it's
+         available
+       - When a union during 'put' does not match, produce an error instead of
+         aborting
+
+2008-08-28  David Lutterkort  <dlutter@redhat.com>
+
+       Fix a bug with transferring skeletons
+       It is possible for a skeleton to move from one subtree lens to another, if
+       both use the same key; since the lenses might have different skeleton
+       types, we need to detect this and discard the skeleton if its type does not
+       match the lens that is used during put.
+
+       skel_instance_of: fix bad check for regexp match
+       The return value of regexp_match was interpreted incorrectly, making it
+       seem that the skel_instance_of test should fail if we ever tried to match
+       an empty string.
+
+2008-08-27  David Lutterkort  <dlutter@redhat.com>
+
+       Some files for the test root
+
+       A test for the del typecheck
+
+       Script to run lens tests through Valgrind
+       We don't run this as part of 'make check' since it's _very_ slow.
+
+       Dhclient: change some defaults for del
+       This is really a bug in how string literals are unescaped by the lexer, but
+       we can sidestep the problem here.
+
+       The lexer bug is https://fedorahosted.org/augeas/ticket/12
+
+2008-08-27  Free Ekanayaka  <free@64studio.com>
+
+       Dhclient lens
+
+2008-08-26  Raphael Pinson  <raphink@gmail.com>
+
+       Add OpenVPN lens and associated test
+
+2008-08-27  Free Ekanayaka  <free@64studio.com>
+
+       Dput: add allowed_distributions entry
+       See man dput.cf(5) from a recent dput version (Ubuntu/hardy or
+       Debian/lenny)
+
+2008-08-26  David Lutterkort  <dlutter@redhat.com>
+
+       Typecheck del lens
+       The builtin lens 'del RE STR' was missing a typecheck: the default string
+       STR must match the regular expression RE, otherwise we might produce text
+       that we cant parse back in.
+
+       This patch fixes that, adds a test that the check is performed, and fixes
+       all the places in existing lenses where a use of 'del' failed the
+       typecheck.
+
+2008-08-18  Nahum Shalman  <nshalman elys com>
+
+       Shellvars: fix arrays so that saving works properly  * based on an IRC conversation with raphink
+
+2008-08-25  David Lutterkort  <dlutter@redhat.com>
+
+       Acknowledge Free Ekanayaka
+
+2008-08-25  Free Ekanayaka  <free@64studio.com>
+
+       Ldap lens
+
+       Spacevars lens
+
+2008-08-24  Free Ekanayaka  <free@64studio.com>
+
+       Interfaces: new lens to process Debian's /etc/network/interfaces
+
+2008-08-25  David Lutterkort  <dlutter@redhat.com>
+
+       Util.comment: produce #comment nodes
+
+2008-08-14  Raphael Pinson  <raphink@gmail.com>
+
+       Inifile: complete rewrite. Also rewrite lenses using Inifile
+       Adapt Php, Dput, Puppet and the corresponding tests to use the new Inifile
+       module.
+
+       Php: allow entries outside of sections
+       Adapt php.aug to support entries outside of sections and still map sections
+       as labels (Fix #9)
+
+2008-08-15  David Lutterkort  <dlutter@redhat.com>
+
+       Shellvars: one more cornercase with double quoted strings
+
+       Shellvars: much improved handling
+       - handle single and double quoted strings correctly
+       - parse arrays into a subtree
+
+       Inspired by a chat and preliminary work by nahamu
+
+       skel_instance_of: remove pointless check
+       There is no point in trying to match against skel->text for a store lens
+       since that is always NULL.
+
+       Fix syntax error in test
+
+       augl_error: Initialize info
+
+2008-08-14  David Lutterkort  <dlutter@redhat.com>
+
+       aug_mv: fix bug when moving at the root level
+       When moving from the root level, the source node needs to be removed from
+       aug->tree, not aug->tree->children. In addition, the list_remove macro must
+       be passed aug->tree and not a local variable holding that value, since we
+       might have to remove the list entry that aug->tree is pointing to.
+
+       Added test in test-mv.sh to test that moving at the root level works.
+
+       Module names are treated case-insensitively
+       Before, if you had a module 'Mod' in file 'mod.aug' and requested variable
+       'MoD.var' from another module, the interpreter would throw itself into a
+       loop where it kept loading 'mod.aug', but never found 'MoD.var' because the
+       comparison of module names 'MoD' and 'Mod' was case sensitive.
+
+2008-08-13  Raphael Pinson  <raphink@gmail.com>
+
+       Add puppet.aug and associated test
+
+       test_php.aug: make a nice test for PHP
+
+       Php: simplified and based on Inifile
+       "Slightly" simplify php.aug now that the comment issue is fixed in
+       inifile.aug
+
+       Inifile: use #comment for comment fields
+       Adapt test_dput.aug and test_inifile.aug
+
+       Inifile: no space around seps by default
+
+       Inifile: reformat inifile.aug, ignore empty comments
+       Reformat inifile.aug :
+         - improve readability
+         - limit line width to 80 chars
+         - change a few var names
+       Ignore empty comments
+       Adapt test_dput.aug to ignore empty comments
+
+       Fstab: map comments and support empty lines
+
+       Sudoers: clean up comment definition
+
+2008-08-12  David Lutterkort  <dlutter@redhat.com>
+
+       Hosts: handle comments at the end of a host entry
+       Comments are put into the tree as part of that host node, i.e. will live as
+       long as the host entry.
+
+       Based on an initial patch by Kjetil Torgrim Homme <kjetilho@linpro.no>
+
+2008-08-12  Raphael Pinson  <raphink@gmail.com>
+
+       Pam: Use eol, indent, comment and empty from Util
+
+       Util: add eol, indent, comment and empty
+
+       Pam: allow comments at the end of lines and leading spaces
+
+       Xinetd: better handling of whitespace
+       - allow indented comments
+       - allow spaces around "}" to close a service
+
+2008-08-12  David Lutterkort  <dlutter@redhat.com>
+
+       Exports: fix failing test
+       Exports.lns uses Hosts.comment .. since that changed, we also need to
+       change Exports.lns
+
+2008-08-12  Raphael Pinson  <raphink@gmail.com>
+
+       Hosts: put comments into tree and better whitespace handling
+       - allow spaces at the end of the line
+       - allow indentation at the beginning of entries
+       - allow indented comments
+       - show comments as fields and ignore empty lines and empty comments
+
+       Handle indentation for Sudoers
+       Allow indentation for every field
+       cmnd_spec: use sto_to_com_cmnd (allows spaces)
+       Add a test with new tricky commands in spec
+
+       Various small fixes for Sudoers
+       Deal with empty comments in empty.
+       Add "!" as a valid parameter delimiter in Defaults.
+       Make tests a bit more interesting in test_sudoers.aug.
+
+       Sudoers: fix Runas_Spec
+       sep_cont is not mandatory after runas_spec.
+       Remove a space after a runas_spec in the test.
+
+       Sudoers: various fixes for Defaults
+       Do not allow "Defaults.*" as user name for spec (instead of "Defaults").
+       Simplify Defaults type from (@|:|>) into [@:>].
+       Make a specific regexp for Defaults value to allow spaces.
+       Add a test line in test_sudoers.aug to test a more complex Defaults line.
+
+       Add sudoers lens and associated test
+
+2008-08-11  David Lutterkort  <dlutter@redhat.com>
+
+       Test for continuation lines
+
+       Posix ERE compliant escaping
+       Posix extended regular expressions treat a backslash outside of a character
+       class always as an escape character, with the character sequence '\\x'
+       being identical to 'x', even if 'x' is a special char like '['.
+
+       Inside character classes, the backslash does not escape anything, and is
+       treated as an ordianry character.
+
+       See regex(7) or
+       http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04
+
+2008-08-09  David Lutterkort  <dlutter@redhat.com>
+
+       Revamp the dict data structure
+       Dicts were simple linked lists of key/value pairs, and appending and
+       searching on those lists caused serious slowdown when the dicts became
+       large, for example when writing an /etc/hosts file with > 2000 lines.
+
+       Dicts are now organized as arrays that are kept sorted by the key, and
+       lookup is done through binary search. Though this is still quadratic in
+       theory, it behaves linearly in practice even for a very large /etc/hosts
+       file (~ 60k lines); when keys appear in order (e.g. when they are generated
+       by a sequence) or when all entries fall under one key, adding an entry to a
+       dict is O(log n).
+
+       Don't use registers in split_iter
+       The data in the registers was never used, calculating it causes some
+       overhead in the matcher.
+
+2008-08-08  David Lutterkort  <dlutter@redhat.com>
+
+       Eliminate unneeded calls to regexp_match in split_iter
+
+       Don't call regexp_match when we know that there is no match
+       It is common in the put direction that we try and split when we're already
+       inside a leaf node. In that case, we know that there is no possible split,
+       and therefore can save the trouble of calling regexp_match.
+
+       Avoid O(n^2) runtime by appending to lists in constant time
+       The data structure used to keep track of successive matches of an iterated
+       lens, a split list, was being appended to by traversing the list for each
+       new element. Now, we remember the last element on the list and append in
+       constant time.
+
+       The same was true in a few other places: the building of a tree and of
+       skeletons suffered from the same problem.
+
+       Dicts still have that problem - they need to be changed to hash tables to
+       address this issue.
+
+       Add list_reverse and list_tail_cons
+       list_reverse reverses a list in place. list_tail_cons appends to a list in
+       constant time, since it is given a pointer to the tail of the list.
+
+2008-08-07  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.3.0 for changeset 60f2a13c2528
+
+       Release 0.3.0
+
+       Mention the exit status
+
+       Version libfa and libaugeas
+       Use libtool's version support to properly version these two libraries. For
+       libaugeas, we also bump the minor version, since we just added aug_mv to
+       the interface.
+
+       Check that 'put' fails when invalid tree entries are present
+       put_quant_star and create_quant_star did not compare the part of the tree
+       they should transform against the part of the tree they actually
+       transformed. This lead to parts of the tree getting ignored during 'put' if
+       the tree contained invalid nodes, and ultimately to files getting
+       truncated.
+
+       This is now checked and causes a 'Short iteration' error, avoiding file
+       truncation. The fix also uncovered an error in the test for Aptsources.lns,
+       where an invalid tree node was put into the tree, but did not lead to a
+       test failure.
+
+       Fixes bug https://fedorahosted.org/augeas/ticket/1
+
+       Return an exit status from augtool
+       augtool will return a non-zero exit status if any command issued
+       failed. This is useful when piping multiple commands into augtool to check
+       that they all succeeded.
+
+2008-07-29  David Lutterkort  <dlutter@redhat.com>
+
+       Fix failures on FreeBSD
+       (1) Point augtool at the lenses in the source dir (not FreeBSD problem,
+           happens whenever Augeas is not installed yet)
+       (2) Remove bashism 'echo $"..."' with 'echo -e "..."'
+
+       Quiet the test
+
+2008-07-29  Raphael Pinson  <raphink@gmail.com>
+
+       Use regexp union instead of lens union in php.aug
+       Using a union of regexps is much faster than a union of lenses, since the
+       regular expressions that are constructed internally are much simpler.
+
+2008-07-25  Raphael Pinson  <raphink@gmail.com>
+
+       Fix php.aug now that inifile.aug supports spaces in values
+
+       Add PHP module and associated (basic) test file
+
+2008-07-29  Raphael Pinson  <raphink@gmail.com>
+
+       Use regexp union instead of lens union in dput.aug
+       Using a union of regexps is much faster than a union of lenses, since the
+       regular expressions that are constructed internally are much simpler.
+
+2008-07-25  Raphael Pinson  <raphink@gmail.com>
+
+       Rewrite dput.aug using inifile.aug Add a few keywords from man dput.cf Fix test file after rewrite
+
+       Allow spaces in entry values
+
+       Allow spaces in titles
+
+       Fix empty comments in INI file
+
+2008-07-29  David Lutterkort  <dlutter@redhat.com>
+
+       Include canonicalize.h
+       On non-glibc systems, we need to make sure canonicalize_file_name is
+       declared from gnulib.
+
+       Fail the whole test if one of the lens tests fails
+
+2008-07-28  David Lutterkort  <dlutter@redhat.com>
+
+       Add a call to move a subtree to the public API
+
+2008-07-26  David Lutterkort  <dlutter@redhat.com>
+
+       Refactor tree_create
+
+       Don't run the typechecker by default from try
+
+2008-07-24  David Lutterkort  <dlutter@redhat.com>
+
+       Flatten the tree of lenses
+       For union and concat, we used to store multiple unions/concats in a binary
+       tree. Now, the tree is flattened and a string of concats is stored as one
+       lens.
+
+       Allow a key and store in each branch of a union
+
+       lns_key_regexp: store does not do anything about the key
+       We used to generate tree nodes with a NULL label for a STORE, but that is
+       no longer the case, and therefore the STORE lens should not produce any key
+       regexp.
+
+       Correctly handle saving to nonexistant files
+
+       Store system errors
+       When encountering system errors while reading or writing a file, extract
+       the full error message corresponding to errno and store it in error/message
+
+2008-07-23  Raphael Pinson  <raphink@gmail.com>
+
+       Add AptPreferences module and associated test
+
+       Add bbhosts module and associated test
+
+       Add ntp module and associated test
+
+       Add logrotate and associated test
+
+       Add support for end of line comments in entry* Add new entry* lenses for comments_nosharp Make more generic entry and comment lenses Update test_inifile.aug to test end of line comments
+
+       Add inifile generic module and associated test module
+
+2008-07-22  David Lutterkort  <dlutter@redhat.com>
+
+       Fix segfault when running 'augtool print'
+
+2008-07-21  David Lutterkort  <dlutter@redhat.com>
+
+       Canonicalize file names before writing
+       We used to clobber symlinks because writing a file consists of writing to
+       an intermediate .augnew file, and then moving that over the target file. To
+       keep target files that are symlinks intact, we now canonicalize the target
+       filename and then move the intermediate file to the canonicalized target
+       file.
+
+       Avoid picking '\0' in examples.
+       Now, we only pick '\0' as the example character for a transition if it is
+       the only char for that transition.
+
+2008-07-18  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.2.2 for changeset e7f6d16e75df
+
+       Release 0.2.2
+
+       Rename rule because FreeBSD's make chokes on it
+       Rename the rule .FORCE-datadir.h to FORCE-datadir.h
+
+       Sample dput.cf for dput lens
+
+       Lens for Debian's dput files
+       Contributed by Raphael Pinson
+
+2008-07-17  David Lutterkort  <dlutter@redhat.com>
+
+       augtool: Print '(none)' when getting a path with no value
+       The output used to be mangled. Now it is 'path = value' if hte path has a
+       non-NULL value, 'path (none)' if the path exists but has a NULL value, and
+       'path (o)' if an error occurred.
+
+       Added tag release-0.2.1 for changeset 13fdcd9bb18a
+
+       aliases.aug: Do not require whitespace after commas
+       It's perfectly fine to have an alias like 'alias: target1,target2'
+
+       Bug reported by Greg Swift
+
+2008-07-16  David Lutterkort  <dlutter@redhat.com>
+
+       Fix insertion before the first child
+       Inserting a node as the new first child was completely broken.
+
+       Bug reported by Raphael Pinson.
+
+       Add support for 'insert' in unit tests
+       Two new primitives 'insa' (insert after) and 'insb' (insert before) are
+       added so that unit tests can modify the tree through insert, as in
+
+         test lns put str after
+           insa label path = str2
+
+       It would be nice to kill insert with one primitive, but that would have
+       either required special syntax (like 'ins STR before/after STR') or some
+       addition to the type system to make it syntactically reasonable.
+
+2008-07-09  David Lutterkort  <dlutter@redhat.com>
+
+       Test that putting into an empty string works
+
+       Initialize state->pos in lns_parse and lns_get
+       Otherwise, get and parse on an empty string will produce a 'short
+       iteration' error, even if the empty string is acceptable for that lens.
+
+2008-07-07  David Lutterkort  <dlutter@redhat.com>
+
+       Put the default dir for lenses into DATADIR (the real fix)
+       Reworks 527:14602e2757dd in a way that actually works and conforms to the
+       GNU coding standards.
+
+       Most of this fix suggested by Jim Meyering, I only touched it up a little
+       (and no doubt introduced all the bugs).
+
+       Check for NULL values in the put direction of store
+       This is now flagged as an error instead of causing a segfault.
+
+2008-07-03  David Lutterkort  <dlutter@redhat.com>
+
+       Lens for /etc/exports
+
+2008-07-01  David Lutterkort  <dlutter@redhat.com>
+
+       Release 0.2.1
+
+       distclean-local: Do not clobber build/aux
+
+       Suppress generated manpages
+
+2008-06-30  David Lutterkort  <dlutter@redhat.com>
+
+       Put the default dir for lenses into DATADIR
+       Instead of hardcoding the default dir for lenses to somewhere in '/usr',
+       look in DATADIR - that's after all where the default lenses are installed
+       if DATADIR (or PREFIX) is changed.
+
+       Man page for augparse
+
+       Put Augeas version into footer
+
+2008-06-23  David Lutterkort  <dlutter@redhat.com>
+
+       Auto-generate the ChangeLog file from mercurial logs
+       Reviewed-by: David Lutterkort <dlutter@redhat.com>
+
+2008-06-13  David Lutterkort  <dlutter@redhat.com>
+
+       Fix two problems in the grub lens
+       (1) The grub lens did not handle blank lines
+       (2) Ubuntu uses 'quiet' in its boot stanzas, which we didn't know about
+
+       Reported by Jason Dobies
+
+       Produce more helpful errors
+       The previous check whether we could proces the entire input was too crude
+       and produced the unhelpful error message "Get could not process entire
+       input", pointing to the start of the string, even if the problem was much
+       farther down the line.
+
+       With this change, error messages contain an indication to where the error
+       happened that is a little closer to the actual trouble spot.
+
+2008-06-12  David Lutterkort  <dlutter@redhat.com>
+
+       Check that we take the right branch in a union
+
+       Process /etc/sysconfig/selinux
+       Patch by Alan Pevec
+
+       Fix segfault when aug_init/close are called multiple times
+       The way we cached the regexp '[0-9]+/' was totally botched. We now allocate
+       the pattern statically in memory and pin it to protect it from being freed,
+       ever.
+
+       Reported by Harald Hoyer
+
+2008-06-06  David Lutterkort  <dlutter@redhat.com>
+
+       Initialize out parameters
+
+       Change struct fields of type (const char *) to (char *)
+       There were many places where struct fields were declared (const char *) but
+       then used as (char *) - mostly to free them. Remove the 'const' from those
+       fields.
+
+       I would really appreciate if somebody could look over these and make sure I
+       don't throw away constness in too many places. It seems strange to declare a
+       field as non-const, even if the string referenced by it is never modified,
+       and only ever free'd when the enclosing struct is free'd.
+
+2008-06-05  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.2.0 for changeset d23f95cd13f3
+
+       Release 0.2.0
+
+2008-06-03  David Lutterkort  <dlutter@redhat.com>
+
+       Remove bashisms from test scripts
+       Make tests scripts work with plain old sh; also, don't hardcode location of
+       Ruby interpreter to /usr/bin/ruby.
+
+       Work around a problem with Bison on FreeBSD
+       Bison looks for _STDLIB_H to see if stdlib.h has been included, but the
+       system includes use _STDLIB_H_; that makes Bison think malloc/free have not
+       been declared yet and it goes and does that. gcc then complains about the
+       duplicate declaration.
+
+       Infrastructure and import of gnulib modules
+       We do not keep the gnulib sources in our own repo. Instead, autogen.sh now
+       calls out to bootstrap to pull in needed files from gnulib.
+
+       The bootstrap script was copied from libvirt.
+
+2008-06-02  David Lutterkort  <dlutter@redhat.com>
+
+       Use a build aux dir (in build/aux)
+
+       Use autoheader and generate config.h
+
+       Work around lack of open_memstream on non-GNU systems
+       Since open_memstream is only available with glibc, wrap its use and fall
+       back to writing to a tempfile on other platforms.
+
+       Remove src/config.h
+       It was a bad idea to begin with; fold the contents into internal.h and make
+       room for a generated config.h
+
+       Support the @include syntax
+       Debian uses lines of the form '@include module' to reference other pam
+       configs. The official PAM docs don't mention it, but obviously it works.
+
+       Handle trailing whitespace in pam.d; split module-arguments
+
+       Allow multiple comma-separated fs types in fstab
+       On Debian Etch, the CDROM has fs type 'udf,iso9660'
+
+       Handle blank lines in /etc/hosts
+
+       Fix missing ref on an info struct in syntax.c(compile_minus)
+
+2008-05-30  Jim Meyering  <meyering@redhat.com>
+
+       * tests/test-lenses.sh: more quotes, protect against space in abs_srcdir
+
+       don't conflate top_srcdir and abs_top_srcdir
+       * tests/Makefile.am: Use $(var), rather than obsolete @var@ notation.
+       (TESTS_ENVIRONMENT): Rename LHS to match RHS to help avoid (my) confusion:
+       s/top_builddir/abs_top_builddir/ and s/top_srcdir/abs_top_srcdir/.
+       * tests/augtest: Reflect renamings.
+       * tests/test-interpreter.sh: Likewise.
+       * tests/test-get.sh: Likewise, and remove unused top_builddir= assignment.
+       * tests/test-lenses.sh: Likewise; remove unnecessary braces, add quotes
+       to protect against pathological $TMPDIR.
+
+2008-05-29  David Lutterkort  <dlutter@redhat.com>
+
+       Make distcheck work again
+       Restore top_builddir and top_srcdir so that augtest passes during make
+       distcheck.
+
+       Fix memory leak in make_exn_lns_error
+
+2008-05-29  Jim Meyering  <meyering@redhat.com>
+
+       Remove some absolute paths for binaries.
+       * tests/Makefile.am [TESTS_ENVIRONMENT]: Add a PATH definition that
+       lets tests invoke "augtool" and "augparse" without any absolute prefix.
+       Remove top_builddir and top_srcdir definitions; no longer needed.
+       * tests/augtest: Remove definition of AUGTOOL.  Update use.
+       * tests/test-lenses.sh: Likewise for AUGPARSE.
+       * tests/test-interpreter.sh: Likewise.
+       * tests/rec-initdefault.rb: Use 'augtool -n' in place of #{AUGTOOL}.
+
+2008-05-23  David Lutterkort  <dlutter@redhat.com>
+
+       Fix use of possibly uninitialized variable
+       * get.c(lns_parse): initialize skel; gcc complains about possible
+         uninitialized use
+
+2008-05-28  David Lutterkort  <dlutter@redhat.com>
+
+       Check that augtool reads all of tests/root/ without error
+
+2008-05-23  David Lutterkort  <dlutter@redhat.com>
+
+       Add a test to check we take the right branch
+       This does essentially the same as the test Pass_prefix_union introduced
+       with cset 489:3f4414038a30, but in a real world lens.
+
+       Escape | when turning a string into a regexp
+
+       Add source statements in shell scripts as '.source' nodes
+
+       Escape label strings when creating the key regexp for them
+
+       Allow lower case characters in shell vars
+
+2008-05-23  Jim Meyering  <meyering@redhat.com>
+
+       "echo get /|augtool -n" would read one past end of malloc'd buffer * src/augeas.c (make_path): Avoid buffer overrun.
+
+2008-05-23  David Lutterkort  <dlutter@redhat.com>
+
+       Fix a major bug in the get implementation of lenses
+       We used to process the input from left to right, matching the regular
+       expressions of lenses with the input successively. That is very wrong, in
+       particular, it leads to lens union choosing the wrong branch: in the union
+       l1|l2, union would always choose l1 if l1 matched a prefix of l2.
+
+       We now process the input in a top-down fashion, splitting the string into
+       parts as we descend in the tree of lenses. As evidenced by the test
+       pass_prefix_union, that fixes the bad behavior.
+
+       Incidentally, it also uncovered another bug in the test_hosts.aug, where a
+       test passed, even though the string we were using did not end with the
+       newline that is mandatory for Hosts.record.
+
+       This change also does away with pasing flags and a FILE* for logging
+       details about hte parse process; they don't really make sense anymore, nor
+       is that behavior very useful in a library.
+
+2008-05-22  David Lutterkort  <dlutter@redhat.com>
+
+       Fix use of uninitialized pointer
+       ERR must be initialized, since it is later passed to free_lns_error
+
+       Lens for vsftpd.conf
+       The lens is very tight, in that it only allows actual options, and knows
+       what kind of value each option accepts.
+
+2008-05-21  James Antill  <james@code.and.org>
+
+        Fix for the joy that is the glibc asprintf API.
+
+2008-05-21  James Antill  <james@and.org>
+
+        Minor fix to not use bad memory.
+
+        Remove strcat's for stpcpy's
+
+        Fix escaping strings that end in \  Fix escaping of unprintable bytes
+
+        Fix buffer overflow on strings ending in \
+
+2008-05-21  David Lutterkort  <dlutter@redhat.com>
+
+       Use glibtoolize on OSX
+       Patch provided by Rizwan Kassim
+
+2008-05-21  Jim Meyering  <meyering@redhat.com>
+
+       Make a file-scoped static array "const".
+
+2008-05-18  Jim Meyering  <meyering@redhat.com>
+
+       * src/augtool.c (cleanpath): Don't access path[-1].
+
+       * src/transform.c (transform_save): Detect pre-fclose write failure.
+
+       * src/internal.c (read_file): Rewrite, plugging a file descriptor leak.
+
+2008-05-16  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.1.1 for changeset fae07193655a
+
+       Release 0.1.1
+
+       Add dependency on ref.h
+
+       Get rid of compiled regexps earlier
+       After we're done with a transform, release the memory used by compiled
+       regexps; storage for compiled regexps accounts for the lion's share of
+       Augeas' memory needs.
+
+       Before this patch, augtool run against the files in tests/root/ used more
+       than 10MB of memory; with this patch, that is done to 250 kB after the
+       initial load, with a spike of about 6MB during loading.
+
+2008-05-15  David Lutterkort  <dlutter@redhat.com>
+
+       Misc leak fixes in the interpreter
+       * Do not ref the old binding in bind_type, ownership is transferred from
+         the caller to the new list head
+       * Unref the argument of an apply and the func computed in compile_compose
+       * Unref the value after it is bound in the context in compile_decl
+       * Unref various things in define_native_intl
+
+       Don't leak the key when appending dict entries
+
+       Free the actual struct exn when freeing an exn value
+       Factor freeing a struct exn into free_exn; previously, the code did not
+       free the storage for the struct exn itself.
+
+       Don't leak key/value in parse on error
+
+       Do not leak the split on error
+       put_subtree has to free the split it computes; previously, it leaked that
+       if an error inside the subtree occurred.
+
+       Free loadpath
+       Although not strictly necessary, it makes it easier to run augparse through
+       valgrind and get meaningful results.
+
+       Free path
+
+       Don't leak SNAME
+
+       Free the lns_error in lens_put
+
+       Cleanly free regexp patterns; put empty_pattern into ro storage
+
+       Ref the returned tree
+       The tree that tree_set_glue and tree_rm_glue return needs to have its ref
+       increased, as the calling conventions for builtin functions stipulate that
+       the returned value is owned by the caller
+
+2008-05-14  David Lutterkort  <dlutter@redhat.com>
+
+       Report errors more clearly in the tree
+       When an error happens during get/put, store additional info in the tree:
+       for get errors, store the position in the file where the error occured, for
+       put errors, the path of the node. In both cases, also store the
+       human-readable message.
+
+       For a file F, all this information is stored underneath /augeas/F/error,
+       with the value associated with /augeas/F/error giving some indication about
+       the kind of error encountered.
+
+2008-05-13  David Lutterkort  <dlutter@redhat.com>
+
+       Report errors during put
+
+       Check that values match the regexp for the corresponding store during put
+
+       Lens and transform for /etc/fstab
+       The lens could be further refined by distinguishing between the legal
+       values in the first field (LABEL=xxx vs special file system vs device) and
+       by trying to model more of the vfs/option dependencies, but that's more of
+       a v2 feature.
+
+       Remove bad assertions
+       It is perfectly legal for create_* functions to be called with a non-NULL
+       skeleton; that happens for example when the union combinator puts a tree
+       that "jumped branches", i.e. whose get used one branch of the union, and
+       the put uses the other branch because of changes to the tree.
+
+       Reduce the number of calls to collect
+       We were calling collect way too often, which was slowing things down. Also
+       broke collect into separate subfunctions so we can see better when one of
+       them becomes a bottleneck.
+
+       Stricter skeleton instance check for del and store
+       Besides having the right tag, del and store match a skeleton only if the
+       text for that skeleton also matches their regexp.
+
+       Weaken the check for key, label, seq, and counter a tiny bit.
+
+2008-05-12  David Lutterkort  <dlutter@redhat.com>
+
+       Proper typecheck for lens unions
+       Check that lenses have disjoint ctypes and atypes in a union.
+
+       Fix up the existing lenses that violate that.
+
+2008-05-09  David Lutterkort  <dlutter@redhat.com>
+
+       Keep re_cset_as_string from including an explicit '\0'
+       We use NUL delimited strings; that means we can not use a CSET
+       representation that mentions '\0' explicitly.
+
+       Use the new '-' operator for key_re
+
+       Add subtraction of regular expressions to the language
+       It is now possible to say something like
+
+         let re = /[a-z]+/ - "baseurl"
+
+       The '-' operator is only defined between regexps.
+
+       Add REGEXP_MINUS; move REGEXP_TO_FA to regexp.c
+
+       Refactor typechecking for union/concat
+       The typechecking for union and concat is incredibly similar, but was
+       implemented with too much code duplication.
+
+       Store character sets as bitsets
+       Also clean up the definition of the bitset type and make the bitset_*
+       functions const correct
+
+       Add fa_as_regexp that converts an automaton back to a regexp
+       During conversion from FA to regexp, our FA mutates into a 'generalized
+       transition graph' where transitions aren't labelled with character
+       intervals, but with regular expressions.
+
+       There are lots of gyrations to keep the generated regexp reasonably short
+       (and syntactically correct)
+
+2008-05-08  David Lutterkort  <dlutter@redhat.com>
+
+       Check for (some) allocation failures
+
+       Reference count 'struct re' instances
+
+       Split ref counting macros into separate header
+
+       Remove use of bad REALLOC macro.
+       The old REALLOC macro caused an automatic memory leak when REALLOC
+       failed. Use of REALLOC_N instead also forces checking of more allocation
+       failures.
+
+       Safer memory allocation from libvirt
+
+       Fix a rather embarrassing #ifdef problem
+       When __GNUC__ was not defined, a big chunk of internal.h was suppressed
+       that is not compiler dependent.
+
+       Also, add ATTRIBUTE_PURE macro.
+
+       Switch to using unsigned char internally
+       Since we use chars as indices into arrays in some cases, it is simpler to
+       treat characters as unsigned. This also addresses passing possibly signed
+       chars to is* functions - by using unsigned char, we avoid possible silent
+       conversion problems when going from char -> int.
+
+       There were also cases where we iterated over chars using a char, which was
+       prone to silent overflow.
+
+       Fix mistaken assignments in asserts
+       Reported by Jeff Johnson
+
+2008-05-06  David Lutterkort  <dlutter@redhat.com>
+
+       Cleaner way of turning off expensive asserts
+       Avoid littering everything with #ifdef's, define an 'expensive_assert'
+       instead that expands to nothing unless HASH_DEBUG_VERIFY is defined.
+
+       Patch by Jim Meyering
+
+       Small fixes to the specfile
+       Suggested by Michael Schwendt
+
+2008-05-05  David Lutterkort  <dlutter@redhat.com>
+
+       Lens and transform for xinetd.conf
+
+       Enclose the regexp for a key in (..) before adding a /
+
+       Properly determine if segment needs qualifier
+       For segments with label NULL, we didn't qualify the first sibling with the
+       NULL label since we were comparing NULL to the result of seg_label, which
+       was "(none)"
+
+       Be more consistent in how NULL labels are printed
+
+       Suppress assert of hash_verify
+       Doing the assert(hash_verify(hash)) at various places in hash.c is very
+       expensive and slows things down considerably when assertions are turned
+       on.
+
+       Rather than turning assertions off globally, only do the hash_verify
+       asserts when they are explicitly requested by defining HASH_DEBUG_VERIFY
+
+       Do not minimize freshly created regexps
+       The minimization imposes a serious performance penalty, and is generally
+       not needed.
+
+       This also exposes a bug in fa_overlap; for acceptToAccept to work properly,
+       it needs to be passed a deterministic automaton.
+
+       Fix containment check
+       Checking for FA2\FA1 being empty was plain silly; this check is a little
+       better, but still not the correct disjointness check.
+
+2008-05-02  David Lutterkort  <dlutter@redhat.com>
+
+       Spec file fixes
+
+2008-05-01  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.1.0 for changeset c032a957c316
+
+       Version 0.1.0
+
+       Rename parameter 'glob' to 'glb'
+       gcc on RHEL4 gets confused and thinks that that shadows the global 'glob'
+       function.
+
+2008-04-30  David Lutterkort  <dlutter@redhat.com>
+
+       Process lots of files in /etc/sysconfig
+       Load all those shell-script style config files from /etc/sysconfig using
+       the generic Shellvars lens.
+
+       Ultimately, it would be better if we definedfor each of them which
+       variables are actually going to be looked at (together with some
+       restrictions on possible values)
+
+       Test files for various /etc/sysconfig files
+       The next commit will add a lens for handling shell var style files in
+       /etc/sysconfig. These are simply test/sample files. No functionality.
+
+       Refactor ifcfg.aug
+       This puts the bits that are generally useful for processing /etc/sysconfig
+       files into shell.aug
+
+2008-04-30  Jim Meyering  <meyering@redhat.com>
+
+       check for a few failed memory allocations
+       * src/augtool.c: check for a few failed memory allocations
+
+2008-04-30  Harald Hoyer  <harald@redhat.com>
+
+       do ldconfig in post/postun of the libs subpackage
+
+2008-04-28  David Lutterkort  <dlutter@redhat.com>
+
+       Free the value when freeing a tree node
+
+       Plug another memory leak
+
+2008-04-25  David Lutterkort  <dlutter@redhat.com>
+
+       Fix segfault when aug_get was passed a "/"
+       In that case, make_path returns NULL, which must be checked.
+
+       The bigger question, why "/" is not a valid path is a little more subtle:
+       the tree is really edge-labeled, not node-labeled, i.e. a label applies to
+       the edge going from a parent to its child, but root has no parent, and
+       therefore "/" does not really make sense.
+
+       Split multiple baseurl's in a yum file into multiple baseurl nodes
+       With this, the schema for yum config files may now contain nodes like
+         { "section"
+            ... other key/value pairs ...
+            { "baseurl" = "url1" }
+            { "baseurl" = "url2" }
+            ...
+            { "baseurl" = "urlN" }
+            ... other key/value pairs ...
+         }
+
+       Note that the baseurl nodes have to be consecutive; otherwise, put will
+       fail.
+
+2008-04-24  David Lutterkort  <dlutter@redhat.com>
+
+       Fix lens selection in union
+       The logic in put to select the appropriate branch in unions got it wrong if
+       the first branch matched the empty word, because applies only checked that
+       the atype for the sublens matched some of the tree. It has to check for a
+       complete match of its tree.
+
+       This change fixes that and adds a test to demonstrate the problem.
+
+       Fix ref counting error in lns_make_plus
+       We burnt the passed-in ownership of L when constructing STAR; also, since
+       we unref STAR at the end, we need to take ownership of STAR->LENS when
+       constructing the concat of L and STAR->LENS
+
+       * src/fa.c (string_extend): Handle realloc failure.
+       Patch by Jim Meyering
+
+       Update AUTHORS/NEWS
+
+       Processing of Apt's sources files
+       Contributed by Dean Wilson
+
+       Make sure install preserves timestamps
+       Avoids getting into trouble with the .aug files in augeas-libs on multilib
+       when installing more than one arch.
+
+       See http://fedoraproject.org/wiki/PackagingDrafts/MultilibTricks
+
+       Remove trailing whitespace from the end of lines
+       No functional change, only formatting.
+
+2008-04-23  David Lutterkort  <dlutter@redhat.com>
+
+       Remove aug_exists - it does not exist anymore
+
+       Delete old, outdated notes
+
+       Some repo files for yum
+
+       Add todo file for low-level tasks that don't make sense on the website
+
+       Split libraries into a -libs package
+       This also includes the files in /usr/share/augeas, since they are read by
+       the library and control how configuration files are processed.
+
+       Patch provided by Harald Hoyer
+
+       Include the augtool manpage as doc in the RPM
+
+       Don't die on NULL entries in args
+       There is no guarantee that parseline will fill all of args with strings,
+       empty or otherwise; chk_args needs to be prepared that any entry in args
+       can be NULL.
+
+       Also, parseline initializes all args as NULL now to guard against garbage
+       pointers accumulating from previous uses.
+
+       Don't complain about missing optional args
+       For example, both 'print' and 'print PATH' are legal. Make sure we accept
+       either.
+
+       Properly handle lines with spaces
+       The lines read in through readline can now have spaces in their arguments,
+       if those arguments are enclosed in single or double quotes.
+
+       Revised help texts
+
+       Man page
+       Provided by Dean Wilson
+
+2008-04-22  David Lutterkort  <dlutter@redhat.com>
+
+       Fix two memory leaks in the interpreter
+
+       Plug more memory leaks
+
+       Fix memory leak from not freeing hash table entries
+
+       Clean up the error path in load_file; free the loaded text in transform_load
+
+       Use fread_file_lim to read entire files
+       The function is taken verbatim from libvirt's util.c, and due to show up in
+       gnulib soon.
+
+       Also, make read_file return a char * instead of the silly const char *.
+
+       Check the return value from hash_create
+
+       More const-correctness fixes
+       Patch provided by Jim Meyering
+
+       File needed for running the tests
+
+       Stick more closely to what the shell accepts as assignments
+
+       Properly escape/unescape quotes in strings
+       Patch provided by Alan Pevec
+
+2008-04-21  David Lutterkort  <dlutter@redhat.com>
+
+       Updated for 0.0.8 and upcoming 0.1.0 release
+
+       Remove aug_exists from public API
+       aug_get now combines the functionality of the old aug_exists and aug_get
+       calls, so that callers can retrieve a value and check whether a path
+       expression matches exactly one node in a single call.
+
+       Make creation of new files work
+       When a subtree is created that corresponds to a brandnew file, create the
+       underlying file properly.
+
+       Propagate failure of transform_save up
+
+       Sync compiler warnings with latest from libvirt
+       This should avoid build failures seen on Debian, caused by
+       -fstack-protector
+
+       Also fix build failure caused by addition of -Wformat-security
+
+       Mention people who sent patches
+
+       Parse network configs in /etc/sysconfig/ifcfg-*
+       Patch provided by Alan Pevec
+
+       Don't mark ROOT for MAKE_PATH as const - it's not always true
+
+       Cap file reads (arbitrarily) at 32MB
+
+       Don't ever try to read a directory
+       Suggested by Jim Meyering.
+
+       Return int from aug_print to indicate errors
+       Check for failures during printing and return an indication whether printing
+       succeeded or not.
+
+       Don't hide pointer in typedef; const correctness
+       The type for the Augeas handle is now called 'augeas' insteda of
+       'augeas_t', and is a struct, not a pointer to a struct.
+
+       Mark the places where the passed-in struct augeas is readonly in the API.
+
+       Patch provided by Jim Meyering
+
+       Change names of macros used to guard against double-inclusion
+       Change the names from __NAME_H to NAME_H_ since __* macros are reserved.
+
+       Suggested by Jim Meyering.
+
+       Add "2008" to the copyright in the headers
+
+2008-04-19  David Lutterkort  <dlutter@redhat.com>
+
+       Remove dependency on glib and use kazlib's hash table instead
+       The dependency on glib was only there for the hash tables used by
+       libfa. Rather than requiring all of glib just for that, use the hash table
+       implementation in hash.[ch] taken from kazlib.
+
+2008-04-18  David Lutterkort  <dlutter@redhat.com>
+
+       Hashtable from Kazlib 1.20
+       Available from http://users.footprints.net/~kaz/kazlib.html
+
+       Abort if failing assertions are not used
+
+2008-04-19  David Lutterkort  <dlutter@redhat.com>
+
+       Remove pathsplit symbol
+
+2008-04-16  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.0.8 for changeset cb00aa18e518
+
+       Release 0.0.8
+
+       Remove unused function
+
+       Install lens tests in lenses/tests/ not lenses/
+
+       Use the right path expression to print the whole tree
+
+       Don't segfault when a test fails without producing any tree
+
+2008-04-15  David Lutterkort  <dlutter@redhat.com>
+
+       Call the node for a boot entry 'title'
+
+2008-04-14  David Lutterkort  <dlutter@redhat.com>
+
+       Remove the use in sequences in some places
+       Where indentation isn't important, we can flatten and simplify the tree by
+       not using seqs. Instead of something like aliases/1, aliases/2, ... we now
+       have alias[1], alias[2] etc.
+
+       Start sequences at 1, in symmetry with the element[N] counting
+
+       Consolidate tree allocation into one make_tree function
+
+       Change the ins syntax to support insert before/after
+       This reflects the change to the aug_insert API
+
+       Handle searching for the last() element properly
+       path_first didn't find anything when looking for 'element[last()]'
+
+       Process grub.conf
+
+       Don't delete too many siblings
+       When a path specified a node that had siblings with the same name, tree_rm
+       was deleting that node and all the siblings after it (because the name
+       label[3] would ssuccessively refer to its later siblings as label[3] was
+       deleted)
+
+       Now, first generate a list of nodes to delete before removing anything.
+
+       Fix put test - it was checking for hte wrong result
+
+       Running a failing test fails loading the whole module
+
+2008-04-11  David Lutterkort  <dlutter@redhat.com>
+
+       Add path expressions allowing XPath-like path matching
+       Path expressions passed in through the public API can now contain indices
+       to denote a specific sibling (including [last()]) amongst siblings with
+       multiple labels, and use '*' to match nodes with any label.
+
+       Syntax and semantics follow XPath.
+
+       Run all tests - don't abort after the first failure
+
+2008-04-10  David Lutterkort  <dlutter@redhat.com>
+
+       Escape values and enclose them in quotes when printing
+
+       Typecheck only on the first test
+       It's enough to pass -c to augtool on the first test we run; doing it again
+       in later tests is completely redundant and just slows the test run down.
+
+2008-04-09  David Lutterkort  <dlutter@redhat.com>
+
+       Complain if a transform is built from a lens orphaning a key/value
+       Such a transform would lose information when applied and can't be
+       valid. Ideally, this check would be in the typechecker, but requires
+       dependant types, too much of a complication right now.
+
+       Clean up some confusion around the semantics of store
+       Store does not create a tree; instead it puts a value in place where the
+       enclosing subtree will find it.
+
+       During lens building, there is now a check to make sure the key and value
+       are set in at most one place in each subtree. Ideally, this check would
+       happen in the typechecker, but it would require that we parametrize the
+       lens type, considerably complicating matters.
+
+       When get encounters an error during a test, include hte tree in the exn
+       lns_get now returns a tree even if the full input was not consumed. To
+       check whether get succeeded, the ERR parameter needs to be checked.
+
+       Update README
+
+       Remove 'spec' files and tests that don't make sense any longer
+
+       Fail test scripts on _any_ unexpected error
+
+       Distribute lens tests
+
+       Suppress .rpmnew/save files
+
+       Obey AUG_TYPE_CHECK flag
+       Do not do the expensive lens type checks if AUG_TYPE_CHECK is not set. Run
+       augtool with -c in tests to ensure tests do type checks.
+
+       Update augtool round-trip tests and add them to 'make check'
+       Update the tests to the new layout of the tree.
+
+       augtest allows marking tests to skip (by putting 'skip=true' into the
+       test) and sets the exit status properly so that 'make check' will fail if
+       one of the augtool tests fails
+
+       Fix underallocation
+
+       Only attempt to save if there are dirty files
+
+       Reread the original file from the same root on save
+
+       Pass the children of the right tree
+
+       Fix some errors that made aug_save fail
+
+       Mark a freshly loaded tree as clean
+
+       Check the return value of asprintf
+       Handling of asprintf failures (and allocation failures in general) needs a
+       lot more work.
+
+       Small touchup - needs much more work
+
+       Fix segfault if a qualified name references the module it is in
+       Now explicitly referencing the enclosing module works properly: if the name
+       is already defined locally, everything works, and if it is not, an error is
+       produced.
+
+2008-04-08  David Lutterkort  <dlutter@redhat.com>
+
+       Typecheck the atype of concat and iter
+
+       Typecheck the atype of union
+
+       Change the typecheck on union
+       Typecheck unions l1|l2 less strictly (and less annoyingly) by requiring
+       that l2 has a chance of ever being used, and not the stricter criterion of
+       disjoint ctypes for l1 and l2
+
+       Port of the lenses for inittab and sshd_config tothe new syntax
+
+       Curb the repeated printing of exceptions
+
+       Clearer error message
+
+       Processing of pam.d
+
+       Pull some useful space deleters into Util
+
+       Check that let expressions work
+
+       Fix problem in concating filters
+       The check whether we fully own a filter in compile_concat, and therefore
+       can modify it destructively, was wrong. Besides holding the only reference
+       to the filter, we also need to be holding the only reference to the value
+       wrapping the filter.
+
+       Mark hosts and aliases for autoloading
+
+       Load from the new ../lenses dir
+
+       Obey setting of an explicit root directory
+
+       Don't segfault when there is no filter arg for a match
+       Before, running "augtool match '/augeas/files/*/error'" would result in a
+       segfault. Now it prints all matching entries, regardless of their value.
+
+       Handle continuation lines; more thorough tests
+
+       Check that labels and keys do not contain a '/'
+       We rely on that fact in various places when handling paths; '/' is the
+       separator of path components and can never appear in a path component.
+
+       Print a newline on EOF
+
+       Autoloading of files for augtool
+       Autoload is indicated by putting a 'autoload ...' statement as the first
+       expression in a module. Currently, there can only be one autoload; the
+       identifier mentioned in the autoload must be defined in the enclosing
+       module.
+
+2008-04-07  David Lutterkort  <dlutter@redhat.com>
+
+       Builtins for filters and transforms
+       Three simple builtins to construct transforms:
+
+       - incl : string -> filter includes all files matching a glob
+       - excl : string -> filter -> filter excludes all files matching a glob
+       - transform: lens -> filter -> transform
+
+2008-04-08  David Lutterkort  <dlutter@redhat.com>
+
+       Implement free_lens
+
+2008-04-07  David Lutterkort  <dlutter@redhat.com>
+
+       A lens for yum
+
+       Fix bad free
+
+       Add Util.split
+
+       Local let expressions
+       Add syntax for
+         let a =
+           let b = exp in
+             exp
+
+       Plug two more memory leaks
+       - require_exp_type is sometimes called with a term that already has
+         a type. Don't typecheck such terms again
+       - compile_compose should not run the full typechecker on the closure it is
+         building, since parts of it have been typechecked already. Instead,
+         manually create types for the new terms. Also, don't evaluate the
+         subexpressions since their values are not used at all
+
+       Add a 'gensym' builtin
+
+       More ref ocunting fixes
+       - aug_close now releases the list of modules
+       - compile_bracket cleans up the arg
+       - augparse closes the augeas connection, mostly so that we can see leaks
+         in valgrind better
+
+2008-04-04  David Lutterkort  <dlutter@redhat.com>
+
+       Fix major brainfart in ref counting lists
+       The way lists were reference counted (and particularly unref'd) was just
+       plain stupid wrong. A list 'next' pointer is no different from any other
+       pointer when it comes to ref counting.
+
+       Initialize *err properly, even if there is no tree
+
+       Fix bug with nested subtrees
+       There was no clear indication if a subtree was a leaf (and should therefore
+       not grow any tree returned by its child) or was an interior subtree (so
+       that any returned tree needs to become a child of a new tree)
+
+       Kludge around an inconsistency with print_tree
+
+       Beginnings of tests for the interpreter
+
+       Exceptions during compilation countas failure
+
+       Fix how the key regexp for unions is calculated
+       Union would produce spurious empty keys, for example in the expression
+         [ key /a/ . ([ l1 ] | [ l2 ]) ]
+       the union would get an atype of '//' which is wrong, since the subtree []
+       does not contribute to an atype.
+
+       Start a util module with some common functions
+
+       Run lens tests during 'make check'
+
+       Fix bug introduced in 292:5123e63e004b
+       Don't compare with the whole path if there is a parent, only the last
+       component of that path.
+
+       Handle trailing slashes on loadpath components cleanly
+
+       /etc/aliases processing in the new syntax with tests
+
+       Allow rm from toplevel of tree
+       The only issue with this is that the dirty flag can not be set properly
+       when deleting from the toplevel of the tree since the flag has to be set on
+       the parent, which we don't have.
+
+       This is really only an issue if (a) we delete the whole tree (b) the next
+       sibling of the node we delete is semantically different from the deleted
+       node (e.g. because it goes into a different file)
+
+       Either way, this only happens during tests; in the 'real' tree, toplevel
+       nodes are fixed, like /files and /augeas, and we don't really have an issue
+       there.
+
+       Small tweaks
+
+       Produce exn when tree_rm/tree_set fail
+
+       Update yylloc for string/regexp constants
+
+2008-04-03  David Lutterkort  <dlutter@redhat.com>
+
+       When compile_exp produces an exn, bind it anyway
+       This avoids lots of trouble with NULL values
+
+       Desugar (lens)+
+       The construct (lens)+ is now processed as lens . lens*
+
+       Fix segv on repetition of regexps
+
+       Clearer error messages from typechecking lenses
+
+       Fix key regexp for union; throw exception on subtrees with multiple keys
+
+       Have lens constructors return exns on failure
+       Also refactor exception generation.
+
+       Add a test that produces an exception
+
+       Allow '*' as a test result indicating an expected exception
+
+       Error propagation from lns_put
+       Record a lns_error if things don't work out during put. Generate an
+       exception on error.
+
+       A very first lens in the new syntax, with tests
+
+       Use the default string for a del lens, really.
+
+       Module names must be consistent with the name of the file they are in
+       The basename of the file must be the name of the module, lowercased and
+       with ".aug" appended
+
+       Add explicit loadpath
+       augtool and augparse now take an explicit loadpath with the -I option,
+       which can be repeated multiple times.
+
+       aug_init takes a loadpath as a new argument
+
+       Load needed modules
+       When the module for a qualified identifier Mod.name is not loaded yet,
+       automatically load it by looking for a file mod.aug on the module load
+       path.
+
+       Rename struct env to struct module
+
+       Separate function composition from concatenation
+       Function composition is now written as 'f ; g' instead of 'f . g'
+
+       Allow tree constants with NULL labels
+
+       Clean up printing of empty trees
+
+       Clarify the reference counting terminology
+
+       Free the skel that lns_put creates initially
+
+       Make sure free_dict frees the whole dict
+
+       Fix reference problem
+       The wrong type was being unref'd
+
+2008-04-02  David Lutterkort  <dlutter@redhat.com>
+
+       Free the whole dictionary
+       While entries are looked up, dict->entry changes; dict->mark is the head of
+       the list of all entries that were ever in the dict.
+
+       Clear skel and dict in state so assertions in create_ don't trip
+
+       Always split the full tree
+       There's no need to support splitting a partial tree for now. This means
+       that lns_put will put TREE and all its siblings.
+
+       Fix incorrect usage of size parameter for re_match
+
+       Add missing break in get/parse_union
+       Without it, it acts like a concat that drops trees on the floor
+
+       Allow printing of hidden tree nodes
+       When printing test results, we want to see the full tree
+
+       Pass lns_error to parse; free dicts and skels
+
+       Report errors from get as exceptions
+       Adds a value kind 'EXN'. When the interpreter gets such a value, it bails
+       out immediately.
+
+       lns_get now reports parse errors in an lns_error struct, which is turned
+       into an exception in the interpreter.
+
+       Added tag ml-syntax-start for changeset fcd6c04a1eed
+
+       A subtree without a key matches "/"
+
+       Print \n after test result
+
+       Allocate enough bytes for string in unescape
+
+       Free regexps cleanly
+
+       Fill in subtree->atype with empty regexp
+
+2008-04-01  David Lutterkort  <dlutter@redhat.com>
+
+       Interpreter for the new file description syntax
+       This is by no means done, but done enough to allow incremental fixes from
+       now on. This checkin still contains lots of FIXME's and bugs. Very simple
+       unit tests do work though.
+
+       The syntax for describing files is now a very simple OCaml-like functional
+       language; the file syntax.c implements an interpreter for that language.
+
+2008-03-25  David Lutterkort  <dlutter@redhat.com>
+
+       Revamp the language
+
+2008-03-14  David Lutterkort  <dlutter@redhat.com>
+
+       Remove comment about fa_overlap/fa_ambig_example
+       I don't really have the data to support preferring one over the other that.
+
+       Rename parse_* functions to get_*
+
+       Rename parser.c to get.c
+
+       Add bcprules (by Benjamin Pierce); needed by lenses.tex
+
+       Added tag release-0.0.7 for changeset 93563112907c
+
+       Release 0.0.7
+
+       Expose typechecking in augtool
+       Run 'augtool -c' to get typechecking. Very useful during
+       development. (Though augparse is even more useful when writing new lenses)
+
+       Be a little more restrictive on when to dump the whole grammar
+
+       Fix lenses so that they pass type checking.
+       There were several subtle amibuities in the lenses previously, which the
+       typechecker nicely discovers now.
+
+       When splitting the tree, check that we are atthe right subtree
+       Without the check, spliting at a subtree just gobbles up trees without any
+       regard for what that tree is. This becmoes a problem in a sequence like
+         [ COMMENT ] * . [ key FOO . store BAR ] *
+       when there is no comment, and therefore no subtree witha NULL label. A tree
+       with a single node matching FOO is wrongly split as if there was a COMMENT
+       (which, if it were there would have to have a NULL label)
+
+2008-03-13  David Lutterkort  <dlutter@redhat.com>
+
+       Defer allocating storage for a state_set as long as possible
+
+       Rename constants state_set_* to array_*
+       We use state_set_initial_size and state_set_max_stride for both state_set
+       and transitions arrays. Rename them to array_initial_size and
+       array_max_expansion
+
+       Speed up FA_MINUS by checking for some simple cases with fixed results
+
+       Speed up fa_contains by not determinizing FA1
+
+       Speed up intersection
+       (1) Do not determinize before intersecting
+       (2) Check if one of the automata is the empty language, and return the
+           empty language if so
+
+       Store transitions in an array
+       Brings about a 10% performance gain since we don't allocate each transition
+       individually, and since traversing and accessing transitions is a wee bit
+       faster.
+
+       Remove unused macro
+
+       Clean up fa_iter some
+       Now both cases (max == -1 for unbounded iteration) and max >=0 use the same
+       code to generate the automaton (fa){min}
+
+       Compute union and concat in place internally
+       Reduces the number of times we clone an fa for internal purposes, and
+       therefore the memory management overhead.
+
+       Rejigger the weights assigned by chr_score to make fa_example more predictable
+
+       Minor optimization for fa_example
+
+       Keep the list of states for clone in a sorted set
+       This speeds up things enormously (for cmfm.aug, augparse goes from 17s to 6s)
+
+       Store that pairs of states for intersection in a hash table
+
+       Sorted state sets
+       When order of states in a set doesn't matter, allow the set to be kept
+       sorted so that search can use binary search.
+
+2008-03-12  David Lutterkort  <dlutter@redhat.com>
+
+       Fix two memory leaks
+
+       Remove the last uses of FA_MAP
+       Use STATE_SET instead, since it's faster and lighterweight
+
+       Rename structs fa_state and fa_trans to state and trans
+
+       [mq]: min_hopcroft.patch
+
+       Sort transitions before generating examples
+       Otherwise, examples depend on the order in which transitions appear for
+       each state.
+
+       Add state sets at head of state_set_list
+
+       Use state_set in fa_clone
+       To speed up fa_clone, keep the correspondence between old and new states in
+       a state_set to reduce allocation overhead.
+
+       Reverse transitions in place in fa_reverse
+
+       Improve the performance of fa_intersect with better data structures
+       Store the map of (s1, s2) -> s for intersection in nested state sets
+       instead of a linked list.
+
+       Faster data structures for sets of states and a list of sets of states
+       Store the list of sets of states for determinize in a hash table. Since I
+       don't feel like implementing my own, pull in glib and use GHashTable.
+
+       Store sets of states in an array rather than in a linked list. This greatly
+       reducs the overhead from memory allocations, since the array is expanded by
+       doubling its size (up to some threshold)
+
+2008-03-11  David Lutterkort  <dlutter@redhat.com>
+
+       fa_star added a spurious epstrans loop on new initial
+
+       Mark live and reachable states
+       Performance improvement. Instead of allocating temporary lists for live and
+       reachable states, use one bit each in the state to mark them for that
+       purpose.
+
+       Add typechecking of lenses
+       Concatenation and iteration of lenses is now checked for ambiguity. Union
+       is checked for disjointness, but that is only flagged as a warning, since
+       it's mostly a harmless problem, and fixing it requires writing nasty
+       regexps in the spec files.
+
+       Fix existing specs to pass typeckecking. Typechecking is extremely slow
+       right now, some of that will be addressed shortly. For now, augtool does
+       not do typechecking, but augparse does by default.
+
+2008-03-10  David Lutterkort  <dlutter@redhat.com>
+
+       Fix subtle bug in determinize
+       Fix a bug that would only hit if '\0' is ever in points.
+
+2008-03-06  David Lutterkort  <dlutter@redhat.com>
+
+       Add fa_ambig_example to generate ambiguous words
+       Generate an ambiguous string upv given two languages and directions on how
+       to split that string into u.pv and up.v. Algorithm from Anders Moeller from
+       the dk.brics.grammar package.
+
+       Fix example generation, it was completely broken
+       The previous algorithm was way too simplistic, and failed on more
+       complicated languages.
+
+       fa_example now generates a relatively short word, subject to certain
+       preferences, so that for example, alnum characters are preferred over
+       printable ones, and those over nonprintable ones.
+
+       Fix some cornercases in fa_example
+
+2008-03-05  David Lutterkort  <dlutter@redhat.com>
+
+       Add generators and tests for some basic languages
+       Basic languages are the empty language, the language containing only the
+       empty word, and the total language \Sigma^*
+
+       Fix tyops
+
+       Added tag release-0.0.6 for changeset 9a4f846673ac
+
+       Released version 0.0.6
+
+       Allow influencing the behavior of save
+       By passing one of the flags AUG_SAVE_BACKUP or AUG_SAVE_NEWFILE to
+       aug_init, it is possible to influence the behavior of aug_save to either
+       overwrite files in palce, save originals with extension .augsave, or put
+       changes into files with extension .augnew.
+
+       Also added switches to augtool to set this from the command line, and to
+       set the filesystem root.
+
+       Added tag release-0.0.5 for changeset 0efe2a620e39
+
+       Mark print_re as unused
+
+       Release 0.0.5
+
+       Make aug_close public
+
+       Public API change: include a reference to an augeas_t in all calls
+       To make Augeas threadsafe, we need to move away from keeping stuff in
+       global variables.
+
+2008-03-04  David Lutterkort  <dlutter@redhat.com>
+
+       Add fa_example which produces an example string from a regular language
+
+       Add a test that performs Anders Moeller's ambiguity algorithm manually
+
+       Two bug fixes
+       (1) fa_make_char_set would never create transitions with min == max
+       (2) fa_intersect got things wrong when t2 had an interval that overlapped
+           several intervals on t1
+
+       Also added tests to check these two problems.
+
+       Fix handling of negated charsets
+       Negated charsets where handled entirely wrong. A character set is now
+       represented as a map from char -> {0, 1}. That map is rather big (one byte
+       per character)
+
+       Fix order in which libraries are installed
+       libaugeas must be installed after libfa, since it depends on it.
+
+       Remove old sketch of interface; not needed anymore
+
+       Compute the complement, set difference and overlap of two languages
+
+       Fix a bug in how '.' is being handled
+       The '.' was treated the same as [\n] instead of [^\n] by mistake.
+
+       Also fixes a small bug in fa_contains.
+
+       Add deciding unambiguously iterable based on ua concatenable
+
+2008-03-03  David Lutterkort  <dlutter@redhat.com>
+
+       Automatically free all automata allocated during a test
+
+       Cleanup the returned FA in fa_intersect
+
+       Add a target to run fatest through valgrind
+
+       Add fa_intersect: intersection of regular languages
+
+       Comment the uses of FA_MAP better and rename some internal helper functions
+
+       Clean up management of state lists
+       Centralise allocating new states for a fa in add_state; that makes sure
+       that all states appear on the list of states in fa->initial.
+
+       Do not rely on gcc >= 4.0 for restricting symbol exports
+       Use a linker script instead. The visibility pragma is only available in gcc
+       >= 4.0, and thus imposes a pretty high burden to build Augeas.
+
+2008-02-29  David Lutterkort  <dlutter@redhat.com>
+
+       Reign in the number of symbols exported from libaugeas
+       Use visibility=hidden to keep most local symbols to ourselves. Still needs
+       some work for augparse/augtool
+
+       Performance improvements
+       (1) Don't minimize the automaton quite so often. Now, only fa_compile minimizes
+           by default.
+       (2) Instead of full-on minimization, clean up the automaton before
+           returning to the user by removing dead transitions/states.
+
+       Remove gratuitous list traversals
+       Replace list_append with list_cons (adds at the head of a list) where order
+       of the list does not matter.
+
+       Add tests for language subsets and equality
+
+       The beginnings of a finite automata library
+       The code is heavily based on the Java package dk.brics.automaton by Anders
+       Moeller (http://www.brics.dk/automaton/)
+
+       Eventually, this should becomea standalone library, seeing how there does
+       not seem to be any open-source, maintained finite automata library.
+
+       Some unit testing help
+       This is an adapted version of CuTest
+       (http://sourceforge.net/projects/cutest/) written by Asim Jalis
+
+       Minimal docs for aug_save and aug_print
+
+2008-02-26  David Lutterkort  <dlutter@redhat.com>
+
+       Ignore more stuff
+
+       Fix segfault in aug_ls
+       When skipping nodes with NULL label, don't segfault if the whole tail of
+       the list has NULL labels
+
+2008-02-25  David Lutterkort  <dlutter@redhat.com>
+
+       Added tag release-0.0.4 for changeset d8e750d82f97
+
+       Version 0.0.4
+
+       Some NEWS
+
+       Package as RPM
+
+       Turn off warnings-as-errors when building spec-lex.l
+       We need -Wno-error, otherwise the CFLAGS passed during mock builds turn
+       checking for unused parameters back on; flex doesn't provide an easy way to
+       generate code that passes those checks (that's the reason for building the
+       liblexer.la convenience lib)
+
+       Only define print_dict when it is used
+
+       Added tag release-0.0.3 for changeset 56cb08f222a3
+
+       Version 0.0.3
+
+       Test for readline in a way that works on RHEL5
+
+       Some build/install tweaks
+       (1) Rename spec in $(datadir)/augeas/spec to lenses
+       (2) Add pkgconfig info for libaugeas
+       (3) Install augeas.h as a header
+
+       Rename AUGEAS_SPECLIB to AUGEAS_LENS_LIB
+
+       Added tag release-0.0.2 for changeset f981ccccb0ab
+
+       Include the try script in the distribution
+
+       Bump version to 0.0.2
+
+       Fix things up so that 'make distcheck' works
+       (1) make test runs work when when top_builddir != top_srcdir
+       (2) Include spec/ files in distribution
+       (3) disable test-grammars.sh since the test grammars are busted right now
+
+       Fix warnings about uninitialized variables
+
+       Add config.h to libaugeas.la
+
+       Stricter types for some combinators. List needed reg lang operations
+
+2008-02-21  David Lutterkort  <dlutter@redhat.com>
+
+       Some changes to the yum description
+       (1) Use a yum.conf that is actually shipping
+       (2) Make COMMENT match blank lines
+       (3) Fix tests to work with updated yum.conf
+
+       Only create /tmp/augcmds.txt if it doesn't exist
+       Nothing deep; just trying to keep Mercurial from marking the file as
+       modified as I change the commands that try runs
+
+       Make aug_ls return all the children for a given path
+       aug_ls did not handle entries that were split across several nodes
+       properly. Now, we find all the nodes for the given path and list their
+       children.
+
+       Fix splitting of AcceptEnv
+       The list of env vars for AcceptEnv was not being split into individual
+       pieces
+
+2008-02-20  David Lutterkort  <dlutter@redhat.com>
+
+       A (pretty kludgy) description for cmfm.conf
+
+       Make printing of skel/dict optional
+
+       Print test results a tad prettier
+
+       Use GNU regex instead of PCRE
+       Use the GNU regex functions from glibc instead of PCRE, as glibc uses a DFA
+       implementation that does not suffer the limitations of PCRE's backtracking
+       implementation.
+
+       The syntax for regular expressions is now RE_SYNTAX_POSIX_MINIMAL_EXTENDED,
+       essentially extended POSIX regular expressions, except that '.' does not
+       match newlines.
+
+       Clean up regexps for POSIX
+       Various small fixes to regexps to make them work properly as POSIX regexps.
+
+       Added tag remove-any-first-follow for changeset 0d22160e9494
+
+       Remove any matches ... and ..? from the language. Remove first/follow sets
+       They currently require lookahead assertions from the underlying regexp
+       engine.
+
+       Since any matches were the only reason to compute first/follow sets, remove
+       those, too.
+
+       Remove the use of the any operators '...' and '..?'
+       These operators inherently require lookahead assertions, but we need to
+       switch to a regexp engine that does not support them.
+
+       Don't segfault when parsing fails
+
+2008-02-19  David Lutterkort  <dlutter@redhat.com>
+
+       Drop CF-oriented check for ambiguity through looking at first sets
+
+       Allow escaping of a slash in tegular expressions
+
+2008-02-18  David Lutterkort  <dlutter@redhat.com>
+
+       Base parsing completely off regexp matching.
+       Parsing now uses regexp matching, and not the CFG-style parsing based on
+       first sets previously used. This actually makes it easier to write specs,
+       since parsing decisions are made based on the complete string, not just the
+       first 'token'.
+
+       The downside is that rules can not be recursive anymore, as that would
+       make the matched language non-regular.
+
+       The main motivator for this change is that it makes it possible to do
+       stricter checking of the input spec using type checking similar to
+       boomerang's string lenses based on operations on regular languages.
+
+       Unfortunately, we have to keep first/follow computations to construct the
+       fairly tricky regexps that are used for ANY patterns.
+
+       Remove unused token T_FIELD
+
+       Rename match.xaction to match.action
+       The field was named initially to avoid a clash with another 'action' field,
+       but that field is gone now.
+
+       Add Match blocks
+
+       Remove leading whitespace inside Match directives
+
+       Fix nested splits
+       For a lens like a . (b . c)*, tree_split used to return a split that looked
+       like [a; b; c; b; c] That is wrong: when we split on the outer '.', we need
+       to produce a split with exactly two entries: [a; b] (where b stands as the
+       first entry in the tree that '*' will act on.
+
+       split_tree_car cleans up recursively computed splits in this manner; those
+       subsplits are mostly computed for their sideeffect, particularly for the
+       fact that they change state->tree.
+
+       Properly print split nodes
+
+       Lenses for sshd_config
+       This is interesting because of the treatment of AcceptEnv and similar
+       constructs
+
+       For split nodes, append entries at the last occurence
+       It is possible that one logical node is split across several physical
+       nodes to accomodate settings that are spread across several lines like
+       'AcceptEnv' for sshd_config. Such lines lead to multiple nodes
+       /system/config/sshd/AcceptEnv (all siblings of each other)
+
+       When a call to aug_set creates a new entry underneath such a split node,
+       make sure that that the new node is put under the last such node. This
+       helps maintain the illusion for users that the split node is really just
+       one node.
+
+2008-02-15  David Lutterkort  <dlutter@redhat.com>
+
+       Report some information underneath /augeas
+       The root directory and information about how files were loaded into the
+       tree are kept in the /augeas hierarchy now
+
+       Fix very bad use of realloc
+
+       Adjust expected diff
+       Do not allow comments to disappear
+
+       Fix test
+       The old diff was bogus (it expected a comment to be removed that has to
+       stay there)
+
+       Cleanly handle comments
+
+       Default COLON to ':' plus tab. Simple tests for aliases
+
+       Informal survey of files in /etc
+
+       Ignore intermediate Latex files
+
+       Store comments in subtrees so they are restored properly
+
+       Turn into a test on a legal tree and make it pass
+
+       Fix split of QUANT_MAYBE. Add create_quant_maybe
+
+       Make aliases work
+
+       Free the results of split_tree
+
+       Properly split an empty * as an empty list
+
+       Try to make putting QUANT_MAYBE work
+       This is still kinda suspect
+
+       parse_subtree must always generates a tree
+       We have to have a subtree, no matter what, even if it is completely
+       empty. If the subtree doesn't contain any key and store instructions, we
+       still need to have a tree [ NULL -> NULL ]
+
+       Modified yum spec that seems to work
+
+       Script to ease testing of augtool
+
+       Enable parsing of pam
+
+       Remove bogus reset of 'record' counter
+
+       Fix print problem
+       Print did not generate paths right; it would print children of a node with
+       a path that did not contain the label of that node.
+
+       Add clear command
+
+       Properly handle a NULL value in aug_set. Make aug_insert deal with NULL labels.
+
+2008-02-14  David Lutterkort  <dlutter@redhat.com>
+
+       Fixed, nicely working tests
+
+       Readline completion
+       Complete command names and tree paths.
+
+       Also cleans up the path entered by the user so that it doesn't have
+       trailing spaces or '/'. Cleaning should probably be done by the public
+       API.
+
+       Major rework
+       Code still unbelievably buggy and segfaults in lots of places, but it is
+       fairly clean and works for choice examples.
+
+       The reworked code is based fairly closely of boomerang and
+       lenses. doc/lenses.tex describes some of the background.
+
+2008-02-13  David Lutterkort  <dlutter@redhat.com>
+
+       Cleaner syntax
+       The spec language now contains instructions on how to build the tree inline
+       with the grammar.
+
+       This change is majorly broken.
+
+2008-02-12  David Lutterkort  <dlutter@redhat.com>
+
+       Better description of lenses
+
+       Different representation of the tree
+       The tree is now represented as a tree data structure, where each node in
+       the tree stores only a path component (label).
+
+2008-02-08  David Lutterkort  <dlutter@redhat.com>
+
+       Beginnings of a formal writeup
+
+2008-01-30  David Lutterkort  <dlutter@redhat.com>
+
+       Remove field references as a match
+       It used to be possible to have a rule like
+         rule: RE '=' $1
+       with the meaning that $1 would match the same thing as RE. That hasn't been
+       used yet; unclear if it ever will.
+
+       When deleting, only mark AST changed when leaf was deleted
+       This is really a kludge to work around the fact that we might construct
+       incomplete AST's.
+
+       Slightly mroe helpful error message during parsing
+
+       Don't segfault when the parse matches nothing
+
+2008-01-29  David Lutterkort  <dlutter@redhat.com>
+
+       Another yum test
+
+       Remove more unneeded cruft
+
+       Remove unneeded safe_free, TRUE and FALSE
+
+       Remove unneeded ROOT_DIR and update augtool help
+
+       Remove dead code and misleading comment
+
+       Remove files not needed any longer
+
+       Update NEWS
+
+       Run all the augtest tests by default and from make check
+
+       Test key/value parsing with yum
+       The test file also nicely illustrates some shortcomings of the way comments
+       are associated with tree entries. There's not enough flexibility to let the
+       user cleanly indicate what a comment goes with (e.g., an entire section,
+       the next key/value pair etc.)
+
+       Initialize fields used as path components
+       When a field is used in a path component, initialize its value from the
+       path. Since it is not possible to change an existing path, this operation
+       is only needed when new parts of the AST are created.
+
+       The code assumes that the leaf for the path component is in the subtree
+       where the leaf's value is used. That is not necessarily true; at least,
+       it's not being checked from the grammar.
+
+       Test that reordering of subtrees works
+
+       Set the root of the tree from include
+
+       Respect ordering of nodes in the config tree.
+       Previously, reordering of branches in the config tree did not lead to a
+       corresponding reordering of elements in the file. Branches in the AST are
+       now reordered in such a way that their ordering reflects the ordering in
+       the config tree.
+
+       Iterator nodes with a $seq action need to be treated special: they do not
+       change the path for the current (iterator) node, only for the child nodes.
+       That is terribly ugly.
+
+       Fix bug in creating sequence subtrees
+
+       Distribute enters so we have one per match
+       Simultaneous traversal of the AST and the config tree is much simpler if
+       any match will only go at most one level deeper. That guarantees that
+       entering a child in the config tree corresponds to entering an AST node
+       (possibly followed by entering some more AST nodes labelled with the same
+       path)
+
+       To this end, split actions with multiple enters into fake SEQUENCE matches
+       (followed by the match that held the initial action). The fake SEQUENCE
+       matches all have exactly one child in their matches field, and one of the
+       enter instructions from the action for them.
+
+       Actions are also lifted up in the grammar as far as possible; in
+       particular, this pulls constants (but not $seq) out of iterators. This
+       ensures that the children of an AST node differ in exactly one path
+       component.
+
+       Push stores to the matches they store in the tree
+       In an assignment, the value being stored can only be a field
+       reference. Push the corresponding action for the store to that field. This
+       simplifies both getting and putting the tree.
+
+       As a byproduct, a number of questionable constructs are spotted and
+       rejected:
+         (1) Assignments that move the value out of the current tree
+         (2) Storing the same value in more than one place in the tree (which
+             would make it possible to change one copy, but not both)
+         (3) Useless enter instructions; they don't cause harm but probably
+             indicate some other problem in the grammar. They are only spotted
+             if they get in the way of a store, but should probably be checked for
+             the whole grammar
+
+       Produce dot files for the grammar
+
+       Various changes to the tests to make them (almost) work
+       (1) Adjust to the fact that the root dir is now a variable
+       (2) Mark tests as failing if augtool exits with an error exit status
+       (3) Use numbers matching [0-9]+ where the grammar uses $seq, otherwise
+           augtool will (rightly) report an impossible path
+
+       Some of the tests are still failing.
+
+       aug_ls: Fix bad parent comparison
+       Before /foo/1000 was listed as a child of /foo/1
+
+       Docs
+
+2008-01-24  David Lutterkort  <dlutter@redhat.com>
+
+       Rough thoughts about emit
+
+2008-01-21  David Lutterkort  <dlutter@redhat.com>
+
+       For quantified groups, count the quantifier as the group
+       Previously, for a match like '(A)*' A was counted as a group, which meant
+       that if an action was attached to the group, all the children of the '*'
+       node in the AST had the same path. By counting the '*' as the group, not
+       'A', the children will have different name if different subtrees are
+       produced in the group.
+
+       This ensures that in the AST, the children of '*' and '+' have different
+       names and simplifies the 'put' direction of the transformation
+       considerably.
+
+       Some config settings - most of them need to be exposed through configure.ac
+
+2008-01-18  David Lutterkort  <dlutter@redhat.com>
+
+       Global filename does not exist. Use basename
+
+       Only increment $seq when it has been used
+       With this change, $seq goes structly sequential in the generated tree
+       nodes. Before, things like comments that don't lead to changes in the tree
+       increased the counter, too.
+
+       Spec files needed by the tests
+
+       Don't segfault in ast_dot on NULL ast
+
+       Only save files with actual changes
+       Split emitting into two parts: updating the AST from the config tree and
+       actually writing the AST to file. do_insertion and do_deletion now report
+       if they made any changes to the tree so that the provider can decide
+       whether to save the file or not.
+
+       As a byproduct, parts of the AST that are no longer needed are actually
+       freed.
+
+       Handle null values/tokens when storing
+
+       Detect association of values with impossible paths
+
+2008-01-17  David Lutterkort  <dlutter@redhat.com>
+
+       Make augtest set AUGEAS_ROOT and AUGEAS_SPECLIB before running augtool.
+       augtest now copies test files into a separate subdirectory and points
+       augtool to that as its root. It also points augtool to ../spec for the spec
+       files.
+
+       Add the spec provider.
+       The provider should have been committed in 57:9e439a136787, but
+       wasn't. Unfortunately, versions of prov_spec.c that would compile with that
+       version have been lost. Therefore, builds between 57:9e439a136787 and this
+       revision will fail.
+
+       Emit a the current tree into a file
+       Based on the AST, generate the file that lead to that AST. Changes to the
+       config tree are mirrored by corresponding changes in the AST before it is
+       written to disk.
+
+       This is a first version that works for some restricted set of grammars, but
+       needs a lot more testing.
+
+       Compute tree handles for each match
+       The handle of a match is a set of regular expressions that indicate which
+       subtrees are generated by that match. Handles are computed based on the
+       actions in the grammar and propagated.
+
+       The handle of an action is a regular expression matching the path generated
+       by that action.
+
+       Build an explicit AST
+       Instead of representing the parsed file by a simple list of tokens, build a
+       fullblown AST for that file. The AST is actually not very abstract, and is
+       directly the parse tree from parsing a file with a certain grammar.
+
+       Split parsing and evaluating into to passes; references to fields
+       are too hard to resolve with a partially constructed AST.
+
+       Also adds a routine (ast_dot) to output the AST as a dot file; this eases
+       debugging tremendously. augparse will now produce dot files when given '-P
+       ast'
+
+       Remove aug_token and any mention of it - that has been replaced by struct
+       ast.
+
+       Represent quantifiers in their own match nodes
+       Instead of using a field in struct match for quantifiers '*', '+', '?',
+       represent quantified expressions by their own struct match, with a matches
+       field pointing to the quantified expression.
+
+       This leads to a cleaner parser and makes constructing an explicit AST
+       simpler.
+
+       Prefer comments over kv
+
+       Print first sets for every match
+       Factor printing of a literal_set into print_literal_set and use it for
+       printing both first and follow sets.
+
+       Remove debug printing in augparse about loaded maps
+
+2008-01-07  David Lutterkort  <dlutter@redhat.com>
+
+       Free tokens entirely when freeing file
+
+       Set action in all path components
+
+2008-01-03  David Lutterkort  <dlutter@redhat.com>
+
+       Provider that uses specs
+       The spec provider is hooked into libaugeas and loaded. It reads spec files
+       from /usr/share/augeas/spec and paths mentioned on AUGEAS_SPECLIB. Files
+       are parsed according to the specs loaded, and values are written into the
+       tree after parsing those files.
+
+       Still missing is saving of the tree back to file, and in particular adding
+       new entries in the tree to such files.
+
+       Move hosts and inittab under /etc
+
+       Always set the passed-in grammars and maps to NULL
+       Without that, it's too easy to pass an invalid pointer in from random
+       nonsense on the stack. And since we do not append to anything the user may
+       pass in, setting to NULL is safe.
+
+       Compile regexps for multiline matching
+
+2008-01-02  David Lutterkort  <dlutter@redhat.com>
+
+       Fix syntax error; we want to test that missing defaults are noticed
+
+       Add filemappings to the language
+       The map construct specifies a grammar and a list of glob patterns that this
+       grammar should be applied to.
+
+       Print the filename in errors about tokens (abbrevs)
+
+       Add name to grammars
+
+       Add -v switch for printing errors
+
+       Two more test grammars
+
+       Execute actions (not writing to tree yet)
+       Actions are executed at the right points during the parse, and a stack of
+       paths is maintained. References to values work with the exception of
+       references to rules.
+
+2007-12-21  David Lutterkort  <dlutter@redhat.com>
+
+       Check grammar acceptance/rejection
+
+       More precise syntax for where actions attach in a rule
+       Previously, it was not clear how far into a rule the current path would be
+       modified during parsing. This syntax defines some clear rules for that:
+         - if the rule applies to a parenthesized group (@n), the
+           path is in effect until the end of the group
+         - if the rule applies to a field (@$n), the new path is used during
+           parsing of that field
+         - the assignment part of the action is done after the field/group
+           has been parsed
+
+       Snapshot before changing the syntax of rule actions
+
+2007-12-20  David Lutterkort  <dlutter@redhat.com>
+
+       Remove unused keyword and token 'default'
+
+       Fix field number computation
+
+       Two more rejection tests
+
+       Add a simple test for rejecting bad grammars
+
+       Don't try to dump a NULL grammar
+
+       Introduce SUBMATCH_P macro; cleanup unnecessary switch statements.
+
+       Statically number all matches in a rule. Check for illegal field refs.
+
+       Collect unprocessed tokens in the parser state.
+
+       Print quantifier after rule reference
+
+       Remove unneeded debug print
+
+       Produce tokens during parsing.
+       Also, nicer printing of the tokens read.
+
+       Stricter checking for ambiguous rules
+       Check that all items in alternatives have non-overlapping first sets. Two
+       sets are overlapping if they both contain an entry pointing to the same
+       struct literal or if the contain entries where the literals have the same
+       patterns (as strings)
+
+       This still misses the case where literals have equivalent regular
+       expresions (e.g. /[ab]/ in one and /[ba]/ in the other) but that seems very
+       hard to determine.
+
+       Print first/follow sets prettier, print control characters escaped with ~
+       Literals from first/follow sets are now reduced back to the abbrev they
+       belong to if that exists.
+
+       Add options to control grammar printing
+
+       Set match->owner for _all_ matches
+
+       Two more sample/test grammars
+
+       First step towards a specification for config files
+       Definition of a simple language for describing the syntax of config files
+       and how they are to be mapped to a tree. Lexer/parser for the language and
+       data structures to hold the specification. Parses files defined by the
+       grammar - processing of the parse is missing though.
+
+2007-12-14  David Lutterkort  <dlutter@redhat.com>
+
+       Factor aug_make_file into internal.c
+
+2007-12-01  David Lutterkort  <dlutter@redhat.com>
+
+       Be more verbose about which tests were run
+
+       Do not include unused util.h
+
+       Mention language bindings
+
+       Added tag release-0.0.1 for changeset 69688020bb1b
+
+       Some news
+
+       Disribute tests and doc/examples.txt
+
+       Some pseudo-code examples
+
+       Explain yourself
+
+2007-11-30  David Lutterkort  <dlutter@redhat.com>
+
+       Add a test that shows how to change the initdefault
+
+       Add help texts and a help command
+
+       Add aug_match as a simple query facility
+
+       Handle /etc/inittab
+
+       Make the ROOT_DIR a constant instead of hardcoding it everywhere
+
+       Test deleting everything from /etc/hosts
+
+       Describe what a test description looks like
+
+       Add a provider for /etc/hosts and reorganize how providers are loaded/saved a little
+
+       aug_rec_save: Check input parameters
+
+       Major overhaul of record parsing
+       Use PCRE to split records with regexps, and abstract a major chunk of
+       functionality out so it is independent of parsing pam config files
+
+       Translate changes in the tree into changes in files (change/insert/delete
+       of nodes are translated into changing fields and insert/delete of fields
+       and records/lines)
+
+       Root filesys that tests pass against
+
+       Basic tests for record parsing
+
+2007-11-26  David Lutterkort  <dlutter@redhat.com>
+
+       Trim trailing slashes from paths
+
+       Keep /system and /system/config around at all times
+
+       Access aug_insert from the command line; do better error checking for aug_insert
+
+       Autotools support for building
+
+       Very simplistic key store with a public API in augeas.h
+       The implementation is braindead and slow, but good enough to experiment
+       with the actual difficulty for augeas: parsing and editing different config
+       files
+
+       augtool gives a basic mean to inspect the keystore from the command line
+
+       Ignore some files
diff --git a/HACKING b/HACKING
new file mode 100644 (file)
index 0000000..419d681
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,54 @@
+This file explains some details about developing the Augeas C library.
+
+Check out the sources
+---------------------
+
+The sources are in a git repo (which you presumably found already)
+
+  git clone git://git.fedorahosted.org/git/augeas.git
+
+Building from git
+-----------------
+
+  Besides the usual build tools (gcc, autoconf, automake etc.) you need the
+  following tools and libraries to build Augeas:
+
+    * Bison
+    * Flex
+    * readline-devel
+    * libselinux-devel (optional)
+
+  Augeas uses gnulib, and you need a checkout of gnulib. The build scripts
+  can create a checkout for you behind the scenes - though if you already
+  have a gnulib checkout, you can pass its location to autogen.sh with the
+  --gnulib-srcdir option.
+
+  At its simplest, you build Augeas from git by running the following
+  commands in the toplevel directory of your Augeas checkout:
+
+    ./autogen.sh [--gnulib-srcdir=$GNULIB_CHECKOUT]
+    make && make install
+
+  It is recommended though to turn on a few development features when
+  building; in particular, stricter compiler warnings and some debug
+  logging. You can pass these options either to autogen.sh or to
+  configure. You'd then run autogen like this:
+
+    ./autogen.sh --enable-compile-warnings=error --enable-debug=yes
+
+Running augtool
+---------------
+
+The script ./src/try can be used to run ./src/augtool against a fresh
+filesystem root. It copies the files from tests/root/ to build/try/ and
+starts augtool against that root, using the lenses from lenses/ (and none
+of the ones that might be installed on your system)
+
+The script can be used for the following; OPTS are options that are passed
+to augtool verbatim
+
+  ./src/try OPTS     - run the commands from /tmp/augcmds.txt
+  ./src/try cli OPTS - start an interactive session with augtool
+  ./src/try gdb      - start gdb and set it up for debugging augtool
+  ./src/try valgrind - run the commands from /tmp/augcmds.txt through augtool
+                       under valgrind to check for memory leaks
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..5458714
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..14aa121
--- /dev/null
@@ -0,0 +1,26 @@
+SUBDIRS=gnulib/lib src gnulib/tests tests man doc examples
+
+ACLOCAL_AMFLAGS = -I gnulib/m4
+
+lensdir=$(datadir)/augeas/lenses/dist
+lenstestdir=$(datadir)/augeas/lenses/dist/tests
+
+dist_lens_DATA=$(wildcard lenses/*.aug)
+dist_lenstest_DATA=$(wildcard lenses/tests/*.aug)
+
+EXTRA_DIST=augeas.spec build/aux/move-if-change Makefile.am HACKING
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = augeas.pc
+
+distclean-local:
+       -find $(top_builddir)/build/* -maxdepth 0 -not -name aux | xargs rm -rf
+
+ChangeLog:
+       if test -d $(top_srcdir)/.git; then                             \
+         $(top_srcdir)/build/aux/gitlog-to-changelog > $@;             \
+       fi
+
+dist: ChangeLog
+
+.PHONY: ChangeLog
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..b85cf5b
--- /dev/null
@@ -0,0 +1,1581 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(dist_lens_DATA) \
+       $(dist_lenstest_DATA) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(srcdir)/augeas.pc.in \
+       $(srcdir)/augeas.spec.in $(srcdir)/config.h.in \
+       $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+       build/aux/config.guess build/aux/config.rpath \
+       build/aux/config.sub build/aux/depcomp build/aux/install-sh \
+       build/aux/ltmain.sh build/aux/missing build/aux/ylwrap
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = augeas.pc augeas.spec
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(lensdir)" "$(DESTDIR)$(lenstestdir)" \
+       "$(DESTDIR)$(pkgconfigdir)"
+DATA = $(dist_lens_DATA) $(dist_lenstest_DATA) $(pkgconfig_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir dist dist-all distcheck
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = gnulib/lib src gnulib/tests tests man doc examples
+ACLOCAL_AMFLAGS = -I gnulib/m4
+lensdir = $(datadir)/augeas/lenses/dist
+lenstestdir = $(datadir)/augeas/lenses/dist/tests
+dist_lens_DATA = $(wildcard lenses/*.aug)
+dist_lenstest_DATA = $(wildcard lenses/tests/*.aug)
+EXTRA_DIST = augeas.spec build/aux/move-if-change Makefile.am HACKING
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = augeas.pc
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+augeas.pc: $(top_builddir)/config.status $(srcdir)/augeas.pc.in
+       cd $(top_builddir) && $(SHELL) ./config.status $@
+augeas.spec: $(top_builddir)/config.status $(srcdir)/augeas.spec.in
+       cd $(top_builddir) && $(SHELL) ./config.status $@
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+distclean-libtool:
+       -rm -f libtool config.lt
+install-dist_lensDATA: $(dist_lens_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(lensdir)" || $(MKDIR_P) "$(DESTDIR)$(lensdir)"
+       @list='$(dist_lens_DATA)'; test -n "$(lensdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(lensdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(lensdir)" || exit $$?; \
+       done
+
+uninstall-dist_lensDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(dist_lens_DATA)'; test -n "$(lensdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(lensdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(lensdir)" && rm -f $$files
+install-dist_lenstestDATA: $(dist_lenstest_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(lenstestdir)" || $(MKDIR_P) "$(DESTDIR)$(lenstestdir)"
+       @list='$(dist_lenstest_DATA)'; test -n "$(lenstestdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(lenstestdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(lenstestdir)" || exit $$?; \
+       done
+
+uninstall-dist_lenstestDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(dist_lenstest_DATA)'; test -n "$(lenstestdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(lenstestdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(lenstestdir)" && rm -f $$files
+install-pkgconfigDATA: $(pkgconfig_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
+       @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+       done
+
+uninstall-pkgconfigDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -755 \
+               -exec chmod u+rwx,go+rx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lzma*) \
+         lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(DATA) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+       for dir in "$(DESTDIR)$(lensdir)" "$(DESTDIR)$(lenstestdir)" "$(DESTDIR)$(pkgconfigdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr \
+       distclean-libtool distclean-local distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-dist_lensDATA install-dist_lenstestDATA \
+       install-pkgconfigDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-dist_lensDATA uninstall-dist_lenstestDATA \
+       uninstall-pkgconfigDATA
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+       ctags-recursive install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am am--refresh check check-am clean clean-generic \
+       clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
+       dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
+       distcheck distclean distclean-generic distclean-hdr \
+       distclean-libtool distclean-local distclean-tags \
+       distcleancheck distdir distuninstallcheck dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dist_lensDATA \
+       install-dist_lenstestDATA install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man install-pdf \
+       install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       installdirs-am maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+       ps ps-am tags tags-recursive uninstall uninstall-am \
+       uninstall-dist_lensDATA uninstall-dist_lenstestDATA \
+       uninstall-pkgconfigDATA
+
+
+distclean-local:
+       -find $(top_builddir)/build/* -maxdepth 0 -not -name aux | xargs rm -rf
+
+ChangeLog:
+       if test -d $(top_srcdir)/.git; then                             \
+         $(top_srcdir)/build/aux/gitlog-to-changelog > $@;             \
+       fi
+
+dist: ChangeLog
+
+.PHONY: ChangeLog
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Makefile.inc b/Makefile.inc
new file mode 100644 (file)
index 0000000..a791ae5
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- Makefile-automake -*-
+#
+# Support for running programs with failmalloc preloaded. Include in other
+# automake files and make sure the following variables are set:
+#
+# FAILMALLOC_START - number of first FAILMALLOC_INTERVAL
+# FAILMALLOC_REP   - how often to repeat with increasing FAILMALLOC_INTERVAL
+# FAILMALLOC_PROG  - the program to run with linfailmalloc preloaded
+
+if WITH_FAILMALLOC
+failmalloc: failmalloc-run
+else
+failmalloc: failmalloc-error
+endif
+
+failmalloc-run: $(FAILMALLOC_PROG)
+       @(echo "Running $(FAILMALLOC_PROG) with failmalloc";    \
+      for i in $$(seq $(FAILMALLOC_START) $$(expr $(FAILMALLOC_START) + $(FAILMALLOC_REP) - 1)) ; do \
+         resp=$$(libtool --mode=execute env LD_PRELOAD=$(LIBFAILMALLOC) FAILMALLOC_INTERVAL=$$i $(FAILMALLOC_PROG));        \
+         status=$$?;                                          \
+         if [ $$status -ne 0 -a $$status -ne 2 ] ;     then       \
+           printf "%5d FAIL %3d %s\n" $$i $$status "$$resp" ; \
+         elif [ x$(V) = x1 -o $$(( $$i % 100 )) -eq 0 ] ; then \
+           printf "%5d PASS %s\n" $$i "$$resp" ;              \
+         fi                                                   \
+       done)
+
+failmalloc-error:
+       @(echo "You need to turn on failmalloc support with --with-failmalloc"; \
+         exit 1)
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..3fa214c
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,651 @@
+0.8.1 - 2011-04-15
+  - augtool: respect autosave flag in oneshot mode, bug #193; fix segfault
+    caused by unmatched bracket in path expression, bug #186
+  - eliminate a global variable in the lexer, fixes BZ 690286
+  - replace an erroneous assert(0) with a proper error message when none of
+    the alternatives in a union match during saving, bug #183
+  - improve AIX support
+  - Lens changes/additions
+    * Access: support the format @netgroup@@nisdomain, bug #190
+    * Fstab: fix parsing of SELinux labels in the fscontext option (Matt Booth)
+    * Grub: support 'device' directive for UEFI boot, bug #189; support
+      'configfile' and 'background' (Onur Küçük)
+    * Httpd: handle continuation lines (Bill Pemberton); autoload
+      httpd.conf on Fedora/RHEL, BZ 688149; fix support for single-quoted
+      strings
+    * Iptables: support --tcp-flags, bug #157; allow blank and comment
+      lines anywhere
+    * Mysql: include /etc/my.cnf used on Fedora/RHEL, BZ 688053
+    * NagiosCfg: parse setting multiple values on one line (Sebastien Aperghis)
+    * NagiosObjects: process /etc/nagios3/objects/*.cfg (Sebastien Aperghis)
+    * Nsswitch: support 'sudoers' as a database, bug #187
+    * Shellvars: autoload /etc/rc.conf used in FreeBSD (Rich Jones)
+    * Sudoers: support '#include' and '#includedir', bug #188
+    * Yum: exclude /etc/yum/pluginconf.d/versionlock.list (Bill Pemberton)
+
+0.8.0 - 2011-02-22
+  - add new 'square' lens combinator
+  - add new aug_span API function
+  - augtool: short options for --nostdinc, --noload, and --noautoload
+  - augtool: read commands from tty after executing file with --interactive
+  - augtool: add --autosave option
+  - augtool: add --span option to load nodes' span
+  - augtool: add span command to get the node's span according to the input
+    file
+  - augtool: really be quiet when we shouldn't be echoing
+  - fix segfault in get.c with L_MAYBE lens; bug #180
+  - fix segfault when a path expression called regexp() with an invalid
+    regexp; bug #168
+  - improved vim syntax file
+  - replace augtest by test-augtool.sh to obviate the need for Ruby to run
+    tests
+  - use sys_wait module from gnulib; bug #164
+  - Lens changes/additions
+    * Access: new lens for /etc/security/access.conf (Lorenzo Dalrio)
+    * Crypttab: new lens for /etc/crypttab (Frederic Lespez)
+    * Dhcpd: new lens
+    * Exports: accept hostnames with dashes; bug #169 (Sergio Ballestrero)
+    * Grub: add various Solaris extensions (Dominic Cleal); support "map"
+      entries, bug #148
+    * Httpd: new lens for Apache config
+    * Inifile: new lens indented_title_label
+    * Interfaces: allow indentation for "iface" entries; bug #182
+    * Mysql: change default comment delimiter from ';' to '#'; bug #181
+    * Nsswitch: accept various add'l databases; bug #171
+    * PuppetFileserver: new lens for Puppet's fileserver.conf (Frederic Lespez)
+    * REsolv: allow comments starting with ';'; bug #173 (erinn)
+    * Shellvars: autoload various snmpd config files; bug #170 (erinn)
+    * Solaris_system: new lens for /etc/system on Solaris (Dominic Cleal)
+    * Util (comment_c_style, empty_generic, empty_c_style): new lenses
+    * Xml: generic lens to process XML files
+    * Xorg: make "position" in "screen" optional; allow "Extensions"
+      section; bug #175 (omzkk)
+
+0.7.4 - 2010-11-19
+  - augtool: new clearm command to parallel setm
+  - augtool: add --file option
+  - Fix SEGV under gcc 4.5, caused by difficulties of the gcc optimizer
+    handling bitfields (bug #149; rhbz #651992)
+  - Preserve parse errors under /augeas//error: commit 5ee81630, released
+    in 0.7.3, introduced a regression that would cause the loss of parse
+    errors; bug #138
+  - Avoid losing already parsed nodes under certain circumstances; bug #144
+  - Properly record the new mtime of a saved file; previously the mtime in
+    the tree was reset to 0 when a file was saved, causing unnecessary file
+    reloads
+  - fix a SEGV when using L_MAYBE in recursive lens; bug #136
+  - Incompatible lens changes
+    * Fstab: parse option values
+    * Squid: various improvements, see bug #46;
+    * Xinetd: map service names differently
+  - Lens changes/additions
+    * Aptsources: map comments properly, allow indented lines; bug #151
+    * Grub: add indomU setting for Debian. Allow '=' as separator in title;
+      bug #150
+    * Fstab: also process /etc/mtab
+    * Inetd: support rpc services
+    * Iptables: allow underscore in chain names
+    * Keepalived: new lens for /etc/keepalived/keepalived.conf
+    * Krb5: allow digits in realm names; bug #139
+    * Login_defs: new lens for /etc/login.defs (Erinn Looney-Triggs)
+    * Mke2fs: new lens for /etc/mke2fs.conf
+    * Nrpe: new lens for Nagios nrpe (Marc Fournier)
+    * Nsswitch: new lens for /etc/nsswitch.conf
+    * Odbc: new lens for /etc/odbc.ini (Marc Fournier)
+    * Pg_hba: New lens; bug #140 (Aurelien Bompard). Add system path on
+      Debian; bug #154 (Marc Fournier)
+    * Postfix_master: parse arguments in double quotes; bug #69
+    * Resolv: new lens for /etc/resolv.conf
+    * Shells: new lens for /etc/shells
+    * Shellvars: parse ulimit builtin
+    * Sudoers: load file from /usr/local/etc (Mathieu Arnold) Allow
+      'visiblepw' parameter flag; bug #143. Read files from /etc/sudoers.d
+    * Syslog: new lens for /etc/syslog.conf (Mathieu Arnold)
+    * Util: exclude dpkg backup files; bug #153 (Marc Fournier)
+    * Yum: accept continuation lines for gpgkey; bug #132
+
+0.7.3 - 2010-08-06
+  - aug_load: only reparse files that have actually changed; greatly speeds
+    up reloading
+  - record all variables in /augeas/variables, regardless of whether they
+    were defined with aug_defvar or aug_defnode; make sure
+    /augeas/variables always exists
+  - redefine all variables (by reevaluating their corresponding
+    expressions) after a aug_load. This makes variables 'sticky' across
+    loads
+  - fix behavior of aug_defnode to not fail when the expression evaluates
+    to a nonempty node set
+  - make gnulib a git submodule so that we record the gnulib commit off
+    which we are based
+  - allow 'let rec' with non-recursive RHS
+  - fix memory corruption when reloading a tree into which a variable
+    defined by defnode points (BZ 613967)
+  - plug a few small memory leaks, and some segfaults
+  - Lens changes/additions
+    * Device_map: new lens for grub's device.map (Matt Booth)
+    * Limits: also look for files in /etc/security/limits.d
+    * Mysql: new lens (Tim Stoop)
+    * Shellvars: read /etc/sysconfig/suseconfig (Frederik Wagner)
+    * Sudoers: allow escaped spaces in user/group names (Raphael Pinson)
+    * Sysconfig: lens for the shell subdialect used in /etc/sysconfig; lens
+      strips quotes automatically
+
+0.7.2 - 2010-06-22
+  - new API call aug_setm to set/create multiple nodes simultaneously
+  - record expression used in a defvar underneath /augeas/variables
+  - Lens changes/additions
+    * Group: add test for disabled account (Raphael Pinson)
+    * Grub: handle comments within a boot stanza
+    * Iptables: also look for /etc/iptables-save (Nicolas Valcarcel)
+    * Modules_conf: new lens for /etc/modules.conf (Matt Booth)
+    * Securetty: added handling of emtpy lines/comments (Frederik Wagner)
+    * Shellvars: added SuSE sysconfig puppet files (Frederik Wagner),
+      process /etc/environment (seph)
+    * Shellvars_list: Shellvars-like lens that treats strings of
+      space-separated words as lists (Frederik Wagner)
+
+0.7.1 - 2010-04-21
+  - new primitive lens 'value' to set value of a node to a constant,
+    similar to 'label' for the key (see http://augeas.net/docs/lenses.html)
+  - new builtins for printing and getting the types of a lens (see
+    http://augeas.net/docs/builtins.html)
+  - add unit type to lens language; allow '_' as an identifier in let's to
+    force evaluation for side effect only
+  - Various fixes for Solaris. Augeas now builds cleanly on Solaris 5.10,
+    and most of the tests pass. The three tests that fail all fail because
+    the test scripts have Linux idiosyncrasies. This needs to be addressed
+    in a future release. Much thanks to Dagobert Michelsen and the OpenCSW
+    project (http://www.opencsw.org/) for providing me with access to their
+    build farm.
+  - fix crash when recursive lens was used in a nonrecursive lens (bug #100)
+  - context free parser/recursive lenses: handle 'l?' properly (bug #119);
+    distinguish between successful parse and parse with an error at end of
+    input; do caller filtering to avoid spurious ambiguous parses with
+    grammars containing epsilon productions
+  - aug_get: return -1 when multiple nodes match (bug #121)
+  - much better error message when iteration stops prematurely during
+    put/create than the dreaded 'Short iteration'
+  - augtool: ignore empty lines from stdin; report error when get fails
+  - fix memory leak in file_info (transform.c); this was leaking a file
+    name every time we loaded a file (Laine Stump)
+  - nicer error message when typechecker spots ambiguity in atype
+  - libfa: handle '(a|)' and 'r{min,}' properly
+  - locale independence: handle a literal '|' properly on systems that lack
+    use_locale
+  - bootstrap: pull in isblank explicitly (needed on Solaris)
+  - src/lens.c (lns_check_rec): fix refcounting mistake on error path (bug #120)
+  - fix SEGV when loading empty files
+  - improvements in handling some OOM's
+  - Lens changes/additions
+    * Approx: lens and test for the approx proxy server (Tim Stoop)
+    * Cgconfig: lens and tests for libcgroup config (Ivana Hutarova Varekova)
+    * Cgrules: new lens and test (Ivana Hutarova Varekova)
+    * Cobblermodules: lens + tests for cobbler's modules.conf (Shannon Hughes)
+    * Debctrl: new lens and test (Dominique Dumont)
+    * Dput: add 'allow_dcut' parameter (bug #105) (Raphael Pinson)
+    * Dhclient: add rfc code parsing (bug #107) (Raphael Pinson)
+    * Group: handle disabled passwords
+    * Grub: support empty kernel parameters, Suse incl.s (Frederik Wagner)
+    * Inittab: allow ':' in the process field (bug #109)
+    * Logrotate: tolerate whitespace at the end of a line (bug #101); files
+      can be separated by newlines (bug #104) (Raphael Pinson)
+    * Modprobe: Suse includes (Frederik Wagner)
+    * Nagisocfg: lens and test for /etc/nagios3/nagios.cfg (Tim Stoop)
+    * Ntp: add 'tinker' directive (bug #103)
+    * Passwd: parse NIS entries on Solaris
+    * Securetty: new lens and test for /etc/securetty (Simon Josi)
+    * Shellvars: handle a bare 'export VAR'; Suse includes (Frederik
+      Wagner); allow spaces after/before opening/closing parens for array
+    * Sshd: allow optional arguments in subsystem commands (Matt Palmer)
+    * Sudoers: allow del_negate even if no negate_node is found (bug #106)
+               (Raphael Pinson); accept 'secure_path' (BZ 566134) (Stuart
+               Sears)
+
+0.7.0 - 2010-01-14
+  - Support for context-free lenses via the 'let rec' keyword. The syntax
+    is experimental, though the feature is here to stay. See
+    lenses/json.aug for an example of what's possible with that.
+  - Support for case-insensitive regular expressions. Simply append 'i' to
+    a regexp literal to make it case-insensitive, e.g. /hello/i will match
+    all variations of hello, regardless of case.
+  - Major revamp of augtool. In particular, path expressions don't need to
+    be quoted anymore. The online help has been greatly improved.
+  - Check during load/save that each file is only matched by one transform
+    under /augeas/load. If there are multiple transforms for a file, the
+    file is skipped.
+  - New error codes AUG_ENOLENS and AUG_EMXFM
+  - Do not choke on non-existing lens during save
+  - Change the metadata for files under /augeas/files slightly: the node
+    /augeas/files/$PATH/lens now has the name of the lens used to load the
+    file; the source location of that lens has moved to
+    /augeas/files/$PATH/lens/info
+  - New public functions fa_nocase, fa_is_nocase, and fa_expand_nocase in
+    libfa
+  - Various smaller bug fixes, performance improvements and improved error
+    messages
+  - Lens changes/additions
+    * Cobblersettings: new lens and test (Bryan Kearney)
+    * Iptables: allow quoted strings as arguments; handle both negation
+      syntaxes
+    * Json: lens and tests for generic Json files
+    * Lokkit: allow '-' in arguments
+    * Samba: accept entry keys with ':' (Partha Aji)
+    * Shellvars: allow arrays that span multiple lines
+    * Xinetd (name): fix bad '-' in character class
+
+0.6.0 - 2009-11-30
+  - Add error reporting API (aug_error and related calls); use to report
+    error details in a variety of places
+  - Path expressions: add regexp matching; add operator '|' to form union
+    of nodesets (ticket #89)
+  - Tolerate non-C locales from the environment (ticket #35); it is no
+    longer necessary to set the locale to C from the outside
+  - use stpcpy/stpncpy from gnulib (needed for building on Solaris)
+  - Properly check regexp literals for syntax errors (ticket #93)
+  - Distribute and install vim syntax files (ticket #97)
+  - many more bugfixes
+  - Lens changes/additions
+    * Apt_preferences: support version pin; filter out empty lines (Matt
+      Palmer)
+    * Cron: variables can contain '_' etc. (ticket #94)
+    * Ethers: new lens for /etc/ethers (Satoru SATOH)
+    * Fstab: allow '#' in spec (ticket #95)
+    * Group: allow empty password field (ticket #95)
+    * Inittab: parse end-of-line comments into a #comment
+    * Krb5: support kdc section; add v4_name_convert subsection to
+      libdefaults (ticket #95)
+    * Lokkit: add mising eol to forward_port; make argument for --trust
+      more permissive
+    * Pam: allow '-' before type
+    * Postfix_access: new lens for /etc/postfix/access (Partha Aji)
+    * Rx: allow '!' in device_name
+    * Sudoers: allow certain backslash-quoted characters in a command (Matt
+      Palmer)
+    * Wine: new lens to read Windows registry files
+
+0.5.3 - 2009-09-14
+  - Match trees on label + value, not just label; see
+    tests/modules/pass_strip_quotes.aug for how that enables stripping
+    quotes
+  - Do not trip over symlinks to files on a different device during save;
+    fixes problems with writing to /etc/grub.conf on Fedora/RHEL
+  - API (defnode): always add the newly created node into the resulting
+    nodeset
+  - Add preceding-sibling and following-sibling axes to path expressions
+  - augtool, augparse: add --version option (bug #88)
+  - Change file info recorded under /augeas/files/FILE/*: remove lens/id
+    and move lens/info to lens
+  - Properly record new files under /augeas/files (bug #78)
+  - aug_load: clean up variables to avoid dangling references (bug #79)
+  - Make Augeas work on AIX
+  - Ignore anything but regular files when globbing
+  - Add 'clear' function to language for use in unit tests
+  - typechecker: print example trees in tree format
+  - libfa: properly support regexps with embedded NUL's
+  - Lens changes/additions
+    * Xorg: revamped, fixes various parse failures (Matt Booth)
+    * Inetd: new lens and test (Matt Palmer)
+    * Multipath: new lens and test
+    * Slapd: also read /etc/openldap.slapd.conf (bug #85)
+
+0.5.2 - 2009-07-13
+  - Make Augeas work on Mac OS/X (bug #66) (Anders Bjoerklund)
+  - reduce symbols exported from libfa with linker script
+  - add --echo option to augtool
+  - require Automake 1.11 (Jim Meyering)
+  - avoid spurious save attempts for freshly read files
+  - Lens changes/additions
+    * Inittab: schema change: use 'id' field as name of subtree for a line,
+      instead of a generated number. Map comments as '#comment' (Matt Palmer)
+    * Logrotate: make owner/group in create statement optional, allow
+      filenames to be indented
+    * Ntp: allow additional options for server etc. (bug #72)
+    * Shellvars: allow backticks as quote characters (bug #74)
+    * Yum: also read files in /etc/yum/pluginconf.d (Marc Fournier)
+
+0.5.1 - 2009-06-09
+  - augeas.h: flag AUG_NO_MODL_AUTOLOAD suppresses initial loading
+              of modules; exposed as --noautoload in augtool
+  - augtool: don't prompt when input is not from tty (Raphael Pinson)
+  - augparse: add --notypecheck option
+  - path expressions: allow things like '/foo and /bar[3]' in predicates
+  - Lens changes/additions
+    * Aliases: map comments as #comment (Raphael Pinson)
+    * Build, Rx, Sep: new utility modules (Raphael Pinson)
+    * Cron: new lens (Raphael Pinson)
+    * Dnsmasq: process files in /etc/dnsmasq.d/* (ticket #65)
+    * Grub: parse kernel and module args into separate nodes; parse
+            arguments for 'serial', 'terminal', and 'chainloader'; allow
+            optional argument for 'savedefault'
+    * Interfaces: make compliant with actual Debian spec (Matt Palmer)
+    * Iptables: relax regexp for chain names; allow comment lines mixed
+                in with chains and rules (ticket #51)
+    * Logrotate: allow '=' as separator (ticket #61); make newline at end
+                 of scriptlet optional
+    * Modprobe: handle comments at end of line
+    * Ntp: parse fudge record (Raphael Pinson); parse all directives in
+           default Fedora ntp.conf; process 'broadcastdelay', 'leapfile',
+           and enable/disable flags (ticket #62)
+    * Pbuilder: new lens for Debian's personal builder (Raphael Pinson)
+    * Php: add default path on Fedora/RHEL (Marc Fournier)
+    * Squid: handle indented entries (Raphael Pinson)
+    * Shellvars: map 'export' and 'unset'; map comments as #comment
+                 (Raphael Pinson)
+    * Sudoers: allow backslashes inside values (ticket #60) (Raphael Pinson)
+    * Vsftpd: map comments as #comment; handle empty lines; find
+              vsftpd.conf on Fedora/RHEL
+    * Xinetd: map comments as #comment (Raphael Pinson)
+
+0.5.0 - 2009-03-27
+  - Clean up interface for libfa; the interface is now considered stable
+  - New aug_load API call; allows controlling which files to load by
+    modifying /augeas/load and then calling aug_load; on startup, the
+    transforms marked with autoload are reported under /augeas/load
+  - New flag AUG_NO_LOAD for aug_init to keep it from loading files on
+    startup; add --noload option to augtool
+  - New API calls aug_defvar and aug_defnode to define variables for
+    path expressions; exposed as 'defvar' and 'defnode' in augtool
+  - Lenses distributed with Augeas are now installed in
+    /usr/share/augeas/lenses/dist, which is searched after
+    /usr/share/augeas/lenses, so that lenses installed by other packages
+    take precedence
+  - New program examples/fadot to draw various finite automata (Francis
+    Giraldeau)
+  - Report line number and character offset in the tree when parsing a
+    file with a lens fails
+  - Fix error in propagation of dirty flag, which could lead to only
+    parts of a tree being saved when multiple files were modified
+  - Flush files to disk before moving them
+  - Fix a number of memory corruptions in the XPath evaluator
+  - Several performance improvements in libfa
+  - Lens changes/additions
+    * Grub: process embedded comments for update-grub (Raphael Pinson)
+    * Iptables: new lens for /etc/sysconfig/iptables
+    * Krb5: new lens for /etc/krb5.conf
+    * Limits: map dpmain as value of 'domain' node, not as label
+              (Raphael Pinson)
+    * Lokkit: new lens for /etc/sysconfig/system-config-firewall
+    * Modprobe: new lens for /etc/modprobe.d/*
+    * Sudoers: more finegrained parsing (ticket #48) (Raphael Pinson)
+
+0.4.2 - 2009-03-09
+  - Do not delete files that had an error upon parsing
+  - For Fedora/EPEL RPM's, BuildRequire libselinux-devel (bug #26)
+  - Bug fixes in path expressions
+    * for numbers, the meaning of '<' and '<=' was reversed
+  - Always create an entry /files in aug_init
+  - New builtin 'Sys' module with functions 'getenv' and 'read_file',
+    the latter reads a the contents of a file into a string
+  - Lens changes/additions
+    * Postfix_main: handle continuation lines
+    * Bbhosts, Hosts, Logrotate, Sudoers: label comment nodes as '#comment'
+    * Sshd: map comments as '#comment' nodes
+    * Squid: add all keywords from squid 2.7 and 3 (Francois Deppierraz)
+    * Logrotate: process unit suffixes for 'size' and 'minsize'
+
+0.4.1 - 2009-03-02
+  - Remove files when their entire subtree under /files is deleted
+  - Various bug fixes and syntax enhancements for path expressions
+    (see tests/xpath.tests for details)
+  - Evaluate path expressions with multiple predicates correctly
+  - Fix incorrect setting of /augeas/events/saved
+  - Major cleanup of matching during get; drastically improves
+    performance for very large (on the order of 10k lines) config files
+  - Small performance improvement in the typechecker
+  - Reject invalid character sets like [x-u] during typecheck
+  - Build with compile warnings set to 'maximum' instead of 'error', so
+    that builds on platforms with broken headers will work out of the box
+  - Lens changes/additions
+    * Util.stdexcl now excludes .augsave and .augnew files
+    * Logrotate: allow 'yearly' schedule, spaces around braces
+    * Ntp: fix so that it processes ntp.conf on Fedora 10
+    * Services: lens for /etc/services (Raphael Pinson)
+    * Xorg: new lens and tests (Raphael Pinson)
+
+0.4.0 - 2009-02-06
+  - Much improved and expanded support for path expressions in the public
+    API. See doc/xpath.txt and tests/xpath.tests for details.
+  - Solaris support: builds at least on OpenSolaris 2008.11
+  - Lens changes/additions
+    * Grub: support color and savedefault
+    * DarkIce: new lens for http://darkice.tyrell.hu/ (Free Ekanayaka)
+
+0.3.6 - 2009-01-26
+  - report version in /augeas/version, report legal save modes in
+    /augeas/version/save/mode for feature tests/version checking
+  - dynamically change behavior of aug_save; add noop save mode
+    (Bryan Kearney)
+  - plug memory leak, more portable SELinux test (Jim Meyering)
+  - fix bz #478619 - do not use abspath (Arnaud Gomes-do-Vale)
+  - fix segfault when branch in a union does not have a ktype
+  - Lens changes/additions
+    * Dpkg: new lens for Debian's dpkg.cfg (Robin Lee Powell)
+    * Limits: new lens for /etc/security/limits.conf (Free Ekanayaka)
+    * Soma: new lens for http://www.somasuite.org/ config
+      (Free Ekanayaka)
+    * Php, Gdm: fix minor regexp error (Marc Fournier)
+      expand filter for Php config files (Robin Lee Powell)
+    * Phpvars: whitspace fixes (Free Ekanayaka)
+    * Puppet: accept indented puppet.conf (ticket #25)
+
+0.3.5 - 2008-12-23
+  - add an option to rewrite files by overwriting their contents instead of
+    putting the new file in place atomically with rename(2); file contents
+    are only copied after rename fails with EXDEV or EBUSY, and only if the
+    node /augeas/save/copy_if_rename_fails (fix #32)
+  - saving of backup (.augsave) files now works even if the original and
+    backup files are on different devices
+  - major refactoring of how path expressions are handled internally. Fixes
+    a number of bugs and oddities (e.g. tickets #7 and #23)
+  - fix a bug in fa_as_regexp: a '.' wasn't escaped, ultimately leading to
+    spurious errors from the typechecker
+  - Lens changes/additions
+    * Group: process /etc/group (Free Ekanayaka)
+    * Passwd: process /etc/passwd (Free Ekanayaka)
+    * Phpvars: process files that set PHP variables, in particular
+      /etc/squirrelmail/config.php (Free Ekanayaka)
+    * Rsyncd: process /etc/rsyncd.conf (Marc Fournier)
+    * Shellvars: process /etc/arno-iptables-firewall/debconf.cfg and
+      /etc/cron-apt/config (Free Ekanayaka), load /etc/sysconfig/sendmail
+    * Postfix: process postfix's main.cf and master.cf (Free Ekanayaka)
+    * Squid: new lens for squid.conf (Free Ekanayaka)
+    * Webmin: new lens (Free Ekanayaka)
+    * Xinetd: make sure equal sign is surrounded by spaces (#30)
+    * Sshd: change the structure of Condition subtrees (Dominique Dumont)
+
+0.3.4 - 2008-11-05
+  - fix saving of backup files; in 0.3.3, when AUG_SAVE_BACKUP was passed
+    to aug_init, aug_save would always fail
+
+0.3.3 - 2008-10-24
+  - restore the behavior of aug_save; in 0.3.2, aug_save broke API by
+    returning the number of files changed on success instead of 0
+
+0.3.2 - 2008-10-21
+  - saving now reports which files were actually changed in
+    /augeas/events/saved; aug_save also returns the number of files
+    that were changed
+  - preserve file owner, permissions and SELinux context when changing a file.
+  - make saving idempotent, i.e. when a change to the tree does not result
+    in changes to the actual file's content, do not touch the original file
+  - report an error if there are nodes in the tree with a label that
+    is not allowed by the lens
+  - quietly append a newline to files that do not have one
+  - generate lens documentation using NaturalDocs and publish those
+    on the Auegas website (Raphael Pinson)
+  - Lens changes/additions
+    * Grub: support the 'password' directive (Joel Nimety)
+    * Grub: support 'serial' and 'terminal' directives (Sean E. Millichamp)
+    * Samba: change default indentation and separators (Free Ekanayaka)
+    * Logrotate: process tabooext, add dateext flag (Sean E. Millichamp)
+    * Sshd: Cleaner handling of 'Match' blocks (Dominique Dumont)
+    * Monit: new lens (Free Ekanayaka)
+    * Ldap: merge with Spacevars (Free Ekanayaka)
+    * Shellvars: support /etc/default (Free Ekanayaka)
+    * Shellvars: handle space at the end of a line
+
+0.3.1 - 2008-09-04
+  - Major performance improvement when processing huge files, reducing some
+    O(n^2) behavior to O(n) behavior. It's now entirely feasible to
+    manipulate for example /etc/hosts files with 65k lines
+  - Handle character escapes '\x' in regular expressions in compliance with
+    Posix ERE
+  - aug_mv: fix bug when moving at the root level
+  - Fix endless loop when using a mixed-case module name like MyMod.lns
+  - Typecheck del lens: for 'del RE STR', STR must match RE
+  - Properly typecheck the '?' operator, especially the atype; also allow
+    '?' to be applied to lenses that contain only 'store', and do not
+    produce tree nodes.
+  - Many new/improved lenses
+    * many lenses now map comments as '#comment' nodes instead of just
+      deleting them
+    * Sudoers: added (Raphael Pinson)
+    * Hosts: map comments into tree, handle whitespace and comments
+             at the end of a line (Kjetil Homme)
+    * Xinetd: allow indented comments and spaces around "}" (Raphael Pinson)
+    * Pam: allow comments at the end of lines and leading spaces
+           (Raphael Pinson)
+    * Fstab: map comments and support empty lines (Raphael Pinson)
+    * Inifile: major revamp (Raphael Pinson)
+    * Puppet: new lens for /etc/puppet.conf (Raphael Pinson)
+    * Shellvars: handle quoted strings and arrays (Nahum Shalman)
+    * Php: map entries outside of sections to a '.anon' section
+           (Raphael Pinson)
+    * Ldap: new lens for /etc/ldap.conf (Free Ekanayaka)
+    * Dput: add allowed_distributions entry (Free Ekanayaka)
+    * OpenVPN: new lens for /etc/openvpn/{client,server}.conf (Raphael Pinson)
+    * Dhclient: new lens for /etc/dhcp3/dhclient.conf (Free Ekanayaka)
+    * Samba: new lens for /etc/samba/smb.conf (Free Ekanayaka)
+    * Slapd: new lens for /etc/ldap/slapd.conf (Free Ekanayaka)
+    * Dnsmasq: new lens for /etc/dnsmasq.conf (Free Ekanayaka)
+    * Sysctl: new lens for /etc/sysctl.conf (Sean Millichamp)
+
+0.3.0 - 2008-08-07
+  - Add aug_mv call to public API
+  - Do not clobber symlinks, instead write new files to target of symlink
+  - Fail 'put' when tree has invalid entries
+  - Set exit status of augtool
+  - Avoid picking special characters, in particular '\0', in examples (libfa)
+  - Store system errors, using strerror, in the tree during writing of files
+  - New lenses
+    * Generic inifile module (Raphael Pinson)
+    * logrotate (Raphael Pinson)
+    * /etc/ntp.conf (Raphael Pinson)
+    * /etc/apt/preferences (Raphael Pinson)
+    * bbhosts for Big Brother [http://www.bb4.org/] (Raphael Pinson)
+    * php.ini (Raphael Pinson)
+
+0.2.2 - 2008-07-18
+  - Fix segfault in store.put on NULL values
+  - Properly move default lens dir with DATADIR (Jim Meyering)
+  - Fix 'short iteration' error on get/parse of empty string; this bug
+    made it impossible to save into a new file
+  - Add 'insa' and 'insb' primitives to allow insertion from
+    put unit tests
+  - aug_insert: handle insertion before first child properly
+  - New lenses
+    * /etc/exports: NFS exports
+    * /etc/dput.cf: Debian's dput (Raphael Pinson)
+    * /etc/aliases: don't require whitespace after comma (Greg Swift)
+
+0.2.1 - 2008-07-01
+  - Address some compilation issues found on Ubuntu/Debian unstable
+  - Fix segfault when aug_init/close are called multiple times
+  - Man page for augparse
+  - New lenses
+    * /etc/sysconfig/selinux
+    * Bugfixes for grub.conf
+
+0.2.0 - 2008-06-05
+  - Augeas is now much more portable
+    * Pull in gnulib on non-glibc systems
+    * Augeas now builds and runs on FreeBSD (possibly others, too)
+  - Various fixes for memory corruption and the like
+    (Jim Meyering, James Antill)
+  - New lenses
+    * vsftpd.conf
+    * various bugfixes in existing lenses
+
+0.1.1 - 2008-05-16
+  - Add subtraction of regexps to the language, for example
+      let re = /[a-z]+/ - /(Allow|Deny)Users/
+  - Report errors during get/put in the tree; added subnodes to
+    /augeas/files/PATH/error for that purpose
+  - Many many bugfixes:
+    * plugged all known memory leaks
+    * fixed typecheck for lens union (l1 | l2) which was plain wrong
+    * reduce overall memory usage by releasing unused compiled regexps
+    * further performance improvements in libfa
+    * check that values match the regexps in STORE when saving
+  - libfa can now convert an automaton back to a regular expression
+    (FA_AS_REGEXP)
+  - New lenses
+    * /etc/fstab
+    * /etc/xinetd.conf and /etc/xinetd.d/*
+
+0.1.0 - 2008-05-01
+  - Various changes to public API:
+    * Remove aug_exists from public API, and merge functionality into aug_get
+    * Do not hide pointer behind typedef; instead Augeas 'handle' type is now
+      struct augeas, typedef'd to augeas (Jim Meyering)
+    * Const-correctness of public API, return error indication
+      from aug_print (Jim Meyering)
+    * Make buildable on Debian Etch (remove -fstack-protector from compiler
+      switches)
+  - Public API is now stable, and existing calls will be supported without
+    further changes
+  - New schema:
+    * /etc/sysconfig/network-scripts/ifcfg-* (Alan Pevec)
+    * Assorted other files from /etc/sysconfig (the ones that just set
+      shell variables)
+    * /etc/apt/sources.list and /etc/apt/sources.list.d/* (Dean Wilson)
+  - Man page for augtool (Dean Wilson)
+
+0.0.8 - 2008-04-16
+  - Complete rewrite of the language for schema descriptions
+
+0.0.7 - 2008-03-14
+  - Typecheck lenses; in particular, discover and complain about ambiguous
+    concatenation and iteration
+  - Enable typechecking for augparse by default, and for augtool via the
+    '-c' flag
+  - Fixed lens definitions in spec/ to pass typechecking. They contained
+    quite a few stupid and subtle problems
+  - Greatly improved libfa performance to make typechecking reasonably
+    fast. Typechecking cmfm.aug went from more than two hours to under two
+    seconds
+
+0.0.6 - 2008-03-05
+  - Make it possible to overwrite files when saving with and without
+    backups
+  - Take the filesystem root as an optional argument to aug_init
+  - Expose these two things as command line options in augtool
+
+0.0.5 - 2008-03-05
+  - Changed public API to contain explicit reference to augeas_t
+    structure. This makes it easier to write threadsafe code using Augeas
+  - Added libfa, finite automata library, though it's not yet used by
+    Augeas
+
+0.0.4 - 2008-02-25
+  - package as RPM and make sure Augeas can be build on Fedora/RHEL
+
+0.0.3 - 2008-02-25
+  - further rework; file processing now resembles Boomerang lenses much
+    more closely
+  - major revamp of the internal tree representation (ordered tree where
+    multiple children can have the same label, including NULL labels)
+  - move away from LL(1) parsing in favor of regular languages, since they
+    enable much better ahead-of-time checks (which are not implemented yet)
+
+0.0.2 - 2008-01-29:
+  - completely reworked
+  - processing of files is now based on a textual description of the
+    structure of the files (basically a LL(1) grammar)
+
+0.0.1 - 2007-12-01:
+  - First release.
+  - Public API and basic tree data structure.
+  - Record scanning works.
+  - Providers for pam.d, inittab and /etc/hosts
+  - Simple tests and test driver
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..92d9e87
--- /dev/null
+++ b/README
@@ -0,0 +1,78 @@
+Introduction
+------------
+
+  Augeas is a library and command line tool that focuses on the most basic
+  problem in handling Linux configurations programmatically: editing actual
+  configuration files in a controlled manner.
+
+  To that end, Augeas exposes a tree of all configuration settings (well,
+  all the ones it knows about) and a simple local API for manipulating the
+  tree. Augeas then modifies underlying configuration files according to
+  the changes that have been made to the tree; it does as little modeling
+  of configurations as possible, and focuses exclusivley on transforming
+  the tree-oriented syntax of its public API to the myriad syntaxes of
+  individual configuration files.
+
+  This focus on editing sets Augeas apart from any other configuration tool
+  I know of. Hopefully, Augeas will form a more solid foundation on which
+  these tools can be built; with a clean, simple API these tools should
+  be able to focus more on their core concerns and less on the mechanics
+  of running sed, grep, awk, etc. to tweak a config file.
+
+  If all you need is a tool to edit configuration files, you only need to
+  concern yourself with the handful of public API calls that Augeas exposes
+  (or their equivalent language bindings). However, to teach Augeas about a
+  new file format, you need to describe that file format in Augeas's domain
+  specific language (a very small subset of ML) Documentation for that
+  language can be found on the Augeas website at http://augeas.net/ If you
+  do that, please contribute the description if at all possible, or include
+  it in the distribution of your software - all you need to do for that is
+  add a couple of text files, there is no need to change existing
+  code. Ultimately, Augeas should describe all config files commonly found
+  on a Linux system.
+
+Non-goals
+---------
+
+  Augeas is as much defined by the things it does _not_ try to accomplish
+  as by its goals:
+
+    * No abstraction from native config format, i.e. the organization of
+      the tree mirrors closely how the native config files are organized
+    * No cross-platform abstraction - what is logically the same value may
+      live in different places in the tree on different
+      distributions. Dealing with that should be left to a higher-level
+      tool
+    * No remote management support. Augeas is a local API, other ways of
+      access to Augeas should be built on top of it
+    * No (or very little) modelling. Augeas is focused on syntax
+      transformation, not on any higher-level understanding of
+      configuration.
+
+  The above non-goals are of course important concerns in
+  practice. Historically though, too many config mgmt projects have failed
+  because they set their sights too high and tried to address syntax
+  transformation, modelling, remote support, and scalable management all in
+  one. That leads to a lack of focus, and to addressing each of those goals
+  unsatisfactorily.
+
+Building
+--------
+
+  These instructions apply to building a released tarball. If you want to
+  build from a git checkout, see the file HACKING.
+
+  See the generic instructions in INSTALL. Generally,
+    ./configure
+    make && make install
+  should be all that is needed.
+
+  You need to have readline-devel installed. On systems that support
+  SELinux, you should also install libselinux-devel.
+
+Documentation
+-------------
+
+Documentation can be found on Augeas' website http://augeas.net/ The site
+also contains information on how to get in touch, what you can do to help
+etc.
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..7168cf3
--- /dev/null
@@ -0,0 +1,140 @@
+dnl
+dnl Taken from libvirt/acinclude.m4
+dnl
+dnl We've added:
+dnl   -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
+dnl We've removed
+dnl   CFLAGS="$realsave_CFLAGS"
+dnl   to avoid clobbering user-specified CFLAGS
+dnl
+AC_DEFUN([AUGEAS_COMPILE_WARNINGS],[
+    dnl ******************************
+    dnl More compiler warnings
+    dnl ******************************
+
+    AC_ARG_ENABLE(compile-warnings,
+                  AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
+                                 [Turn on compiler warnings]),,
+                  [enable_compile_warnings="m4_default([$1],[maximum])"])
+
+    warnCFLAGS=
+
+    common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
+
+    case "$enable_compile_warnings" in
+    no)
+        try_compiler_flags=""
+       ;;
+    minimum)
+       try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
+       ;;
+    yes)
+       try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
+       ;;
+    maximum|error)
+       try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+       try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
+       try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
+       try_compiler_flags="$try_compiler_flags $common_flags"
+       if test "$enable_compile_warnings" = "error" ; then
+           try_compiler_flags="$try_compiler_flags -Werror"
+       fi
+       ;;
+    *)
+       AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
+       ;;
+    esac
+
+    compiler_flags=
+    for option in $try_compiler_flags; do
+       SAVE_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $option"
+       AC_MSG_CHECKING([whether gcc understands $option])
+       AC_TRY_LINK([], [],
+               has_option=yes,
+               has_option=no,)
+       CFLAGS="$SAVE_CFLAGS"
+       AC_MSG_RESULT($has_option)
+       if test $has_option = yes; then
+         compiler_flags="$compiler_flags $option"
+       fi
+       unset has_option
+       unset SAVE_CFLAGS
+    done
+    unset option
+    unset try_compiler_flags
+
+    AC_ARG_ENABLE(iso-c,
+                  AC_HELP_STRING([--enable-iso-c],
+                                 [Try to warn if code is not ISO C ]),,
+                  [enable_iso_c=no])
+
+    AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
+    complCFLAGS=
+    if test "x$enable_iso_c" != "xno"; then
+       if test "x$GCC" = "xyes"; then
+       case " $CFLAGS " in
+           *[\ \       ]-ansi[\ \      ]*) ;;
+           *) complCFLAGS="$complCFLAGS -ansi" ;;
+       esac
+       case " $CFLAGS " in
+           *[\ \       ]-pedantic[\ \  ]*) ;;
+           *) complCFLAGS="$complCFLAGS -pedantic" ;;
+       esac
+       fi
+    fi
+    AC_MSG_RESULT($complCFLAGS)
+
+    WARN_CFLAGS="$compiler_flags $complCFLAGS"
+    AC_SUBST(WARN_CFLAGS)
+])
+
+dnl
+dnl Determine readline linker flags in a way that works on RHEL 5
+dnl Check for rl_completion_matches (missing on OS/X)
+dnl
+AC_DEFUN([AUGEAS_CHECK_READLINE], [
+  AC_CHECK_HEADERS([readline/readline.h])
+
+  # Check for readline.
+  AC_CHECK_LIB(readline, readline,
+          [use_readline=yes; READLINE_LIBS=-lreadline],
+          [use_readline=no])
+
+  # If the above test failed, it may simply be that -lreadline requires
+  # some termcap-related code, e.g., from one of the following libraries.
+  # See if adding one of them to LIBS helps.
+  if test $use_readline = no; then
+      saved_libs=$LIBS
+      LIBS=
+      AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib)
+      case $LIBS in
+        no*) ;;  # handle "no" and "none required"
+        *) # anything else is a -lLIBRARY
+          # Now, check for -lreadline again, also using $LIBS.
+          # Note: this time we use a different function, so that
+          # we don't get a cached "no" result.
+          AC_CHECK_LIB(readline, rl_initialize,
+                  [use_readline=yes
+                   READLINE_LIBS="-lreadline $LIBS"],,
+                  [$LIBS])
+          ;;
+      esac
+      test $use_readline = no &&
+          AC_MSG_WARN([readline library not found])
+      LIBS=$saved_libs
+  fi
+
+  if test $use_readline = no; then
+    AC_MSG_ERROR(Could not find a working readline library (see config.log for details).)
+  fi
+
+  AC_SUBST(READLINE_LIBS)
+
+  if test $use_readline = yes; then
+      saved_libs=$LIBS
+      LIBS=$READLINE_LIBS
+      AC_CHECK_FUNCS([rl_completion_matches])
+      LIBS=$saved_libs
+  fi
+])
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..6508993
--- /dev/null
@@ -0,0 +1,1551 @@
+# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
+[m4_warning([this file was generated for autoconf 2.66.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# po.m4 serial 17 (gettext-0.18)
+dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ([2.50])
+
+dnl Checks for all prerequisites of the po subdirectory.
+AC_DEFUN([AM_PO_SUBDIRS],
+[
+  AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+  AC_REQUIRE([AC_PROG_INSTALL])dnl
+  AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+  AC_REQUIRE([AM_NLS])dnl
+
+  dnl Release version of the gettext macros. This is used to ensure that
+  dnl the gettext macros and po/Makefile.in.in are in sync.
+  AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
+
+  dnl Perform the following tests also if --disable-nls has been given,
+  dnl because they are needed for "make dist" to work.
+
+  dnl Search for GNU msgfmt in the PATH.
+  dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
+  dnl The second test excludes FreeBSD msgfmt.
+  AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
+    [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+     (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+    :)
+  AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
+
+  dnl Test whether it is GNU msgfmt >= 0.15.
+changequote(,)dnl
+  case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
+    *) MSGFMT_015=$MSGFMT ;;
+  esac
+changequote([,])dnl
+  AC_SUBST([MSGFMT_015])
+changequote(,)dnl
+  case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
+    *) GMSGFMT_015=$GMSGFMT ;;
+  esac
+changequote([,])dnl
+  AC_SUBST([GMSGFMT_015])
+
+  dnl Search for GNU xgettext 0.12 or newer in the PATH.
+  dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
+  dnl The second test excludes FreeBSD xgettext.
+  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
+    [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
+     (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
+    :)
+  dnl Remove leftover from FreeBSD xgettext call.
+  rm -f messages.po
+
+  dnl Test whether it is GNU xgettext >= 0.15.
+changequote(,)dnl
+  case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
+    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
+    *) XGETTEXT_015=$XGETTEXT ;;
+  esac
+changequote([,])dnl
+  AC_SUBST([XGETTEXT_015])
+
+  dnl Search for GNU msgmerge 0.11 or newer in the PATH.
+  AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
+    [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
+
+  dnl Installation directories.
+  dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
+  dnl have to define it here, so that it can be used in po/Makefile.
+  test -n "$localedir" || localedir='${datadir}/locale'
+  AC_SUBST([localedir])
+
+  dnl Support for AM_XGETTEXT_OPTION.
+  test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
+  AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
+
+  AC_CONFIG_COMMANDS([po-directories], [[
+    for ac_file in $CONFIG_FILES; do
+      # Support "outfile[:infile[:infile...]]"
+      case "$ac_file" in
+        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+      esac
+      # PO directories have a Makefile.in generated from Makefile.in.in.
+      case "$ac_file" in */Makefile.in)
+        # Adjust a relative srcdir.
+        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+        # In autoconf-2.13 it is called $ac_given_srcdir.
+        # In autoconf-2.50 it is called $srcdir.
+        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+        case "$ac_given_srcdir" in
+          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+          /*) top_srcdir="$ac_given_srcdir" ;;
+          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
+        esac
+        # Treat a directory as a PO directory if and only if it has a
+        # POTFILES.in file. This allows packages to have multiple PO
+        # directories under different names or in different locations.
+        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
+          rm -f "$ac_dir/POTFILES"
+          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
+          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[  ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
+          POMAKEFILEDEPS="POTFILES.in"
+          # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
+          # on $ac_dir but don't depend on user-specified configuration
+          # parameters.
+          if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+            # The LINGUAS file contains the set of available languages.
+            if test -n "$OBSOLETE_ALL_LINGUAS"; then
+              test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+            fi
+            ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+            # Hide the ALL_LINGUAS assigment from automake < 1.5.
+            eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+            POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+          else
+            # The set of available languages was given in configure.in.
+            # Hide the ALL_LINGUAS assigment from automake < 1.5.
+            eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
+          fi
+          # Compute POFILES
+          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+          # Compute UPDATEPOFILES
+          # as      $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+          # Compute DUMMYPOFILES
+          # as      $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+          # Compute GMOFILES
+          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+          case "$ac_given_srcdir" in
+            .) srcdirpre= ;;
+            *) srcdirpre='$(srcdir)/' ;;
+          esac
+          POFILES=
+          UPDATEPOFILES=
+          DUMMYPOFILES=
+          GMOFILES=
+          for lang in $ALL_LINGUAS; do
+            POFILES="$POFILES $srcdirpre$lang.po"
+            UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+            DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+            GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+          done
+          # CATALOGS depends on both $ac_dir and the user's LINGUAS
+          # environment variable.
+          INST_LINGUAS=
+          if test -n "$ALL_LINGUAS"; then
+            for presentlang in $ALL_LINGUAS; do
+              useit=no
+              if test "%UNSET%" != "$LINGUAS"; then
+                desiredlanguages="$LINGUAS"
+              else
+                desiredlanguages="$ALL_LINGUAS"
+              fi
+              for desiredlang in $desiredlanguages; do
+                # Use the presentlang catalog if desiredlang is
+                #   a. equal to presentlang, or
+                #   b. a variant of presentlang (because in this case,
+                #      presentlang can be used as a fallback for messages
+                #      which are not translated in the desiredlang catalog).
+                case "$desiredlang" in
+                  "$presentlang"*) useit=yes;;
+                esac
+              done
+              if test $useit = yes; then
+                INST_LINGUAS="$INST_LINGUAS $presentlang"
+              fi
+            done
+          fi
+          CATALOGS=
+          if test -n "$INST_LINGUAS"; then
+            for lang in $INST_LINGUAS; do
+              CATALOGS="$CATALOGS $lang.gmo"
+            done
+          fi
+          test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
+          sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
+          for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
+            if test -f "$f"; then
+              case "$f" in
+                *.orig | *.bak | *~) ;;
+                *) cat "$f" >> "$ac_dir/Makefile" ;;
+              esac
+            fi
+          done
+        fi
+        ;;
+      esac
+    done]],
+   [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
+    # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
+    # from automake < 1.5.
+    eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
+    # Capture the value of LINGUAS because we need it to compute CATALOGS.
+    LINGUAS="${LINGUAS-%UNSET%}"
+   ])
+])
+
+dnl Postprocesses a Makefile in a directory containing PO files.
+AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
+[
+  # When this code is run, in config.status, two variables have already been
+  # set:
+  # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
+  # - LINGUAS is the value of the environment variable LINGUAS at configure
+  #   time.
+
+changequote(,)dnl
+  # Adjust a relative srcdir.
+  ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
+  ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
+  ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
+  # In autoconf-2.13 it is called $ac_given_srcdir.
+  # In autoconf-2.50 it is called $srcdir.
+  test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
+  case "$ac_given_srcdir" in
+    .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
+    /*) top_srcdir="$ac_given_srcdir" ;;
+    *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+  # Find a way to echo strings without interpreting backslash.
+  if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
+    gt_echo='echo'
+  else
+    if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
+      gt_echo='printf %s\n'
+    else
+      echo_func () {
+        cat <<EOT
+$*
+EOT
+      }
+      gt_echo='echo_func'
+    fi
+  fi
+
+  # A sed script that extracts the value of VARIABLE from a Makefile.
+  sed_x_variable='
+# Test if the hold space is empty.
+x
+s/P/P/
+x
+ta
+# Yes it was empty. Look if we have the expected variable definition.
+/^[     ]*VARIABLE[     ]*=/{
+  # Seen the first line of the variable definition.
+  s/^[  ]*VARIABLE[     ]*=//
+  ba
+}
+bd
+:a
+# Here we are processing a line from the variable definition.
+# Remove comment, more precisely replace it with a space.
+s/#.*$/ /
+# See if the line ends in a backslash.
+tb
+:b
+s/\\$//
+# Print the line, without the trailing backslash.
+p
+tc
+# There was no trailing backslash. The end of the variable definition is
+# reached. Clear the hold space.
+s/^.*$//
+x
+bd
+:c
+# A trailing backslash means that the variable definition continues in the
+# next line. Put a nonempty string into the hold space to indicate this.
+s/^.*$/P/
+x
+:d
+'
+changequote([,])dnl
+
+  # Set POTFILES to the value of the Makefile variable POTFILES.
+  sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
+  POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
+  # Compute POTFILES_DEPS as
+  #   $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
+  POTFILES_DEPS=
+  for file in $POTFILES; do
+    POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
+  done
+  POMAKEFILEDEPS=""
+
+  if test -n "$OBSOLETE_ALL_LINGUAS"; then
+    test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
+  fi
+  if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
+    # The LINGUAS file contains the set of available languages.
+    ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
+    POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
+  else
+    # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
+    sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
+    ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
+  fi
+  # Hide the ALL_LINGUAS assigment from automake < 1.5.
+  eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
+  # Compute POFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
+  # Compute UPDATEPOFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
+  # Compute DUMMYPOFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
+  # Compute GMOFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
+  # Compute PROPERTIESFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
+  # Compute CLASSFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
+  # Compute QMFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
+  # Compute MSGFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
+  # Compute RESOURCESDLLFILES
+  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
+  case "$ac_given_srcdir" in
+    .) srcdirpre= ;;
+    *) srcdirpre='$(srcdir)/' ;;
+  esac
+  POFILES=
+  UPDATEPOFILES=
+  DUMMYPOFILES=
+  GMOFILES=
+  PROPERTIESFILES=
+  CLASSFILES=
+  QMFILES=
+  MSGFILES=
+  RESOURCESDLLFILES=
+  for lang in $ALL_LINGUAS; do
+    POFILES="$POFILES $srcdirpre$lang.po"
+    UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
+    DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
+    GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
+    PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
+    CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
+    QMFILES="$QMFILES $srcdirpre$lang.qm"
+    frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+    MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
+    frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+    RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
+  done
+  # CATALOGS depends on both $ac_dir and the user's LINGUAS
+  # environment variable.
+  INST_LINGUAS=
+  if test -n "$ALL_LINGUAS"; then
+    for presentlang in $ALL_LINGUAS; do
+      useit=no
+      if test "%UNSET%" != "$LINGUAS"; then
+        desiredlanguages="$LINGUAS"
+      else
+        desiredlanguages="$ALL_LINGUAS"
+      fi
+      for desiredlang in $desiredlanguages; do
+        # Use the presentlang catalog if desiredlang is
+        #   a. equal to presentlang, or
+        #   b. a variant of presentlang (because in this case,
+        #      presentlang can be used as a fallback for messages
+        #      which are not translated in the desiredlang catalog).
+        case "$desiredlang" in
+          "$presentlang"*) useit=yes;;
+        esac
+      done
+      if test $useit = yes; then
+        INST_LINGUAS="$INST_LINGUAS $presentlang"
+      fi
+    done
+  fi
+  CATALOGS=
+  JAVACATALOGS=
+  QTCATALOGS=
+  TCLCATALOGS=
+  CSHARPCATALOGS=
+  if test -n "$INST_LINGUAS"; then
+    for lang in $INST_LINGUAS; do
+      CATALOGS="$CATALOGS $lang.gmo"
+      JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
+      QTCATALOGS="$QTCATALOGS $lang.qm"
+      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+      TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
+      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+      CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
+    done
+  fi
+
+  sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
+  if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
+    # Add dependencies that cannot be formulated as a simple suffix rule.
+    for lang in $ALL_LINGUAS; do
+      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
+      cat >> "$ac_file.tmp" <<EOF
+$frobbedlang.msg: $lang.po
+       @echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
+       \$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+    done
+  fi
+  if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
+    # Add dependencies that cannot be formulated as a simple suffix rule.
+    for lang in $ALL_LINGUAS; do
+      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
+      cat >> "$ac_file.tmp" <<EOF
+$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
+       @echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
+       \$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
+EOF
+    done
+  fi
+  if test -n "$POMAKEFILEDEPS"; then
+    cat >> "$ac_file.tmp" <<EOF
+Makefile: $POMAKEFILEDEPS
+EOF
+  fi
+  mv "$ac_file.tmp" "$ac_file"
+])
+
+dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
+AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
+[
+  XGETTEXT_EXTRA_OPTIONS=
+])
+
+dnl Registers an option to be passed to xgettext in the po subdirectory.
+AC_DEFUN([AM_XGETTEXT_OPTION],
+[
+  AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
+  XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
+])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# 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.
+
+# serial 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES(CC)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  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.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# (`yes' being less verbose, `no' or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules],
+[  --enable-silent-rules          less verbose build output (undo: `make V=1')
+  --disable-silent-rules         verbose build output (undo: `make V=0')])
+case $enable_silent_rules in
+yes) AM_DEFAULT_VERBOSITY=0;;
+no)  AM_DEFAULT_VERBOSITY=1;;
+*)   AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001, 2003, 2005  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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  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.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([gnulib/m4/00gnulib.m4])
+m4_include([gnulib/m4/alloca.m4])
+m4_include([gnulib/m4/argz.m4])
+m4_include([gnulib/m4/btowc.m4])
+m4_include([gnulib/m4/canonicalize.m4])
+m4_include([gnulib/m4/codeset.m4])
+m4_include([gnulib/m4/configmake.m4])
+m4_include([gnulib/m4/ctype.m4])
+m4_include([gnulib/m4/double-slash-root.m4])
+m4_include([gnulib/m4/dup2.m4])
+m4_include([gnulib/m4/eealloc.m4])
+m4_include([gnulib/m4/environ.m4])
+m4_include([gnulib/m4/errno_h.m4])
+m4_include([gnulib/m4/extensions.m4])
+m4_include([gnulib/m4/fcntl-o.m4])
+m4_include([gnulib/m4/fcntl_h.m4])
+m4_include([gnulib/m4/float_h.m4])
+m4_include([gnulib/m4/fnmatch.m4])
+m4_include([gnulib/m4/getdelim.m4])
+m4_include([gnulib/m4/getline.m4])
+m4_include([gnulib/m4/getopt.m4])
+m4_include([gnulib/m4/getpagesize.m4])
+m4_include([gnulib/m4/glibc21.m4])
+m4_include([gnulib/m4/gnulib-common.m4])
+m4_include([gnulib/m4/gnulib-comp.m4])
+m4_include([gnulib/m4/include_next.m4])
+m4_include([gnulib/m4/intlmacosx.m4])
+m4_include([gnulib/m4/intmax_t.m4])
+m4_include([gnulib/m4/inttypes_h.m4])
+m4_include([gnulib/m4/isblank.m4])
+m4_include([gnulib/m4/langinfo_h.m4])
+m4_include([gnulib/m4/lcmessage.m4])
+m4_include([gnulib/m4/lib-ld.m4])
+m4_include([gnulib/m4/lib-link.m4])
+m4_include([gnulib/m4/lib-prefix.m4])
+m4_include([gnulib/m4/libtool.m4])
+m4_include([gnulib/m4/localcharset.m4])
+m4_include([gnulib/m4/locale-fr.m4])
+m4_include([gnulib/m4/locale-ja.m4])
+m4_include([gnulib/m4/locale-tr.m4])
+m4_include([gnulib/m4/locale-zh.m4])
+m4_include([gnulib/m4/locale_h.m4])
+m4_include([gnulib/m4/localename.m4])
+m4_include([gnulib/m4/lock.m4])
+m4_include([gnulib/m4/longlong.m4])
+m4_include([gnulib/m4/lstat.m4])
+m4_include([gnulib/m4/ltoptions.m4])
+m4_include([gnulib/m4/ltsugar.m4])
+m4_include([gnulib/m4/ltversion.m4])
+m4_include([gnulib/m4/lt~obsolete.m4])
+m4_include([gnulib/m4/malloc.m4])
+m4_include([gnulib/m4/malloca.m4])
+m4_include([gnulib/m4/mbrtowc.m4])
+m4_include([gnulib/m4/mbsinit.m4])
+m4_include([gnulib/m4/mbsrtowcs.m4])
+m4_include([gnulib/m4/mbstate_t.m4])
+m4_include([gnulib/m4/mbtowc.m4])
+m4_include([gnulib/m4/memchr.m4])
+m4_include([gnulib/m4/mempcpy.m4])
+m4_include([gnulib/m4/mmap-anon.m4])
+m4_include([gnulib/m4/mode_t.m4])
+m4_include([gnulib/m4/multiarch.m4])
+m4_include([gnulib/m4/nl_langinfo.m4])
+m4_include([gnulib/m4/onceonly.m4])
+m4_include([gnulib/m4/open.m4])
+m4_include([gnulib/m4/pathmax.m4])
+m4_include([gnulib/m4/printf.m4])
+m4_include([gnulib/m4/putenv.m4])
+m4_include([gnulib/m4/readlink.m4])
+m4_include([gnulib/m4/realloc.m4])
+m4_include([gnulib/m4/regex.m4])
+m4_include([gnulib/m4/safe-alloc.m4])
+m4_include([gnulib/m4/selinux-context-h.m4])
+m4_include([gnulib/m4/selinux-selinux-h.m4])
+m4_include([gnulib/m4/setenv.m4])
+m4_include([gnulib/m4/setlocale.m4])
+m4_include([gnulib/m4/size_max.m4])
+m4_include([gnulib/m4/ssize_t.m4])
+m4_include([gnulib/m4/stat.m4])
+m4_include([gnulib/m4/stdbool.m4])
+m4_include([gnulib/m4/stddef_h.m4])
+m4_include([gnulib/m4/stdint.m4])
+m4_include([gnulib/m4/stdint_h.m4])
+m4_include([gnulib/m4/stdio_h.m4])
+m4_include([gnulib/m4/stdlib_h.m4])
+m4_include([gnulib/m4/stpcpy.m4])
+m4_include([gnulib/m4/stpncpy.m4])
+m4_include([gnulib/m4/string_h.m4])
+m4_include([gnulib/m4/strndup.m4])
+m4_include([gnulib/m4/strnlen.m4])
+m4_include([gnulib/m4/strstr.m4])
+m4_include([gnulib/m4/symlink.m4])
+m4_include([gnulib/m4/sys_stat_h.m4])
+m4_include([gnulib/m4/sys_wait_h.m4])
+m4_include([gnulib/m4/thread.m4])
+m4_include([gnulib/m4/threadlib.m4])
+m4_include([gnulib/m4/time_h.m4])
+m4_include([gnulib/m4/unistd_h.m4])
+m4_include([gnulib/m4/vasnprintf.m4])
+m4_include([gnulib/m4/vasprintf.m4])
+m4_include([gnulib/m4/warn-on-use.m4])
+m4_include([gnulib/m4/wchar_h.m4])
+m4_include([gnulib/m4/wchar_t.m4])
+m4_include([gnulib/m4/wcrtomb.m4])
+m4_include([gnulib/m4/wctob.m4])
+m4_include([gnulib/m4/wctomb.m4])
+m4_include([gnulib/m4/wctype_h.m4])
+m4_include([gnulib/m4/wint_t.m4])
+m4_include([gnulib/m4/xsize.m4])
+m4_include([gnulib/m4/yield.m4])
+m4_include([acinclude.m4])
diff --git a/augeas.pc.in b/augeas.pc.in
new file mode 100644 (file)
index 0000000..c97847d
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: augeas
+Version: @VERSION@
+Description: Augeas configuration editing library
+Requires:
+Libs: -L${libdir} -laugeas @LIBS@
+Cflags: -I${includedir}
diff --git a/augeas.spec b/augeas.spec
new file mode 100644 (file)
index 0000000..d06db2a
--- /dev/null
@@ -0,0 +1,143 @@
+Name:           augeas
+Version:        0.8.1
+Release:        1%{?dist}
+Summary:        A library for changing configuration files
+
+Group:          System Environment/Libraries
+License:        LGPLv2+
+URL:            http://augeas.net/
+Source0:        http://augeas.net/download/%{name}-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires:  readline-devel libselinux-devel
+Requires:       %{name}-libs = %{version}-%{release}
+
+%description
+A library for programmatically editing configuration files. Augeas parses
+configuration files into a tree structure, which it exposes through its
+public API. Changes made through the API are written back to the initially
+read files.
+
+The transformation works very hard to preserve comments and formatting
+details. It is controlled by ``lens'' definitions that describe the file
+format and the transformation into a tree.
+
+%package        devel
+Summary:        Development files for %{name}
+Group:          Development/Libraries
+Requires:       %{name}-libs = %{version}-%{release}
+Requires:       pkgconfig
+
+%description    devel
+The %{name}-devel package contains libraries and header files for
+developing applications that use %{name}.
+
+
+%package        libs
+Summary:        Libraries for %{name}
+Group:          System Environment/Libraries
+
+%description    libs
+The libraries for %{name}.
+
+
+%prep
+%setup -q
+
+%build
+%configure --disable-static
+make %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p"
+find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post libs -p /sbin/ldconfig
+
+%postun libs -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/augtool
+%{_bindir}/augparse
+%{_bindir}/fadot
+%doc %{_mandir}/man1/*
+%{_datadir}/vim/vimfiles/syntax/augeas.vim
+%{_datadir}/vim/vimfiles/ftdetect/augeas.vim
+
+%files libs
+%defattr(-,root,root,-)
+# %{_datadir}/augeas and %{_datadir}/augeas/lenses are owned
+# by filesystem.
+%{_datadir}/augeas/lenses/dist
+%{_libdir}/*.so.*
+%doc AUTHORS COPYING NEWS
+
+%files devel
+%defattr(-,root,root,-)
+%doc
+%{_includedir}/*
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/augeas.pc
+
+%changelog
+* Fri Apr 15 2011 David Lutterkort <lutter@redhat.com> - 0.8.1-1
+- New version
+
+* Tue Feb 22 2011 David Lutterkort <lutter@redhat.com> - 0.8.0-1
+- New version
+
+* Fri Nov 19 2010 David Lutterkort <lutter@redhat.com> - 0.7.4-1
+- New version
+
+* Fri Aug  6 2010 David Lutterkort <lutter@redhat.com> - 0.7.3-1
+- New version
+
+* Tue Jun 22 2010 David Lutterkort <lutter@redhat.com> - 0.7.2-1
+- Fix ownership of /usr/share/augeas. BZ 569393
+
+* Wed Apr 21 2010 David Lutterkort <lutter@redhat.com> - 0.7.1-1
+- New version
+
+* Thu Jan 14 2010 David Lutterkort <lutter@redhat.com> - 0.7.0-1
+- New version
+
+* Mon Nov 30 2009 David Lutterkort <lutter@redhat.com> - 0.6.0-1
+- Install vim syntax files
+
+* Mon Sep 14 2009 David Lutterkort <lutter@redhat.com> - 0.5.3-1
+- New version
+
+* Mon Jul 13 2009 David Lutterkort <lutter@redhat.com> - 0.5.2-1
+- New version
+
+* Fri Jun  5 2009 David Lutterkort <lutter@redhat.com> - 0.5.1-1
+- Install fadot
+
+* Fri Mar 27 2009 David Lutterkort <lutter@redhat.com> - 0.5.0-2
+- fadot isn't being installed just yet
+
+* Tue Mar 24 2009 David Lutterkort <lutter@redhat.com> - 0.5.0-1
+- New program /usr/bin/fadot
+
+* Mon Mar  9 2009 David Lutterkort <lutter@redhat.com> - 0.4.2-1
+- New version
+
+* Fri Feb 27 2009 David Lutterkort <lutter@redhat.com> - 0.4.1-1
+- New version
+
+* Fri Feb  6 2009 David Lutterkort <lutter@redhat.com> - 0.4.0-1
+- New version
+
+* Mon Jan 26 2009 David Lutterkort <lutter@redhat.com> - 0.3.6-1
+- New version
+
+* Tue Dec 23 2008 David Lutterkort <lutter@redhat.com> - 0.3.5-1
+- New version
+
+* Mon Feb 25 2008 David Lutterkort <dlutter@redhat.com> - 0.0.4-1
+- Initial specfile
diff --git a/augeas.spec.in b/augeas.spec.in
new file mode 100644 (file)
index 0000000..d60ba95
--- /dev/null
@@ -0,0 +1,143 @@
+Name:           augeas
+Version:        @VERSION@
+Release:        1%{?dist}
+Summary:        A library for changing configuration files
+
+Group:          System Environment/Libraries
+License:        LGPLv2+
+URL:            http://augeas.net/
+Source0:        http://augeas.net/download/%{name}-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires:  readline-devel libselinux-devel
+Requires:       %{name}-libs = %{version}-%{release}
+
+%description
+A library for programmatically editing configuration files. Augeas parses
+configuration files into a tree structure, which it exposes through its
+public API. Changes made through the API are written back to the initially
+read files.
+
+The transformation works very hard to preserve comments and formatting
+details. It is controlled by ``lens'' definitions that describe the file
+format and the transformation into a tree.
+
+%package        devel
+Summary:        Development files for %{name}
+Group:          Development/Libraries
+Requires:       %{name}-libs = %{version}-%{release}
+Requires:       pkgconfig
+
+%description    devel
+The %{name}-devel package contains libraries and header files for
+developing applications that use %{name}.
+
+
+%package        libs
+Summary:        Libraries for %{name}
+Group:          System Environment/Libraries
+
+%description    libs
+The libraries for %{name}.
+
+
+%prep
+%setup -q
+
+%build
+%configure --disable-static
+make %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p"
+find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post libs -p /sbin/ldconfig
+
+%postun libs -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/augtool
+%{_bindir}/augparse
+%{_bindir}/fadot
+%doc %{_mandir}/man1/*
+%{_datadir}/vim/vimfiles/syntax/augeas.vim
+%{_datadir}/vim/vimfiles/ftdetect/augeas.vim
+
+%files libs
+%defattr(-,root,root,-)
+# %{_datadir}/augeas and %{_datadir}/augeas/lenses are owned
+# by filesystem.
+%{_datadir}/augeas/lenses/dist
+%{_libdir}/*.so.*
+%doc AUTHORS COPYING NEWS
+
+%files devel
+%defattr(-,root,root,-)
+%doc
+%{_includedir}/*
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/augeas.pc
+
+%changelog
+* Fri Apr 15 2011 David Lutterkort <lutter@redhat.com> - 0.8.1-1
+- New version
+
+* Tue Feb 22 2011 David Lutterkort <lutter@redhat.com> - 0.8.0-1
+- New version
+
+* Fri Nov 19 2010 David Lutterkort <lutter@redhat.com> - 0.7.4-1
+- New version
+
+* Fri Aug  6 2010 David Lutterkort <lutter@redhat.com> - 0.7.3-1
+- New version
+
+* Tue Jun 22 2010 David Lutterkort <lutter@redhat.com> - 0.7.2-1
+- Fix ownership of /usr/share/augeas. BZ 569393
+
+* Wed Apr 21 2010 David Lutterkort <lutter@redhat.com> - 0.7.1-1
+- New version
+
+* Thu Jan 14 2010 David Lutterkort <lutter@redhat.com> - 0.7.0-1
+- New version
+
+* Mon Nov 30 2009 David Lutterkort <lutter@redhat.com> - 0.6.0-1
+- Install vim syntax files
+
+* Mon Sep 14 2009 David Lutterkort <lutter@redhat.com> - 0.5.3-1
+- New version
+
+* Mon Jul 13 2009 David Lutterkort <lutter@redhat.com> - 0.5.2-1
+- New version
+
+* Fri Jun  5 2009 David Lutterkort <lutter@redhat.com> - 0.5.1-1
+- Install fadot
+
+* Fri Mar 27 2009 David Lutterkort <lutter@redhat.com> - 0.5.0-2
+- fadot isn't being installed just yet
+
+* Tue Mar 24 2009 David Lutterkort <lutter@redhat.com> - 0.5.0-1
+- New program /usr/bin/fadot
+
+* Mon Mar  9 2009 David Lutterkort <lutter@redhat.com> - 0.4.2-1
+- New version
+
+* Fri Feb 27 2009 David Lutterkort <lutter@redhat.com> - 0.4.1-1
+- New version
+
+* Fri Feb  6 2009 David Lutterkort <lutter@redhat.com> - 0.4.0-1
+- New version
+
+* Mon Jan 26 2009 David Lutterkort <lutter@redhat.com> - 0.3.6-1
+- New version
+
+* Tue Dec 23 2008 David Lutterkort <lutter@redhat.com> - 0.3.5-1
+- New version
+
+* Mon Feb 25 2008 David Lutterkort <dlutter@redhat.com> - 0.0.4-1
+- Initial specfile
diff --git a/build/aux/arg-nonnull.h b/build/aux/arg-nonnull.h
new file mode 100644 (file)
index 0000000..6c2f1e8
--- /dev/null
@@ -0,0 +1,26 @@
+/* A C macro for declaring that specific arguments must not be NULL.
+   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/>.  */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+   that the values passed as arguments n, ..., m must be non-NULL pointers.
+   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
+#ifndef _GL_ARG_NONNULL
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
+#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+#  define _GL_ARG_NONNULL(params)
+# endif
+#endif
diff --git a/build/aux/c++defs.h b/build/aux/c++defs.h
new file mode 100644 (file)
index 0000000..b6821a6
--- /dev/null
@@ -0,0 +1,271 @@
+/* C++ compatible function declaration macros.
+   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/>.  */
+
+#ifndef _GL_CXXDEFS_H
+#define _GL_CXXDEFS_H
+
+/* The three most frequent use cases of these macros are:
+
+   * For providing a substitute for a function that is missing on some
+     platforms, but is declared and works fine on the platforms on which
+     it exists:
+
+       #if @GNULIB_FOO@
+       # if !@HAVE_FOO@
+       _GL_FUNCDECL_SYS (foo, ...);
+       # endif
+       _GL_CXXALIAS_SYS (foo, ...);
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+
+   * For providing a replacement for a function that exists on all platforms,
+     but is broken/insufficient and needs to be replaced on some platforms:
+
+       #if @GNULIB_FOO@
+       # if @REPLACE_FOO@
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+       #   undef foo
+       #   define foo rpl_foo
+       #  endif
+       _GL_FUNCDECL_RPL (foo, ...);
+       _GL_CXXALIAS_RPL (foo, ...);
+       # else
+       _GL_CXXALIAS_SYS (foo, ...);
+       # endif
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+
+   * For providing a replacement for a function that exists on some platforms
+     but is broken/insufficient and needs to be replaced on some of them and
+     is additionally either missing or undeclared on some other platforms:
+
+       #if @GNULIB_FOO@
+       # if @REPLACE_FOO@
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+       #   undef foo
+       #   define foo rpl_foo
+       #  endif
+       _GL_FUNCDECL_RPL (foo, ...);
+       _GL_CXXALIAS_RPL (foo, ...);
+       # else
+       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
+       _GL_FUNCDECL_SYS (foo, ...);
+       #  endif
+       _GL_CXXALIAS_SYS (foo, ...);
+       # endif
+       _GL_CXXALIASWARN (foo);
+       #elif defined GNULIB_POSIXCHECK
+       ...
+       #endif
+*/
+
+/* _GL_EXTERN_C declaration;
+   performs the declaration with C linkage.  */
+#if defined __cplusplus
+# define _GL_EXTERN_C extern "C"
+#else
+# define _GL_EXTERN_C extern
+#endif
+
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
+   declares a replacement function, named rpl_func, with the given prototype,
+   consisting of return type, parameters, and attributes.
+   Example:
+     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+                                  _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
+  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
+  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
+
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
+   declares the system function, named func, with the given prototype,
+   consisting of return type, parameters, and attributes.
+   Example:
+     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
+                                  _GL_ARG_NONNULL ((1)));
+ */
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
+  _GL_EXTERN_C rettype func parameters_and_attributes
+
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
+   declares a C++ alias called GNULIB_NAMESPACE::func
+   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
+   Example:
+     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+ */
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
+  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                                \
+    {                                                         \
+      rettype (*const func) parameters = ::rpl_func;          \
+    }                                                         \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+   except that the C function rpl_func may have a slightly different
+   declaration.  A cast is used to silence the "invalid conversion" error
+   that would otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                                     \
+    {                                                              \
+      rettype (*const func) parameters =                           \
+        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
+    }                                                              \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
+   declares a C++ alias called GNULIB_NAMESPACE::func
+   that redirects to the system provided function func, if GNULIB_NAMESPACE
+   is defined.
+   Example:
+     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+ */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+  /* If we were to write
+       rettype (*const func) parameters = ::func;
+     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
+     better (remove an indirection through a 'static' pointer variable),
+     but then the _GL_CXXALIASWARN macro below would cause a warning not only
+     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                     \
+    {                                              \
+      static rettype (*func) parameters = ::func;  \
+    }                                              \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
+   except that the C function func may have a slightly different declaration.
+   A cast is used to silence the "invalid conversion" error that would
+   otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                          \
+    {                                                   \
+      static rettype (*func) parameters =               \
+        reinterpret_cast<rettype(*)parameters>(::func); \
+    }                                                   \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
+   except that the C function is picked among a set of overloaded functions,
+   namely the one with rettype2 and parameters2.  Two consecutive casts
+   are used to silence the "cannot find a match" and "invalid conversion"
+   errors that would otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+  /* The outer cast must be a reinterpret_cast.
+     The inner cast: When the function is defined as a set of overloaded
+     functions, it works as a static_cast<>, choosing the designated variant.
+     When the function is defined as a single variant, it works as a
+     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+    namespace GNULIB_NAMESPACE                                                \
+    {                                                                         \
+      static rettype (*func) parameters =                                     \
+        reinterpret_cast<rettype(*)parameters>(                               \
+          (rettype2(*)parameters2)(::func));                                  \
+    }                                                                         \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN (func);
+   causes a warning to be emitted when ::func is used but not when
+   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
+   variants.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN(func) \
+   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN_1(func,namespace) \
+   _GL_CXXALIASWARN_2 (func, namespace)
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+   we enable the warning only when not optimizing.  */
+# if !__OPTIMIZE__
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+    _GL_WARN_ON_USE (func, \
+                     "The symbol ::" #func " refers to the system function. " \
+                     "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+     extern __typeof__ (func) func
+# else
+#  define _GL_CXXALIASWARN_2(func,namespace) \
+     _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN(func) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
+   causes a warning to be emitted when the given overloaded variant of ::func
+   is used but not when GNULIB_NAMESPACE::func is used.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
+                        GNULIB_NAMESPACE)
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
+   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+   we enable the warning only when not optimizing.  */
+# if !__OPTIMIZE__
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
+                         "The symbol ::" #func " refers to the system function. " \
+                         "Use " #namespace "::" #func " instead.")
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+     extern __typeof__ (func) func
+# else
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
+     _GL_EXTERN_C int _gl_cxxalias_dummy
+# endif
+#else
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
+#endif /* _GL_CXXDEFS_H */
diff --git a/build/aux/config.guess b/build/aux/config.guess
new file mode 100755 (executable)
index 0000000..0e30d56
--- /dev/null
@@ -0,0 +1,1407 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-07-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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit 0 ;;
+    amiga:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    arc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    hp300:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mac68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    macppc:OpenBSD:*:*)
+       echo powerpc-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+       echo m88k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvmeppc:OpenBSD:*:*)
+       echo powerpc-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    pmax:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sgi:OpenBSD:*:*)
+       echo mipseb-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sun3:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    *:OpenBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    alpha:OSF1:*:*)
+       if test $UNAME_RELEASE = "V4.0"; then
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+       fi
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit 0 ;;
+    Alpha*:OpenVMS:*:*)
+       echo alpha-hp-vms
+       exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit 0 ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit 0;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit 0 ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit 0 ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit 0;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit 0 ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit 0 ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit 0 ;;
+    DRS?6000:UNIX_SV:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7 && exit 0 ;;
+       esac ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit 0 ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit 0 ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # 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}
+       exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit 0 ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit 0 ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c \
+         && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+         && exit 0
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit 0 ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit 0 ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit 0 ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit 0 ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit 0 ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    AViiON:dgux:*:*)
+        # 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 ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit 0 ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit 0 ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit 0 ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+       exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit 0 ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+               echo rs6000-ibm-aix3.2.5
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit 0 ;;
+    *:AIX:*:[45])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           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" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #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);
+
+                  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
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           # avoid double evaluation of $set_cc_for_build
+           test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+       echo unknown-hitachi-hiuxwe2
+       exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit 0 ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit 0 ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit 0 ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit 0 ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    *:UNICOS/mp:*:*)
+       echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 
+       exit 0 ;;
+    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 0 ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
+       # Determine whether the default compiler uses glibc.
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #if __GLIBC__ >= 2
+       LIBC=gnu
+       #else
+       LIBC=
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+       # GNU/FreeBSD systems have a "k" prefix to indicate we are using
+       # FreeBSD's kernel, but not the complete OS.
+       case ${LIBC} in gnu) kernel_only='k' ;; esac
+       echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+       exit 0 ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit 0 ;;
+    i*:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit 0 ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit 0 ;;
+    x86:Interix*:[34]*)
+       echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+       exit 0 ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit 0 ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit 0 ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit 0 ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    *:GNU:*:*)
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit 0 ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit 0 ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit 0 ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    mips:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips
+       #undef mipsel
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mipsel
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+       ;;
+    mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips64
+       #undef mips64el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mips64el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips64
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+       ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit 0 ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit 0 ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit 0 ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit 0 ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       # Set LC_ALL=C to ensure ld outputs messages in English.
+       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit 0 ;;
+         coff-i386)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit 0 ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit 0 ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #ifdef __ELF__
+       # ifdef __GLIBC__
+       #  if __GLIBC__ >= 2
+       LIBC=gnu
+       #  else
+       LIBC=gnulibc1
+       #  endif
+       # else
+       LIBC=gnulibc1
+       # endif
+       #else
+       #ifdef __INTEL_COMPILER
+       LIBC=gnu
+       #else
+       LIBC=gnuaout
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+       test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+       test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit 0 ;;
+    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,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit 0 ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit 0 ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit 0 ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit 0 ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit 0 ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit 0 ;;
+    i*86:*:5:[78]*)
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit 0 ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit 0 ;;
+    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 i386.
+       echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit 0 ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit 0 ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit 0 ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit 0 ;;
+    M68*:*:R3V[567]*:*)
+       test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit 0 ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit 0 ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit 0 ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit 0 ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit 0 ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit 0 ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit 0 ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit 0 ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit 0 ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit 0 ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit 0 ;;
+    *:Darwin:*:*)
+       case `uname -p` in
+           *86) UNAME_PROCESSOR=i686 ;;
+           powerpc) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit 0 ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit 0 ;;
+    NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit 0 ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit 0 ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit 0 ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit 0 ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit 0 ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit 0 ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit 0 ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit 0 ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit 0 ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit 0 ;;
+    c34*)
+       echo c34-convex-bsd
+       exit 0 ;;
+    c38*)
+       echo c38-convex-bsd
+       exit 0 ;;
+    c4*)
+       echo c4-convex-bsd
+       exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/build/aux/config.rpath b/build/aux/config.rpath
new file mode 100755 (executable)
index 0000000..8bd7f5d
--- /dev/null
@@ -0,0 +1,690 @@
+#! /bin/sh
+# Output a system dependent set of variables, describing how to set the
+# run time search path of shared libraries in an executable.
+#
+#   Copyright 1996-2011 Free Software Foundation, Inc.
+#   Taken from GNU libtool, 2001
+#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+#   This file is free software; the Free Software Foundation gives
+#   unlimited permission to copy and/or distribute it, with or without
+#   modifications, as long as this notice is preserved.
+#
+# The first argument passed to this file is the canonical host specification,
+#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# should be set by the caller.
+#
+# The set of defined variables is at the end of this script.
+
+# Known limitations:
+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
+#   than 256 bytes, otherwise the compiler driver will dump core. The only
+#   known workaround is to choose shorter directory names for the build
+#   directory and/or the installation directory.
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+shrext=.so
+
+host="$1"
+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# Code taken from libtool.m4's _LT_CC_BASENAME.
+
+for cc_temp in $CC""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
+
+# Code taken from libtool.m4's _LT_COMPILER_PIC.
+
+wl=
+if test "$GCC" = yes; then
+  wl='-Wl,'
+else
+  case "$host_os" in
+    aix*)
+      wl='-Wl,'
+      ;;
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      ;;
+    hpux9* | hpux10* | hpux11*)
+      wl='-Wl,'
+      ;;
+    irix5* | irix6* | nonstopux*)
+      wl='-Wl,'
+      ;;
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+        ecc*)
+          wl='-Wl,'
+          ;;
+        icc* | ifort*)
+          wl='-Wl,'
+          ;;
+        lf95*)
+          wl='-Wl,'
+          ;;
+        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,'
+              ;;
+          esac
+          ;;
+      esac
+      ;;
+    newsos6)
+      ;;
+    *nto* | *qnx*)
+      ;;
+    osf3* | osf4* | osf5*)
+      wl='-Wl,'
+      ;;
+    rdos*)
+      ;;
+    solaris*)
+      case $cc_basename in
+        f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+          wl='-Qoption ld '
+          ;;
+        *)
+          wl='-Wl,'
+          ;;
+      esac
+      ;;
+    sunos4*)
+      wl='-Qoption ld '
+      ;;
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      wl='-Wl,'
+      ;;
+    sysv4*MP*)
+      ;;
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      wl='-Wl,'
+      ;;
+    unicos*)
+      wl='-Wl,'
+      ;;
+    uts4*)
+      ;;
+  esac
+fi
+
+# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
+
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+
+case "$host_os" in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # Set some defaults for GNU ld with shared library support. These
+  # are reset later if shared libraries are not supported. Putting them
+  # here allows them to be overridden if necessary.
+  # Unlike libtool, we use -rpath here, not --rpath, since the documented
+  # option of GNU ld is called -rpath, not --rpath.
+  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+  case "$host_os" in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+        ld_shlibs=no
+      fi
+      ;;
+    amigaos*)
+      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
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    cygwin* | mingw* | pw32* | cegcc*)
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    haiku*)
+      ;;
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      ;;
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    netbsd*)
+      ;;
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+        ld_shlibs=no
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+          ld_shlibs=no
+          ;;
+        *)
+          if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+            hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+          else
+            ld_shlibs=no
+          fi
+          ;;
+      esac
+      ;;
+    sunos4*)
+      hardcode_direct=yes
+      ;;
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+  esac
+  if test "$ld_shlibs" = no; then
+    hardcode_libdir_flag_spec=
+  fi
+else
+  case "$host_os" in
+    aix3*)
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes; then
+        # Neither direct hardcoding nor static linking is supported with a
+        # broken collect2.
+        hardcode_direct=unsupported
+      fi
+      ;;
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+        # On IA64, the linker does run time linking by default, so we don't
+        # have to do anything special.
+        aix_use_runtimelinking=no
+      else
+        aix_use_runtimelinking=no
+        # Test if we are trying to use run time linking or normal
+        # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+        # need to do runtime linking.
+        case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+          for ld_flag in $LDFLAGS; do
+            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+              aix_use_runtimelinking=yes
+              break
+            fi
+          done
+          ;;
+        esac
+      fi
+      hardcode_direct=yes
+      hardcode_libdir_separator=':'
+      if test "$GCC" = yes; then
+        case $host_os in aix4.[012]|aix4.[012].*)
+          collect2name=`${CC} -print-prog-name=collect2`
+          if test -f "$collect2name" && \
+            strings "$collect2name" | grep resolve_lib_name >/dev/null
+          then
+            # We have reworked collect2
+            :
+          else
+            # We have old collect2
+            hardcode_direct=unsupported
+            hardcode_minus_L=yes
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_libdir_separator=
+          fi
+          ;;
+        esac
+      fi
+      # Begin _LT_AC_SYS_LIBPATH_AIX.
+      echo 'int main () { return 0; }' > conftest.c
+      ${CC} ${LDFLAGS} conftest.c -o conftest
+      aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+      if test -z "$aix_libpath"; then
+        aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+      fi
+      if test -z "$aix_libpath"; then
+        aix_libpath="/usr/lib:/lib"
+      fi
+      rm -f conftest.c conftest
+      # End _LT_AC_SYS_LIBPATH_AIX.
+      if test "$aix_use_runtimelinking" = yes; then
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+      else
+        if test "$host_cpu" = ia64; then
+          hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+        else
+          hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        fi
+      fi
+      ;;
+    amigaos*)
+      case "$host_cpu" in
+        powerpc)
+          ;;
+        m68k)
+          hardcode_libdir_flag_spec='-L$libdir'
+          hardcode_minus_L=yes
+          ;;
+      esac
+      ;;
+    bsdi[45]*)
+      ;;
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      libext=lib
+      ;;
+    darwin* | rhapsody*)
+      hardcode_direct=no
+      if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    dgux*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      ;;
+    freebsd2.2*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    freebsd2*)
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      ;;
+    freebsd* | dragonfly*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    hpux9*)
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      ;;
+    hpux10*)
+      if test "$with_gnu_ld" = no; then
+        hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator=:
+        hardcode_direct=yes
+        # hardcode_minus_L: Not really in the search PATH,
+        # but as the default location of the library.
+        hardcode_minus_L=yes
+      fi
+      ;;
+    hpux11*)
+      if test "$with_gnu_ld" = no; then
+        hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator=:
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct=no
+            ;;
+          *)
+            hardcode_direct=yes
+            # hardcode_minus_L: Not really in the search PATH,
+            # but as the default location of the library.
+            hardcode_minus_L=yes
+            ;;
+        esac
+      fi
+      ;;
+    irix5* | irix6* | nonstopux*)
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    netbsd*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    newsos6)
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    *nto* | *qnx*)
+      ;;
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+        hardcode_direct=yes
+        if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+          hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+        else
+          case "$host_os" in
+            openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+              hardcode_libdir_flag_spec='-R$libdir'
+              ;;
+            *)
+              hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+              ;;
+          esac
+        fi
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      ;;
+    osf3*)
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    osf4* | osf5*)
+      if test "$GCC" = yes; then
+        hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+        # Both cc and cxx compiler support -rpath directly
+        hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      hardcode_libdir_separator=:
+      ;;
+    solaris*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      ;;
+    sunos4*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      ;;
+    sysv4)
+      case $host_vendor in
+        sni)
+          hardcode_direct=yes # is this really true???
+          ;;
+        siemens)
+          hardcode_direct=no
+          ;;
+        motorola)
+          hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+          ;;
+      esac
+      ;;
+    sysv4.3*)
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+        ld_shlibs=yes
+      fi
+      ;;
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      ;;
+    sysv5* | sco3.2v5* | sco5v6*)
+      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator=':'
+      ;;
+    uts4*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      ;;
+    *)
+      ld_shlibs=no
+      ;;
+  esac
+fi
+
+# Check dynamic linker characteristics
+# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
+# Unlike libtool.m4, here we don't care about _all_ names of the library, but
+# only about the one the linker finds when passed -lNAME. This is the last
+# element of library_names_spec in libtool.m4, or possibly two of them if the
+# linker has special search rules.
+library_names_spec=      # the last element of library_names_spec in libtool.m4
+libname_spec='lib$name'
+case "$host_os" in
+  aix3*)
+    library_names_spec='$libname.a'
+    ;;
+  aix[4-9]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  amigaos*)
+    case "$host_cpu" in
+      powerpc*)
+        library_names_spec='$libname$shrext' ;;
+      m68k)
+        library_names_spec='$libname.a' ;;
+    esac
+    ;;
+  beos*)
+    library_names_spec='$libname$shrext'
+    ;;
+  bsdi[45]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  cygwin* | mingw* | pw32* | cegcc*)
+    shrext=.dll
+    library_names_spec='$libname.dll.a $libname.lib'
+    ;;
+  darwin* | rhapsody*)
+    shrext=.dylib
+    library_names_spec='$libname$shrext'
+    ;;
+  dgux*)
+    library_names_spec='$libname$shrext'
+    ;;
+  freebsd* | dragonfly*)
+    case "$host_os" in
+      freebsd[123]*)
+        library_names_spec='$libname$shrext$versuffix' ;;
+      *)
+        library_names_spec='$libname$shrext' ;;
+    esac
+    ;;
+  gnu*)
+    library_names_spec='$libname$shrext'
+    ;;
+  haiku*)
+    library_names_spec='$libname$shrext'
+    ;;
+  hpux9* | hpux10* | hpux11*)
+    case $host_cpu in
+      ia64*)
+        shrext=.so
+        ;;
+      hppa*64*)
+        shrext=.sl
+        ;;
+      *)
+        shrext=.sl
+        ;;
+    esac
+    library_names_spec='$libname$shrext'
+    ;;
+  interix[3-9]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  irix5* | irix6* | nonstopux*)
+    library_names_spec='$libname$shrext'
+    case "$host_os" in
+      irix5* | nonstopux*)
+        libsuff= shlibsuff=
+        ;;
+      *)
+        case $LD in
+          *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
+          *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
+          *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
+          *) libsuff= shlibsuff= ;;
+        esac
+        ;;
+    esac
+    ;;
+  linux*oldld* | linux*aout* | linux*coff*)
+    ;;
+  linux* | k*bsd*-gnu | kopensolaris*-gnu)
+    library_names_spec='$libname$shrext'
+    ;;
+  knetbsd*-gnu)
+    library_names_spec='$libname$shrext'
+    ;;
+  netbsd*)
+    library_names_spec='$libname$shrext'
+    ;;
+  newsos6)
+    library_names_spec='$libname$shrext'
+    ;;
+  *nto* | *qnx*)
+    library_names_spec='$libname$shrext'
+    ;;
+  openbsd*)
+    library_names_spec='$libname$shrext$versuffix'
+    ;;
+  os2*)
+    libname_spec='$name'
+    shrext=.dll
+    library_names_spec='$libname.a'
+    ;;
+  osf3* | osf4* | osf5*)
+    library_names_spec='$libname$shrext'
+    ;;
+  rdos*)
+    ;;
+  solaris*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sunos4*)
+    library_names_spec='$libname$shrext$versuffix'
+    ;;
+  sysv4 | sysv4.3*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sysv4*MP*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+    library_names_spec='$libname$shrext'
+    ;;
+  tpf*)
+    library_names_spec='$libname$shrext'
+    ;;
+  uts4*)
+    library_names_spec='$libname$shrext'
+    ;;
+esac
+
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+
+LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
+
+# How to pass a linker flag through the compiler.
+wl="$escaped_wl"
+
+# Static library suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally "so").
+shlibext="$shlibext"
+
+# Format of library name prefix.
+libname_spec="$escaped_libname_spec"
+
+# Library names that the linker finds when passed -lNAME.
+library_names_spec="$escaped_library_names_spec"
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator="$hardcode_libdir_separator"
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct="$hardcode_direct"
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L="$hardcode_minus_L"
+
+EOF
diff --git a/build/aux/config.sub b/build/aux/config.sub
new file mode 100755 (executable)
index 0000000..9d7f733
--- /dev/null
@@ -0,0 +1,1504 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-07-04'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k \
+       | m32r | m68000 | m68k | m88k | mcore \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64vr | mips64vrel \
+       | mips64orion | mips64orionel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | msp430 \
+       | ns16k | ns32k \
+       | openrisc | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+       | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xscale | xstormy16 | xtensa \
+       | z8k)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | amd64-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* \
+       | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* \
+       | m32r-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | mcore-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | msp430-* \
+       | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+       | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tron-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+       | xtensa-* \
+       | ymp-* \
+       | z8k-*)
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       mmix*)
+               basic_machine=mmix-knuth
+               os=-mmixware
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nv1)
+               basic_machine=nv1-cray
+               os=-unicosmp
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       or32 | or32-*)
+               basic_machine=or32-unknown
+               os=-coff
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparc | sparcv9 | sparcv9b)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
+             | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+    c4x-* | tic4x-*)
+        os=-coff
+        ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/build/aux/depcomp b/build/aux/depcomp
new file mode 100755 (executable)
index 0000000..df8eea7
--- /dev/null
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
+    echo >> "$depfile"
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[     ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${
+              s/^ *//
+              s/ \\*$//
+              s/$/:/
+              p
+            }' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::     \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/build/aux/gitlog-to-changelog b/build/aux/gitlog-to-changelog
new file mode 100755 (executable)
index 0000000..4559704
--- /dev/null
@@ -0,0 +1,191 @@
+eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
+  & eval 'exec perl -wS "$0" $argv:q'
+    if 0;
+# Convert git log output to ChangeLog format.
+
+my $VERSION = '2009-10-30 13:46'; # UTC
+# The definition above must lie within the first 8 lines in order
+# for the Emacs time-stamp write hook (at end) to update it.
+# If you change this file with Emacs, please let the write hook
+# do its job.  Otherwise, update this string manually.
+
+# 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/>.
+
+# Written by Jim Meyering
+
+use strict;
+use warnings;
+use Getopt::Long;
+use POSIX qw(strftime);
+
+(my $ME = $0) =~ s|.*/||;
+
+# use File::Coda; # http://meyering.net/code/Coda/
+END {
+  defined fileno STDOUT or return;
+  close STDOUT and return;
+  warn "$ME: failed to close standard output: $!\n";
+  $? ||= 1;
+}
+
+sub usage ($)
+{
+  my ($exit_code) = @_;
+  my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
+  if ($exit_code != 0)
+    {
+      print $STREAM "Try `$ME --help' for more information.\n";
+    }
+  else
+    {
+      print $STREAM <<EOF;
+Usage: $ME [OPTIONS] [ARGS]
+
+Convert git log output to ChangeLog format.  If present, any ARGS
+are passed to "git log".  To avoid ARGS being parsed as options to
+$ME, they may be preceded by '--'.
+
+OPTIONS:
+
+   --since=DATE convert only the logs since DATE;
+                  the default is to convert all log entries.
+   --format=FMT set format string for commit subject and body;
+                  see 'man git-log' for the list of format metacharacters;
+                  the default is '%s%n%b%n'
+
+   --help       display this help and exit
+   --version    output version information and exit
+
+EXAMPLE:
+
+  $ME --since=2008-01-01 > ChangeLog
+  $ME -- -n 5 foo > last-5-commits-to-branch-foo
+
+EOF
+    }
+  exit $exit_code;
+}
+
+# If the string $S is a well-behaved file name, simply return it.
+# If it contains white space, quotes, etc., quote it, and return the new string.
+sub shell_quote($)
+{
+  my ($s) = @_;
+  if ($s =~ m![^\w+/.,-]!)
+    {
+      # Convert each single quote to '\''
+      $s =~ s/\'/\'\\\'\'/g;
+      # Then single quote the string.
+      $s = "'$s'";
+    }
+  return $s;
+}
+
+sub quoted_cmd(@)
+{
+  return join (' ', map {shell_quote $_} @_);
+}
+
+{
+  my $since_date = '1970-01-01 UTC';
+  my $format_string = '%s%n%b%n';
+  GetOptions
+    (
+     help => sub { usage 0 },
+     version => sub { print "$ME version $VERSION\n"; exit },
+     'since=s' => \$since_date,
+     'format=s' => \$format_string,
+    ) or usage 1;
+
+  my @cmd = (qw (git log --log-size), "--since=$since_date",
+             '--pretty=format:%ct  %an  <%ae>%n%n'.$format_string, @ARGV);
+  open PIPE, '-|', @cmd
+    or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
+            . "(Is your Git too old?  Version 1.5.1 or later is required.)\n");
+
+  my $prev_date_line = '';
+  while (1)
+    {
+      defined (my $in = <PIPE>)
+        or last;
+      $in =~ /^log size (\d+)$/
+        or die "$ME:$.: Invalid line (expected log size):\n$in";
+      my $log_nbytes = $1;
+
+      my $log;
+      my $n_read = read PIPE, $log, $log_nbytes;
+      $n_read == $log_nbytes
+        or die "$ME:$.: unexpected EOF\n";
+
+      my @line = split "\n", $log;
+      my $author_line = shift @line;
+      defined $author_line
+        or die "$ME:$.: unexpected EOF\n";
+      $author_line =~ /^(\d+)  (.*>)$/
+        or die "$ME:$.: Invalid line "
+          . "(expected date/author/email):\n$author_line\n";
+
+      my $date_line = sprintf "%s  $2\n", strftime ("%F", localtime ($1));
+      # If this line would be the same as the previous date/name/email
+      # line, then arrange not to print it.
+      if ($date_line ne $prev_date_line)
+        {
+          $prev_date_line eq ''
+            or print "\n";
+          print $date_line;
+        }
+      $prev_date_line = $date_line;
+
+      # Omit "Signed-off-by..." lines.
+      @line = grep !/^Signed-off-by: .*>$/, @line;
+
+      # If there were any lines
+      if (@line == 0)
+        {
+          warn "$ME: warning: empty commit message:\n  $date_line\n";
+        }
+      else
+        {
+          # Remove leading and trailing blank lines.
+          while ($line[0] =~ /^\s*$/) { shift @line; }
+          while ($line[$#line] =~ /^\s*$/) { pop @line; }
+
+          # Prefix each non-empty line with a TAB.
+          @line = map { length $_ ? "\t$_" : '' } @line;
+
+          print "\n", join ("\n", @line), "\n";
+        }
+
+      defined ($in = <PIPE>)
+        or last;
+      $in ne "\n"
+        and die "$ME:$.: unexpected line:\n$in";
+    }
+
+  close PIPE
+    or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
+  # FIXME-someday: include $PROCESS_STATUS in the diagnostic
+}
+
+# Local Variables:
+# mode: perl
+# indent-tabs-mode: nil
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "my $VERSION = '"
+# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "'; # UTC"
+# End:
diff --git a/build/aux/install-sh b/build/aux/install-sh
new file mode 100755 (executable)
index 0000000..6781b98
--- /dev/null
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""       $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+       shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+       case $mode in
+         *' '* | *'    '* | *'
+'*       | *'*'* | *'?'* | *'['*)
+           echo "$0: invalid mode: $mode" >&2
+           exit 1;;
+       esac
+       shift;;
+
+    -o) chowncmd="$chownprog $2"
+       shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+       shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)        shift
+       break;;
+
+    -*)        echo "$0: invalid option: $1" >&2
+       exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      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.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dst_arg: Is a directory" >&2
+       exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+       (dirname "$dst") 2>/dev/null ||
+       expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+            X"$dst" : 'X\(//\)[^/]' \| \
+            X"$dst" : 'X\(//\)$' \| \
+            X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+       echo X"$dst" |
+           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)[^/].*/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\).*/{
+                  s//\1/
+                  q
+                }
+                s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+       # Create intermediate dirs using mode 755 as modified by the umask.
+       # This is like FreeBSD 'install' as of 1997-10-28.
+       umask=`umask`
+       case $stripcmd.$umask in
+         # Optimize common cases.
+         *[2367][2367]) mkdir_umask=$umask;;
+         .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+         *[0-7])
+           mkdir_umask=`expr $umask + 22 \
+             - $umask % 100 % 40 + $umask % 20 \
+             - $umask % 10 % 4 + $umask % 2
+           `;;
+         *) mkdir_umask=$umask,go-w;;
+       esac
+
+       # With -d, create the new directory with the user-specified mode.
+       # Otherwise, rely on $mkdir_umask.
+       if test -n "$dir_arg"; then
+         mkdir_mode=-m$mode
+       else
+         mkdir_mode=
+       fi
+
+       posix_mkdir=false
+       case $umask in
+         *[123567][0-7][0-7])
+           # POSIX mkdir -p sets u+wx bits regardless of umask, which
+           # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+           ;;
+         *)
+           tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+           trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+           if (umask $mkdir_umask &&
+               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+           then
+             if test -z "$dir_arg" || {
+                  # Check for POSIX incompatibilities with -m.
+                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                  # other-writeable bit of parent directory when it shouldn't.
+                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                  case $ls_ld_tmpdir in
+                    d????-?r-*) different_mode=700;;
+                    d????-?--*) different_mode=755;;
+                    *) false;;
+                  esac &&
+                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                  }
+                }
+             then posix_mkdir=:
+             fi
+             rmdir "$tmpdir/d" "$tmpdir"
+           else
+             # Remove any dirs left behind by ancient mkdir implementations.
+             rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+           fi
+           trap '' 0;;
+       esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+       umask $mkdir_umask &&
+       $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+       /*) prefix='/';;
+       -*) prefix='./';;
+       *)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+       test -z "$d" && continue
+
+       prefix=$prefix$d
+       if test -d "$prefix"; then
+         prefixes=
+       else
+         if $posix_mkdir; then
+           (umask=$mkdir_umask &&
+            $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+           # Don't fail if two instances are running concurrently.
+           test -d "$prefix" || exit 1
+         else
+           case $prefix in
+             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+             *) qprefix=$prefix;;
+           esac
+           prefixes="$prefixes '$qprefix'"
+         fi
+       fi
+       prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+       # Don't fail if two instances are running concurrently.
+       (umask $mkdir_umask &&
+        eval "\$doit_exec \$mkdirprog $prefixes") ||
+         test -d "$dstdir" || exit 1
+       obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"    2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+       # Now remove or move aside any old file at destination location.
+       # We try this two ways since rm can't unlink itself on some
+       # systems and the destination file might be busy for other
+       # reasons.  In this case, the final cleanup might fail but the new
+       # file should still install successfully.
+       {
+         test ! -f "$dst" ||
+         $doit $rmcmd -f "$dst" 2>/dev/null ||
+         { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+           { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+         } ||
+         { echo "$0: cannot unlink or rename $dst" >&2
+           (exit 1); exit 1
+         }
+       } &&
+
+       # Now rename the file to the real destination.
+       $doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/build/aux/ltmain.sh b/build/aux/ltmain.sh
new file mode 100755 (executable)
index 0000000..d8efb57
--- /dev/null
@@ -0,0 +1,8745 @@
+# Generated from ltmain.m4sh.
+
+# libtool (GNU libtool) 2.2.10
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
+# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool 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 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#       --config             show all configuration variables
+#       --debug              enable verbose shell tracing
+#   -n, --dry-run            display commands without modifying any files
+#       --features           display basic configuration information and exit
+#       --mode=MODE          use operation mode MODE
+#       --preserve-dup-deps  don't remove duplicate dependency libraries
+#       --quiet, --silent    don't print informational messages
+#       --no-quiet, --no-silent
+#                            print informational messages (default)
+#       --tag=TAG            use configuration variables from tag TAG
+#   -v, --verbose            print more informational messages than default
+#       --no-verbose         don't print the extra informational messages
+#       --version            print version information
+#   -h, --help, --help-all   print short, long, or detailed help message
+#
+# MODE must be one of the following:
+#
+#         clean              remove files from the build directory
+#         compile            compile a source file into a libtool object
+#         execute            automatically set library path, then run a program
+#         finish             complete the installation of libtool libraries
+#         install            install libraries or executables
+#         link               create a library or an executable
+#         uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.  When passed as first option,
+# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#         host-triplet:        $host
+#         shell:               $SHELL
+#         compiler:            $LTCC
+#         compiler flags:              $LTCFLAGS
+#         linker:              $LD (gnu? $with_gnu_ld)
+#         $progname:   (GNU libtool) 2.2.10
+#         automake:    $automake_version
+#         autoconf:    $autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+
+PROGRAM=libtool
+PACKAGE=libtool
+VERSION=2.2.10
+TIMESTAMP=""
+package_revision=1.3175
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# NLS nuisances: We save the old values to restore during execute mode.
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+         export $lt_var
+         lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+         lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+       fi"
+done
+LC_ALL=C
+LANGUAGE=C
+export LANGUAGE LC_ALL
+
+$lt_unset CDPATH
+
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+
+
+: ${CP="cp -f"}
+test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${EGREP="/bin/grep -E"}
+: ${FGREP="/bin/grep -F"}
+: ${GREP="/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/bin/sed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77     # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS="  $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar='s,^/\([^/]*\).*$,\1,'
+pathcdr='s,^/[^/]*,,'
+removedotparts=':dotsl
+               s@/\./@/@g
+               t dotsl
+               s,/\.$,/,'
+collapseslashes='s@/\{1,\}@/@g'
+finalslash='s,/*$,/,'
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+#             value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+  # Start from root dir and reassemble the path.
+  func_normal_abspath_result=
+  func_normal_abspath_tpath=$1
+  func_normal_abspath_altnamespace=
+  case $func_normal_abspath_tpath in
+    "")
+      # Empty path, that just means $cwd.
+      func_stripname '' '/' "`pwd`"
+      func_normal_abspath_result=$func_stripname_result
+      return
+    ;;
+    # The next three entries are used to spot a run of precisely
+    # two leading slashes without using negated character classes;
+    # we take advantage of case's first-match behaviour.
+    ///*)
+      # Unusual form of absolute path, do nothing.
+    ;;
+    //*)
+      # Not necessarily an ordinary path; POSIX reserves leading '//'
+      # and for example Cygwin uses it to access remote file shares
+      # over CIFS/SMB, so we conserve a leading double slash if found.
+      func_normal_abspath_altnamespace=/
+    ;;
+    /*)
+      # Absolute path, do nothing.
+    ;;
+    *)
+      # Relative path, prepend $cwd.
+      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+    ;;
+  esac
+  # Cancel out all the simple stuff to save iterations.  We also want
+  # the path to end with a slash for ease of parsing, so make sure
+  # there is one (and only one) here.
+  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+  while :; do
+    # Processed it all yet?
+    if test "$func_normal_abspath_tpath" = / ; then
+      # If we ascended to the root using ".." the result may be empty now.
+      if test -z "$func_normal_abspath_result" ; then
+        func_normal_abspath_result=/
+      fi
+      break
+    fi
+    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcar"`
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+        -e "$pathcdr"`
+    # Figure out what to do with it
+    case $func_normal_abspath_tcomponent in
+      "")
+        # Trailing empty path component, ignore it.
+      ;;
+      ..)
+        # Parent dir; strip last assembled component from result.
+        func_dirname "$func_normal_abspath_result"
+        func_normal_abspath_result=$func_dirname_result
+      ;;
+      *)
+        # Actual path component, append it.
+        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+      ;;
+    esac
+  done
+  # Restore leading double-slash if one was found on entry.
+  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+#             value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+  func_relative_path_result=
+  func_normal_abspath "$1"
+  func_relative_path_tlibdir=$func_normal_abspath_result
+  func_normal_abspath "$2"
+  func_relative_path_tbindir=$func_normal_abspath_result
+
+  # Ascend the tree starting from libdir
+  while :; do
+    # check if we have found a prefix of bindir
+    case $func_relative_path_tbindir in
+      $func_relative_path_tlibdir)
+        # found an exact match
+        func_relative_path_tcancelled=
+        break
+        ;;
+      $func_relative_path_tlibdir*)
+        # found a matching prefix
+        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+        func_relative_path_tcancelled=$func_stripname_result
+        if test -z "$func_relative_path_result"; then
+          func_relative_path_result=.
+        fi
+        break
+        ;;
+      *)
+        func_dirname $func_relative_path_tlibdir
+        func_relative_path_tlibdir=${func_dirname_result}
+        if test "x$func_relative_path_tlibdir" = x ; then
+          # Have to descend all the way to the root!
+          func_relative_path_result=../$func_relative_path_result
+          func_relative_path_tcancelled=$func_relative_path_tbindir
+          break
+        fi
+        func_relative_path_result=../$func_relative_path_result
+        ;;
+    esac
+  done
+
+  # Now calculate path; take care to avoid doubling-up slashes.
+  func_stripname '' '/' "$func_relative_path_result"
+  func_relative_path_result=$func_stripname_result
+  func_stripname '/' '/' "$func_relative_path_tcancelled"
+  if test "x$func_stripname_result" != x ; then
+    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+  fi
+
+  # Normalisation. If bindir is libdir, return empty string,
+  # else relative path ending with a slash; either way, target
+  # file name can be directly appended.
+  if test ! -z "$func_relative_path_result"; then
+    func_stripname './' '' "$func_relative_path_result/"
+    func_relative_path_result=$func_stripname_result
+  fi
+}
+
+# The name of this program:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+       # list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+       IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "$my_tmpdir"
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+       func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+       my_arg=`$ECHO "$1" | $SED \
+           -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+       eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+           $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+       eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $SED -n '/(C)/!b go
+       :more
+       /\./!{
+         N
+         s/\n# / /
+         b more
+       }
+       :go
+       /^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+       s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $SED -n '/^# Usage:/,/^#  *.*--help/ {
+        s/^# //
+       s/^# *$//
+       s/\$progname/'$progname'/
+       p
+    }' < "$progpath"
+    echo
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help [NOEXIT]
+# Echo long help message to standard output and exit,
+# unless 'noexit' is passed as argument.
+func_help ()
+{
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+        s/^# //
+       s/^# *$//
+       s*\$progname*'$progname'*
+       s*\$host*'"$host"'*
+       s*\$SHELL*'"$SHELL"'*
+       s*\$LTCC*'"$LTCC"'*
+       s*\$LTCFLAGS*'"$LTCFLAGS"'*
+       s*\$LD*'"$LD"'*
+       s/\$with_gnu_ld/'"$with_gnu_ld"'/
+       s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+       s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+       p
+     }' < "$progpath"
+    ret=$?
+    if test -z "$1"; then
+      exit $ret
+    fi
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    func_error "missing argument for $1."
+    exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      echo "enable shared libraries"
+    else
+      echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      echo "enable static libraries"
+    else
+      echo "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+       taglist="$taglist $tagname"
+
+       # Evaluate the configuration.  Be careful to quote the path
+       # and the sed script, to avoid splitting on whitespace, but
+       # also don't use non-portable quotes within backquotes within
+       # quotes we have to do it in 2 steps:
+       extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+       eval "$extractedcf"
+      else
+       func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# Parse options once, thoroughly.  This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+  # Shorthand for --mode=foo, only valid as the first argument
+  case $1 in
+  clean|clea|cle|cl)
+    shift; set dummy --mode clean ${1+"$@"}; shift
+    ;;
+  compile|compil|compi|comp|com|co|c)
+    shift; set dummy --mode compile ${1+"$@"}; shift
+    ;;
+  execute|execut|execu|exec|exe|ex|e)
+    shift; set dummy --mode execute ${1+"$@"}; shift
+    ;;
+  finish|finis|fini|fin|fi|f)
+    shift; set dummy --mode finish ${1+"$@"}; shift
+    ;;
+  install|instal|insta|inst|ins|in|i)
+    shift; set dummy --mode install ${1+"$@"}; shift
+    ;;
+  link|lin|li|l)
+    shift; set dummy --mode link ${1+"$@"}; shift
+    ;;
+  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+    shift; set dummy --mode uninstall ${1+"$@"}; shift
+    ;;
+  esac
+
+  # Parse non-mode specific arguments:
+  while test "$#" -gt 0; do
+    opt="$1"
+    shift
+
+    case $opt in
+      --config)                func_config                                     ;;
+
+      --debug)         preserve_args="$preserve_args $opt"
+                       func_echo "enabling shell trace mode"
+                       opt_debug='set -x'
+                       $opt_debug
+                       ;;
+
+      -dlopen)         test "$#" -eq 0 && func_missing_arg "$opt" && break
+                       execute_dlfiles="$execute_dlfiles $1"
+                       shift
+                       ;;
+
+      --dry-run | -n)  opt_dry_run=:                                   ;;
+      --features)       func_features                                  ;;
+      --finish)                mode="finish"                                   ;;
+
+      --mode)          test "$#" -eq 0 && func_missing_arg "$opt" && break
+                       case $1 in
+                         # Valid mode arguments:
+                         clean)        ;;
+                         compile)      ;;
+                         execute)      ;;
+                         finish)       ;;
+                         install)      ;;
+                         link)         ;;
+                         relink)       ;;
+                         uninstall)    ;;
+
+                         # Catch anything else as an error
+                         *) func_error "invalid argument for $opt"
+                            exit_cmd=exit
+                            break
+                            ;;
+                       esac
+
+                       mode="$1"
+                       shift
+                       ;;
+
+      --preserve-dup-deps)
+                       opt_duplicate_deps=:                            ;;
+
+      --quiet|--silent)        preserve_args="$preserve_args $opt"
+                       opt_silent=:
+                       opt_verbose=false
+                       ;;
+
+      --no-quiet|--no-silent)
+                       preserve_args="$preserve_args $opt"
+                       opt_silent=false
+                       ;;
+
+      --verbose| -v)   preserve_args="$preserve_args $opt"
+                       opt_silent=false
+                       opt_verbose=:
+                       ;;
+
+      --no-verbose)    preserve_args="$preserve_args $opt"
+                       opt_verbose=false
+                       ;;
+
+      --tag)           test "$#" -eq 0 && func_missing_arg "$opt" && break
+                       preserve_args="$preserve_args $opt $1"
+                       func_enable_tag "$1"    # tagname is set here
+                       shift
+                       ;;
+
+      # Separate optargs to long options:
+      -dlopen=*|--mode=*|--tag=*)
+                       func_opt_split "$opt"
+                       set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+                       shift
+                       ;;
+
+      -\?|-h)          func_usage                                      ;;
+      --help)          opt_help=:                                      ;;
+      --help-all)      opt_help=': help-all'                           ;;
+      --version)       func_version                                    ;;
+
+      -*)              func_fatal_help "unrecognized option \`$opt'"   ;;
+
+      *)               nonopt="$opt"
+                       break
+                       ;;
+    esac
+  done
+
+
+  case $host in
+    *cygwin* | *mingw* | *pw32* | *cegcc*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+      ;;
+  esac
+
+  # Having warned about all mis-specified options, bail out if
+  # anything was wrong.
+  $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+$opt_help || {
+  # Sanity checks first:
+  func_check_version_match
+
+  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+    func_fatal_configuration "not configured to build any kind of library"
+  fi
+
+  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+  # Darwin sucks
+  eval std_shrext=\"$shrext_cmds\"
+
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    func_error "unrecognized option \`-dlopen'"
+    $ECHO "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    test -f "$1" &&
+      $SED -e 4q "$1" 2>/dev/null \
+        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+       for lalib_p_l in 1 2 3 4
+       do
+           read lalib_p_line
+           case "$lalib_p_line" in
+               \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+           esac
+       done
+       exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_ltwrapper_scriptname_result=""
+    if func_ltwrapper_executable_p "$1"; then
+       func_dirname_and_basename "$1" "" "."
+       func_stripname '' '.exe' "$func_basename_result"
+       func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)        . "$1" ;;
+    *)         . "./$1" ;;
+    esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+        func_quote_for_eval "$arg"
+       CC_quoted="$CC_quoted $func_quote_for_eval_result"
+      done
+      CC_expanded=`func_echo_all $CC`
+      CC_quoted_expanded=`func_echo_all $CC_quoted`
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+       for z in $available_tags; do
+         if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+           # Evaluate the configuration.
+           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+           CC_quoted=
+           for arg in $CC; do
+             # Double-quote args containing other shell metacharacters.
+             func_quote_for_eval "$arg"
+             CC_quoted="$CC_quoted $func_quote_for_eval_result"
+           done
+           CC_expanded=`func_echo_all $CC`
+           CC_quoted_expanded=`func_echo_all $CC_quoted`
+           case "$@ " in
+           " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+           " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
+             # The compiler in the base compile command matches
+             # the one in the tagged configuration.
+             # Assume this is the tagged configuration we want.
+             tagname=$z
+             break
+             ;;
+           esac
+         fi
+       done
+       # If $tagname still isn't set, then no tagged configuration
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+         func_echo "unable to infer tagged configuration"
+         func_fatal_error "specify a tag with \`--tag'"
+#      else
+#        func_verbose "using $tagname tagged configuration"
+       fi
+       ;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+       # do not "continue".  Instead, add this to base_compile
+       lastarg="$arg"
+       arg_mode=normal
+       ;;
+
+      target )
+       libobj="$arg"
+       arg_mode=normal
+       continue
+       ;;
+
+      normal )
+       # Accept any command-line options.
+       case $arg in
+       -o)
+         test -n "$libobj" && \
+           func_fatal_error "you cannot specify \`-o' more than once"
+         arg_mode=target
+         continue
+         ;;
+
+       -pie | -fpie | -fPIE)
+          pie_flag="$pie_flag $arg"
+         continue
+         ;;
+
+       -shared | -static | -prefer-pic | -prefer-non-pic)
+         later="$later $arg"
+         continue
+         ;;
+
+       -no-suppress)
+         suppress_opt=no
+         continue
+         ;;
+
+       -Xcompiler)
+         arg_mode=arg  #  the next one goes into the "base_compile" arg list
+         continue      #  The current "srcfile" will either be retained or
+         ;;            #  replaced later.  I would guess that would be a bug.
+
+       -Wc,*)
+         func_stripname '-Wc,' '' "$arg"
+         args=$func_stripname_result
+         lastarg=
+         save_ifs="$IFS"; IFS=','
+         for arg in $args; do
+           IFS="$save_ifs"
+           func_quote_for_eval "$arg"
+           lastarg="$lastarg $func_quote_for_eval_result"
+         done
+         IFS="$save_ifs"
+         func_stripname ' ' '' "$lastarg"
+         lastarg=$func_stripname_result
+
+         # Add the arguments to base_compile.
+         base_compile="$base_compile $lastarg"
+         continue
+         ;;
+
+       *)
+         # Accept the current argument as the source file.
+         # The previous "srcfile" becomes the current argument.
+         #
+         lastarg="$srcfile"
+         srcfile="$arg"
+         ;;
+       esac  #  case $arg
+       ;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_quote_for_eval "$lastarg"
+      base_compile="$base_compile $func_quote_for_eval_result"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+       func_basename "$srcfile"
+       libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+       test "$build_libtool_libs" != yes && \
+         func_fatal_configuration "can not build a shared library"
+       build_old_libs=no
+       continue
+       ;;
+
+      -static)
+       build_libtool_libs=no
+       build_old_libs=yes
+       continue
+       ;;
+
+      -prefer-pic)
+       pic_mode=yes
+       continue
+       ;;
+
+      -prefer-non-pic)
+       pic_mode=no
+       continue
+       ;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'   &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2* | cegcc*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+       func_echo "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+      removelist="$removelist $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    removelist="$removelist $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+       command="$base_compile $qsrcfile $pic_flag"
+      else
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+       # Place PIC objects in $objdir
+       command="$command -o $lobj"
+      fi
+
+      func_show_eval_locale "$command" \
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+       func_show_eval '$MV "$output_obj" "$lobj"' \
+         'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+       suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+       # Don't build PIC code
+       command="$base_compile $qsrcfile$pie_flag"
+      else
+       command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+       command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $opt_dry_run || $RM $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+       func_show_eval '$MV "$output_obj" "$obj"' \
+         'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+       removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+  test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to build PIC objects only
+  -prefer-non-pic   try to build non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+  -Wc,FLAG          pass FLAG directly to the compiler
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -bindir BINDIR    specify path to binaries directory (for systems where
+                    libraries must be found in the PATH setting at runtime)
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+  -Wc,FLAG
+  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
+  -Wl,FLAG
+  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
+  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$mode'"
+        ;;
+    esac
+
+    echo
+    $ECHO "Try \`$progname --help' for more information about other modes."
+}
+
+# Now that we've collected a possible --mode arg, show help if necessary
+if $opt_help; then
+  if test "$opt_help" = :; then
+    func_mode_help
+  else
+    {
+      func_help noexit
+      for mode in compile link execute install finish uninstall clean; do
+       func_mode_help
+      done
+    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    {
+      func_help noexit
+      for mode in compile link execute install finish uninstall clean; do
+       echo
+       func_mode_help
+      done
+    } |
+    sed '1d
+      /^When reporting/,/^Report/{
+       H
+       d
+      }
+      $x
+      /information about other modes/d
+      /more detailed .*MODE/d
+      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
+  fi
+  exit $?
+fi
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      test -f "$file" \
+       || func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$file" \
+         || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+       func_source "$file"
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && \
+           func_warning "\`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       func_dirname "$file" "" "."
+       dir="$func_dirname_result"
+
+       if test -f "$dir/$objdir/$dlname"; then
+         dir="$dir/$objdir"
+       else
+         if test ! -f "$dir/$dlname"; then
+           func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+         fi
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       func_dirname "$file" "" "."
+       dir="$func_dirname_result"
+       ;;
+
+      *)
+       func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+       continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -* | *.la | *.lo ) ;;
+      *)
+       # Do a test to see if this is really a libtool program.
+       if func_ltwrapper_script_p "$file"; then
+         func_source "$file"
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       elif func_ltwrapper_executable_p "$file"; then
+         func_ltwrapper_scriptname "$file"
+         func_source "$func_ltwrapper_scriptname_result"
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+       ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_quote_for_eval "$file"
+      args="$args $func_quote_for_eval_result"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+       # Export the shlibpath_var.
+       eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+       eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+             else
+               $lt_unset $lt_var
+             fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+       eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+       echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+       libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+       if test -n "$finish_cmds"; then
+         # Do each command in the finish commands.
+         func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+       fi
+       if test -n "$finish_eval"; then
+         # Do the single finish_eval.
+         eval cmds=\"$finish_eval\"
+         $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+       $cmds"
+       fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    echo "----------------------------------------------------------------------"
+    echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $ECHO "   $libdir"
+    done
+    echo
+    echo "If you ever happen to want to link against installed libraries"
+    echo "in a given directory, LIBDIR, you must either use libtool, and"
+    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $ECHO "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $ECHO "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    echo
+
+    echo "See any operating system documentation about shared libraries for"
+    case $host in
+      solaris2.[6789]|solaris2.1[0-9])
+        echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+       echo "pages."
+       ;;
+      *)
+        echo "more information, such as the ld(1) and ld.so(8) manual pages."
+        ;;
+    esac
+    echo "----------------------------------------------------------------------"
+    exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       case $nonopt in *shtool*) :;; *) false;; esac; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    install_prog="$install_prog$func_quote_for_eval_result"
+    install_shared_prog=$install_prog
+    case " $install_prog " in
+      *[\\\ /]cp\ *) install_cp=: ;;
+      *) install_cp=false ;;
+    esac
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    no_mode=:
+    for arg
+    do
+      arg2=
+      if test -n "$dest"; then
+       files="$files $dest"
+       dest=$arg
+       continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+       if $install_cp; then :; else
+         prev=$arg
+       fi
+       ;;
+      -g | -m | -o)
+       prev=$arg
+       ;;
+      -s)
+       stripme=" -s"
+       continue
+       ;;
+      -*)
+       ;;
+      *)
+       # If the previous option needed an argument, then skip it.
+       if test -n "$prev"; then
+         if test "x$prev" = x-m && test -n "$install_override_mode"; then
+           arg2=$install_override_mode
+           no_mode=false
+         fi
+         prev=
+       else
+         dest=$arg
+         continue
+       fi
+       ;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      install_prog="$install_prog $func_quote_for_eval_result"
+      if test -n "$arg2"; then
+       func_quote_for_eval "$arg2"
+      fi
+      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -n "$install_override_mode" && $no_mode; then
+      if $install_cp; then :; else
+       func_quote_for_eval "$install_override_mode"
+       install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
+      fi
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+       func_fatal_help "no file or destination specified"
+      else
+       func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+       func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+       case $file in
+       *.lo) ;;
+       *)
+         func_fatal_help "\`$destdir' must be an absolute directory name"
+         ;;
+       esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+       # Do the static libraries later.
+       staticlibs="$staticlibs $file"
+       ;;
+
+      *.la)
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$file" \
+         || func_fatal_help "\`$file' is not a valid libtool archive"
+
+       library_names=
+       old_library=
+       relink_command=
+       func_source "$file"
+
+       # Add the libdir to current_libdirs if it is the destination.
+       if test "X$destdir" = "X$libdir"; then
+         case "$current_libdirs " in
+         *" $libdir "*) ;;
+         *) current_libdirs="$current_libdirs $libdir" ;;
+         esac
+       else
+         # Note the libdir as a future libdir.
+         case "$future_libdirs " in
+         *" $libdir "*) ;;
+         *) future_libdirs="$future_libdirs $libdir" ;;
+         esac
+       fi
+
+       func_dirname "$file" "/" ""
+       dir="$func_dirname_result"
+       dir="$dir$objdir"
+
+       if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+         test "$inst_prefix_dir" = "$destdir" && \
+           func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+         fi
+
+         func_warning "relinking \`$file'"
+         func_show_eval "$relink_command" \
+           'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+       fi
+
+       # See the names of the shared library.
+       set dummy $library_names; shift
+       if test -n "$1"; then
+         realname="$1"
+         shift
+
+         srcname="$realname"
+         test -n "$relink_command" && srcname="$realname"T
+
+         # Install the shared library and build the symlinks.
+         func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
+             'exit $?'
+         tstripme="$stripme"
+         case $host_os in
+         cygwin* | mingw* | pw32* | cegcc*)
+           case $realname in
+           *.dll.a)
+             tstripme=""
+             ;;
+           esac
+           ;;
+         esac
+         if test -n "$tstripme" && test -n "$striplib"; then
+           func_show_eval "$striplib $destdir/$realname" 'exit $?'
+         fi
+
+         if test "$#" -gt 0; then
+           # Delete the old symlinks, and create new ones.
+           # Try `ln -sf' first, because the `ln' binary might depend on
+           # the symlink we replace!  Solaris /bin/ln does not understand -f,
+           # so we also need to try rm && ln -s.
+           for linkname
+           do
+             test "$linkname" != "$realname" \
+               && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+           done
+         fi
+
+         # Do each command in the postinstall commands.
+         lib="$destdir/$realname"
+         func_execute_cmds "$postinstall_cmds" 'exit $?'
+       fi
+
+       # Install the pseudo-library for information purposes.
+       func_basename "$file"
+       name="$func_basename_result"
+       instname="$dir/$name"i
+       func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+       # Maybe install the static library, too.
+       test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+       ;;
+
+      *.lo)
+       # Install (i.e. copy) a libtool object.
+
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         func_basename "$file"
+         destfile="$func_basename_result"
+         destfile="$destdir/$destfile"
+       fi
+
+       # Deduce the name of the destination old-style object file.
+       case $destfile in
+       *.lo)
+         func_lo2o "$destfile"
+         staticdest=$func_lo2o_result
+         ;;
+       *.$objext)
+         staticdest="$destfile"
+         destfile=
+         ;;
+       *)
+         func_fatal_help "cannot copy a libtool object to \`$destfile'"
+         ;;
+       esac
+
+       # Install the libtool object if requested.
+       test -n "$destfile" && \
+         func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+       # Install the old object if enabled.
+       if test "$build_old_libs" = yes; then
+         # Deduce the name of the old-style object file.
+         func_lo2o "$file"
+         staticobj=$func_lo2o_result
+         func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+       fi
+       exit $EXIT_SUCCESS
+       ;;
+
+      *)
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         func_basename "$file"
+         destfile="$func_basename_result"
+         destfile="$destdir/$destfile"
+       fi
+
+       # If the file is missing, and there is a .exe on the end, strip it
+       # because it is most likely a libtool script we actually want to
+       # install
+       stripped_ext=""
+       case $file in
+         *.exe)
+           if test ! -f "$file"; then
+             func_stripname '' '.exe' "$file"
+             file=$func_stripname_result
+             stripped_ext=".exe"
+           fi
+           ;;
+       esac
+
+       # Do a test to see if this is really a libtool program.
+       case $host in
+       *cygwin* | *mingw*)
+           if func_ltwrapper_executable_p "$file"; then
+             func_ltwrapper_scriptname "$file"
+             wrapper=$func_ltwrapper_scriptname_result
+           else
+             func_stripname '' '.exe' "$file"
+             wrapper=$func_stripname_result
+           fi
+           ;;
+       *)
+           wrapper=$file
+           ;;
+       esac
+       if func_ltwrapper_script_p "$wrapper"; then
+         notinst_deplibs=
+         relink_command=
+
+         func_source "$wrapper"
+
+         # Check the variables that should have been set.
+         test -z "$generated_by_libtool_version" && \
+           func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+         finalize=yes
+         for lib in $notinst_deplibs; do
+           # Check to see that each library is installed.
+           libdir=
+           if test -f "$lib"; then
+             func_source "$lib"
+           fi
+           libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+           if test -n "$libdir" && test ! -f "$libfile"; then
+             func_warning "\`$lib' has not been installed in \`$libdir'"
+             finalize=no
+           fi
+         done
+
+         relink_command=
+         func_source "$wrapper"
+
+         outputname=
+         if test "$fast_install" = no && test -n "$relink_command"; then
+           $opt_dry_run || {
+             if test "$finalize" = yes; then
+               tmpdir=`func_mktempdir`
+               func_basename "$file$stripped_ext"
+               file="$func_basename_result"
+               outputname="$tmpdir/$file"
+               # Replace the output file specification.
+               relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
+
+               $opt_silent || {
+                 func_quote_for_expand "$relink_command"
+                 eval "func_echo $func_quote_for_expand_result"
+               }
+               if eval "$relink_command"; then :
+                 else
+                 func_error "error: relink \`$file' with the above command before installing it"
+                 $opt_dry_run || ${RM}r "$tmpdir"
+                 continue
+               fi
+               file="$outputname"
+             else
+               func_warning "cannot relink \`$file'"
+             fi
+           }
+         else
+           # Install the binary that we compiled earlier.
+           file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
+         fi
+       fi
+
+       # remove .exe since cygwin /usr/bin/install will append another
+       # one anyway
+       case $install_prog,$host in
+       */usr/bin/install*,*cygwin*)
+         case $file:$destfile in
+         *.exe:*.exe)
+           # this is ok
+           ;;
+         *.exe:*)
+           destfile=$destfile.exe
+           ;;
+         *:*.exe)
+           func_stripname '' '.exe' "$destfile"
+           destfile=$func_stripname_result
+           ;;
+         esac
+         ;;
+       esac
+       func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+       $opt_dry_run || if test -n "$outputname"; then
+         ${RM}r "$tmpdir"
+       fi
+       ;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+       func_show_eval "$old_striplib $oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+       my_dlsyms="${my_outputname}S.c"
+      else
+       func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+       # Discover the nlist of each of the dlfiles.
+       nlist="$output_objdir/${my_outputname}.nm"
+
+       func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+       # Parse the name list into a source file.
+       func_verbose "creating $output_objdir/$my_dlsyms"
+
+       $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+       if test "$dlself" = yes; then
+         func_verbose "generating symbol list for \`$output'"
+
+         $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+         # Add our own program objects to the symbol list.
+         progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+         for progfile in $progfiles; do
+           func_verbose "extracting global C symbols from \`$progfile'"
+           $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+         done
+
+         if test -n "$exclude_expsyms"; then
+           $opt_dry_run || {
+             eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+           }
+         fi
+
+         if test -n "$export_symbols_regex"; then
+           $opt_dry_run || {
+             eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+           }
+         fi
+
+         # Prepare the list of exported symbols
+         if test -z "$export_symbols"; then
+           export_symbols="$output_objdir/$outputname.exp"
+           $opt_dry_run || {
+             $RM $export_symbols
+             eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+             case $host in
+             *cygwin* | *mingw* | *cegcc* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+               ;;
+             esac
+           }
+         else
+           $opt_dry_run || {
+             eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+             eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+             eval '$MV "$nlist"T "$nlist"'
+             case $host in
+               *cygwin* | *mingw* | *cegcc* )
+                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                 ;;
+             esac
+           }
+         fi
+       fi
+
+       for dlprefile in $dlprefiles; do
+         func_verbose "extracting global C symbols from \`$dlprefile'"
+         func_basename "$dlprefile"
+         name="$func_basename_result"
+         $opt_dry_run || {
+           eval '$ECHO ": $name " >> "$nlist"'
+           eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+         }
+       done
+
+       $opt_dry_run || {
+         # Make sure we have at least an empty file.
+         test -f "$nlist" || : > "$nlist"
+
+         if test -n "$exclude_expsyms"; then
+           $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+           $MV "$nlist"T "$nlist"
+         fi
+
+         # Try sorting and uniquifying the output.
+         if $GREP -v "^: " < "$nlist" |
+             if sort -k 3 </dev/null >/dev/null 2>&1; then
+               sort -k 3
+             else
+               sort +2
+             fi |
+             uniq > "$nlist"S; then
+           :
+         else
+           $GREP -v "^: " < "$nlist" > "$nlist"S
+         fi
+
+         if test -f "$nlist"S; then
+           eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+         else
+           echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
+         fi
+
+         echo >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+"
+         case $host in
+         *cygwin* | *mingw* | *cegcc* )
+           echo >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs.  */"
+           lt_dlsym_const= ;;
+         *osf5*)
+           echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+           lt_dlsym_const= ;;
+         *)
+           lt_dlsym_const=const ;;
+         esac
+
+         echo >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+         case $need_lib_prefix in
+         no)
+           eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+           ;;
+         *)
+           eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+           ;;
+         esac
+         echo >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+       } # !$opt_dry_run
+
+       pic_flag_for_symtable=
+       case "$compile_command " in
+       *" -static "*) ;;
+       *)
+         case $host in
+         # compiling the symbol table file with pic_flag works around
+         # a FreeBSD bug that causes programs to crash when -lm is
+         # linked before any other PIC object.  But we must not use
+         # pic_flag when linking with -static.  The problem exists in
+         # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+         *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+           pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+         *-*-hpux*)
+           pic_flag_for_symtable=" $pic_flag"  ;;
+         *)
+           if test "X$my_pic_p" != Xno; then
+             pic_flag_for_symtable=" $pic_flag"
+           fi
+           ;;
+         esac
+         ;;
+       esac
+       symtab_cflags=
+       for arg in $LTCFLAGS; do
+         case $arg in
+         -pie | -fpie | -fPIE) ;;
+         *) symtab_cflags="$symtab_cflags $arg" ;;
+         esac
+       done
+
+       # Now compile the dynamic symbol file.
+       func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+       # Clean up the generated files.
+       func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+       # Transform the symbol file into the correct name.
+       symfileobj="$output_objdir/${my_outputname}S.$objext"
+       case $host in
+       *cygwin* | *mingw* | *cegcc* )
+         if test -f "$output_objdir/$my_outputname.def"; then
+           compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+           finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+         else
+           compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+           finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         fi
+         ;;
+       *)
+         compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+         ;;
+       esac
+       ;;
+      *)
+       func_fatal_error "unknown suffix for \`$my_dlsyms'"
+       ;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+# Despite the name, also deal with 64 bit binaries.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
+      win32_nmres=`eval $NM -f posix -A $1 |
+       $SED -n -e '
+           1,100{
+               / I /{
+                   s,.*,import,
+                   p
+                   q
+               }
+           }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    if test "$lock_old_archive_extraction" = yes; then
+      lockfile=$f_ex_an_ar_oldlib.lock
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+       func_echo "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    fi
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
+                  'stat=$?; rm -f "$lockfile"; exit $stat'
+    if test "$lock_old_archive_extraction" = yes; then
+      $opt_dry_run || rm -f "$lockfile"
+    fi
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+       *) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+       *" $my_xlib_u "*)
+         func_arith $extracted_serial + 1
+         extracted_serial=$func_arith_result
+         my_xlib_u=lt$extracted_serial-$my_xlib ;;
+       *) break ;;
+       esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+       func_verbose "Extracting $my_xabs"
+       # Do not bother doing anything if just a dry run
+       $opt_dry_run || {
+         darwin_orig_dir=`pwd`
+         cd $my_xdir || exit $?
+         darwin_archive=$my_xabs
+         darwin_curdir=`pwd`
+         darwin_base_archive=`basename "$darwin_archive"`
+         darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+         if test -n "$darwin_arches"; then
+           darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+           darwin_arch=
+           func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+           for darwin_arch in  $darwin_arches ; do
+             func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+             cd "$darwin_curdir"
+             $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+           done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+           darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+           darwin_file=
+           darwin_files=
+           for darwin_file in $darwin_filelist; do
+             darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
+             $LIPO -create -output "$darwin_file" $darwin_files
+           done # $darwin_filelist
+           $RM -rf unfat-$$
+           cd "$darwin_orig_dir"
+         else
+           cd $darwin_orig_dir
+           func_extract_an_archive "$my_xdir" "$my_xabs"
+         fi # $darwin_arches
+       } # !$opt_dry_run
+       ;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+       ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+       func_emit_wrapper_arg1=${1-no}
+
+       $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    file=\"\$0\""
+
+    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
+    $ECHO "\
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+    ECHO=\"$qECHO\"
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string "--lt-"
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=\$0
+  shift
+  for lt_opt
+  do
+    case \"\$lt_opt\" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
+        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
+        cat \"\$lt_dump_D/\$lt_dump_F\"
+        exit 0
+      ;;
+    --lt-*)
+        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+
+  # Print the debug banner immediately:
+  if test -n \"\$lt_option_debug\"; then
+    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+  fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+  case $host in
+  # Backslashes separate directories on plain windows
+  *-*-mingw | *-*-os2* | *-cegcc*)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        func_lt_dump_args \${1+\"\$@\"} 1>&2
+      fi
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+    ;;
+
+  *)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        func_lt_dump_args \${1+\"\$@\"} 1>&2
+      fi
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+    ;;
+  esac
+  $ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  for lt_wr_arg
+  do
+    case \$lt_wr_arg in
+    --lt-*) ;;
+    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
+    esac
+    shift
+  done
+  func_exec_program_core \${1+\"\$@\"}
+}
+
+  # Parse options
+  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
+  done
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+       if test "$fast_install" = yes; then
+         $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+         $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+       $ECHO \"\$relink_command_output\" >&2
+       $RM \"\$progdir/\$file\"
+       exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+       else
+         $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+       fi
+
+       $ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+       # Export our shlibpath_var if we have one.
+       if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+         $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+       fi
+
+       # fixup the dll searchpath if we need to.
+       if test -n "$dllsearchpath"; then
+         $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+       fi
+
+       $ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+      func_exec_program \${1+\"\$@\"}
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+
+
+# func_to_host_path arg
+#
+# Convert paths to host format when used with build tools.
+# Intended for use with "native" mingw (where libtool itself
+# is running under the msys shell), or in the following cross-
+# build environments:
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin.  Calling this function does no harm for other
+# $host/$build combinations not listed above.
+#
+# ARG is the path (on $build) that should be converted to
+# the proper representation for $host. The result is stored
+# in $func_to_host_path_result.
+func_to_host_path ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1"; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        case $build in
+          *mingw* ) # actually, msys
+            # awkward: cmd appends spaces to result
+            func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
+              $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_path_result=`cygpath -w "$1" |
+             $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # Unfortunately, winepath does not exit with a non-zero
+            # error code, so we are forced to check the contents of
+            # stdout. On the other hand, if the command is not
+            # found, the shell will set an exit code of 127 and print
+            # *an error message* to stdout. So we must check for both
+            # error code of zero AND non-empty stdout, which explains
+            # the odd construction:
+            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
+              func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
+                $SED -e "$lt_sed_naive_backslashify"`
+            else
+              # Allow warning below.
+              func_to_host_path_result=
+            fi
+            ;;
+        esac
+        if test -z "$func_to_host_path_result" ; then
+          func_error "Could not determine host path corresponding to"
+          func_error "  \`$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback:
+          func_to_host_path_result="$1"
+        fi
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_path
+
+# func_to_host_pathlist arg
+#
+# Convert pathlists to host format when used with build tools.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+#
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
+#
+# ARG is a pathlist (on $build) that should be converted to
+# the proper representation on $host. The result is stored
+# in $func_to_host_pathlist_result.
+func_to_host_pathlist ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1"; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        # Remove leading and trailing path separator characters from
+        # ARG. msys behavior is inconsistent here, cygpath turns them
+        # into '.;' and ';.', and winepath ignores them completely.
+       func_stripname : : "$1"
+        func_to_host_pathlist_tmp1=$func_stripname_result
+        case $build in
+          *mingw* ) # Actually, msys.
+            # Awkward: cmd appends spaces to result.
+            func_to_host_pathlist_result=`
+             ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
+             $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # unfortunately, winepath doesn't convert pathlists
+            func_to_host_pathlist_result=""
+            func_to_host_pathlist_oldIFS=$IFS
+            IFS=:
+            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+              IFS=$func_to_host_pathlist_oldIFS
+              if test -n "$func_to_host_pathlist_f" ; then
+                func_to_host_path "$func_to_host_pathlist_f"
+                if test -n "$func_to_host_path_result" ; then
+                  if test -z "$func_to_host_pathlist_result" ; then
+                    func_to_host_pathlist_result="$func_to_host_path_result"
+                  else
+                    func_append func_to_host_pathlist_result ";$func_to_host_path_result"
+                  fi
+                fi
+              fi
+            done
+            IFS=$func_to_host_pathlist_oldIFS
+            ;;
+        esac
+        if test -z "$func_to_host_pathlist_result"; then
+          func_error "Could not determine the host path(s) corresponding to"
+          func_error "  \`$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback. This may break if $1 contains DOS-style drive
+          # specifications. The fix is not to complicate the expression
+          # below, but for the user to provide a working wine installation
+          # with winepath so that path translation in the cross-to-mingw
+          # case works properly.
+          lt_replace_pathsep_nix_to_dos="s|:|;|g"
+          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
+            $SED -e "$lt_replace_pathsep_nix_to_dos"`
+        fi
+        # Now, add the leading and trailing path separators back
+        case "$1" in
+          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+            ;;
+        esac
+        case "$1" in
+          *: ) func_append func_to_host_pathlist_result ";"
+            ;;
+        esac
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_pathlist
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+       cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+*/
+EOF
+           cat <<"EOF"
+#ifdef _MSC_VER
+# define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* declarations of non-ANSI functions */
+#if defined(__MINGW32__)
+# ifdef __STRICT_ANSI__
+int _putenv (const char *);
+# endif
+#elif defined(__CYGWIN__)
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+/* #elif defined (other platforms) ... */
+#endif
+
+/* portability defines, excluding path handling macros */
+#if defined(_MSC_VER)
+# define setmode _setmode
+# define stat    _stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+# define S_IXUSR _S_IEXEC
+# ifndef _INTPTR_T_DEFINED
+#  define _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#elif defined(__MINGW32__)
+# define setmode _setmode
+# define stat    _stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+#elif defined(__CYGWIN__)
+# define HAVE_SETENV
+# define FOPEN_WB "wb"
+/* #elif defined (other platforms) ... */
+#endif
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+/* path handling portability macros */
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+       (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#if defined(LT_DEBUGWRAPPER)
+static int lt_debug = 1;
+#else
+static int lt_debug = 0;
+#endif
+
+const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_debugprintf (const char *file, int line, const char *fmt, ...);
+void lt_fatal (const char *file, int line, const char *message, ...);
+static const char *nonnull (const char *s);
+static const char *nonempty (const char *s);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+char **prepare_spawn (char **argv);
+void lt_dump_script (FILE *f);
+EOF
+
+           cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+           if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+              func_to_host_pathlist "$temp_rpath"
+             cat <<EOF
+const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+           else
+             cat <<"EOF"
+const char * LIB_PATH_VALUE   = "";
+EOF
+           fi
+
+           if test -n "$dllsearchpath"; then
+              func_to_host_pathlist "$dllsearchpath:"
+             cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+           else
+             cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE   = "";
+EOF
+           fi
+
+           if test "$fast_install" = yes; then
+             cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+           else
+             cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+           fi
+
+
+           cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX         "--lt-"
+
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
+static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int  newargc;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *actual_cwrapper_name;
+  char *target_name;
+  char *lt_argv_zero;
+  intptr_t rval = 127;
+
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  newargz = XMALLOC (char *, argc + 1);
+
+  /* very simple arg parsing; don't want to rely on getopt
+   * also, copy all non cwrapper options to newargz, except
+   * argz[0], which is handled differently
+   */
+  newargc=0;
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+       {
+EOF
+           case "$host" in
+             *mingw* | *cygwin* )
+               # make stdout use "unix" line endings
+               echo "          setmode(1,_O_BINARY);"
+               ;;
+             esac
+
+           cat <<"EOF"
+         lt_dump_script (stdout);
+         return 0;
+       }
+      if (strcmp (argv[i], debug_opt) == 0)
+       {
+          lt_debug = 1;
+          continue;
+       }
+      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+        {
+          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+             namespace, but it is not one of the ones we know about and
+             have already dealt with, above (inluding dump-script), then
+             report an error. Otherwise, targets might begin to believe
+             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+             namespace. The first time any user complains about this, we'll
+             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+             or a configure.ac-settable value.
+           */
+          lt_fatal (__FILE__, __LINE__,
+                   "unrecognized %s option: '%s'",
+                    ltwrapper_option_prefix, argv[i]);
+        }
+      /* otherwise ... */
+      newargz[++newargc] = xstrdup (argv[i]);
+    }
+  newargz[++newargc] = NULL;
+
+EOF
+           cat <<EOF
+  /* The GNU banner must be the first non-error debug message */
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+EOF
+           cat <<"EOF"
+  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
+  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
+
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
+  lt_debugprintf (__FILE__, __LINE__,
+                  "(main) found exe (before symlink chase) at: %s\n",
+                 tmp_pathspec);
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  lt_debugprintf (__FILE__, __LINE__,
+                  "(main) found exe (after symlink chase) at: %s\n",
+                 actual_cwrapper_path);
+  XFREE (tmp_pathspec);
+
+  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+  /* wrapper name transforms */
+  strendzap (actual_cwrapper_name, ".exe");
+  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+  XFREE (actual_cwrapper_name);
+  actual_cwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  /* target_name transforms -- use actual target program name; might have lt- prefix */
+  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+  strendzap (target_name, ".exe");
+  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+  XFREE (target_name);
+  target_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(main) libtool target name: %s\n",
+                 target_name);
+EOF
+
+           cat <<EOF
+  newargz[0] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+                   strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+  strcpy (newargz[0], actual_cwrapper_path);
+  strcat (newargz[0], "$objdir");
+  strcat (newargz[0], "/");
+EOF
+
+           cat <<"EOF"
+  /* stop here, and copy so we don't have to do this twice */
+  tmp_pathspec = xstrdup (newargz[0]);
+
+  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+  strcat (newargz[0], actual_cwrapper_name);
+
+  /* DO want the lt- prefix here if it exists, so use target_name */
+  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+  XFREE (tmp_pathspec);
+  tmp_pathspec = NULL;
+EOF
+
+           case $host_os in
+             mingw*)
+           cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[0], '\\')) != NULL)
+      {
+       *p = '/';
+      }
+    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+      {
+       *p = '/';
+      }
+  }
+EOF
+           ;;
+           esac
+
+           cat <<"EOF"
+  XFREE (target_name);
+  XFREE (actual_cwrapper_path);
+  XFREE (actual_cwrapper_name);
+
+  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
+  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+
+  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
+                 nonnull (lt_argv_zero));
+  for (i = 0; i < newargc; i++)
+    {
+      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
+                     i, nonnull (newargz[i]));
+    }
+
+EOF
+
+           case $host_os in
+             mingw*)
+               cat <<"EOF"
+  /* execv doesn't actually work on mingw as expected on unix */
+  newargz = prepare_spawn (newargz);
+  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      lt_debugprintf (__FILE__, __LINE__,
+                     "(main) failed to launch target \"%s\": %s\n",
+                     lt_argv_zero, nonnull (strerror (errno)));
+      return 127;
+    }
+  return rval;
+EOF
+               ;;
+             *)
+               cat <<"EOF"
+  execv (lt_argv_zero, newargz);
+  return rval; /* =127, but avoids unused variable warning */
+EOF
+               ;;
+           esac
+
+           cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal (__FILE__, __LINE__, "memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+                         string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
+                  nonempty (path));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
+                  nonempty (path));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
+                  nonempty (wrapper));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+       return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+       {
+         concat_name = xstrdup (wrapper);
+         if (check_executable (concat_name))
+           return concat_name;
+         XFREE (concat_name);
+       }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+       has_slash = 1;
+       break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+       {
+         for (p = path; *p; p = p_next)
+           {
+             const char *q;
+             size_t p_len;
+             for (q = p; *q; q++)
+               if (IS_PATH_SEPARATOR (*q))
+                 break;
+             p_len = q - p;
+             p_next = (*q == '\0' ? q : q + 1);
+             if (p_len == 0)
+               {
+                 /* empty path: current directory */
+                 if (getcwd (tmp, LT_PATHMAX) == NULL)
+                   lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+                              nonnull (strerror (errno)));
+                 tmp_len = strlen (tmp);
+                 concat_name =
+                   XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+                 memcpy (concat_name, tmp, tmp_len);
+                 concat_name[tmp_len] = '/';
+                 strcpy (concat_name + tmp_len + 1, wrapper);
+               }
+             else
+               {
+                 concat_name =
+                   XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+                 memcpy (concat_name, p, p_len);
+                 concat_name[p_len] = '/';
+                 strcpy (concat_name + p_len + 1, wrapper);
+               }
+             if (check_executable (concat_name))
+               return concat_name;
+             XFREE (concat_name);
+           }
+       }
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+              nonnull (strerror (errno)));
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      lt_debugprintf (__FILE__, __LINE__,
+                     "checking path component for symlinks: %s\n",
+                     tmp_pathspec);
+      if (lstat (tmp_pathspec, &s) == 0)
+       {
+         if (S_ISLNK (s.st_mode) != 0)
+           {
+             has_symlinks = 1;
+             break;
+           }
+
+         /* search backwards for last DIR_SEPARATOR */
+         p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+         while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+           p--;
+         if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+           {
+             /* no more DIR_SEPARATORS left */
+             break;
+           }
+         *p = '\0';
+       }
+      else
+       {
+         lt_fatal (__FILE__, __LINE__,
+                   "error accessing file \"%s\": %s",
+                   tmp_pathspec, nonnull (strerror (errno)));
+       }
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal (__FILE__, __LINE__,
+               "could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+       *str = '\0';
+    }
+  return str;
+}
+
+void
+lt_debugprintf (const char *file, int line, const char *fmt, ...)
+{
+  va_list args;
+  if (lt_debug)
+    {
+      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
+      va_start (args, fmt);
+      (void) vfprintf (stderr, fmt, args);
+      va_end (args);
+    }
+}
+
+static void
+lt_error_core (int exit_status, const char *file,
+              int line, const char *mode,
+              const char *message, va_list ap)
+{
+  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *file, int line, const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
+  va_end (ap);
+}
+
+static const char *
+nonnull (const char *s)
+{
+  return s ? s : "(null)";
+}
+
+static const char *
+nonempty (const char *s)
+{
+  return (s && !*s) ? "(empty)" : nonnull (s);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_setenv) setting '%s' to '%s'\n",
+                  nonnull (name), nonnull (value));
+  {
+#ifdef HAVE_SETENV
+    /* always make a copy, for consistency with !HAVE_SETENV */
+    char *str = xstrdup (value);
+    setenv (name, str, 1);
+#else
+    int len = strlen (name) + 1 + strlen (value) + 1;
+    char *str = XMALLOC (char, len);
+    sprintf (str, "%s=%s", name, value);
+    if (putenv (str) != EXIT_SUCCESS)
+      {
+        XFREE (str);
+      }
+#endif
+  }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+  char *new_value;
+  if (orig_value && *orig_value)
+    {
+      int orig_value_len = strlen (orig_value);
+      int add_len = strlen (add);
+      new_value = XMALLOC (char, add_len + orig_value_len + 1);
+      if (to_end)
+        {
+          strcpy (new_value, orig_value);
+          strcpy (new_value + orig_value_len, add);
+        }
+      else
+        {
+          strcpy (new_value, add);
+          strcpy (new_value + add_len, orig_value);
+        }
+    }
+  else
+    {
+      new_value = xstrdup (add);
+    }
+  return new_value;
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+                  nonnull (name), nonnull (value));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      /* some systems can't cope with a ':'-terminated path #' */
+      int len = strlen (new_value);
+      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+        {
+          new_value[len-1] = '\0';
+        }
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+  lt_debugprintf (__FILE__, __LINE__,
+                 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+                  nonnull (name), nonnull (value));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+EOF
+           case $host_os in
+             mingw*)
+               cat <<"EOF"
+
+/* Prepares an argument vector before calling spawn().
+   Note that spawn() does not by itself call the command interpreter
+     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
+      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+         GetVersionEx(&v);
+         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
+      }) ? "cmd.exe" : "command.com").
+   Instead it simply concatenates the arguments, separated by ' ', and calls
+   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
+   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
+   special way:
+   - Space and tab are interpreted as delimiters. They are not treated as
+     delimiters if they are surrounded by double quotes: "...".
+   - Unescaped double quotes are removed from the input. Their only effect is
+     that within double quotes, space and tab are treated like normal
+     characters.
+   - Backslashes not followed by double quotes are not special.
+   - But 2*n+1 backslashes followed by a double quote become
+     n backslashes followed by a double quote (n >= 0):
+       \" -> "
+       \\\" -> \"
+       \\\\\" -> \\"
+ */
+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+char **
+prepare_spawn (char **argv)
+{
+  size_t argc;
+  char **new_argv;
+  size_t i;
+
+  /* Count number of arguments.  */
+  for (argc = 0; argv[argc] != NULL; argc++)
+    ;
+
+  /* Allocate new argument vector.  */
+  new_argv = XMALLOC (char *, argc + 1);
+
+  /* Put quoted arguments into the new argument vector.  */
+  for (i = 0; i < argc; i++)
+    {
+      const char *string = argv[i];
+
+      if (string[0] == '\0')
+       new_argv[i] = xstrdup ("\"\"");
+      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+       {
+         int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+         size_t length;
+         unsigned int backslashes;
+         const char *s;
+         char *quoted_string;
+         char *p;
+
+         length = 0;
+         backslashes = 0;
+         if (quote_around)
+           length++;
+         for (s = string; *s != '\0'; s++)
+           {
+             char c = *s;
+             if (c == '"')
+               length += backslashes + 1;
+             length++;
+             if (c == '\\')
+               backslashes++;
+             else
+               backslashes = 0;
+           }
+         if (quote_around)
+           length += backslashes + 1;
+
+         quoted_string = XMALLOC (char, length + 1);
+
+         p = quoted_string;
+         backslashes = 0;
+         if (quote_around)
+           *p++ = '"';
+         for (s = string; *s != '\0'; s++)
+           {
+             char c = *s;
+             if (c == '"')
+               {
+                 unsigned int j;
+                 for (j = backslashes + 1; j > 0; j--)
+                   *p++ = '\\';
+               }
+             *p++ = c;
+             if (c == '\\')
+               backslashes++;
+             else
+               backslashes = 0;
+           }
+         if (quote_around)
+           {
+             unsigned int j;
+             for (j = backslashes; j > 0; j--)
+               *p++ = '\\';
+             *p++ = '"';
+           }
+         *p = '\0';
+
+         new_argv[i] = quoted_string;
+       }
+      else
+       new_argv[i] = (char *) string;
+    }
+  new_argv[argc] = NULL;
+
+  return new_argv;
+}
+EOF
+               ;;
+           esac
+
+            cat <<"EOF"
+void lt_dump_script (FILE* f)
+{
+EOF
+           func_emit_wrapper yes |
+              $SED -e 's/\([\\"]\)/\\\1/g' \
+                  -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
+
+            cat <<"EOF"
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_win32_import_lib_p ARG
+# True if ARG is an import lib, as indicated by $file_magic_cmd
+func_win32_import_lib_p ()
+{
+    $opt_debug
+    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
+    *import*) : ;;
+    *) false ;;
+    esac
+}
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    bindir=
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+       test "$build_libtool_libs" != yes && \
+         func_fatal_configuration "can not build a shared library"
+       build_old_libs=no
+       break
+       ;;
+      -all-static | -static | -static-libtool-libs)
+       case $arg in
+       -all-static)
+         if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+           func_warning "complete static linking is impossible in this configuration"
+         fi
+         if test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+         ;;
+       -static)
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=built
+         ;;
+       -static-libtool-libs)
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+         ;;
+       esac
+       build_libtool_libs=no
+       build_old_libs=yes
+       break
+       ;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+       case $prev in
+       output)
+         func_append compile_command " @OUTPUT@"
+         func_append finalize_command " @OUTPUT@"
+         ;;
+       esac
+
+       case $prev in
+       bindir)
+         bindir="$arg"
+         prev=
+         continue
+         ;;
+       dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           func_append compile_command " @SYMFILE@"
+           func_append finalize_command " @SYMFILE@"
+           preload=yes
+         fi
+         case $arg in
+         *.la | *.lo) ;;  # We handle these cases below.
+         force)
+           if test "$dlself" = no; then
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         self)
+           if test "$prev" = dlprefiles; then
+             dlself=yes
+           elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+             dlself=yes
+           else
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         *)
+           if test "$prev" = dlfiles; then
+             dlfiles="$dlfiles $arg"
+           else
+             dlprefiles="$dlprefiles $arg"
+           fi
+           prev=
+           continue
+           ;;
+         esac
+         ;;
+       expsyms)
+         export_symbols="$arg"
+         test -f "$arg" \
+           || func_fatal_error "symbol file \`$arg' does not exist"
+         prev=
+         continue
+         ;;
+       expsyms_regex)
+         export_symbols_regex="$arg"
+         prev=
+         continue
+         ;;
+       framework)
+         case $host in
+           *-*-darwin*)
+             case "$deplibs " in
+               *" $qarg.ltframework "*) ;;
+               *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+                  ;;
+             esac
+             ;;
+         esac
+         prev=
+         continue
+         ;;
+       inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
+       objectlist)
+         if test -f "$arg"; then
+           save_arg=$arg
+           moreargs=
+           for fil in `cat "$save_arg"`
+           do
+#            moreargs="$moreargs $fil"
+             arg=$fil
+             # A libtool-controlled object.
+
+             # Check to see that this really is a libtool object.
+             if func_lalib_unsafe_p "$arg"; then
+               pic_object=
+               non_pic_object=
+
+               # Read the .lo file
+               func_source "$arg"
+
+               if test -z "$pic_object" ||
+                  test -z "$non_pic_object" ||
+                  test "$pic_object" = none &&
+                  test "$non_pic_object" = none; then
+                 func_fatal_error "cannot find name of object for \`$arg'"
+               fi
+
+               # Extract subdirectory from the argument.
+               func_dirname "$arg" "/" ""
+               xdir="$func_dirname_result"
+
+               if test "$pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 pic_object="$xdir$pic_object"
+
+                 if test "$prev" = dlfiles; then
+                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+                     dlfiles="$dlfiles $pic_object"
+                     prev=
+                     continue
+                   else
+                     # If libtool objects are unsupported, then we need to preload.
+                     prev=dlprefiles
+                   fi
+                 fi
+
+                 # CHECK ME:  I think I busted this.  -Ossama
+                 if test "$prev" = dlprefiles; then
+                   # Preload the old-style object.
+                   dlprefiles="$dlprefiles $pic_object"
+                   prev=
+                 fi
+
+                 # A PIC object.
+                 func_append libobjs " $pic_object"
+                 arg="$pic_object"
+               fi
+
+               # Non-PIC object.
+               if test "$non_pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 non_pic_object="$xdir$non_pic_object"
+
+                 # A standard non-PIC object
+                 func_append non_pic_objects " $non_pic_object"
+                 if test -z "$pic_object" || test "$pic_object" = none ; then
+                   arg="$non_pic_object"
+                 fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 func_append non_pic_objects " $non_pic_object"
+               fi
+             else
+               # Only an error if not doing a dry-run.
+               if $opt_dry_run; then
+                 # Extract subdirectory from the argument.
+                 func_dirname "$arg" "/" ""
+                 xdir="$func_dirname_result"
+
+                 func_lo2o "$arg"
+                 pic_object=$xdir$objdir/$func_lo2o_result
+                 non_pic_object=$xdir$func_lo2o_result
+                 func_append libobjs " $pic_object"
+                 func_append non_pic_objects " $non_pic_object"
+               else
+                 func_fatal_error "\`$arg' is not a valid libtool object"
+               fi
+             fi
+           done
+         else
+           func_fatal_error "link input file \`$arg' does not exist"
+         fi
+         arg=$save_arg
+         prev=
+         continue
+         ;;
+       precious_regex)
+         precious_files_regex="$arg"
+         prev=
+         continue
+         ;;
+       release)
+         release="-$arg"
+         prev=
+         continue
+         ;;
+       rpath | xrpath)
+         # We need an absolute path.
+         case $arg in
+         [\\/]* | [A-Za-z]:[\\/]*) ;;
+         *)
+           func_fatal_error "only absolute run-paths are allowed"
+           ;;
+         esac
+         if test "$prev" = rpath; then
+           case "$rpath " in
+           *" $arg "*) ;;
+           *) rpath="$rpath $arg" ;;
+           esac
+         else
+           case "$xrpath " in
+           *" $arg "*) ;;
+           *) xrpath="$xrpath $arg" ;;
+           esac
+         fi
+         prev=
+         continue
+         ;;
+       shrext)
+         shrext_cmds="$arg"
+         prev=
+         continue
+         ;;
+       weak)
+         weak_libs="$weak_libs $arg"
+         prev=
+         continue
+         ;;
+       xcclinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         func_append compile_command " $qarg"
+         func_append finalize_command " $qarg"
+         continue
+         ;;
+       xcompiler)
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         func_append compile_command " $qarg"
+         func_append finalize_command " $qarg"
+         continue
+         ;;
+       xlinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $wl$qarg"
+         prev=
+         func_append compile_command " $wl$qarg"
+         func_append finalize_command " $wl$qarg"
+         continue
+         ;;
+       *)
+         eval "$prev=\"\$arg\""
+         prev=
+         continue
+         ;;
+       esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+       if test -n "$link_static_flag"; then
+         # See comment for -static flag below, for more details.
+         func_append compile_command " $link_static_flag"
+         func_append finalize_command " $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -allow-undefined)
+       # FIXME: remove this flag sometime in the future.
+       func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+       ;;
+
+      -avoid-version)
+       avoid_version=yes
+       continue
+       ;;
+
+      -bindir)
+       prev=bindir
+       continue
+       ;;
+
+      -dlopen)
+       prev=dlfiles
+       continue
+       ;;
+
+      -dlpreopen)
+       prev=dlprefiles
+       continue
+       ;;
+
+      -export-dynamic)
+       export_dynamic=yes
+       continue
+       ;;
+
+      -export-symbols | -export-symbols-regex)
+       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+         func_fatal_error "more than one -exported-symbols argument is not allowed"
+       fi
+       if test "X$arg" = "X-export-symbols"; then
+         prev=expsyms
+       else
+         prev=expsyms_regex
+       fi
+       continue
+       ;;
+
+      -framework)
+       prev=framework
+       continue
+       ;;
+
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+       case $with_gcc/$host in
+       no/*-*-irix* | /*-*-irix*)
+         func_append compile_command " $arg"
+         func_append finalize_command " $arg"
+         ;;
+       esac
+       continue
+       ;;
+
+      -L*)
+       func_stripname '-L' '' "$arg"
+       dir=$func_stripname_result
+       if test -z "$dir"; then
+         if test "$#" -gt 0; then
+           func_fatal_error "require no space between \`-L' and \`$1'"
+         else
+           func_fatal_error "need path for \`-L' option"
+         fi
+       fi
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         absdir=`cd "$dir" && pwd`
+         test -z "$absdir" && \
+           func_fatal_error "cannot determine absolute directory name of \`$dir'"
+         dir="$absdir"
+         ;;
+       esac
+       case "$deplibs " in
+       *" -L$dir "*) ;;
+       *)
+         deplibs="$deplibs -L$dir"
+         lib_search_path="$lib_search_path $dir"
+         ;;
+       esac
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+         testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$dir:"*) ;;
+         ::) dllsearchpath=$dir;;
+         *) dllsearchpath="$dllsearchpath:$dir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         ::) dllsearchpath=$testbindir;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+       continue
+       ;;
+
+      -l*)
+       if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
+           # These systems don't actually have a C or math library (as such)
+           continue
+           ;;
+         *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C and math libraries are in the System framework
+           deplibs="$deplibs System.ltframework"
+           continue
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           test "X$arg" = "X-lc" && continue
+           ;;
+         esac
+       elif test "X$arg" = "X-lc_r"; then
+        case $host in
+        *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+          # Do not include libc_r directly, use -pthread flag.
+          continue
+          ;;
+        esac
+       fi
+       deplibs="$deplibs $arg"
+       continue
+       ;;
+
+      -module)
+       module=yes
+       continue
+       ;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot)
+       compiler_flags="$compiler_flags $arg"
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+       prev=xcompiler
+       continue
+       ;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+       compiler_flags="$compiler_flags $arg"
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+       case "$new_inherited_linker_flags " in
+           *" $arg "*) ;;
+           * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+       esac
+       continue
+       ;;
+
+      -multi_module)
+       single_module="${wl}-multi_module"
+       continue
+       ;;
+
+      -no-fast-install)
+       fast_install=no
+       continue
+       ;;
+
+      -no-install)
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+         # The PATH hackery in wrapper scripts is required on Windows
+         # and Darwin in order for the loader to find any dlls it needs.
+         func_warning "\`-no-install' is ignored for $host"
+         func_warning "assuming \`-no-fast-install' instead"
+         fast_install=no
+         ;;
+       *) no_install=yes ;;
+       esac
+       continue
+       ;;
+
+      -no-undefined)
+       allow_undefined=no
+       continue
+       ;;
+
+      -objectlist)
+       prev=objectlist
+       continue
+       ;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+       prev=precious_regex
+       continue
+       ;;
+
+      -release)
+       prev=release
+       continue
+       ;;
+
+      -rpath)
+       prev=rpath
+       continue
+       ;;
+
+      -R)
+       prev=xrpath
+       continue
+       ;;
+
+      -R*)
+       func_stripname '-R' '' "$arg"
+       dir=$func_stripname_result
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         func_fatal_error "only absolute run-paths are allowed"
+         ;;
+       esac
+       case "$xrpath " in
+       *" $dir "*) ;;
+       *) xrpath="$xrpath $dir" ;;
+       esac
+       continue
+       ;;
+
+      -shared)
+       # The effects of -shared are defined in a previous loop.
+       continue
+       ;;
+
+      -shrext)
+       prev=shrext
+       continue
+       ;;
+
+      -static | -static-libtool-libs)
+       # The effects of -static are defined in a previous loop.
+       # We used to do the same as -all-static on platforms that
+       # didn't have a PIC flag, but the assumption that the effects
+       # would be equivalent was wrong.  It would break on at least
+       # Digital Unix and AIX.
+       continue
+       ;;
+
+      -thread-safe)
+       thread_safe=yes
+       continue
+       ;;
+
+      -version-info)
+       prev=vinfo
+       continue
+       ;;
+
+      -version-number)
+       prev=vinfo
+       vinfo_number=yes
+       continue
+       ;;
+
+      -weak)
+        prev=weak
+       continue
+       ;;
+
+      -Wc,*)
+       func_stripname '-Wc,' '' "$arg"
+       args=$func_stripname_result
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+         arg="$arg $func_quote_for_eval_result"
+         compiler_flags="$compiler_flags $func_quote_for_eval_result"
+       done
+       IFS="$save_ifs"
+       func_stripname ' ' '' "$arg"
+       arg=$func_stripname_result
+       ;;
+
+      -Wl,*)
+       func_stripname '-Wl,' '' "$arg"
+       args=$func_stripname_result
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+         arg="$arg $wl$func_quote_for_eval_result"
+         compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+         linker_flags="$linker_flags $func_quote_for_eval_result"
+       done
+       IFS="$save_ifs"
+       func_stripname ' ' '' "$arg"
+       arg=$func_stripname_result
+       ;;
+
+      -Xcompiler)
+       prev=xcompiler
+       continue
+       ;;
+
+      -Xlinker)
+       prev=xlinker
+       continue
+       ;;
+
+      -XCClinker)
+       prev=xcclinker
+       continue
+       ;;
+
+      # -msg_* for osf cc
+      -msg_*)
+       func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+
+      # Flags to be passed through unchanged, with rationale:
+      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
+      # -r[0-9][0-9]*        specify processor for the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
+      # +DA*, +DD*           enable 64-bit mode for the HP compiler
+      # -q*                  compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
+      # -F/path              path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # @file                GCC response files
+      # -tp=*                Portland pgcc target processor selection
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
+        func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+
+      *.$objext)
+       # A standard object.
+       objs="$objs $arg"
+       ;;
+
+      *.lo)
+       # A libtool-controlled object.
+
+       # Check to see that this really is a libtool object.
+       if func_lalib_unsafe_p "$arg"; then
+         pic_object=
+         non_pic_object=
+
+         # Read the .lo file
+         func_source "$arg"
+
+         if test -z "$pic_object" ||
+            test -z "$non_pic_object" ||
+            test "$pic_object" = none &&
+            test "$non_pic_object" = none; then
+           func_fatal_error "cannot find name of object for \`$arg'"
+         fi
+
+         # Extract subdirectory from the argument.
+         func_dirname "$arg" "/" ""
+         xdir="$func_dirname_result"
+
+         if test "$pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           pic_object="$xdir$pic_object"
+
+           if test "$prev" = dlfiles; then
+             if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+               dlfiles="$dlfiles $pic_object"
+               prev=
+               continue
+             else
+               # If libtool objects are unsupported, then we need to preload.
+               prev=dlprefiles
+             fi
+           fi
+
+           # CHECK ME:  I think I busted this.  -Ossama
+           if test "$prev" = dlprefiles; then
+             # Preload the old-style object.
+             dlprefiles="$dlprefiles $pic_object"
+             prev=
+           fi
+
+           # A PIC object.
+           func_append libobjs " $pic_object"
+           arg="$pic_object"
+         fi
+
+         # Non-PIC object.
+         if test "$non_pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           non_pic_object="$xdir$non_pic_object"
+
+           # A standard non-PIC object
+           func_append non_pic_objects " $non_pic_object"
+           if test -z "$pic_object" || test "$pic_object" = none ; then
+             arg="$non_pic_object"
+           fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           func_append non_pic_objects " $non_pic_object"
+         fi
+       else
+         # Only an error if not doing a dry-run.
+         if $opt_dry_run; then
+           # Extract subdirectory from the argument.
+           func_dirname "$arg" "/" ""
+           xdir="$func_dirname_result"
+
+           func_lo2o "$arg"
+           pic_object=$xdir$objdir/$func_lo2o_result
+           non_pic_object=$xdir$func_lo2o_result
+           func_append libobjs " $pic_object"
+           func_append non_pic_objects " $non_pic_object"
+         else
+           func_fatal_error "\`$arg' is not a valid libtool object"
+         fi
+       fi
+       ;;
+
+      *.$libext)
+       # An archive.
+       deplibs="$deplibs $arg"
+       old_deplibs="$old_deplibs $arg"
+       continue
+       ;;
+
+      *.la)
+       # A libtool-controlled library.
+
+       if test "$prev" = dlfiles; then
+         # This library was specified with -dlopen.
+         dlfiles="$dlfiles $arg"
+         prev=
+       elif test "$prev" = dlprefiles; then
+         # The library was specified with -dlpreopen.
+         dlprefiles="$dlprefiles $arg"
+         prev=
+       else
+         deplibs="$deplibs $arg"
+       fi
+       continue
+       ;;
+
+      # Some other compiler argument.
+      *)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       func_quote_for_eval "$arg"
+       arg="$func_quote_for_eval_result"
+       ;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_duplicate_deps ; then
+       case "$libs " in
+       *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+       esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+       for pre_post_dep in $predeps $postdeps; do
+         case "$pre_post_deps " in
+         *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+         esac
+         pre_post_deps="$pre_post_deps $pre_post_dep"
+       done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+       passes="conv dlpreopen link"
+       for file in $dlfiles $dlprefiles; do
+         case $file in
+         *.la) ;;
+         *)
+           func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+           ;;
+         esac
+       done
+       ;;
+    prog)
+       compile_deplibs=
+       finalize_deplibs=
+       alldeplibs=no
+       newdlfiles=
+       newdlprefiles=
+       passes="conv scan dlopen dlpreopen link"
+       ;;
+    *)  passes="conv"
+       ;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+       ## FIXME: Find the place where the list is rebuilt in the wrong
+       ##        order, and fix it there properly
+        tmp_deplibs=
+       for deplib in $deplibs; do
+         tmp_deplibs="$deplib $tmp_deplibs"
+       done
+       deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+        test "$linkmode,$pass" = "prog,scan"; then
+       libs="$deplibs"
+       deplibs=
+      fi
+      if test "$linkmode" = prog; then
+       case $pass in
+       dlopen) libs="$dlfiles" ;;
+       dlpreopen) libs="$dlprefiles" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+       # Collect and forward deplibs of preopened libtool libs
+       for lib in $dlprefiles; do
+         # Ignore non-libtool-libs
+         dependency_libs=
+         case $lib in
+         *.la) func_source "$lib" ;;
+         esac
+
+         # Collect preopened libtool deplibs, except any this library
+         # has declared as weak libs
+         for deplib in $dependency_libs; do
+           func_basename "$deplib"
+            deplib_base=$func_basename_result
+           case " $weak_libs " in
+           *" $deplib_base "*) ;;
+           *) deplibs="$deplibs $deplib" ;;
+           esac
+         done
+       done
+       libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+       # Collect dlpreopened libraries
+       save_deplibs="$deplibs"
+       deplibs=
+      fi
+
+      for deplib in $libs; do
+       lib=
+       found=no
+       case $deplib in
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           compiler_flags="$compiler_flags $deplib"
+           if test "$linkmode" = lib ; then
+               case "$new_inherited_linker_flags " in
+                   *" $deplib "*) ;;
+                   * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+               esac
+           fi
+         fi
+         continue
+         ;;
+       -l*)
+         if test "$linkmode" != lib && test "$linkmode" != prog; then
+           func_warning "\`-l' is ignored for archives/objects"
+           continue
+         fi
+         func_stripname '-l' '' "$deplib"
+         name=$func_stripname_result
+         if test "$linkmode" = lib; then
+           searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+         else
+           searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+         fi
+         for searchdir in $searchdirs; do
+           for search_ext in .la $std_shrext .so .a; do
+             # Search the libtool library
+             lib="$searchdir/lib${name}${search_ext}"
+             if test -f "$lib"; then
+               if test "$search_ext" = ".la"; then
+                 found=yes
+               else
+                 found=no
+               fi
+               break 2
+             fi
+           done
+         done
+         if test "$found" != yes; then
+           # deplib doesn't seem to be a libtool library
+           if test "$linkmode,$pass" = "prog,link"; then
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             deplibs="$deplib $deplibs"
+             test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+           fi
+           continue
+         else # deplib is a libtool library
+           # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+           # We need to do some special things here, and not later.
+           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+             case " $predeps $postdeps " in
+             *" $deplib "*)
+               if func_lalib_p "$lib"; then
+                 library_names=
+                 old_library=
+                 func_source "$lib"
+                 for l in $old_library $library_names; do
+                   ll="$l"
+                 done
+                 if test "X$ll" = "X$old_library" ; then # only static version available
+                   found=no
+                   func_dirname "$lib" "" "."
+                   ladir="$func_dirname_result"
+                   lib=$ladir/$old_library
+                   if test "$linkmode,$pass" = "prog,link"; then
+                     compile_deplibs="$deplib $compile_deplibs"
+                     finalize_deplibs="$deplib $finalize_deplibs"
+                   else
+                     deplibs="$deplib $deplibs"
+                     test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+                   fi
+                   continue
+                 fi
+               fi
+               ;;
+             *) ;;
+             esac
+           fi
+         fi
+         ;; # -l
+       *.ltframework)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           deplibs="$deplib $deplibs"
+           if test "$linkmode" = lib ; then
+               case "$new_inherited_linker_flags " in
+                   *" $deplib "*) ;;
+                   * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+               esac
+           fi
+         fi
+         continue
+         ;;
+       -L*)
+         case $linkmode in
+         lib)
+           deplibs="$deplib $deplibs"
+           test "$pass" = conv && continue
+           newdependency_libs="$deplib $newdependency_libs"
+           func_stripname '-L' '' "$deplib"
+           newlib_search_path="$newlib_search_path $func_stripname_result"
+           ;;
+         prog)
+           if test "$pass" = conv; then
+             deplibs="$deplib $deplibs"
+             continue
+           fi
+           if test "$pass" = scan; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           func_stripname '-L' '' "$deplib"
+           newlib_search_path="$newlib_search_path $func_stripname_result"
+           ;;
+         *)
+           func_warning "\`-L' is ignored for archives/objects"
+           ;;
+         esac # linkmode
+         continue
+         ;; # -L
+       -R*)
+         if test "$pass" = link; then
+           func_stripname '-R' '' "$deplib"
+           dir=$func_stripname_result
+           # Make sure the xrpath contains only unique directories.
+           case "$xrpath " in
+           *" $dir "*) ;;
+           *) xrpath="$xrpath $dir" ;;
+           esac
+         fi
+         deplibs="$deplib $deplibs"
+         continue
+         ;;
+       *.la) lib="$deplib" ;;
+       *.$libext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+           continue
+         fi
+         case $linkmode in
+         lib)
+           # Linking convenience modules into shared libraries is allowed,
+           # but linking other static libraries is non-portable.
+           case " $dlpreconveniencelibs " in
+           *" $deplib "*) ;;
+           *)
+             valid_a_lib=no
+             case $deplibs_check_method in
+               match_pattern*)
+                 set dummy $deplibs_check_method; shift
+                 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+                 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
+                   | $EGREP "$match_pattern_regex" > /dev/null; then
+                   valid_a_lib=yes
+                 fi
+               ;;
+               pass_all)
+                 valid_a_lib=yes
+               ;;
+             esac
+             if test "$valid_a_lib" != yes; then
+               echo
+               $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because the file extensions .$libext of this argument makes me believe"
+               echo "*** that it is just a static archive that I should not use here."
+             else
+               echo
+               $ECHO "*** Warning: Linking the shared library $output against the"
+               $ECHO "*** static library $deplib is not portable!"
+               deplibs="$deplib $deplibs"
+             fi
+             ;;
+           esac
+           continue
+           ;;
+         prog)
+           if test "$pass" != link; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           continue
+           ;;
+         esac # linkmode
+         ;; # *.$libext
+       *.lo | *.$objext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+         elif test "$linkmode" = prog; then
+           if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+             # If there is no dlopen support or we're linking statically,
+             # we need to preload.
+             newdlprefiles="$newdlprefiles $deplib"
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             newdlfiles="$newdlfiles $deplib"
+           fi
+         fi
+         continue
+         ;;
+       %DEPLIBS%)
+         alldeplibs=yes
+         continue
+         ;;
+       esac # case $deplib
+
+       if test "$found" = yes || test -f "$lib"; then :
+       else
+         func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+       fi
+
+       # Check to see that this really is a libtool archive.
+       func_lalib_unsafe_p "$lib" \
+         || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+       func_dirname "$lib" "" "."
+       ladir="$func_dirname_result"
+
+       dlname=
+       dlopen=
+       dlpreopen=
+       libdir=
+       library_names=
+       old_library=
+       inherited_linker_flags=
+       # If the library was installed with an old release of libtool,
+       # it will not redefine variables installed, or shouldnotlink
+       installed=yes
+       shouldnotlink=no
+       avoidtemprpath=
+
+
+       # Read the .la file
+       func_source "$lib"
+
+       # Convert "-framework foo" to "foo.ltframework"
+       if test -n "$inherited_linker_flags"; then
+         tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
+         for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+           case " $new_inherited_linker_flags " in
+             *" $tmp_inherited_linker_flag "*) ;;
+             *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+           esac
+         done
+       fi
+       dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       if test "$linkmode,$pass" = "lib,link" ||
+          test "$linkmode,$pass" = "prog,scan" ||
+          { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+         test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+         test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+       fi
+
+       if test "$pass" = conv; then
+         # Only check for convenience libraries
+         deplibs="$lib $deplibs"
+         if test -z "$libdir"; then
+           if test -z "$old_library"; then
+             func_fatal_error "cannot find name of link library for \`$lib'"
+           fi
+           # It is a libtool convenience library, so add in its objects.
+           convenience="$convenience $ladir/$objdir/$old_library"
+           old_convenience="$old_convenience $ladir/$objdir/$old_library"
+         elif test "$linkmode" != prog && test "$linkmode" != lib; then
+           func_fatal_error "\`$lib' is not a convenience library"
+         fi
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           deplibs="$deplib $deplibs"
+           if $opt_duplicate_deps ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done
+         continue
+       fi # $pass = conv
+
+
+       # Get the name of the library we link against.
+       linklib=
+       for l in $old_library $library_names; do
+         linklib="$l"
+       done
+       if test -z "$linklib"; then
+         func_fatal_error "cannot find name of link library for \`$lib'"
+       fi
+
+       # This library was specified with -dlopen.
+       if test "$pass" = dlopen; then
+         if test -z "$libdir"; then
+           func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+         fi
+         if test -z "$dlname" ||
+            test "$dlopen_support" != yes ||
+            test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking
+           # statically, we need to preload.  We also need to preload any
+           # dependent libraries so libltdl's deplib preloader doesn't
+           # bomb out in the load deplibs phase.
+           dlprefiles="$dlprefiles $lib $dependency_libs"
+         else
+           newdlfiles="$newdlfiles $lib"
+         fi
+         continue
+       fi # $pass = dlopen
+
+       # We need an absolute path.
+       case $ladir in
+       [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+       *)
+         abs_ladir=`cd "$ladir" && pwd`
+         if test -z "$abs_ladir"; then
+           func_warning "cannot determine absolute directory name of \`$ladir'"
+           func_warning "passing it literally to the linker, although it might fail"
+           abs_ladir="$ladir"
+         fi
+         ;;
+       esac
+       func_basename "$lib"
+       laname="$func_basename_result"
+
+       # Find the relevant object directory and library name.
+       if test "X$installed" = Xyes; then
+         if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           func_warning "library \`$lib' was moved."
+           dir="$ladir"
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+           dir="$libdir"
+           absdir="$libdir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+         if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           dir="$ladir"
+           absdir="$abs_ladir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         else
+           dir="$ladir/$objdir"
+           absdir="$abs_ladir/$objdir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         fi
+       fi # $installed = yes
+       func_stripname 'lib' '.la' "$laname"
+       name=$func_stripname_result
+
+       # This library was specified with -dlpreopen.
+       if test "$pass" = dlpreopen; then
+         if test -z "$libdir" && test "$linkmode" = prog; then
+           func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+         fi
+         # Prefer using a static library (so that no silly _DYNAMIC symbols
+         # are required to link).
+         if test -n "$old_library"; then
+           newdlprefiles="$newdlprefiles $dir/$old_library"
+           # Keep a list of preopened convenience libraries to check
+           # that they are being used correctly in the link pass.
+           test -z "$libdir" && \
+               dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+         # Otherwise, use the dlname, so that lt_dlopen finds it.
+         elif test -n "$dlname"; then
+           newdlprefiles="$newdlprefiles $dir/$dlname"
+         else
+           newdlprefiles="$newdlprefiles $dir/$linklib"
+         fi
+       fi # $pass = dlpreopen
+
+       if test -z "$libdir"; then
+         # Link the convenience library
+         if test "$linkmode" = lib; then
+           deplibs="$dir/$old_library $deplibs"
+         elif test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$dir/$old_library $compile_deplibs"
+           finalize_deplibs="$dir/$old_library $finalize_deplibs"
+         else
+           deplibs="$lib $deplibs" # used for prog,scan pass
+         fi
+         continue
+       fi
+
+
+       if test "$linkmode" = prog && test "$pass" != link; then
+         newlib_search_path="$newlib_search_path $ladir"
+         deplibs="$lib $deplibs"
+
+         linkalldeplibs=no
+         if test "$link_all_deplibs" != no || test -z "$library_names" ||
+            test "$build_libtool_libs" = no; then
+           linkalldeplibs=yes
+         fi
+
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           case $deplib in
+           -L*) func_stripname '-L' '' "$deplib"
+                newlib_search_path="$newlib_search_path $func_stripname_result"
+                ;;
+           esac
+           # Need to link against all dependency_libs?
+           if test "$linkalldeplibs" = yes; then
+             deplibs="$deplib $deplibs"
+           else
+             # Need to hardcode shared library paths
+             # or/and link against static libraries
+             newdependency_libs="$deplib $newdependency_libs"
+           fi
+           if $opt_duplicate_deps ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done # for deplib
+         continue
+       fi # $linkmode = prog...
+
+       if test "$linkmode,$pass" = "prog,link"; then
+         if test -n "$library_names" &&
+            { { test "$prefer_static_libs" = no ||
+                test "$prefer_static_libs,$installed" = "built,yes"; } ||
+              test -z "$old_library"; }; then
+           # We need to hardcode the library path
+           if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+             # Make sure the rpath contains only unique directories.
+             case "$temp_rpath:" in
+             *"$absdir:"*) ;;
+             *) temp_rpath="$temp_rpath$absdir:" ;;
+             esac
+           fi
+
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi # $linkmode,$pass = prog,link...
+
+         if test "$alldeplibs" = yes &&
+            { test "$deplibs_check_method" = pass_all ||
+              { test "$build_libtool_libs" = yes &&
+                test -n "$library_names"; }; }; then
+           # We only need to search for static libraries
+           continue
+         fi
+       fi
+
+       link_static=no # Whether the deplib will be linked statically
+       use_static_libs=$prefer_static_libs
+       if test "$use_static_libs" = built && test "$installed" = yes; then
+         use_static_libs=no
+       fi
+       if test -n "$library_names" &&
+          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+         case $host in
+         *cygwin* | *mingw* | *cegcc*)
+             # No point in relinking DLLs because paths are not encoded
+             notinst_deplibs="$notinst_deplibs $lib"
+             need_relink=no
+           ;;
+         *)
+           if test "$installed" = no; then
+             notinst_deplibs="$notinst_deplibs $lib"
+             need_relink=yes
+           fi
+           ;;
+         esac
+         # This is a shared library
+
+         # Warn about portability, can't link against -module's on some
+         # systems (darwin).  Don't bleat about dlopened modules though!
+         dlopenmodule=""
+         for dlpremoduletest in $dlprefiles; do
+           if test "X$dlpremoduletest" = "X$lib"; then
+             dlopenmodule="$dlpremoduletest"
+             break
+           fi
+         done
+         if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+           echo
+           if test "$linkmode" = prog; then
+             $ECHO "*** Warning: Linking the executable $output against the loadable module"
+           else
+             $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+           fi
+           $ECHO "*** $linklib is not portable!"
+         fi
+         if test "$linkmode" = lib &&
+            test "$hardcode_into_libs" = yes; then
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi
+
+         if test -n "$old_archive_from_expsyms_cmds"; then
+           # figure out the soname
+           set dummy $library_names
+           shift
+           realname="$1"
+           shift
+           libname=`eval "\\$ECHO \"$libname_spec\""`
+           # use dlname if we got it. it's perfectly good, no?
+           if test -n "$dlname"; then
+             soname="$dlname"
+           elif test -n "$soname_spec"; then
+             # bleh windows
+             case $host in
+             *cygwin* | mingw* | *cegcc*)
+               func_arith $current - $age
+               major=$func_arith_result
+               versuffix="-$major"
+               ;;
+             esac
+             eval soname=\"$soname_spec\"
+           else
+             soname="$realname"
+           fi
+
+           # Make a new name for the extract_expsyms_cmds to use
+           soroot="$soname"
+           func_basename "$soroot"
+           soname="$func_basename_result"
+           func_stripname 'lib' '.dll' "$soname"
+           newlib=libimp-$func_stripname_result.a
+
+           # If the library has no export list, then create one now
+           if test -f "$output_objdir/$soname-def"; then :
+           else
+             func_verbose "extracting exported symbol list from \`$soname'"
+             func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+           fi
+
+           # Create $newlib
+           if test -f "$output_objdir/$newlib"; then :; else
+             func_verbose "generating import library for \`$soname'"
+             func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+           fi
+           # make sure the library variables are pointing to the new library
+           dir=$output_objdir
+           linklib=$newlib
+         fi # test -n "$old_archive_from_expsyms_cmds"
+
+         if test "$linkmode" = prog || test "$mode" != relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           lib_linked=yes
+           case $hardcode_action in
+           immediate | unsupported)
+             if test "$hardcode_direct" = no; then
+               add="$dir/$linklib"
+               case $host in
+                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+                   *-*-unixware7*) add_dir="-L$dir" ;;
+                 *-*-darwin* )
+                   # if the lib is a (non-dlopened) module then we can not
+                   # link against it, someone is ignoring the earlier warnings
+                   if /usr/bin/file -L $add 2> /dev/null |
+                        $GREP ": [^:]* bundle" >/dev/null ; then
+                     if test "X$dlopenmodule" != "X$lib"; then
+                       $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+                       if test -z "$old_library" ; then
+                         echo
+                         echo "*** And there doesn't seem to be a static archive available"
+                         echo "*** The link will probably fail, sorry"
+                       else
+                         add="$dir/$old_library"
+                       fi
+                     elif test -n "$old_library"; then
+                       add="$dir/$old_library"
+                     fi
+                   fi
+               esac
+             elif test "$hardcode_minus_L" = no; then
+               case $host in
+               *-*-sunos*) add_shlibpath="$dir" ;;
+               esac
+               add_dir="-L$dir"
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = no; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           relink)
+             if test "$hardcode_direct" = yes &&
+                test "$hardcode_direct_absolute" = no; then
+               add="$dir/$linklib"
+             elif test "$hardcode_minus_L" = yes; then
+               add_dir="-L$dir"
+               # Try looking first in the location we're being installed to.
+               if test -n "$inst_prefix_dir"; then
+                 case $libdir in
+                   [\\/]*)
+                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                     ;;
+                 esac
+               fi
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = yes; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           *) lib_linked=no ;;
+           esac
+
+           if test "$lib_linked" != yes; then
+             func_fatal_configuration "unsupported hardcode properties"
+           fi
+
+           if test -n "$add_shlibpath"; then
+             case :$compile_shlibpath: in
+             *":$add_shlibpath:"*) ;;
+             *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+             esac
+           fi
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+             test -n "$add" && compile_deplibs="$add $compile_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+             if test "$hardcode_direct" != yes &&
+                test "$hardcode_minus_L" != yes &&
+                test "$hardcode_shlibpath_var" = yes; then
+               case :$finalize_shlibpath: in
+               *":$libdir:"*) ;;
+               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+               esac
+             fi
+           fi
+         fi
+
+         if test "$linkmode" = prog || test "$mode" = relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           # Finalize command for both is simple: just hardcode it.
+           if test "$hardcode_direct" = yes &&
+              test "$hardcode_direct_absolute" = no; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+             add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+             *":$libdir:"*) ;;
+             *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+             esac
+             add="-l$name"
+           elif test "$hardcode_automatic" = yes; then
+             if test -n "$inst_prefix_dir" &&
+                test -f "$inst_prefix_dir$libdir/$linklib" ; then
+               add="$inst_prefix_dir$libdir/$linklib"
+             else
+               add="$libdir/$linklib"
+             fi
+           else
+             # We cannot seem to hardcode it, guess we'll fake it.
+             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+                 [\\/]*)
+                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                   ;;
+               esac
+             fi
+             add="-l$name"
+           fi
+
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+             test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+           fi
+         fi
+       elif test "$linkmode" = prog; then
+         # Here we assume that one of hardcode_direct or hardcode_minus_L
+         # is not unsupported.  This is valid on all known static and
+         # shared platforms.
+         if test "$hardcode_direct" != unsupported; then
+           test -n "$old_library" && linklib="$old_library"
+           compile_deplibs="$dir/$linklib $compile_deplibs"
+           finalize_deplibs="$dir/$linklib $finalize_deplibs"
+         else
+           compile_deplibs="-l$name -L$dir $compile_deplibs"
+           finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+         fi
+       elif test "$build_libtool_libs" = yes; then
+         # Not a shared library
+         if test "$deplibs_check_method" != pass_all; then
+           # We're trying link a shared library against a static one
+           # but the system doesn't support it.
+
+           # Just print a warning and add the library to dependency_libs so
+           # that the program can be linked against the static library.
+           echo
+           $ECHO "*** Warning: This system can not link to static lib archive $lib."
+           echo "*** I have the capability to make that library automatically link in when"
+           echo "*** you link to this library.  But I can only do this if you have a"
+           echo "*** shared version of the library, which you do not appear to have."
+           if test "$module" = yes; then
+             echo "*** But as you try to build a module library, libtool will still create "
+             echo "*** a static module, that should work as long as the dlopening application"
+             echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+             if test -z "$global_symbol_pipe"; then
+               echo
+               echo "*** However, this would only work if libtool was able to extract symbol"
+               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+               echo "*** not find such a program.  So, this module is probably useless."
+               echo "*** \`nm' from GNU binutils and a full rebuild may help."
+             fi
+             if test "$build_old_libs" = no; then
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         else
+           deplibs="$dir/$old_library $deplibs"
+           link_static=yes
+         fi
+       fi # link shared/static library?
+
+       if test "$linkmode" = lib; then
+         if test -n "$dependency_libs" &&
+            { test "$hardcode_into_libs" != yes ||
+              test "$build_old_libs" = yes ||
+              test "$link_static" = yes; }; then
+           # Extract -R from dependency_libs
+           temp_deplibs=
+           for libdir in $dependency_libs; do
+             case $libdir in
+             -R*) func_stripname '-R' '' "$libdir"
+                  temp_xrpath=$func_stripname_result
+                  case " $xrpath " in
+                  *" $temp_xrpath "*) ;;
+                  *) xrpath="$xrpath $temp_xrpath";;
+                  esac;;
+             *) temp_deplibs="$temp_deplibs $libdir";;
+             esac
+           done
+           dependency_libs="$temp_deplibs"
+         fi
+
+         newlib_search_path="$newlib_search_path $absdir"
+         # Link against this library
+         test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+         # ... and its dependency_libs
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           newdependency_libs="$deplib $newdependency_libs"
+           if $opt_duplicate_deps ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done
+
+         if test "$link_all_deplibs" != no; then
+           # Add the search paths of all dependency libraries
+           for deplib in $dependency_libs; do
+             path=
+             case $deplib in
+             -L*) path="$deplib" ;;
+             *.la)
+               func_dirname "$deplib" "" "."
+               dir="$func_dirname_result"
+               # We need an absolute path.
+               case $dir in
+               [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+               *)
+                 absdir=`cd "$dir" && pwd`
+                 if test -z "$absdir"; then
+                   func_warning "cannot determine absolute directory name of \`$dir'"
+                   absdir="$dir"
+                 fi
+                 ;;
+               esac
+               if $GREP "^installed=no" $deplib > /dev/null; then
+               case $host in
+               *-*-darwin*)
+                 depdepl=
+                 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+                 if test -n "$deplibrary_names" ; then
+                   for tmp in $deplibrary_names ; do
+                     depdepl=$tmp
+                   done
+                   if test -f "$absdir/$objdir/$depdepl" ; then
+                     depdepl="$absdir/$objdir/$depdepl"
+                     darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+                     compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+                     linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+                     path=
+                   fi
+                 fi
+                 ;;
+               *)
+                 path="-L$absdir/$objdir"
+                 ;;
+               esac
+               else
+                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+                 test -z "$libdir" && \
+                   func_fatal_error "\`$deplib' is not a valid libtool archive"
+                 test "$absdir" != "$libdir" && \
+                   func_warning "\`$deplib' seems to be moved"
+
+                 path="-L$absdir"
+               fi
+               ;;
+             esac
+             case " $deplibs " in
+             *" $path "*) ;;
+             *) deplibs="$path $deplibs" ;;
+             esac
+           done
+         fi # link_all_deplibs != no
+       fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+       if test "$linkmode" = "prog"; then
+         compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+         finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+       else
+         compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+       # Link the dlpreopened libraries before other libraries
+       for deplib in $save_deplibs; do
+         deplibs="$deplib $deplibs"
+       done
+      fi
+      if test "$pass" != dlopen; then
+       if test "$pass" != conv; then
+         # Make sure lib_search_path contains only unique directories.
+         lib_search_path=
+         for dir in $newlib_search_path; do
+           case "$lib_search_path " in
+           *" $dir "*) ;;
+           *) lib_search_path="$lib_search_path $dir" ;;
+           esac
+         done
+         newlib_search_path=
+       fi
+
+       if test "$linkmode,$pass" != "prog,link"; then
+         vars="deplibs"
+       else
+         vars="compile_deplibs finalize_deplibs"
+       fi
+       for var in $vars dependency_libs; do
+         # Add libraries to $var in reverse order
+         eval tmp_libs=\"\$$var\"
+         new_libs=
+         for deplib in $tmp_libs; do
+           # FIXME: Pedantically, this is the right thing to do, so
+           #        that some nasty dependency loop isn't accidentally
+           #        broken:
+           #new_libs="$deplib $new_libs"
+           # Pragmatically, this seems to cause very few problems in
+           # practice:
+           case $deplib in
+           -L*) new_libs="$deplib $new_libs" ;;
+           -R*) ;;
+           *)
+             # And here is the reason: when a library appears more
+             # than once as an explicit dependence of a library, or
+             # is implicitly linked in more than once by the
+             # compiler, it is considered special, and multiple
+             # occurrences thereof are not removed.  Compare this
+             # with having the same library being listed as a
+             # dependency of multiple other libraries: in this case,
+             # we know (pedantically, we assume) the library does not
+             # need to be listed more than once, so we keep only the
+             # last copy.  This is not always right, but it is rare
+             # enough that we require users that really mean to play
+             # such unportable linking tricks to link the library
+             # using -Wl,-lname, so that libtool does not consider it
+             # for duplicate removal.
+             case " $specialdeplibs " in
+             *" $deplib "*) new_libs="$deplib $new_libs" ;;
+             *)
+               case " $new_libs " in
+               *" $deplib "*) ;;
+               *) new_libs="$deplib $new_libs" ;;
+               esac
+               ;;
+             esac
+             ;;
+           esac
+         done
+         tmp_libs=
+         for deplib in $new_libs; do
+           case $deplib in
+           -L*)
+             case " $tmp_libs " in
+             *" $deplib "*) ;;
+             *) tmp_libs="$tmp_libs $deplib" ;;
+             esac
+             ;;
+           *) tmp_libs="$tmp_libs $deplib" ;;
+           esac
+         done
+         eval $var=\"$tmp_libs\"
+       done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+       case " $predeps $postdeps $compiler_lib_search_path " in
+       *" $i "*)
+         i=""
+         ;;
+       esac
+       if test -n "$i" ; then
+         tmp_libs="$tmp_libs $i"
+       fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+       func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+       func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+       func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+       func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+       func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+       func_stripname 'lib' '.la' "$outputname"
+       name=$func_stripname_result
+       eval shared_ext=\"$shrext_cmds\"
+       eval libname=\"$libname_spec\"
+       ;;
+      *)
+       test "$module" = no && \
+         func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+       if test "$need_lib_prefix" != no; then
+         # Add the "lib" prefix for modules if required
+         func_stripname '' '.la' "$outputname"
+         name=$func_stripname_result
+         eval shared_ext=\"$shrext_cmds\"
+         eval libname=\"$libname_spec\"
+       else
+         func_stripname '' '.la' "$outputname"
+         libname=$func_stripname_result
+       fi
+       ;;
+      esac
+
+      if test -n "$objs"; then
+       if test "$deplibs_check_method" != pass_all; then
+         func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+       else
+         echo
+         $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+         $ECHO "*** objects $objs is not portable!"
+         libobjs="$libobjs $objs"
+       fi
+      fi
+
+      test "$dlself" != no && \
+       func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+       func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+       if test "$build_libtool_libs" = yes; then
+         # Building a libtool convenience library.
+         # Some compilers have problems with a `.al' extension so
+         # convenience libraries should have the same extension an
+         # archive normally would.
+         oldlibs="$output_objdir/$libname.$libext $oldlibs"
+         build_libtool_libs=convenience
+         build_old_libs=yes
+       fi
+
+       test -n "$vinfo" && \
+         func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+       test -n "$release" && \
+         func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+       # Parse the version information argument.
+       save_ifs="$IFS"; IFS=':'
+       set dummy $vinfo 0 0 0
+       shift
+       IFS="$save_ifs"
+
+       test -n "$7" && \
+         func_fatal_help "too many parameters to \`-version-info'"
+
+       # convert absolute version numbers to libtool ages
+       # this retains compatibility with .la files and attempts
+       # to make the code below a bit more comprehensible
+
+       case $vinfo_number in
+       yes)
+         number_major="$1"
+         number_minor="$2"
+         number_revision="$3"
+         #
+         # There are really only two kinds -- those that
+         # use the current revision as the major version
+         # and those that subtract age and use age as
+         # a minor version.  But, then there is irix
+         # which has an extra 1 added just for fun
+         #
+         case $version_type in
+         darwin|linux|osf|windows|none)
+           func_arith $number_major + $number_minor
+           current=$func_arith_result
+           age="$number_minor"
+           revision="$number_revision"
+           ;;
+         freebsd-aout|freebsd-elf|qnx|sunos)
+           current="$number_major"
+           revision="$number_minor"
+           age="0"
+           ;;
+         irix|nonstopux)
+           func_arith $number_major + $number_minor
+           current=$func_arith_result
+           age="$number_minor"
+           revision="$number_minor"
+           lt_irix_increment=no
+           ;;
+         esac
+         ;;
+       no)
+         current="$1"
+         revision="$2"
+         age="$3"
+         ;;
+       esac
+
+       # Check that each of the things are valid numbers.
+       case $current in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "CURRENT \`$current' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       case $revision in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "REVISION \`$revision' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       case $age in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         func_error "AGE \`$age' must be a nonnegative integer"
+         func_fatal_error "\`$vinfo' is not valid version information"
+         ;;
+       esac
+
+       if test "$age" -gt "$current"; then
+         func_error "AGE \`$age' is greater than the current interface number \`$current'"
+         func_fatal_error "\`$vinfo' is not valid version information"
+       fi
+
+       # Calculate the version variables.
+       major=
+       versuffix=
+       verstring=
+       case $version_type in
+       none) ;;
+
+       darwin)
+         # Like Linux, but with the current version available in
+         # verstring for coding it into the library header
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix="$major.$age.$revision"
+         # Darwin ld doesn't like 0 for these options...
+         func_arith $current + 1
+         minor_current=$func_arith_result
+         xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+         verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current"
+         ;;
+
+       irix | nonstopux)
+         if test "X$lt_irix_increment" = "Xno"; then
+           func_arith $current - $age
+         else
+           func_arith $current - $age + 1
+         fi
+         major=$func_arith_result
+
+         case $version_type in
+           nonstopux) verstring_prefix=nonstopux ;;
+           *)         verstring_prefix=sgi ;;
+         esac
+         verstring="$verstring_prefix$major.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$revision
+         while test "$loop" -ne 0; do
+           func_arith $revision - $loop
+           iface=$func_arith_result
+           func_arith $loop - 1
+           loop=$func_arith_result
+           verstring="$verstring_prefix$major.$iface:$verstring"
+         done
+
+         # Before this point, $major must not contain `.'.
+         major=.$major
+         versuffix="$major.$revision"
+         ;;
+
+       linux)
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix="$major.$age.$revision"
+         ;;
+
+       osf)
+         func_arith $current - $age
+         major=.$func_arith_result
+         versuffix=".$current.$age.$revision"
+         verstring="$current.$age.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$age
+         while test "$loop" -ne 0; do
+           func_arith $current - $loop
+           iface=$func_arith_result
+           func_arith $loop - 1
+           loop=$func_arith_result
+           verstring="$verstring:${iface}.0"
+         done
+
+         # Make executables depend on our current version.
+         verstring="$verstring:${current}.0"
+         ;;
+
+       qnx)
+         major=".$current"
+         versuffix=".$current"
+         ;;
+
+       sunos)
+         major=".$current"
+         versuffix=".$current.$revision"
+         ;;
+
+       windows)
+         # Use '-' rather than '.', since we only want one
+         # extension on DOS 8.3 filesystems.
+         func_arith $current - $age
+         major=$func_arith_result
+         versuffix="-$major"
+         ;;
+
+       *)
+         func_fatal_configuration "unknown library version type \`$version_type'"
+         ;;
+       esac
+
+       # Clear the version info if we defaulted, and they specified a release.
+       if test -z "$vinfo" && test -n "$release"; then
+         major=
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
+         if test "$need_version" = no; then
+           versuffix=
+         else
+           versuffix=".0.0"
+         fi
+       fi
+
+       # Remove version info from name if versioning should be avoided
+       if test "$avoid_version" = yes && test "$need_version" = no; then
+         major=
+         versuffix=
+         verstring=""
+       fi
+
+       # Check to see if the archive will have undefined symbols.
+       if test "$allow_undefined" = yes; then
+         if test "$allow_undefined_flag" = unsupported; then
+           func_warning "undefined symbols not allowed in $host shared libraries"
+           build_libtool_libs=no
+           build_old_libs=yes
+         fi
+       else
+         # Don't allow undefined symbols.
+         allow_undefined_flag="$no_undefined_flag"
+       fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      libobjs="$libobjs $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$mode" != relink; then
+       # Remove our outputs, but don't remove object files since they
+       # may have been created when compiling PIC objects.
+       removelist=
+       tempremovelist=`$ECHO "$output_objdir/*"`
+       for p in $tempremovelist; do
+         case $p in
+           *.$objext | *.gcno)
+              ;;
+           $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+              if test "X$precious_files_regex" != "X"; then
+                if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+                then
+                  continue
+                fi
+              fi
+              removelist="$removelist $p"
+              ;;
+           *) ;;
+         esac
+       done
+       test -n "$removelist" && \
+         func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+       oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+       # Transform .lo files to .o files.
+       oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #        lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
+      #        deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
+      #        dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       temp_xrpath=
+       for libdir in $xrpath; do
+         temp_xrpath="$temp_xrpath -R$libdir"
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+       if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+         dependency_libs="$temp_xrpath $dependency_libs"
+       fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+       case " $dlprefiles $dlfiles " in
+       *" $lib "*) ;;
+       *) dlfiles="$dlfiles $lib" ;;
+       esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+       case "$dlprefiles " in
+       *" $lib "*) ;;
+       *) dlprefiles="$dlprefiles $lib" ;;
+       esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+       if test -n "$rpath"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
+           # these systems don't actually have a c library (as such)!
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C library is in the System framework
+           deplibs="$deplibs System.ltframework"
+           ;;
+         *-*-netbsd*)
+           # Don't link with libc until the a.out ld.so is fixed.
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           ;;
+         *)
+           # Add libc to deplibs on all other systems if necessary.
+           if test "$build_libtool_need_lc" = "yes"; then
+             deplibs="$deplibs -lc"
+           fi
+           ;;
+         esac
+       fi
+
+       # Transform deplibs into only deplibs that can be linked in shared.
+       name_save=$name
+       libname_save=$libname
+       release_save=$release
+       versuffix_save=$versuffix
+       major_save=$major
+       # I'm not sure if I'm treating the release correctly.  I think
+       # release should show up in the -l (ie -lgmp5) so we don't want to
+       # add it in twice.  Is that correct?
+       release=""
+       versuffix=""
+       major=""
+       newdeplibs=
+       droppeddeps=no
+       case $deplibs_check_method in
+       pass_all)
+         # Don't check for shared/static.  Everything works.
+         # This might be a little naive.  We might want to check
+         # whether the library exists or not.  But this is on
+         # osf3 & osf4 and I'm not really sure... Just
+         # implementing what was already the behavior.
+         newdeplibs=$deplibs
+         ;;
+       test_compile)
+         # This code stresses the "libraries are programs" paradigm to its
+         # limits. Maybe even breaks it.  We compile a program, linking it
+         # against the deplibs as a proxy for the library.  Then we can check
+         # whether they linked in statically or dynamically with ldd.
+         $opt_dry_run || $RM conftest.c
+         cat > conftest.c <<EOF
+         int main() { return 0; }
+EOF
+         $opt_dry_run || $RM conftest
+         if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+           ldd_output=`ldd conftest`
+           for i in $deplibs; do
+             case $i in
+             -l*)
+               func_stripname -l '' "$i"
+               name=$func_stripname_result
+               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                 case " $predeps $postdeps " in
+                 *" $i "*)
+                   newdeplibs="$newdeplibs $i"
+                   i=""
+                   ;;
+                 esac
+               fi
+               if test -n "$i" ; then
+                 libname=`eval "\\$ECHO \"$libname_spec\""`
+                 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+                 set dummy $deplib_matches; shift
+                 deplib_match=$1
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   newdeplibs="$newdeplibs $i"
+                 else
+                   droppeddeps=yes
+                   echo
+                   $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+                   echo "*** I have the capability to make that library automatically link in when"
+                   echo "*** you link to this library.  But I can only do this if you have a"
+                   echo "*** shared version of the library, which I believe you do not have"
+                   echo "*** because a test_compile did reveal that the linker did not use it for"
+                   echo "*** its dynamic dependency list that programs get resolved with at runtime."
+                 fi
+               fi
+               ;;
+             *)
+               newdeplibs="$newdeplibs $i"
+               ;;
+             esac
+           done
+         else
+           # Error occurred in the first compile.  Let's try to salvage
+           # the situation: Compile a separate program for each library.
+           for i in $deplibs; do
+             case $i in
+             -l*)
+               func_stripname -l '' "$i"
+               name=$func_stripname_result
+               $opt_dry_run || $RM conftest
+               if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+                 ldd_output=`ldd conftest`
+                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                   case " $predeps $postdeps " in
+                   *" $i "*)
+                     newdeplibs="$newdeplibs $i"
+                     i=""
+                     ;;
+                   esac
+                 fi
+                 if test -n "$i" ; then
+                   libname=`eval "\\$ECHO \"$libname_spec\""`
+                   deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+                   set dummy $deplib_matches; shift
+                   deplib_match=$1
+                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                     newdeplibs="$newdeplibs $i"
+                   else
+                     droppeddeps=yes
+                     echo
+                     $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+                     echo "*** I have the capability to make that library automatically link in when"
+                     echo "*** you link to this library.  But I can only do this if you have a"
+                     echo "*** shared version of the library, which you do not appear to have"
+                     echo "*** because a test_compile did reveal that the linker did not use this one"
+                     echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+                   fi
+                 fi
+               else
+                 droppeddeps=yes
+                 echo
+                 $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+                 echo "*** make it link in!  You will probably need to install it or some"
+                 echo "*** library that it depends on before this library will be fully"
+                 echo "*** functional.  Installing it before continuing would be even better."
+               fi
+               ;;
+             *)
+               newdeplibs="$newdeplibs $i"
+               ;;
+             esac
+           done
+         fi
+         ;;
+       file_magic*)
+         set dummy $deplibs_check_method; shift
+         file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+         for a_deplib in $deplibs; do
+           case $a_deplib in
+           -l*)
+             func_stripname -l '' "$a_deplib"
+             name=$func_stripname_result
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval "\\$ECHO \"$libname_spec\""`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                     # Follow soft links.
+                     if ls -lLd "$potent_lib" 2>/dev/null |
+                        $GREP " -> " >/dev/null; then
+                       continue
+                     fi
+                     # The statement above tries to avoid entering an
+                     # endless loop below, in case of cyclic links.
+                     # We might still enter an endless loop, since a link
+                     # loop can be closed while we follow links,
+                     # but so what?
+                     potlib="$potent_lib"
+                     while test -h "$potlib" 2>/dev/null; do
+                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+                       case $potliblink in
+                       [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+                       *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+                       esac
+                     done
+                     if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+                        $SED -e 10q |
+                        $EGREP "$file_magic_regex" > /dev/null; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+               else
+                 $ECHO "*** with $libname and none of the candidates passed a file format test"
+                 $ECHO "*** using a file magic. Last file checked: $potlib"
+               fi
+             fi
+             ;;
+           *)
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+             ;;
+           esac
+         done # Gone through all deplibs.
+         ;;
+       match_pattern*)
+         set dummy $deplibs_check_method; shift
+         match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+         for a_deplib in $deplibs; do
+           case $a_deplib in
+           -l*)
+             func_stripname -l '' "$a_deplib"
+             name=$func_stripname_result
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval "\\$ECHO \"$libname_spec\""`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                   potlib="$potent_lib" # see symlink-check above in file_magic test
+                   if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
+                      $EGREP "$match_pattern_regex" > /dev/null; then
+                     newdeplibs="$newdeplibs $a_deplib"
+                     a_deplib=""
+                     break 2
+                   fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have"
+               echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+               else
+                 $ECHO "*** with $libname and none of the candidates passed a file format test"
+                 $ECHO "*** using a regex pattern. Last file checked: $potlib"
+               fi
+             fi
+             ;;
+           *)
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+             ;;
+           esac
+         done # Gone through all deplibs.
+         ;;
+       none | unknown | *)
+         newdeplibs=""
+         tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
+         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+           for i in $predeps $postdeps ; do
+             # can't use Xsed below, because $i might contain '/'
+             tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+           done
+         fi
+         case $tmp_deplibs in
+         *[!\  \ ]*)
+           echo
+           if test "X$deplibs_check_method" = "Xnone"; then
+             echo "*** Warning: inter-library dependencies are not supported in this platform."
+           else
+             echo "*** Warning: inter-library dependencies are not known to be supported."
+           fi
+           echo "*** All declared inter-library dependencies are being dropped."
+           droppeddeps=yes
+           ;;
+         esac
+         ;;
+       esac
+       versuffix=$versuffix_save
+       major=$major_save
+       release=$release_save
+       libname=$libname_save
+       name=$name_save
+
+       case $host in
+       *-*-rhapsody* | *-*-darwin1.[012])
+         # On Rhapsody replace the C library with the System framework
+         newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
+         ;;
+       esac
+
+       if test "$droppeddeps" = yes; then
+         if test "$module" = yes; then
+           echo
+           echo "*** Warning: libtool could not satisfy all declared inter-library"
+           $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+           echo "*** a static module, that should work as long as the dlopening"
+           echo "*** application is linked with the -dlopen flag."
+           if test -z "$global_symbol_pipe"; then
+             echo
+             echo "*** However, this would only work if libtool was able to extract symbol"
+             echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+             echo "*** not find such a program.  So, this module is probably useless."
+             echo "*** \`nm' from GNU binutils and a full rebuild may help."
+           fi
+           if test "$build_old_libs" = no; then
+             oldlibs="$output_objdir/$libname.$libext"
+             build_libtool_libs=module
+             build_old_libs=yes
+           else
+             build_libtool_libs=no
+           fi
+         else
+           echo "*** The inter-library dependencies that have been dropped here will be"
+           echo "*** automatically added whenever a program is linked with this library"
+           echo "*** or is declared to -dlopen it."
+
+           if test "$allow_undefined" = no; then
+             echo
+             echo "*** Since this library must not contain undefined symbols,"
+             echo "*** because either the platform does not support them or"
+             echo "*** it was explicitly requested with -no-undefined,"
+             echo "*** libtool will only create a static version of it."
+             if test "$build_old_libs" = no; then
+               oldlibs="$output_objdir/$libname.$libext"
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         fi
+       fi
+       # Done checking deplibs!
+       deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+       *-*-darwin*)
+         newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+         ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+       if test "$hardcode_into_libs" = yes; then
+         # Hardcode the library paths
+         hardcode_libdirs=
+         dep_rpath=
+         rpath="$finalize_rpath"
+         test "$mode" != relink && rpath="$compile_rpath$rpath"
+         for libdir in $rpath; do
+           if test -n "$hardcode_libdir_flag_spec"; then
+             if test -n "$hardcode_libdir_separator"; then
+               if test -z "$hardcode_libdirs"; then
+                 hardcode_libdirs="$libdir"
+               else
+                 # Just accumulate the unique libdirs.
+                 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+                 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+                   ;;
+                 *)
+                   hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+                   ;;
+                 esac
+               fi
+             else
+               eval flag=\"$hardcode_libdir_flag_spec\"
+               dep_rpath="$dep_rpath $flag"
+             fi
+           elif test -n "$runpath_var"; then
+             case "$perm_rpath " in
+             *" $libdir "*) ;;
+             *) perm_rpath="$perm_rpath $libdir" ;;
+             esac
+           fi
+         done
+         # Substitute the hardcoded libdirs into the rpath.
+         if test -n "$hardcode_libdir_separator" &&
+            test -n "$hardcode_libdirs"; then
+           libdir="$hardcode_libdirs"
+           if test -n "$hardcode_libdir_flag_spec_ld"; then
+             eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+           else
+             eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+           fi
+         fi
+         if test -n "$runpath_var" && test -n "$perm_rpath"; then
+           # We should set the runpath_var.
+           rpath=
+           for dir in $perm_rpath; do
+             rpath="$rpath$dir:"
+           done
+           eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+         fi
+         test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+       fi
+
+       shlibpath="$finalize_shlibpath"
+       test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+       if test -n "$shlibpath"; then
+         eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+       fi
+
+       # Get the real and link names of the library.
+       eval shared_ext=\"$shrext_cmds\"
+       eval library_names=\"$library_names_spec\"
+       set dummy $library_names
+       shift
+       realname="$1"
+       shift
+
+       if test -n "$soname_spec"; then
+         eval soname=\"$soname_spec\"
+       else
+         soname="$realname"
+       fi
+       if test -z "$dlname"; then
+         dlname=$soname
+       fi
+
+       lib="$output_objdir/$realname"
+       linknames=
+       for link
+       do
+         linknames="$linknames $link"
+       done
+
+       # Use standard objects if they are pic
+       test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+       test "X$libobjs" = "X " && libobjs=
+
+       delfiles=
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+         export_symbols="$output_objdir/$libname.uexp"
+         delfiles="$delfiles $export_symbols"
+       fi
+
+       orig_export_symbols=
+       case $host_os in
+       cygwin* | mingw* | cegcc*)
+         if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+           # exporting using user supplied symfile
+           if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+             # and it's NOT already a .def file. Must figure out
+             # which of the given symbols are data symbols and tag
+             # them as such. So, trigger use of export_symbols_cmds.
+             # export_symbols gets reassigned inside the "prepare
+             # the list of exported symbols" if statement, so the
+             # include_expsyms logic still works.
+             orig_export_symbols="$export_symbols"
+             export_symbols=
+             always_export_symbols=yes
+           fi
+         fi
+         ;;
+       esac
+
+       # Prepare the list of exported symbols
+       if test -z "$export_symbols"; then
+         if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+           func_verbose "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $opt_dry_run || $RM $export_symbols
+           cmds=$export_symbols_cmds
+           save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             eval cmd=\"$cmd\"
+             func_len " $cmd"
+             len=$func_len_result
+             if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+               func_show_eval "$cmd" 'exit $?'
+               skipped_export=false
+             else
+               # The command line is too long to execute in one step.
+               func_verbose "using reloadable object file for export list..."
+               skipped_export=:
+               # Break out early, otherwise skipped_export may be
+               # set to false by a later but shorter cmd.
+               break
+             fi
+           done
+           IFS="$save_ifs"
+           if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+             func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+       fi
+
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         tmp_export_symbols="$export_symbols"
+         test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+         $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+       fi
+
+       if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+         # The given exports_symbols file has to be filtered, so filter it.
+         func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+         # FIXME: $output_objdir/$libname.filter potentially contains lots of
+         # 's' commands which not all seds can handle. GNU sed should be fine
+         # though. Also, the filter scales superlinearly with the number of
+         # global variables. join(1) would be nice here, but unfortunately
+         # isn't a blessed tool.
+         $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+         delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+         export_symbols=$output_objdir/$libname.def
+         $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+       fi
+
+       tmp_deplibs=
+       for test_deplib in $deplibs; do
+         case " $convenience " in
+         *" $test_deplib "*) ;;
+         *)
+           tmp_deplibs="$tmp_deplibs $test_deplib"
+           ;;
+         esac
+       done
+       deplibs="$tmp_deplibs"
+
+       if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec" &&
+           test "$compiler_needs_object" = yes &&
+           test -z "$libobjs"; then
+           # extract the archives, so we have objects to list.
+           # TODO: could optimize this to just extract one archive.
+           whole_archive_flag_spec=
+         fi
+         if test -n "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+           test "X$libobjs" = "X " && libobjs=
+         else
+           gentop="$output_objdir/${outputname}x"
+           generated="$generated $gentop"
+
+           func_extract_archives $gentop $convenience
+           libobjs="$libobjs $func_extract_archives_result"
+           test "X$libobjs" = "X " && libobjs=
+         fi
+       fi
+
+       if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+         eval flag=\"$thread_safe_flag_spec\"
+         linker_flags="$linker_flags $flag"
+       fi
+
+       # Make a backup of the uninstalled library when relinking
+       if test "$mode" = relink; then
+         $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+       fi
+
+       # Do each of the archive commands.
+       if test "$module" = yes && test -n "$module_cmds" ; then
+         if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+           eval test_cmds=\"$module_expsym_cmds\"
+           cmds=$module_expsym_cmds
+         else
+           eval test_cmds=\"$module_cmds\"
+           cmds=$module_cmds
+         fi
+       else
+         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+           eval test_cmds=\"$archive_expsym_cmds\"
+           cmds=$archive_expsym_cmds
+         else
+           eval test_cmds=\"$archive_cmds\"
+           cmds=$archive_cmds
+         fi
+       fi
+
+       if test "X$skipped_export" != "X:" &&
+          func_len " $test_cmds" &&
+          len=$func_len_result &&
+          test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         :
+       else
+         # The command line is too long to link in one step, link piecewise
+         # or, if using GNU ld and skipped_export is not :, use a linker
+         # script.
+
+         # Save the value of $output and $libobjs because we want to
+         # use them later.  If we have whole_archive_flag_spec, we
+         # want to use save_libobjs as it was before
+         # whole_archive_flag_spec was expanded, because we can't
+         # assume the linker understands whole_archive_flag_spec.
+         # This may have to be revisited, in case too many
+         # convenience libraries get linked in and end up exceeding
+         # the spec.
+         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+         fi
+         save_output=$output
+         func_basename "$output"
+         output_la=$func_basename_result
+
+         # Clear the reloadable object creation command queue and
+         # initialize k to one.
+         test_cmds=
+         concat_cmds=
+         objlist=
+         last_robj=
+         k=1
+
+         if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+           output=${output_objdir}/${output_la}.lnkscript
+           func_verbose "creating GNU ld script: $output"
+           echo 'INPUT (' > $output
+           for obj in $save_libobjs
+           do
+             $ECHO "$obj" >> $output
+           done
+           echo ')' >> $output
+           delfiles="$delfiles $output"
+         elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+           output=${output_objdir}/${output_la}.lnk
+           func_verbose "creating linker input file list: $output"
+           : > $output
+           set x $save_libobjs
+           shift
+           firstobj=
+           if test "$compiler_needs_object" = yes; then
+             firstobj="$1 "
+             shift
+           fi
+           for obj
+           do
+             $ECHO "$obj" >> $output
+           done
+           delfiles="$delfiles $output"
+           output=$firstobj\"$file_list_spec$output\"
+         else
+           if test -n "$save_libobjs"; then
+             func_verbose "creating reloadable object files..."
+             output=$output_objdir/$output_la-${k}.$objext
+             eval test_cmds=\"$reload_cmds\"
+             func_len " $test_cmds"
+             len0=$func_len_result
+             len=$len0
+
+             # Loop over the list of objects to be linked.
+             for obj in $save_libobjs
+             do
+               func_len " $obj"
+               func_arith $len + $func_len_result
+               len=$func_arith_result
+               if test "X$objlist" = X ||
+                  test "$len" -lt "$max_cmd_len"; then
+                 func_append objlist " $obj"
+               else
+                 # The command $test_cmds is almost too long, add a
+                 # command to the queue.
+                 if test "$k" -eq 1 ; then
+                   # The first file doesn't have a previous command to add.
+                   reload_objs=$objlist
+                   eval concat_cmds=\"$reload_cmds\"
+                 else
+                   # All subsequent reloadable object files will link in
+                   # the last one created.
+                   reload_objs="$objlist $last_robj"
+                   eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
+                 fi
+                 last_robj=$output_objdir/$output_la-${k}.$objext
+                 func_arith $k + 1
+                 k=$func_arith_result
+                 output=$output_objdir/$output_la-${k}.$objext
+                 objlist=" $obj"
+                 func_len " $last_robj"
+                 func_arith $len0 + $func_len_result
+                 len=$func_arith_result
+               fi
+             done
+             # Handle the remaining objects by creating one last
+             # reloadable object file.  All subsequent reloadable object
+             # files will link in the last one created.
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             reload_objs="$objlist $last_robj"
+             eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+             if test -n "$last_robj"; then
+               eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+             fi
+             delfiles="$delfiles $output"
+
+           else
+             output=
+           fi
+
+           if ${skipped_export-false}; then
+             func_verbose "generating symbol list for \`$libname.la'"
+             export_symbols="$output_objdir/$libname.exp"
+             $opt_dry_run || $RM $export_symbols
+             libobjs=$output
+             # Append the command to create the export file.
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+             if test -n "$last_robj"; then
+               eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+             fi
+           fi
+
+           test -n "$save_libobjs" &&
+             func_verbose "creating a temporary reloadable object file: $output"
+
+           # Loop through the commands generated above and execute them.
+           save_ifs="$IFS"; IFS='~'
+           for cmd in $concat_cmds; do
+             IFS="$save_ifs"
+             $opt_silent || {
+                 func_quote_for_expand "$cmd"
+                 eval "func_echo $func_quote_for_expand_result"
+             }
+             $opt_dry_run || eval "$cmd" || {
+               lt_exit=$?
+
+               # Restore the uninstalled library and exit
+               if test "$mode" = relink; then
+                 ( cd "$output_objdir" && \
+                   $RM "${realname}T" && \
+                   $MV "${realname}U" "$realname" )
+               fi
+
+               exit $lt_exit
+             }
+           done
+           IFS="$save_ifs"
+
+           if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+             func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+
+          if ${skipped_export-false}; then
+           if test -n "$export_symbols" && test -n "$include_expsyms"; then
+             tmp_export_symbols="$export_symbols"
+             test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+             $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+           fi
+
+           if test -n "$orig_export_symbols"; then
+             # The given exports_symbols file has to be filtered, so filter it.
+             func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+             # FIXME: $output_objdir/$libname.filter potentially contains lots of
+             # 's' commands which not all seds can handle. GNU sed should be fine
+             # though. Also, the filter scales superlinearly with the number of
+             # global variables. join(1) would be nice here, but unfortunately
+             # isn't a blessed tool.
+             $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+             delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+             export_symbols=$output_objdir/$libname.def
+             $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+           fi
+         fi
+
+         libobjs=$output
+         # Restore the value of output.
+         output=$save_output
+
+         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+           test "X$libobjs" = "X " && libobjs=
+         fi
+         # Expand the library linking commands again to reset the
+         # value of $libobjs for piecewise linking.
+
+         # Do each of the archive commands.
+         if test "$module" = yes && test -n "$module_cmds" ; then
+           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+             cmds=$module_expsym_cmds
+           else
+             cmds=$module_cmds
+           fi
+         else
+           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+             cmds=$archive_expsym_cmds
+           else
+             cmds=$archive_cmds
+           fi
+         fi
+       fi
+
+       if test -n "$delfiles"; then
+         # Append the command to remove temporary files to $cmds.
+         eval cmds=\"\$cmds~\$RM $delfiles\"
+       fi
+
+       # Add any objects from preloaded convenience libraries
+       if test -n "$dlprefiles"; then
+         gentop="$output_objdir/${outputname}x"
+         generated="$generated $gentop"
+
+         func_extract_archives $gentop $dlprefiles
+         libobjs="$libobjs $func_extract_archives_result"
+         test "X$libobjs" = "X " && libobjs=
+       fi
+
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $opt_silent || {
+           func_quote_for_expand "$cmd"
+           eval "func_echo $func_quote_for_expand_result"
+         }
+         $opt_dry_run || eval "$cmd" || {
+           lt_exit=$?
+
+           # Restore the uninstalled library and exit
+           if test "$mode" = relink; then
+             ( cd "$output_objdir" && \
+               $RM "${realname}T" && \
+               $MV "${realname}U" "$realname" )
+           fi
+
+           exit $lt_exit
+         }
+       done
+       IFS="$save_ifs"
+
+       # Restore the uninstalled library and exit
+       if test "$mode" = relink; then
+         $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+         if test -n "$convenience"; then
+           if test -z "$whole_archive_flag_spec"; then
+             func_show_eval '${RM}r "$gentop"'
+           fi
+         fi
+
+         exit $EXIT_SUCCESS
+       fi
+
+       # Create links to the real library.
+       for linkname in $linknames; do
+         if test "$realname" != "$linkname"; then
+           func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+         fi
+       done
+
+       # If -module or -export-dynamic was specified, set the dlname.
+       if test "$module" = yes || test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+       func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+       func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+       func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+       func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+       test -n "$objs$old_deplibs" && \
+         func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+       libobj=$output
+       func_lo2o "$libobj"
+       obj=$func_lo2o_result
+       ;;
+      *)
+       libobj=
+       obj="$output"
+       ;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+       if test -n "$whole_archive_flag_spec"; then
+         eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+         reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+       else
+         gentop="$output_objdir/${obj}x"
+         generated="$generated $gentop"
+
+         func_extract_archives $gentop $convenience
+         reload_conv_objs="$reload_objs $func_extract_archives_result"
+       fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+       if test -n "$gentop"; then
+         func_show_eval '${RM}r "$gentop"'
+       fi
+
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+       if test -n "$gentop"; then
+         func_show_eval '${RM}r "$gentop"'
+       fi
+
+       # Create an invalid libtool object if no PIC, so that we don't
+       # accidentally link it into a program.
+       # $show "echo timestamp > $libobj"
+       # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+       # Only do commands if we really have different PIC objects.
+       reload_objs="$libobjs $reload_conv_objs"
+       output="$libobj"
+       func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+       func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+       *cygwin*) func_stripname '' '.exe' "$output"
+                 output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+       func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+       func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+       && test "$dlopen_self" = unknown \
+       && test "$dlopen_self_static" = unknown && \
+         func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+       # On Rhapsody replace the C library is the System framework
+       compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
+       finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
+       ;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+       # Don't allow lazy linking, it breaks C++ global constructors
+       # But is supposedly fixed on 10.4 or later (yay!).
+       if test "$tagname" = CXX ; then
+         case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+           10.[0123])
+             compile_command="$compile_command ${wl}-bind_at_load"
+             finalize_command="$finalize_command ${wl}-bind_at_load"
+           ;;
+         esac
+       fi
+       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+       compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+       ;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $compile_deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $compile_deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       for libdir in $rpath $xrpath; do
+         # This is the magic to use -rpath.
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$perm_rpath " in
+         *" $libdir "*) ;;
+         *) perm_rpath="$perm_rpath $libdir" ;;
+         esac
+       fi
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+         testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$libdir:"*) ;;
+         ::) dllsearchpath=$libdir;;
+         *) dllsearchpath="$dllsearchpath:$libdir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         ::) dllsearchpath=$testbindir;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$finalize_perm_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+       # Transform all the library objects into standard objects.
+       compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+       finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+       func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cegcc* | *mingw32ce*)
+        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
+        wrappers_required=no
+        ;;
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+       # Replace the output file specification.
+       compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+       link_command="$compile_command$compile_rpath"
+
+       # We have no uninstalled library dependencies, so finalize right now.
+       exit_status=0
+       func_show_eval "$link_command" 'exit_status=$?'
+
+       # Delete the generated files.
+       if test -f "$output_objdir/${outputname}S.${objext}"; then
+         func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+       fi
+
+       exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+       finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+       if test -n "$perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+       if test -n "$finalize_perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $finalize_perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+      fi
+
+      if test "$no_install" = yes; then
+       # We don't need to create a wrapper script.
+       link_command="$compile_var$compile_command$compile_rpath"
+       # Replace the output file specification.
+       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+       # Delete the old output file.
+       $opt_dry_run || $RM $output
+       # Link the executable and exit
+       func_show_eval "$link_command" 'exit $?'
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+       # Fast installation is not supported
+       link_command="$compile_var$compile_command$compile_rpath"
+       relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+       func_warning "this platform does not like uninstalled shared libraries"
+       func_warning "\`$output' will be relinked during installation"
+      else
+       if test "$fast_install" != no; then
+         link_command="$finalize_var$compile_command$finalize_rpath"
+         if test "$fast_install" = yes; then
+           relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+         else
+           # fast_install is set to needless
+           relink_command=
+         fi
+       else
+         link_command="$compile_var$compile_command$compile_rpath"
+         relink_command="$finalize_var$finalize_command$finalize_rpath"
+       fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+       # Preserve any variables that may affect compiler behavior
+       for var in $variables_saved_for_relink; do
+         if eval test -z \"\${$var+set}\"; then
+           relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+         elif eval var_value=\$$var; test -z "$var_value"; then
+           relink_command="$var=; export $var; $relink_command"
+         else
+           func_quote_for_eval "$var_value"
+           relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+         fi
+       done
+       relink_command="(cd `pwd`; $relink_command)"
+       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+       # win32 will think the script is a binary if it has
+       # a .exe suffix, so we strip it off here.
+       case $output in
+         *.exe) func_stripname '' '.exe' "$output"
+                output=$func_stripname_result ;;
+       esac
+       # test for cygwin because mv fails w/o .exe extensions
+       case $host in
+         *cygwin*)
+           exeext=.exe
+           func_stripname '' '.exe' "$outputname"
+           outputname=$func_stripname_result ;;
+         *) exeext= ;;
+       esac
+       case $host in
+         *cygwin* | *mingw* )
+           func_dirname_and_basename "$output" "" "."
+           output_name=$func_basename_result
+           output_path=$func_dirname_result
+           cwrappersource="$output_path/$objdir/lt-$output_name.c"
+           cwrapper="$output_path/$output_name.exe"
+           $RM $cwrappersource $cwrapper
+           trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+           func_emit_cwrapperexe_src > $cwrappersource
+
+           # The wrapper executable is built using the $host compiler,
+           # because it contains $host paths and files. If cross-
+           # compiling, it, like the target executable, must be
+           # executed on the $host or under an emulation environment.
+           $opt_dry_run || {
+             $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+             $STRIP $cwrapper
+           }
+
+           # Now, create the wrapper script for func_source use:
+           func_ltwrapper_scriptname $cwrapper
+           $RM $func_ltwrapper_scriptname_result
+           trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+           $opt_dry_run || {
+             # note: this script will not be executed, so do not chmod.
+             if test "x$build" = "x$host" ; then
+               $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+             else
+               func_emit_wrapper no > $func_ltwrapper_scriptname_result
+             fi
+           }
+         ;;
+         * )
+           $RM $output
+           trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+           func_emit_wrapper no > $output
+           chmod +x $output
+         ;;
+       esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+       oldobjs="$libobjs_save $symfileobj"
+       addlibs="$convenience"
+       build_libtool_libs=no
+      else
+       if test "$build_libtool_libs" = module; then
+         oldobjs="$libobjs_save"
+         build_libtool_libs=no
+       else
+         oldobjs="$old_deplibs $non_pic_objects"
+         if test "$preload" = yes && test -f "$symfileobj"; then
+           oldobjs="$oldobjs $symfileobj"
+         fi
+       fi
+       addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+       gentop="$output_objdir/${outputname}x"
+       generated="$generated $gentop"
+
+       func_extract_archives $gentop $addlibs
+       oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       cmds=$old_archive_from_new_cmds
+      else
+
+       # Add any objects from preloaded convenience libraries
+       if test -n "$dlprefiles"; then
+         gentop="$output_objdir/${outputname}x"
+         generated="$generated $gentop"
+
+         func_extract_archives $gentop $dlprefiles
+         oldobjs="$oldobjs $func_extract_archives_result"
+       fi
+
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+       if (for obj in $oldobjs
+           do
+             func_basename "$obj"
+             $ECHO "$func_basename_result"
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         echo "copying selected object files to avoid basename conflicts..."
+         gentop="$output_objdir/${outputname}x"
+         generated="$generated $gentop"
+         func_mkdir_p "$gentop"
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           func_basename "$obj"
+           objbase="$func_basename_result"
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               func_arith $counter + 1
+               counter=$func_arith_result
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
+       eval cmds=\"$old_archive_cmds\"
+
+       func_len " $cmds"
+       len=$func_len_result
+       if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         cmds=$old_archive_cmds
+       else
+         # the command line is too long to link in one step, link in parts
+         func_verbose "using piecewise archive linking..."
+         save_RANLIB=$RANLIB
+         RANLIB=:
+         objlist=
+         concat_cmds=
+         save_oldobjs=$oldobjs
+         oldobjs=
+         # Is there a better way of finding the last object in the list?
+         for obj in $save_oldobjs
+         do
+           last_oldobj=$obj
+         done
+         eval test_cmds=\"$old_archive_cmds\"
+         func_len " $test_cmds"
+         len0=$func_len_result
+         len=$len0
+         for obj in $save_oldobjs
+         do
+           func_len " $obj"
+           func_arith $len + $func_len_result
+           len=$func_arith_result
+           func_append objlist " $obj"
+           if test "$len" -lt "$max_cmd_len"; then
+             :
+           else
+             # the above command should be used before it gets too long
+             oldobjs=$objlist
+             if test "$obj" = "$last_oldobj" ; then
+               RANLIB=$save_RANLIB
+             fi
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+             objlist=
+             len=$len0
+           fi
+         done
+         RANLIB=$save_RANLIB
+         oldobjs=$objlist
+         if test "X$oldobjs" = "X" ; then
+           eval cmds=\"\$concat_cmds\"
+         else
+           eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+         fi
+       fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+       if eval test -z \"\${$var+set}\"; then
+         relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+       elif eval var_value=\$$var; test -z "$var_value"; then
+         relink_command="$var=; export $var; $relink_command"
+       else
+         func_quote_for_eval "$var_value"
+         relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+       fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+       relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+       for installed in no yes; do
+         if test "$installed" = yes; then
+           if test -z "$install_libdir"; then
+             break
+           fi
+           output="$output_objdir/$outputname"i
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
+             case $deplib in
+             *.la)
+               func_basename "$deplib"
+               name="$func_basename_result"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$deplib' is not a valid libtool archive"
+               newdependency_libs="$newdependency_libs $libdir/$name"
+               ;;
+             *) newdependency_libs="$newdependency_libs $deplib" ;;
+             esac
+           done
+           dependency_libs="$newdependency_libs"
+           newdlfiles=
+
+           for lib in $dlfiles; do
+             case $lib in
+             *.la)
+               func_basename "$lib"
+               name="$func_basename_result"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$lib' is not a valid libtool archive"
+               newdlfiles="$newdlfiles $libdir/$name"
+               ;;
+             *) newdlfiles="$newdlfiles $lib" ;;
+             esac
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+             *.la)
+               # Only pass preopened files to the pseudo-archive (for
+               # eventual linking with the app. that links it) if we
+               # didn't already link the preopened objects directly into
+               # the library:
+               func_basename "$lib"
+               name="$func_basename_result"
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+               test -z "$libdir" && \
+                 func_fatal_error "\`$lib' is not a valid libtool archive"
+               newdlprefiles="$newdlprefiles $libdir/$name"
+               ;;
+             esac
+           done
+           dlprefiles="$newdlprefiles"
+         else
+           newdlfiles=
+           for lib in $dlfiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlfiles="$newdlfiles $abs"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlprefiles="$newdlprefiles $abs"
+           done
+           dlprefiles="$newdlprefiles"
+         fi
+         $RM $output
+         # place dlname in correct position for cygwin
+         # In fact, it would be nice if we could use this code for all target
+         # systems that can't hard-code library paths into their executables
+         # and that have no shared library path variable independent of PATH,
+         # but it turns out we can't easily determine that from inspecting
+         # libtool variables, so we have to hard-code the OSs to which it
+         # applies here; at the moment, that means platforms that use the PE
+         # object format with DLL files.  See the long comment at the top of
+         # tests/bindir.at for full details.
+         tdlname=$dlname
+         case $host,$output,$installed,$module,$dlname in
+           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
+             # If a -bindir argument was supplied, place the dll there.
+             if test "x$bindir" != x ;
+             then
+               func_relative_path "$install_libdir" "$bindir"
+               tdlname=$func_relative_path_result$dlname
+             else
+               # Otherwise fall back on heuristic.
+               tdlname=../bin/$dlname
+             fi
+             ;;
+         esac
+         $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+         if test "$installed" = no && test "$need_relink" = yes; then
+           $ECHO >> $output "\
+relink_command=\"$relink_command\""
+         fi
+       done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) RM="$RM $arg"; rmforce=yes ;;
+      -*) RM="$RM $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+       objdir="$origobjdir"
+      else
+       objdir="$dir/$origobjdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+       case " $rmdirs " in
+         *" $objdir "*) ;;
+         *) rmdirs="$rmdirs $objdir" ;;
+       esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+        { test -h "$file"; } >/dev/null 2>&1 ||
+        test -f "$file"; then
+       :
+      elif test -d "$file"; then
+       exit_status=1
+       continue
+      elif test "$rmforce" = yes; then
+       continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+       # Possibly a libtool archive, so verify it.
+       if func_lalib_p "$file"; then
+         func_source $dir/$name
+
+         # Delete the libtool libraries and symlinks.
+         for n in $library_names; do
+           rmfiles="$rmfiles $objdir/$n"
+         done
+         test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+         case "$mode" in
+         clean)
+           case "  $library_names " in
+           # "  " in the beginning catches empty $dlname
+           *" $dlname "*) ;;
+           *) rmfiles="$rmfiles $objdir/$dlname" ;;
+           esac
+           test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+           ;;
+         uninstall)
+           if test -n "$library_names"; then
+             # Do each command in the postuninstall commands.
+             func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+           fi
+
+           if test -n "$old_library"; then
+             # Do each command in the old_postuninstall commands.
+             func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+           fi
+           # FIXME: should reinstall the best remaining shared library.
+           ;;
+         esac
+       fi
+       ;;
+
+      *.lo)
+       # Possibly a libtool object, so verify it.
+       if func_lalib_p "$file"; then
+
+         # Read the .lo file
+         func_source $dir/$name
+
+         # Add PIC object to the list of files to remove.
+         if test -n "$pic_object" &&
+            test "$pic_object" != none; then
+           rmfiles="$rmfiles $dir/$pic_object"
+         fi
+
+         # Add non-PIC object to the list of files to remove.
+         if test -n "$non_pic_object" &&
+            test "$non_pic_object" != none; then
+           rmfiles="$rmfiles $dir/$non_pic_object"
+         fi
+       fi
+       ;;
+
+      *)
+       if test "$mode" = clean ; then
+         noexename=$name
+         case $file in
+         *.exe)
+           func_stripname '' '.exe' "$file"
+           file=$func_stripname_result
+           func_stripname '' '.exe' "$name"
+           noexename=$func_stripname_result
+           # $file with .exe has already been added to rmfiles,
+           # add $file without .exe
+           rmfiles="$rmfiles $file"
+           ;;
+         esac
+         # Do a test to see if this is a libtool program.
+         if func_ltwrapper_p "$file"; then
+           if func_ltwrapper_executable_p "$file"; then
+             func_ltwrapper_scriptname "$file"
+             relink_command=
+             func_source $func_ltwrapper_scriptname_result
+             rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+           else
+             relink_command=
+             func_source $dir/$noexename
+           fi
+
+           # note $name still contains .exe if it was in $file originally
+           # as does the version of $file that was added into $rmfiles
+           rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+           if test "$fast_install" = yes && test -n "$relink_command"; then
+             rmfiles="$rmfiles $objdir/lt-$name"
+           fi
+           if test "X$noexename" != "X$name" ; then
+             rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+           fi
+         fi
+       fi
+       ;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+       func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/build/aux/missing b/build/aux/missing
new file mode 100755 (executable)
index 0000000..28055d2
--- /dev/null
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# 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 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+  lex*|yacc*)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar*)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te*)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison*|yacc*)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f y.tab.h; then
+       echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex*|flex*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f lex.yy.c; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit $?
+    fi
+    ;;
+
+  makeinfo*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+       /^@setfilename/{
+         s/.* \([^ ]*\) *$/\1/
+         p
+         q
+       }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar*)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case $firstarg in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case $firstarg in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/build/aux/move-if-change b/build/aux/move-if-change
new file mode 100755 (executable)
index 0000000..a542417
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is zero if successful, nonzero otherwise.
+
+VERSION='2007-09-28 23:10'; # UTC
+# The definition above must lie within the first 8 lines in order
+# for the Emacs time-stamp write hook (at end) to update it.
+# If you change this file with Emacs, please let the write hook
+# do its job.  Otherwise, update this string manually.
+
+# Copyright (C) 2002-2007 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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/>.
+
+usage="usage: $0 SOURCE DEST"
+
+help="$usage
+  or:  $0 OPTION
+If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
+
+  --help     display this help and exit
+  --version  output version information and exit
+
+Report bugs to <bug-gnulib@gnu.org>."
+
+version=`expr "$VERSION" : '\([^ ]*\)'`
+version="move-if-change (gnulib) $version
+Copyright (C) 2007 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+
+
+for arg
+do
+  case $arg in
+    --help | --hel | --he | --h)
+      exec echo "$help" ;;
+    --version | --versio | --versi | --vers | --ver | --ve | --v)
+      exec echo "$version" ;;
+    --)
+      shift
+      break ;;
+    -*)
+      echo "$0: invalid option: $arg" >&2
+      exit 1 ;;
+    *)
+      break ;;
+  esac
+done
+
+test $# = 2 || { echo "$0: $usage" >&2; exit 1; }
+
+if test -r "$2" && cmp -s -- "$1" "$2"; then
+  rm -f -- "$1"
+else
+  mv -f -- "$1" "$2"
+fi
+
+## Local Variables:
+## eval: (add-hook 'write-file-hooks 'time-stamp)
+## time-stamp-start: "VERSION='"
+## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+## time-stamp-time-zone: "UTC"
+## time-stamp-end: "'; # UTC"
+## End:
diff --git a/build/aux/unused-parameter.h b/build/aux/unused-parameter.h
new file mode 100644 (file)
index 0000000..c8d2071
--- /dev/null
@@ -0,0 +1,36 @@
+/* A C macro for declaring that specific function parameters are not used.
+   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/>.  */
+
+/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter
+   declarations for parameters that are not used.  This helps to reduce
+   warnings, such as from GCC -Wunused-parameter.  The syntax is as follows:
+       type param _GL_UNUSED_PARAMETER
+   or more generally
+       param_decl _GL_UNUSED_PARAMETER
+   For example:
+       int param _GL_UNUSED_PARAMETER
+       int *(*param)(void) _GL_UNUSED_PARAMETER
+   Other possible, but obscure and discouraged syntaxes:
+       int _GL_UNUSED_PARAMETER *(*param)(void)
+       _GL_UNUSED_PARAMETER int *(*param)(void)
+ */
+#ifndef _GL_UNUSED_PARAMETER
+# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+#  define _GL_UNUSED_PARAMETER __attribute__ ((__unused__))
+# else
+#  define _GL_UNUSED_PARAMETER
+# endif
+#endif
diff --git a/build/aux/warn-on-use.h b/build/aux/warn-on-use.h
new file mode 100644 (file)
index 0000000..2cdeec3
--- /dev/null
@@ -0,0 +1,109 @@
+/* A C macro for emitting warnings if a function is used.
+   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/>.  */
+
+/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
+   for FUNCTION which will then trigger a compiler warning containing
+   the text of "literal string" anywhere that function is called, if
+   supported by the compiler.  If the compiler does not support this
+   feature, the macro expands to an unused extern declaration.
+
+   This macro is useful for marking a function as a potential
+   portability trap, with the intent that "literal string" include
+   instructions on the replacement function that should be used
+   instead.  However, one of the reasons that a function is a
+   portability trap is if it has the wrong signature.  Declaring
+   FUNCTION with a different signature in C is a compilation error, so
+   this macro must use the same type as any existing declaration so
+   that programs that avoid the problematic FUNCTION do not fail to
+   compile merely because they included a header that poisoned the
+   function.  But this implies that _GL_WARN_ON_USE is only safe to
+   use if FUNCTION is known to already have a declaration.  Use of
+   this macro implies that there must not be any other macro hiding
+   the declaration of FUNCTION; but undefining FUNCTION first is part
+   of the poisoning process anyway (although for symbols that are
+   provided only via a macro, the result is a compilation error rather
+   than a warning containing "literal string").  Also note that in
+   C++, it is only safe to use if FUNCTION has no overloads.
+
+   For an example, it is possible to poison 'getline' by:
+   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+     [getline]) in configure.ac, which potentially defines
+     HAVE_RAW_DECL_GETLINE
+   - adding this code to a header that wraps the system <stdio.h>:
+     #undef getline
+     #if HAVE_RAW_DECL_GETLINE
+     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+       "not universally present; use the gnulib module getline");
+     #endif
+
+   It is not possible to directly poison global variables.  But it is
+   possible to write a wrapper accessor function, and poison that
+   (less common usage, like &environ, will cause a compilation error
+   rather than issue the nice warning, but the end result of informing
+   the developer about their portability problem is still achieved):
+   #if HAVE_RAW_DECL_ENVIRON
+   static inline char ***rpl_environ (void) { return &environ; }
+   _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+   # undef environ
+   # define environ (*rpl_environ ())
+   #endif
+   */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
+#  define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function.  */
+#  define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function
+# else /* Unsupported.  */
+#  define _GL_WARN_ON_USE(function, message) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+#endif
+
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
+   is like _GL_WARN_ON_USE (function, "string"), except that the function is
+   declared with the given prototype, consisting of return type, parameters,
+   and attributes.
+   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
+   not work in this case.  */
+#ifndef _GL_WARN_ON_USE_CXX
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes \
+     __attribute__ ((__warning__ (msg)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function.  */
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes
+# else /* Unsupported.  */
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+_GL_WARN_EXTERN_C int _gl_warn_on_use
+# endif
+#endif
+
+/* _GL_WARN_EXTERN_C declaration;
+   performs the declaration with C linkage.  */
+#ifndef _GL_WARN_EXTERN_C
+# if defined __cplusplus
+#  define _GL_WARN_EXTERN_C extern "C"
+# else
+#  define _GL_WARN_EXTERN_C extern
+# endif
+#endif
diff --git a/build/aux/ylwrap b/build/aux/ylwrap
new file mode 100755 (executable)
index 0000000..84d5634
--- /dev/null
@@ -0,0 +1,222 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
+# 2007, 2009 Free Software Foundation, Inc.
+#
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# 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 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU 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/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case "$1" in
+  '')
+    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
+    exit 1
+    ;;
+  --basedir)
+    basedir=$2
+    shift 2
+    ;;
+  -h|--h*)
+    cat <<\EOF
+Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
+
+Wrapper for lex/yacc invocations, renaming files as desired.
+
+  INPUT is the input file
+  OUTPUT is one file PROG generates
+  DESIRED is the file we actually want instead of OUTPUT
+  PROGRAM is program to run
+  ARGS are passed to PROG
+
+Any number of OUTPUT,DESIRED pairs may be used.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v|--v*)
+    echo "ylwrap $scriptversion"
+    exit $?
+    ;;
+esac
+
+
+# The input.
+input="$1"
+shift
+case "$input" in
+  [\\/]* | ?:[\\/]*)
+    # Absolute path; do nothing.
+    ;;
+  *)
+    # Relative path.  Make it absolute.
+    input="`pwd`/$input"
+    ;;
+esac
+
+pairlist=
+while test "$#" -ne 0; do
+  if test "$1" = "--"; then
+    shift
+    break
+  fi
+  pairlist="$pairlist $1"
+  shift
+done
+
+# The program to run.
+prog="$1"
+shift
+# Make any relative path in $prog absolute.
+case "$prog" in
+  [\\/]* | ?:[\\/]*) ;;
+  *[\\/]*) prog="`pwd`/$prog" ;;
+esac
+
+# FIXME: add hostname here for parallel makes that run commands on
+# other machines.  But that might take us over the 14-char limit.
+dirname=ylwrap$$
+trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
+mkdir $dirname || exit 1
+
+cd $dirname
+
+case $# in
+  0) "$prog" "$input" ;;
+  *) "$prog" "$@" "$input" ;;
+esac
+ret=$?
+
+if test $ret -eq 0; then
+  set X $pairlist
+  shift
+  first=yes
+  # Since DOS filename conventions don't allow two dots,
+  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
+  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
+  y_tab_nodot="no"
+  if test -f y_tab.c || test -f y_tab.h; then
+    y_tab_nodot="yes"
+  fi
+
+  # The directory holding the input.
+  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
+  # Quote $INPUT_DIR so we can use it in a regexp.
+  # FIXME: really we should care about more than `.' and `\'.
+  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
+
+  while test "$#" -ne 0; do
+    from="$1"
+    # Handle y_tab.c and y_tab.h output by DOS
+    if test $y_tab_nodot = "yes"; then
+      if test $from = "y.tab.c"; then
+       from="y_tab.c"
+      else
+       if test $from = "y.tab.h"; then
+         from="y_tab.h"
+       fi
+      fi
+    fi
+    if test -f "$from"; then
+      # If $2 is an absolute path name, then just use that,
+      # otherwise prepend `../'.
+      case "$2" in
+       [\\/]* | ?:[\\/]*) target="$2";;
+       *) target="../$2";;
+      esac
+
+      # We do not want to overwrite a header file if it hasn't
+      # changed.  This avoid useless recompilations.  However the
+      # parser itself (the first file) should always be updated,
+      # because it is the destination of the .y.c rule in the
+      # Makefile.  Divert the output of all other files to a temporary
+      # file so we can compare them to existing versions.
+      if test $first = no; then
+       realtarget="$target"
+       target="tmp-`echo $target | sed s/.*[\\/]//g`"
+      fi
+      # Edit out `#line' or `#' directives.
+      #
+      # We don't want the resulting debug information to point at
+      # an absolute srcdir; it is better for it to just mention the
+      # .y file with no path.
+      #
+      # We want to use the real output file name, not yy.lex.c for
+      # instance.
+      #
+      # We want the include guards to be adjusted too.
+      FROM=`echo "$from" | sed \
+            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
+            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
+      TARGET=`echo "$2" | sed \
+            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
+            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
+
+      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
+          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
+
+      # Check whether header files must be updated.
+      if test $first = no; then
+       if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
+         echo "$2" is unchanged
+         rm -f "$target"
+       else
+          echo updating "$2"
+          mv -f "$target" "$realtarget"
+        fi
+      fi
+    else
+      # A missing file is only an error for the first file.  This
+      # is a blatant hack to let us support using "yacc -d".  If -d
+      # is not specified, we don't want an error when the header
+      # file is "missing".
+      if test $first = yes; then
+        ret=1
+      fi
+    fi
+    shift
+    shift
+    first=no
+  done
+else
+  ret=$?
+fi
+
+# Remove the directory.
+cd ..
+rm -rf $dirname
+
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..adddf6f
--- /dev/null
@@ -0,0 +1,1339 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to the number of bits in type 'ptrdiff_t'. */
+#undef BITSIZEOF_PTRDIFF_T
+
+/* Define to the number of bits in type 'sig_atomic_t'. */
+#undef BITSIZEOF_SIG_ATOMIC_T
+
+/* Define to the number of bits in type 'size_t'. */
+#undef BITSIZEOF_SIZE_T
+
+/* Define to the number of bits in type 'wchar_t'. */
+#undef BITSIZEOF_WCHAR_T
+
+/* Define to the number of bits in type 'wint_t'. */
+#undef BITSIZEOF_WINT_T
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if // is a file system root distinct from /. */
+#undef DOUBLE_SLASH_IS_DISTINCT_ROOT
+
+/* whether debugging is enabled */
+#undef ENABLE_DEBUG
+
+/* Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string. */
+#undef FUNC_NL_LANGINFO_YESEXPR_WORKS
+
+/* Define to 1 if realpath() can malloc memory, always gives an absolute path,
+   and handles trailing slash correctly. */
+#undef FUNC_REALPATH_WORKS
+
+/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
+   whether the gnulib module canonicalize-lgpl shall be considered present. */
+#undef GNULIB_CANONICALIZE_LGPL
+
+/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
+   whether the gnulib module malloc-gnu shall be considered present. */
+#undef GNULIB_MALLOC_GNU
+
+/* Define to 1 when the gnulib module btowc should be tested. */
+#undef GNULIB_TEST_BTOWC
+
+/* Define to 1 when the gnulib module canonicalize_file_name should be tested.
+   */
+#undef GNULIB_TEST_CANONICALIZE_FILE_NAME
+
+/* Define to 1 when the gnulib module dup2 should be tested. */
+#undef GNULIB_TEST_DUP2
+
+/* Define to 1 when the gnulib module environ should be tested. */
+#undef GNULIB_TEST_ENVIRON
+
+/* Define to 1 when the gnulib module getdelim should be tested. */
+#undef GNULIB_TEST_GETDELIM
+
+/* Define to 1 when the gnulib module getline should be tested. */
+#undef GNULIB_TEST_GETLINE
+
+/* Define to 1 when the gnulib module getopt-gnu should be tested. */
+#undef GNULIB_TEST_GETOPT_GNU
+
+/* Define to 1 when the gnulib module getpagesize should be tested. */
+#undef GNULIB_TEST_GETPAGESIZE
+
+/* Define to 1 when the gnulib module lstat should be tested. */
+#undef GNULIB_TEST_LSTAT
+
+/* Define to 1 when the gnulib module malloc-posix should be tested. */
+#undef GNULIB_TEST_MALLOC_POSIX
+
+/* Define to 1 when the gnulib module mbrtowc should be tested. */
+#undef GNULIB_TEST_MBRTOWC
+
+/* Define to 1 when the gnulib module mbsinit should be tested. */
+#undef GNULIB_TEST_MBSINIT
+
+/* Define to 1 when the gnulib module mbsrtowcs should be tested. */
+#undef GNULIB_TEST_MBSRTOWCS
+
+/* Define to 1 when the gnulib module mbtowc should be tested. */
+#undef GNULIB_TEST_MBTOWC
+
+/* Define to 1 when the gnulib module memchr should be tested. */
+#undef GNULIB_TEST_MEMCHR
+
+/* Define to 1 when the gnulib module mempcpy should be tested. */
+#undef GNULIB_TEST_MEMPCPY
+
+/* Define to 1 when the gnulib module nl_langinfo should be tested. */
+#undef GNULIB_TEST_NL_LANGINFO
+
+/* Define to 1 when the gnulib module open should be tested. */
+#undef GNULIB_TEST_OPEN
+
+/* Define to 1 when the gnulib module putenv should be tested. */
+#undef GNULIB_TEST_PUTENV
+
+/* Define to 1 when the gnulib module readlink should be tested. */
+#undef GNULIB_TEST_READLINK
+
+/* Define to 1 when the gnulib module realloc-posix should be tested. */
+#undef GNULIB_TEST_REALLOC_POSIX
+
+/* Define to 1 when the gnulib module realpath should be tested. */
+#undef GNULIB_TEST_REALPATH
+
+/* Define to 1 when the gnulib module setenv should be tested. */
+#undef GNULIB_TEST_SETENV
+
+/* Define to 1 when the gnulib module setlocale should be tested. */
+#undef GNULIB_TEST_SETLOCALE
+
+/* Define to 1 when the gnulib module stat should be tested. */
+#undef GNULIB_TEST_STAT
+
+/* Define to 1 when the gnulib module stpcpy should be tested. */
+#undef GNULIB_TEST_STPCPY
+
+/* Define to 1 when the gnulib module stpncpy should be tested. */
+#undef GNULIB_TEST_STPNCPY
+
+/* Define to 1 when the gnulib module strndup should be tested. */
+#undef GNULIB_TEST_STRNDUP
+
+/* Define to 1 when the gnulib module strnlen should be tested. */
+#undef GNULIB_TEST_STRNLEN
+
+/* Define to 1 when the gnulib module strstr should be tested. */
+#undef GNULIB_TEST_STRSTR
+
+/* Define to 1 when the gnulib module symlink should be tested. */
+#undef GNULIB_TEST_SYMLINK
+
+/* Define to 1 when the gnulib module unsetenv should be tested. */
+#undef GNULIB_TEST_UNSETENV
+
+/* Define to 1 when the gnulib module vasprintf should be tested. */
+#undef GNULIB_TEST_VASPRINTF
+
+/* Define to 1 when the gnulib module wcrtomb should be tested. */
+#undef GNULIB_TEST_WCRTOMB
+
+/* Define to 1 when the gnulib module wctob should be tested. */
+#undef GNULIB_TEST_WCTOB
+
+/* Define to 1 when the gnulib module wctomb should be tested. */
+#undef GNULIB_TEST_WCTOMB
+
+/* Define to 1 if you have 'alloca' after including <alloca.h>, a header that
+   may be supplied by this distribution. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <argz.h> header file. */
+#undef HAVE_ARGZ_H
+
+/* Define to 1 if you have the <bp-sym.h> header file. */
+#undef HAVE_BP_SYM_H
+
+/* Define to 1 if you have the `btowc' function. */
+#undef HAVE_BTOWC
+
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#undef HAVE_CANONICALIZE_FILE_NAME
+
+/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
+   CoreFoundation framework. */
+#undef HAVE_CFLOCALECOPYCURRENT
+
+/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
+   the CoreFoundation framework. */
+#undef HAVE_CFPREFERENCESCOPYAPPVALUE
+
+/* Define to 1 if you have the declaration of `alarm', and to 0 if you don't.
+   */
+#undef HAVE_DECL_ALARM
+
+/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
+   don't. */
+#undef HAVE_DECL_GETC_UNLOCKED
+
+/* Define to 1 if you have the declaration of `getdelim', and to 0 if you
+   don't. */
+#undef HAVE_DECL_GETDELIM
+
+/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
+   */
+#undef HAVE_DECL_GETENV
+
+/* Define to 1 if you have the declaration of `getline', and to 0 if you
+   don't. */
+#undef HAVE_DECL_GETLINE
+
+/* Define to 1 if you have the declaration of `isblank', and to 0 if you
+   don't. */
+#undef HAVE_DECL_ISBLANK
+
+/* Define to 1 if you have the declaration of `setenv', and to 0 if you don't.
+   */
+#undef HAVE_DECL_SETENV
+
+/* Define to 1 if you have the declaration of `stpncpy', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STPNCPY
+
+/* Define to 1 if you have the declaration of `strndup', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNDUP
+
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
+/* Define to 1 if you have the declaration of `unsetenv', and to 0 if you
+   don't. */
+#undef HAVE_DECL_UNSETENV
+
+/* Define to 1 if you have the declaration of `wctob', and to 0 if you don't.
+   */
+#undef HAVE_DECL_WCTOB
+
+/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you
+   don't. */
+#undef HAVE_DECL__SNPRINTF
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `dup2' function. */
+#undef HAVE_DUP2
+
+/* Define if you have the declaration of environ. */
+#undef HAVE_ENVIRON_DECL
+
+/* Define to 1 if the system has the type `error_t'. */
+#undef HAVE_ERROR_T
+
+/* Define to 1 if you have the `fcntl' function. */
+#undef HAVE_FCNTL
+
+/* Define to 1 if you have the <features.h> header file. */
+#undef HAVE_FEATURES_H
+
+/* Define to 1 if you have the `flockfile' function. */
+#undef HAVE_FLOCKFILE
+
+/* Define to 1 if you have the `fsync' function. */
+#undef HAVE_FSYNC
+
+/* Define to 1 if you have the `funlockfile' function. */
+#undef HAVE_FUNLOCKFILE
+
+/* Define to 1 if you have the `getcwd' function. */
+#undef HAVE_GETCWD
+
+/* Define to 1 if you have the `getdelim' function. */
+#undef HAVE_GETDELIM
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long_only' function. */
+#undef HAVE_GETOPT_LONG_ONLY
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
+#undef HAVE_INTMAX_T
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
+   declares uintmax_t. */
+#undef HAVE_INTTYPES_H_WITH_UINTMAX
+
+/* Define to 1 if you have the `isblank' function. */
+#undef HAVE_ISBLANK
+
+/* Define to 1 if you have the `iswcntrl' function. */
+#undef HAVE_ISWCNTRL
+
+/* Define to 1 if you have the `iswctype' function. */
+#undef HAVE_ISWCTYPE
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#undef HAVE_LANGINFO_CODESET
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+#undef HAVE_LANGINFO_H
+
+/* Define if your <locale.h> file defines LC_MESSAGES. */
+#undef HAVE_LC_MESSAGES
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
+/* Define to 1 if the system has the type `long long int'. */
+#undef HAVE_LONG_LONG_INT
+
+/* Define to 1 if you have the `lstat' function. */
+#undef HAVE_LSTAT
+
+/* Define to 1 if your system has a GNU libc compatible 'malloc' function, and
+   to 0 otherwise. */
+#undef HAVE_MALLOC_GNU
+
+/* Define if the 'malloc' function is POSIX compliant. */
+#undef HAVE_MALLOC_POSIX
+
+/* Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including
+   config.h and <sys/mman.h>. */
+#undef HAVE_MAP_ANONYMOUS
+
+/* Define to 1 if you have the `mbrtowc' function. */
+#undef HAVE_MBRTOWC
+
+/* Define to 1 if you have the `mbsinit' function. */
+#undef HAVE_MBSINIT
+
+/* Define to 1 if you have the `mbsrtowcs' function. */
+#undef HAVE_MBSRTOWCS
+
+/* Define to 1 if <wchar.h> declares mbstate_t. */
+#undef HAVE_MBSTATE_T
+
+/* Define to 1 if you have the `memchr' function. */
+#undef HAVE_MEMCHR
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `mempcpy' function. */
+#undef HAVE_MEMPCPY
+
+/* Define to 1 if you have the `mprotect' function. */
+#undef HAVE_MPROTECT
+
+/* Define to 1 if you have the `newlocale' function. */
+#undef HAVE_NEWLOCALE
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+#undef HAVE_NL_LANGINFO
+
+/* Define to 1 if you have the `open_memstream' function. */
+#undef HAVE_OPEN_MEMSTREAM
+
+/* Define to 1 if you have the <OS.h> header file. */
+#undef HAVE_OS_H
+
+/* Define to 1 if you have the `pathconf' function. */
+#undef HAVE_PATHCONF
+
+/* Define to 1 if you have the `pthread_atfork' function. */
+#undef HAVE_PTHREAD_ATFORK
+
+/* Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE. */
+#undef HAVE_PTHREAD_MUTEX_RECURSIVE
+
+/* Define if the POSIX multithreading library has read/write locks. */
+#undef HAVE_PTHREAD_RWLOCK
+
+/* Define to 1 if atoll is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_ATOLL
+
+/* Define to 1 if btowc is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_BTOWC
+
+/* Define to 1 if canonicalize_file_name is declared even after undefining
+   macros. */
+#undef HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
+
+/* Define to 1 if chown is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_CHOWN
+
+/* Define to 1 if dprintf is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_DPRINTF
+
+/* Define to 1 if dup2 is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_DUP2
+
+/* Define to 1 if dup3 is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_DUP3
+
+/* Define to 1 if duplocale is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_DUPLOCALE
+
+/* Define to 1 if endusershell is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_ENDUSERSHELL
+
+/* Define to 1 if environ is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_ENVIRON
+
+/* Define to 1 if euidaccess is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_EUIDACCESS
+
+/* Define to 1 if faccessat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FACCESSAT
+
+/* Define to 1 if fchdir is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FCHDIR
+
+/* Define to 1 if fchmodat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FCHMODAT
+
+/* Define to 1 if fchownat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FCHOWNAT
+
+/* Define to 1 if fcntl is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FCNTL
+
+/* Define to 1 if fpurge is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FPURGE
+
+/* Define to 1 if fseeko is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FSEEKO
+
+/* Define to 1 if fstatat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FSTATAT
+
+/* Define to 1 if fsync is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FSYNC
+
+/* Define to 1 if ftello is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FTELLO
+
+/* Define to 1 if ftruncate is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FTRUNCATE
+
+/* Define to 1 if futimens is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_FUTIMENS
+
+/* Define to 1 if getcwd is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETCWD
+
+/* Define to 1 if getdelim is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETDELIM
+
+/* Define to 1 if getdomainname is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETDOMAINNAME
+
+/* Define to 1 if getdtablesize is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETDTABLESIZE
+
+/* Define to 1 if getgroups is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETGROUPS
+
+/* Define to 1 if gethostname is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETHOSTNAME
+
+/* Define to 1 if getline is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETLINE
+
+/* Define to 1 if getloadavg is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETLOADAVG
+
+/* Define to 1 if getlogin is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETLOGIN
+
+/* Define to 1 if getlogin_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETLOGIN_R
+
+/* Define to 1 if getpagesize is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETPAGESIZE
+
+/* Define to 1 if getsubopt is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETSUBOPT
+
+/* Define to 1 if getusershell is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GETUSERSHELL
+
+/* Define to 1 if grantpt is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_GRANTPT
+
+/* Define to 1 if initstat_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_INITSTAT_R
+
+/* Define to 1 if isblank is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_ISBLANK
+
+/* Define to 1 if iswctype is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_ISWCTYPE
+
+/* Define to 1 if lchmod is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LCHMOD
+
+/* Define to 1 if lchown is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LCHOWN
+
+/* Define to 1 if link is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LINK
+
+/* Define to 1 if linkat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LINKAT
+
+/* Define to 1 if lseek is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LSEEK
+
+/* Define to 1 if lstat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_LSTAT
+
+/* Define to 1 if mbrlen is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MBRLEN
+
+/* Define to 1 if mbrtowc is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MBRTOWC
+
+/* Define to 1 if mbsinit is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MBSINIT
+
+/* Define to 1 if mbsnrtowcs is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MBSNRTOWCS
+
+/* Define to 1 if mbsrtowcs is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MBSRTOWCS
+
+/* Define to 1 if memmem is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MEMMEM
+
+/* Define to 1 if mempcpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MEMPCPY
+
+/* Define to 1 if memrchr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MEMRCHR
+
+/* Define to 1 if mkdirat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKDIRAT
+
+/* Define to 1 if mkdtemp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKDTEMP
+
+/* Define to 1 if mkfifo is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKFIFO
+
+/* Define to 1 if mkfifoat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKFIFOAT
+
+/* Define to 1 if mknod is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKNOD
+
+/* Define to 1 if mknodat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKNODAT
+
+/* Define to 1 if mkostemp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKOSTEMP
+
+/* Define to 1 if mkostemps is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKOSTEMPS
+
+/* Define to 1 if mkstemp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKSTEMP
+
+/* Define to 1 if mkstemps is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_MKSTEMPS
+
+/* Define to 1 if nl_langinfo is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_NL_LANGINFO
+
+/* Define to 1 if openat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_OPENAT
+
+/* Define to 1 if pipe is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_PIPE
+
+/* Define to 1 if pipe2 is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_PIPE2
+
+/* Define to 1 if popen is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_POPEN
+
+/* Define to 1 if pread is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_PREAD
+
+/* Define to 1 if ptsname is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_PTSNAME
+
+/* Define to 1 if pwrite is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_PWRITE
+
+/* Define to 1 if random_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_RANDOM_R
+
+/* Define to 1 if rawmemchr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_RAWMEMCHR
+
+/* Define to 1 if readlink is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_READLINK
+
+/* Define to 1 if readlinkat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_READLINKAT
+
+/* Define to 1 if realpath is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_REALPATH
+
+/* Define to 1 if renameat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_RENAMEAT
+
+/* Define to 1 if rmdir is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_RMDIR
+
+/* Define to 1 if rpmatch is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_RPMATCH
+
+/* Define to 1 if setenv is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SETENV
+
+/* Define to 1 if setlocale is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SETLOCALE
+
+/* Define to 1 if setstate_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SETSTATE_R
+
+/* Define to 1 if setusershell is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SETUSERSHELL
+
+/* Define to 1 if sleep is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SLEEP
+
+/* Define to 1 if snprintf is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SNPRINTF
+
+/* Define to 1 if srandom_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SRANDOM_R
+
+/* Define to 1 if stat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STAT
+
+/* Define to 1 if stpcpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STPCPY
+
+/* Define to 1 if stpncpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STPNCPY
+
+/* Define to 1 if strcasestr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRCASESTR
+
+/* Define to 1 if strchrnul is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRCHRNUL
+
+/* Define to 1 if strdup is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRDUP
+
+/* Define to 1 if strerror_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRERROR_R
+
+/* Define to 1 if strncat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRNCAT
+
+/* Define to 1 if strndup is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRNDUP
+
+/* Define to 1 if strnlen is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRNLEN
+
+/* Define to 1 if strpbrk is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRPBRK
+
+/* Define to 1 if strsep is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRSEP
+
+/* Define to 1 if strsignal is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRSIGNAL
+
+/* Define to 1 if strtod is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOD
+
+/* Define to 1 if strtok_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOK_R
+
+/* Define to 1 if strtoll is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOLL
+
+/* Define to 1 if strtoull is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRTOULL
+
+/* Define to 1 if strverscmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_STRVERSCMP
+
+/* Define to 1 if symlink is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SYMLINK
+
+/* Define to 1 if symlinkat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_SYMLINKAT
+
+/* Define to 1 if tmpfile is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_TMPFILE
+
+/* Define to 1 if towctrans is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_TOWCTRANS
+
+/* Define to 1 if ttyname_r is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_TTYNAME_R
+
+/* Define to 1 if unlink is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_UNLINK
+
+/* Define to 1 if unlinkat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_UNLINKAT
+
+/* Define to 1 if unlockpt is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_UNLOCKPT
+
+/* Define to 1 if unsetenv is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_UNSETENV
+
+/* Define to 1 if usleep is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_USLEEP
+
+/* Define to 1 if utimensat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_UTIMENSAT
+
+/* Define to 1 if vdprintf is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_VDPRINTF
+
+/* Define to 1 if vsnprintf is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_VSNPRINTF
+
+/* Define to 1 if waitpid is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WAITPID
+
+/* Define to 1 if wcpcpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCPCPY
+
+/* Define to 1 if wcpncpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCPNCPY
+
+/* Define to 1 if wcrtomb is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCRTOMB
+
+/* Define to 1 if wcscasecmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCASECMP
+
+/* Define to 1 if wcscat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCAT
+
+/* Define to 1 if wcschr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCHR
+
+/* Define to 1 if wcscmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCMP
+
+/* Define to 1 if wcscoll is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCOLL
+
+/* Define to 1 if wcscpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCPY
+
+/* Define to 1 if wcscspn is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSCSPN
+
+/* Define to 1 if wcsdup is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSDUP
+
+/* Define to 1 if wcslen is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSLEN
+
+/* Define to 1 if wcsncasecmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNCASECMP
+
+/* Define to 1 if wcsncat is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNCAT
+
+/* Define to 1 if wcsncmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNCMP
+
+/* Define to 1 if wcsncpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNCPY
+
+/* Define to 1 if wcsnlen is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNLEN
+
+/* Define to 1 if wcsnrtombs is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSNRTOMBS
+
+/* Define to 1 if wcspbrk is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSPBRK
+
+/* Define to 1 if wcsrchr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSRCHR
+
+/* Define to 1 if wcsrtombs is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSRTOMBS
+
+/* Define to 1 if wcsspn is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSSPN
+
+/* Define to 1 if wcsstr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSSTR
+
+/* Define to 1 if wcstok is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSTOK
+
+/* Define to 1 if wcswidth is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSWIDTH
+
+/* Define to 1 if wcsxfrm is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCSXFRM
+
+/* Define to 1 if wctob is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCTOB
+
+/* Define to 1 if wctrans is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCTRANS
+
+/* Define to 1 if wctype is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCTYPE
+
+/* Define to 1 if wcwidth is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WCWIDTH
+
+/* Define to 1 if wmemchr is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WMEMCHR
+
+/* Define to 1 if wmemcmp is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WMEMCMP
+
+/* Define to 1 if wmemcpy is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WMEMCPY
+
+/* Define to 1 if wmemmove is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WMEMMOVE
+
+/* Define to 1 if wmemset is declared even after undefining macros. */
+#undef HAVE_RAW_DECL_WMEMSET
+
+/* Define to 1 if _Exit is declared even after undefining macros. */
+#undef HAVE_RAW_DECL__EXIT
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#undef HAVE_READLINE_READLINE_H
+
+/* Define to 1 if you have the `readlink' function. */
+#undef HAVE_READLINK
+
+/* Define if the 'realloc' function is POSIX compliant. */
+#undef HAVE_REALLOC_POSIX
+
+/* Define to 1 if you have the `realpath' function. */
+#undef HAVE_REALPATH
+
+/* Define to 1 if you have the `rl_completion_matches' function. */
+#undef HAVE_RL_COMPLETION_MATCHES
+
+/* Define to 1 if you have the <search.h> header file. */
+#undef HAVE_SEARCH_H
+
+/* Define to 1 if you have the <selinux/context.h> header file. */
+#undef HAVE_SELINUX_CONTEXT_H
+
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
+#undef HAVE_SELINUX_SELINUX_H
+
+/* Define to 1 if you have the `setenv' function. */
+#undef HAVE_SETENV
+
+/* Define to 1 if you have the `setlocale' function. */
+#undef HAVE_SETLOCALE
+
+/* Define to 1 if 'sig_atomic_t' is a signed integer type. */
+#undef HAVE_SIGNED_SIG_ATOMIC_T
+
+/* Define to 1 if 'wchar_t' is a signed integer type. */
+#undef HAVE_SIGNED_WCHAR_T
+
+/* Define to 1 if 'wint_t' is a signed integer type. */
+#undef HAVE_SIGNED_WINT_T
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define if the return value of the snprintf function is the number of of
+   bytes (excluding the terminating NUL) that would have been produced if the
+   buffer had been large enough. */
+#undef HAVE_SNPRINTF_RETVAL_C99
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
+   uintmax_t. */
+#undef HAVE_STDINT_H_WITH_UINTMAX
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `stpcpy' function. */
+#undef HAVE_STPCPY
+
+/* Define if you have the stpncpy() function and it works. */
+#undef HAVE_STPNCPY
+
+/* Define to 1 if you have the `strerror_r' function. */
+#undef HAVE_STRERROR_R
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strndup' function. */
+#undef HAVE_STRNDUP
+
+/* Define to 1 if you have the `strnlen' function. */
+#undef HAVE_STRNLEN
+
+/* Define to 1 if you have the `symlink' function. */
+#undef HAVE_SYMLINK
+
+/* Define to 1 if you have the <sys/bitypes.h> header file. */
+#undef HAVE_SYS_BITYPES_H
+
+/* Define to 1 if you have the <sys/inttypes.h> header file. */
+#undef HAVE_SYS_INTTYPES_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the `tsearch' function. */
+#undef HAVE_TSEARCH
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `unsetenv' function. */
+#undef HAVE_UNSETENV
+
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#undef HAVE_UNSIGNED_LONG_LONG_INT
+
+/* Define to 1 if you have the `uselocale' function. */
+#undef HAVE_USELOCALE
+
+/* Define to 1 if you have the `vasnprintf' function. */
+#undef HAVE_VASNPRINTF
+
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#undef HAVE_WCHAR_H
+
+/* Define if you have the 'wchar_t' type. */
+#undef HAVE_WCHAR_T
+
+/* Define to 1 if you have the `wcrtomb' function. */
+#undef HAVE_WCRTOMB
+
+/* Define to 1 if you have the `wcscoll' function. */
+#undef HAVE_WCSCOLL
+
+/* Define to 1 if you have the `wcslen' function. */
+#undef HAVE_WCSLEN
+
+/* Define to 1 if you have the `wcsnlen' function. */
+#undef HAVE_WCSNLEN
+
+/* Define to 1 if you have the `wctob' function. */
+#undef HAVE_WCTOB
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#undef HAVE_WCTYPE_H
+
+/* Define if you have the 'wint_t' type. */
+#undef HAVE_WINT_T
+
+/* Define to 1 if you have the `wmemchr' function. */
+#undef HAVE_WMEMCHR
+
+/* Define to 1 if you have the `wmemcpy' function. */
+#undef HAVE_WMEMCPY
+
+/* Define to 1 if you have the `wmempcpy' function. */
+#undef HAVE_WMEMPCPY
+
+/* This value is set to 1 to indicate that the system argz facility works */
+#undef HAVE_WORKING_ARGZ
+
+/* Define to 1 if O_NOATIME works. */
+#undef HAVE_WORKING_O_NOATIME
+
+/* Define to 1 if O_NOFOLLOW works. */
+#undef HAVE_WORKING_O_NOFOLLOW
+
+/* Define to 1 if you have the <xlocale.h> header file. */
+#undef HAVE_XLOCALE_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+   slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* If malloc(0) is != NULL, define this to 1. Otherwise define this to 0. */
+#undef MALLOC_0_IS_NONNULL
+
+/* Define to a substitute value for mmap()'s MAP_ANONYMOUS flag. */
+#undef MAP_ANONYMOUS
+
+/* Define if the mbrtowc function has the NULL pwc argument bug. */
+#undef MBRTOWC_NULL_ARG1_BUG
+
+/* Define if the mbrtowc function has the NULL string argument bug. */
+#undef MBRTOWC_NULL_ARG2_BUG
+
+/* Define if the mbrtowc function does not return 0 for a NUL character. */
+#undef MBRTOWC_NUL_RETVAL_BUG
+
+/* Define if the mbrtowc function returns a wrong return value. */
+#undef MBRTOWC_RETVAL_BUG
+
+/* Define to 1 if open() fails to recognize a trailing slash. */
+#undef OPEN_TRAILING_SLASH_BUG
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to the type that is the result of default argument promotions of
+   type mode_t. */
+#undef PROMOTED_MODE_T
+
+/* Define if the pthread_in_use() detection is hard. */
+#undef PTHREAD_IN_USE_DETECTION_HARD
+
+/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
+   'ptrdiff_t'. */
+#undef PTRDIFF_T_SUFFIX
+
+/* Define to 1 if readlink fails to recognize a trailing slash. */
+#undef READLINK_TRAILING_SLASH_BUG
+
+/* Define to 1 if stat needs help when passed a directory name with a trailing
+   slash */
+#undef REPLACE_FUNC_STAT_DIR
+
+/* Define to 1 if stat needs help when passed a file name with a trailing
+   slash */
+#undef REPLACE_FUNC_STAT_FILE
+
+/* Define if nl_langinfo exists but is overridden by gnulib. */
+#undef REPLACE_NL_LANGINFO
+
+/* Define if vasnprintf exists but is overridden by gnulib. */
+#undef REPLACE_VASNPRINTF
+
+/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
+   'sig_atomic_t'. */
+#undef SIG_ATOMIC_T_SUFFIX
+
+/* Define as the maximum value of type 'size_t', if the system doesn't define
+   it. */
+#ifndef SIZE_MAX
+# undef SIZE_MAX
+#endif
+
+/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
+   'size_t'. */
+#undef SIZE_T_SUFFIX
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+       STACK_DIRECTION > 0 => grows toward higher addresses
+       STACK_DIRECTION < 0 => grows toward lower addresses
+       STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+#undef STAT_MACROS_BROKEN
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if the POSIX multithreading library can be used. */
+#undef USE_POSIX_THREADS
+
+/* Define if references to the POSIX multithreading library should be made
+   weak. */
+#undef USE_POSIX_THREADS_WEAK
+
+/* Define if the GNU Pth multithreading library can be used. */
+#undef USE_PTH_THREADS
+
+/* Define if references to the GNU Pth multithreading library should be made
+   weak. */
+#undef USE_PTH_THREADS_WEAK
+
+/* Define if the old Solaris multithreading library can be used. */
+#undef USE_SOLARIS_THREADS
+
+/* Define if references to the old Solaris multithreading library should be
+   made weak. */
+#undef USE_SOLARIS_THREADS_WEAK
+
+/* Define if the Win32 multithreading API can be used. */
+#undef USE_WIN32_THREADS
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to 1 if unsetenv returns void instead of int. */
+#undef VOID_UNSETENV
+
+/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
+   'wchar_t'. */
+#undef WCHAR_T_SUFFIX
+
+/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
+   'wint_t'. */
+#undef WINT_T_SUFFIX
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+   `char[]'. */
+#undef YYTEXT_POINTER
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define if you want regoff_t to be at least as wide POSIX requires. */
+#undef _REGEX_LARGE_OFFSETS
+
+/* Define to 500 only on HP-UX. */
+#undef _XOPEN_SOURCE
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Define to rpl_ if the getopt replacement functions and variables should be
+   used. */
+#undef __GETOPT_PREFIX
+
+/* Define so that glibc/gnulib argp.h does not typedef error_t. */
+#undef __error_t_defined
+
+/* Define to a type to use for `error_t' if it is not otherwise available. */
+#undef error_t
+
+/* Always use our fgetfilecon wrapper. */
+#undef fgetfilecon
+
+/* Define to a replacement function name for fnmatch(). */
+#undef fnmatch
+
+/* Always use our getfilecon wrapper. */
+#undef getfilecon
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to long or long long if <stdint.h> and <inttypes.h> don't define. */
+#undef intmax_t
+
+/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
+   the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
+   earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
+   __APPLE__ && __MACH__ test for MacOS X.
+   __APPLE_CC__ tests for the Apple compiler and its version.
+   __STDC_VERSION__ tests for the C99 mode.  */
+#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
+# define __GNUC_STDC_INLINE__ 1
+#endif
+
+/* Always use our lgetfilecon wrapper. */
+#undef lgetfilecon
+
+/* Define to a type if <wchar.h> does not define. */
+#undef mbstate_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
+/* Define to the type of st_nlink in struct stat, or a supertype. */
+#undef nlink_t
+
+/* Define as the type of the result of subtracting two pointers, if the system
+   doesn't define it. */
+#undef ptrdiff_t
+
+/* Define to rpl_re_comp if the replacement should be used. */
+#undef re_comp
+
+/* Define to rpl_re_compile_fastmap if the replacement should be used. */
+#undef re_compile_fastmap
+
+/* Define to rpl_re_compile_pattern if the replacement should be used. */
+#undef re_compile_pattern
+
+/* Define to rpl_re_exec if the replacement should be used. */
+#undef re_exec
+
+/* Define to rpl_re_match if the replacement should be used. */
+#undef re_match
+
+/* Define to rpl_re_match_2 if the replacement should be used. */
+#undef re_match_2
+
+/* Define to rpl_re_search if the replacement should be used. */
+#undef re_search
+
+/* Define to rpl_re_search_2 if the replacement should be used. */
+#undef re_search_2
+
+/* Define to rpl_re_set_registers if the replacement should be used. */
+#undef re_set_registers
+
+/* Define to rpl_re_set_syntax if the replacement should be used. */
+#undef re_set_syntax
+
+/* Define to rpl_re_syntax_options if the replacement should be used. */
+#undef re_syntax_options
+
+/* Define to rpl_regcomp if the replacement should be used. */
+#undef regcomp
+
+/* Define to rpl_regerror if the replacement should be used. */
+#undef regerror
+
+/* Define to rpl_regexec if the replacement should be used. */
+#undef regexec
+
+/* Define to rpl_regfree if the replacement should be used. */
+#undef regfree
+
+/* Define to the equivalent of the C99 'restrict' keyword, or to
+   nothing if this is not supported.  Do not define if restrict is
+   supported directly.  */
+#undef restrict
+/* Work around a bug in Sun C++: it does not support _Restrict or
+   __restrict__, even though the corresponding Sun C compiler ends up with
+   "#define restrict _Restrict" or "#define restrict __restrict__" in the
+   previous line.  Perhaps some future version of Sun C++ will work with
+   restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
+#if defined __SUNPRO_CC && !defined __RESTRICT
+# define _Restrict
+# define __restrict__
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define as a signed type of the same size as size_t. */
+#undef ssize_t
+
+/* Define as a marker that can be attached to declarations that might not
+    be used.  This helps to reduce warnings, such as from
+    GCC -Wunused-parameter.  */
+#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_UNUSED __attribute__ ((__unused__))
+#else
+# define _GL_UNUSED
+#endif
+/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
+   is a misnomer outside of parameter lists.  */
+#define _UNUSED_PARAMETER_ _GL_UNUSED
+
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..f041066
--- /dev/null
+++ b/configure
@@ -0,0 +1,33765 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.66 for augeas 0.8.1.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1
+
+  test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
+      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='augeas'
+PACKAGE_TARNAME='augeas'
+PACKAGE_VERSION='0.8.1'
+PACKAGE_STRING='augeas 0.8.1'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
+
+ac_unique_file="src/augeas.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+gl_use_threads_default=
+gl_func_list=
+gl_header_list=
+gl_fnmatch_required=POSIX
+gl_getopt_required=POSIX
+gl_getopt_required=POSIX
+ac_subst_vars='gltests_LTLIBOBJS
+gltests_LIBOBJS
+gl_LTLIBOBJS
+gl_LIBOBJS
+am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+LIBTESTS_LIBDEPS
+YIELD_LIB
+LTLIBMULTITHREAD
+LIBMULTITHREAD
+LTLIBTHREAD
+LIBTHREAD
+LIBPTH_PREFIX
+LTLIBPTH
+LIBPTH
+INTL_MACOSX_LIBS
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H
+NEXT_FCNTL_H
+REPLACE_OPENAT
+REPLACE_OPEN
+REPLACE_FCNTL
+HAVE_OPENAT
+HAVE_FCNTL
+GNULIB_OPENAT
+GNULIB_OPEN
+GNULIB_FCNTL
+LOCALE_TR_UTF8
+gltests_WITNESS
+REPLACE_ISWCNTRL
+HAVE_WCTYPE_H
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H
+NEXT_WCTYPE_H
+HAVE_ISWCNTRL
+REPLACE_ISWBLANK
+HAVE_WCTRANS_T
+HAVE_WCTYPE_T
+HAVE_ISWBLANK
+GNULIB_TOWCTRANS
+GNULIB_WCTRANS
+GNULIB_ISWCTYPE
+GNULIB_WCTYPE
+GNULIB_ISWBLANK
+HAVE_WINT_T
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H
+NEXT_WCHAR_H
+HAVE_FEATURES_H
+HAVE_UNISTD_H
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H
+NEXT_UNISTD_H
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
+TIME_H_DEFINES_STRUCT_TIMESPEC
+NEXT_AS_FIRST_DIRECTIVE_TIME_H
+NEXT_TIME_H
+REPLACE_TIMEGM
+REPLACE_NANOSLEEP
+REPLACE_MKTIME
+REPLACE_LOCALTIME_R
+HAVE_TIMEGM
+HAVE_STRPTIME
+HAVE_NANOSLEEP
+HAVE_DECL_LOCALTIME_R
+GNULIB_TIME_R
+GNULIB_TIMEGM
+GNULIB_STRPTIME
+GNULIB_NANOSLEEP
+GNULIB_MKTIME
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H
+NEXT_SYS_WAIT_H
+GNULIB_WAITPID
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H
+NEXT_SYS_STAT_H
+NEXT_AS_FIRST_DIRECTIVE_STRING_H
+NEXT_STRING_H
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H
+NEXT_STDLIB_H
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H
+NEXT_STDIO_H
+STDINT_H
+WINT_T_SUFFIX
+WCHAR_T_SUFFIX
+SIG_ATOMIC_T_SUFFIX
+SIZE_T_SUFFIX
+PTRDIFF_T_SUFFIX
+HAVE_SIGNED_WINT_T
+HAVE_SIGNED_WCHAR_T
+HAVE_SIGNED_SIG_ATOMIC_T
+BITSIZEOF_WINT_T
+BITSIZEOF_WCHAR_T
+BITSIZEOF_SIG_ATOMIC_T
+BITSIZEOF_SIZE_T
+BITSIZEOF_PTRDIFF_T
+HAVE_SYS_BITYPES_H
+HAVE_SYS_INTTYPES_H
+HAVE_STDINT_H
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H
+NEXT_STDINT_H
+HAVE_SYS_TYPES_H
+HAVE_INTTYPES_H
+HAVE_WCHAR_H
+HAVE_UNSIGNED_LONG_LONG_INT
+HAVE_LONG_LONG_INT
+HAVE__BOOL
+STDBOOL_H
+SELINUX_CONTEXT_H
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H
+NEXT_SELINUX_SELINUX_H
+LIB_SELINUX
+APPLE_UNIVERSAL_BUILD
+UNDEFINE_STRTOK_R
+REPLACE_STRTOK_R
+REPLACE_STRSIGNAL
+REPLACE_STRNLEN
+REPLACE_STRNDUP
+REPLACE_STRNCAT
+REPLACE_STRERROR_R
+REPLACE_STRERROR
+REPLACE_STRCASESTR
+REPLACE_STRSTR
+REPLACE_STRDUP
+REPLACE_STPNCPY
+REPLACE_MEMMEM
+REPLACE_MEMCHR
+HAVE_STRVERSCMP
+HAVE_DECL_STRSIGNAL
+HAVE_DECL_STRERROR_R
+HAVE_DECL_STRTOK_R
+HAVE_STRCASESTR
+HAVE_STRSEP
+HAVE_STRPBRK
+HAVE_DECL_STRNLEN
+HAVE_DECL_STRNDUP
+HAVE_DECL_STRDUP
+HAVE_STRCHRNUL
+HAVE_STPNCPY
+HAVE_STPCPY
+HAVE_RAWMEMCHR
+HAVE_DECL_MEMRCHR
+HAVE_MEMPCPY
+HAVE_DECL_MEMMEM
+HAVE_MEMCHR
+HAVE_MBSLEN
+GNULIB_STRVERSCMP
+GNULIB_STRSIGNAL
+GNULIB_STRERROR_R
+GNULIB_STRERROR
+GNULIB_MBSTOK_R
+GNULIB_MBSSEP
+GNULIB_MBSSPN
+GNULIB_MBSPBRK
+GNULIB_MBSCSPN
+GNULIB_MBSCASESTR
+GNULIB_MBSPCASECMP
+GNULIB_MBSNCASECMP
+GNULIB_MBSCASECMP
+GNULIB_MBSSTR
+GNULIB_MBSRCHR
+GNULIB_MBSCHR
+GNULIB_MBSNLEN
+GNULIB_MBSLEN
+GNULIB_STRTOK_R
+GNULIB_STRCASESTR
+GNULIB_STRSTR
+GNULIB_STRSEP
+GNULIB_STRPBRK
+GNULIB_STRNLEN
+GNULIB_STRNDUP
+GNULIB_STRNCAT
+GNULIB_STRDUP
+GNULIB_STRCHRNUL
+GNULIB_STPNCPY
+GNULIB_STPCPY
+GNULIB_RAWMEMCHR
+GNULIB_MEMRCHR
+GNULIB_MEMPCPY
+GNULIB_MEMMEM
+GNULIB_MEMCHR
+LOCALE_FR_UTF8
+LOCALE_ZH_CN
+LOCALE_JA
+REPLACE_UTIMENSAT
+REPLACE_STAT
+REPLACE_MKNOD
+REPLACE_MKFIFO
+REPLACE_MKDIR
+REPLACE_LSTAT
+REPLACE_FUTIMENS
+REPLACE_FSTATAT
+REPLACE_FSTAT
+HAVE_UTIMENSAT
+HAVE_MKNODAT
+HAVE_MKNOD
+HAVE_MKFIFOAT
+HAVE_MKFIFO
+HAVE_MKDIRAT
+HAVE_LSTAT
+HAVE_LCHMOD
+HAVE_FUTIMENS
+HAVE_FSTATAT
+HAVE_FCHMODAT
+GNULIB_UTIMENSAT
+GNULIB_STAT
+GNULIB_MKNODAT
+GNULIB_MKNOD
+GNULIB_MKFIFOAT
+GNULIB_MKFIFO
+GNULIB_MKDIRAT
+GNULIB_LSTAT
+GNULIB_LCHMOD
+GNULIB_FUTIMENS
+GNULIB_FSTATAT
+GNULIB_FCHMODAT
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H
+NEXT_LOCALE_H
+HAVE_XLOCALE_H
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H
+NEXT_STDDEF_H
+STDDEF_H
+HAVE_WCHAR_T
+REPLACE_NULL
+REPLACE_DUPLOCALE
+REPLACE_SETLOCALE
+HAVE_DUPLOCALE
+GNULIB_DUPLOCALE
+GNULIB_SETLOCALE
+LOCALCHARSET_TESTS_ENVIRONMENT
+GLIBC21
+HAVE_LANGINFO_YESEXPR
+HAVE_LANGINFO_ERA
+HAVE_LANGINFO_T_FMT_AMPM
+HAVE_LANGINFO_CODESET
+HAVE_LANGINFO_H
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H
+NEXT_LANGINFO_H
+REPLACE_NL_LANGINFO
+HAVE_NL_LANGINFO
+GNULIB_NL_LANGINFO
+LTLIBINTL
+LIBINTL
+GETOPT_H
+HAVE_GETOPT_H
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H
+NEXT_GETOPT_H
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS
+UNISTD_H_HAVE_WINSOCK2_H
+REPLACE_WRITE
+REPLACE_USLEEP
+REPLACE_UNLINKAT
+REPLACE_UNLINK
+REPLACE_TTYNAME_R
+REPLACE_SYMLINK
+REPLACE_SLEEP
+REPLACE_RMDIR
+REPLACE_READLINK
+REPLACE_PWRITE
+REPLACE_PREAD
+REPLACE_LSEEK
+REPLACE_LINKAT
+REPLACE_LINK
+REPLACE_LCHOWN
+REPLACE_GETPAGESIZE
+REPLACE_GETGROUPS
+REPLACE_GETLOGIN_R
+REPLACE_GETDOMAINNAME
+REPLACE_GETCWD
+REPLACE_FCHOWNAT
+REPLACE_DUP2
+REPLACE_DUP
+REPLACE_CLOSE
+REPLACE_CHOWN
+HAVE_SYS_PARAM_H
+HAVE_OS_H
+HAVE_DECL_TTYNAME_R
+HAVE_DECL_GETUSERSHELL
+HAVE_DECL_GETPAGESIZE
+HAVE_DECL_GETLOGIN_R
+HAVE_DECL_GETDOMAINNAME
+HAVE_DECL_FCHDIR
+HAVE_DECL_ENVIRON
+HAVE_USLEEP
+HAVE_UNLINKAT
+HAVE_SYMLINKAT
+HAVE_SYMLINK
+HAVE_SLEEP
+HAVE_READLINKAT
+HAVE_READLINK
+HAVE_PWRITE
+HAVE_PREAD
+HAVE_PIPE2
+HAVE_PIPE
+HAVE_LINKAT
+HAVE_LINK
+HAVE_LCHOWN
+HAVE_GETPAGESIZE
+HAVE_GETLOGIN
+HAVE_GETHOSTNAME
+HAVE_GETGROUPS
+HAVE_GETDTABLESIZE
+HAVE_FTRUNCATE
+HAVE_FSYNC
+HAVE_FCHOWNAT
+HAVE_FCHDIR
+HAVE_FACCESSAT
+HAVE_EUIDACCESS
+HAVE_DUP3
+HAVE_DUP2
+HAVE_CHOWN
+GNULIB_WRITE
+GNULIB_USLEEP
+GNULIB_UNLINKAT
+GNULIB_UNLINK
+GNULIB_UNISTD_H_SIGPIPE
+GNULIB_UNISTD_H_GETOPT
+GNULIB_TTYNAME_R
+GNULIB_SYMLINKAT
+GNULIB_SYMLINK
+GNULIB_SLEEP
+GNULIB_RMDIR
+GNULIB_READLINKAT
+GNULIB_READLINK
+GNULIB_PWRITE
+GNULIB_PREAD
+GNULIB_PIPE2
+GNULIB_PIPE
+GNULIB_LSEEK
+GNULIB_LINKAT
+GNULIB_LINK
+GNULIB_LCHOWN
+GNULIB_GETUSERSHELL
+GNULIB_GETPAGESIZE
+GNULIB_GETLOGIN_R
+GNULIB_GETLOGIN
+GNULIB_GETHOSTNAME
+GNULIB_GETGROUPS
+GNULIB_GETDTABLESIZE
+GNULIB_GETDOMAINNAME
+GNULIB_GETCWD
+GNULIB_FTRUNCATE
+GNULIB_FSYNC
+GNULIB_FCHOWNAT
+GNULIB_FCHDIR
+GNULIB_FACCESSAT
+GNULIB_EUIDACCESS
+GNULIB_ENVIRON
+GNULIB_DUP3
+GNULIB_DUP2
+GNULIB_CLOSE
+GNULIB_CHOWN
+REPLACE_VSPRINTF
+REPLACE_VSNPRINTF
+REPLACE_VPRINTF
+REPLACE_VFPRINTF
+REPLACE_VDPRINTF
+REPLACE_VASPRINTF
+REPLACE_TMPFILE
+REPLACE_STDIO_WRITE_FUNCS
+REPLACE_SPRINTF
+REPLACE_SNPRINTF
+REPLACE_RENAMEAT
+REPLACE_RENAME
+REPLACE_REMOVE
+REPLACE_PRINTF
+REPLACE_POPEN
+REPLACE_PERROR
+REPLACE_OBSTACK_PRINTF
+REPLACE_GETLINE
+REPLACE_GETDELIM
+REPLACE_FTELLO
+REPLACE_FTELL
+REPLACE_FSEEKO
+REPLACE_FSEEK
+REPLACE_FREOPEN
+REPLACE_FPURGE
+REPLACE_FPRINTF
+REPLACE_FOPEN
+REPLACE_FFLUSH
+REPLACE_FCLOSE
+REPLACE_DPRINTF
+HAVE_VDPRINTF
+HAVE_VASPRINTF
+HAVE_RENAMEAT
+HAVE_FTELLO
+HAVE_FSEEKO
+HAVE_DPRINTF
+HAVE_DECL_VSNPRINTF
+HAVE_DECL_SNPRINTF
+HAVE_DECL_OBSTACK_PRINTF
+HAVE_DECL_GETLINE
+HAVE_DECL_GETDELIM
+HAVE_DECL_FTELLO
+HAVE_DECL_FSEEKO
+HAVE_DECL_FPURGE
+GNULIB_VSPRINTF_POSIX
+GNULIB_VSNPRINTF
+GNULIB_VPRINTF_POSIX
+GNULIB_VPRINTF
+GNULIB_VFPRINTF_POSIX
+GNULIB_VFPRINTF
+GNULIB_VDPRINTF
+GNULIB_VASPRINTF
+GNULIB_TMPFILE
+GNULIB_STDIO_H_SIGPIPE
+GNULIB_SPRINTF_POSIX
+GNULIB_SNPRINTF
+GNULIB_RENAMEAT
+GNULIB_RENAME
+GNULIB_REMOVE
+GNULIB_PUTS
+GNULIB_PUTCHAR
+GNULIB_PUTC
+GNULIB_PRINTF_POSIX
+GNULIB_PRINTF
+GNULIB_POPEN
+GNULIB_PERROR
+GNULIB_OBSTACK_PRINTF_POSIX
+GNULIB_OBSTACK_PRINTF
+GNULIB_GETLINE
+GNULIB_GETDELIM
+GNULIB_FWRITE
+GNULIB_FTELLO
+GNULIB_FTELL
+GNULIB_FSEEKO
+GNULIB_FSEEK
+GNULIB_FREOPEN
+GNULIB_FPUTS
+GNULIB_FPUTC
+GNULIB_FPURGE
+GNULIB_FPRINTF_POSIX
+GNULIB_FPRINTF
+GNULIB_FOPEN
+GNULIB_FFLUSH
+GNULIB_FCLOSE
+GNULIB_DPRINTF
+FNMATCH_H
+FLOAT_H
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H
+NEXT_FLOAT_H
+EOVERFLOW_VALUE
+EOVERFLOW_HIDDEN
+ENOLINK_VALUE
+ENOLINK_HIDDEN
+EMULTIHOP_VALUE
+EMULTIHOP_HIDDEN
+ERRNO_H
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H
+NEXT_ERRNO_H
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H
+NEXT_CTYPE_H
+PRAGMA_COLUMNS
+PRAGMA_SYSTEM_HEADER
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE
+INCLUDE_NEXT
+HAVE_ISBLANK
+GNULIB_ISBLANK
+pkglibexecdir
+lispdir
+REPLACE_WCTOMB
+REPLACE_UNSETENV
+REPLACE_STRTOD
+REPLACE_SETENV
+REPLACE_REALPATH
+REPLACE_REALLOC
+REPLACE_PUTENV
+REPLACE_MKSTEMP
+REPLACE_MBTOWC
+REPLACE_MALLOC
+REPLACE_CANONICALIZE_FILE_NAME
+REPLACE_CALLOC
+HAVE_DECL_UNSETENV
+HAVE_UNLOCKPT
+HAVE_SYS_LOADAVG_H
+HAVE_STRUCT_RANDOM_DATA
+HAVE_STRTOULL
+HAVE_STRTOLL
+HAVE_STRTOD
+HAVE_DECL_SETENV
+HAVE_SETENV
+HAVE_RPMATCH
+HAVE_REALPATH
+HAVE_RANDOM_R
+HAVE_RANDOM_H
+HAVE_PTSNAME
+HAVE_MKSTEMPS
+HAVE_MKSTEMP
+HAVE_MKOSTEMPS
+HAVE_MKOSTEMP
+HAVE_MKDTEMP
+HAVE_GRANTPT
+HAVE_GETSUBOPT
+HAVE_DECL_GETLOADAVG
+HAVE_CANONICALIZE_FILE_NAME
+HAVE_ATOLL
+HAVE__EXIT
+GNULIB_WCTOMB
+GNULIB_UNSETENV
+GNULIB_UNLOCKPT
+GNULIB_SYSTEM_POSIX
+GNULIB_STRTOULL
+GNULIB_STRTOLL
+GNULIB_STRTOD
+GNULIB_SETENV
+GNULIB_RPMATCH
+GNULIB_REALPATH
+GNULIB_REALLOC_POSIX
+GNULIB_RANDOM_R
+GNULIB_PUTENV
+GNULIB_PTSNAME
+GNULIB_MKSTEMPS
+GNULIB_MKSTEMP
+GNULIB_MKOSTEMPS
+GNULIB_MKOSTEMP
+GNULIB_MKDTEMP
+GNULIB_MBTOWC
+GNULIB_MALLOC_POSIX
+GNULIB_GRANTPT
+GNULIB_GETSUBOPT
+GNULIB_GETLOADAVG
+GNULIB_CANONICALIZE_FILE_NAME
+GNULIB_CALLOC_POSIX
+GNULIB_ATOLL
+GNULIB__EXIT
+LOCALE_FR
+REPLACE_WCSWIDTH
+REPLACE_WCWIDTH
+REPLACE_WCSNRTOMBS
+REPLACE_WCSRTOMBS
+REPLACE_WCRTOMB
+REPLACE_MBSNRTOWCS
+REPLACE_MBSRTOWCS
+REPLACE_MBRLEN
+REPLACE_MBRTOWC
+REPLACE_MBSINIT
+REPLACE_WCTOB
+REPLACE_BTOWC
+REPLACE_MBSTATE_T
+HAVE_DECL_WCWIDTH
+HAVE_DECL_WCTOB
+HAVE_WCSWIDTH
+HAVE_WCSTOK
+HAVE_WCSSTR
+HAVE_WCSPBRK
+HAVE_WCSSPN
+HAVE_WCSCSPN
+HAVE_WCSRCHR
+HAVE_WCSCHR
+HAVE_WCSDUP
+HAVE_WCSXFRM
+HAVE_WCSCOLL
+HAVE_WCSNCASECMP
+HAVE_WCSCASECMP
+HAVE_WCSNCMP
+HAVE_WCSCMP
+HAVE_WCSNCAT
+HAVE_WCSCAT
+HAVE_WCPNCPY
+HAVE_WCSNCPY
+HAVE_WCPCPY
+HAVE_WCSCPY
+HAVE_WCSNLEN
+HAVE_WCSLEN
+HAVE_WMEMSET
+HAVE_WMEMMOVE
+HAVE_WMEMCPY
+HAVE_WMEMCMP
+HAVE_WMEMCHR
+HAVE_WCSNRTOMBS
+HAVE_WCSRTOMBS
+HAVE_WCRTOMB
+HAVE_MBSNRTOWCS
+HAVE_MBSRTOWCS
+HAVE_MBRLEN
+HAVE_MBRTOWC
+HAVE_MBSINIT
+HAVE_BTOWC
+GNULIB_WCSWIDTH
+GNULIB_WCSTOK
+GNULIB_WCSSTR
+GNULIB_WCSPBRK
+GNULIB_WCSSPN
+GNULIB_WCSCSPN
+GNULIB_WCSRCHR
+GNULIB_WCSCHR
+GNULIB_WCSDUP
+GNULIB_WCSXFRM
+GNULIB_WCSCOLL
+GNULIB_WCSNCASECMP
+GNULIB_WCSCASECMP
+GNULIB_WCSNCMP
+GNULIB_WCSCMP
+GNULIB_WCSNCAT
+GNULIB_WCSCAT
+GNULIB_WCPNCPY
+GNULIB_WCSNCPY
+GNULIB_WCPCPY
+GNULIB_WCSCPY
+GNULIB_WCSNLEN
+GNULIB_WCSLEN
+GNULIB_WMEMSET
+GNULIB_WMEMMOVE
+GNULIB_WMEMCPY
+GNULIB_WMEMCMP
+GNULIB_WMEMCHR
+GNULIB_WCWIDTH
+GNULIB_WCSNRTOMBS
+GNULIB_WCSRTOMBS
+GNULIB_WCRTOMB
+GNULIB_MBSNRTOWCS
+GNULIB_MBSRTOWCS
+GNULIB_MBRLEN
+GNULIB_MBRTOWC
+GNULIB_MBSINIT
+GNULIB_WCTOB
+GNULIB_BTOWC
+ARGZ_H
+ALLOCA_H
+ALLOCA
+LTALLOCA
+GL_COND_LIBTOOL_FALSE
+GL_COND_LIBTOOL_TRUE
+USE_VERSION_SCRIPT_FALSE
+USE_VERSION_SCRIPT_TRUE
+VERSION_SCRIPT_FLAGS
+READLINE_LIBS
+AUGEAS_CFLAGS
+WARN_CFLAGS
+LEXLIB
+LEX_OUTPUT_ROOT
+LEX
+YFLAGS
+YACC
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+AR
+OBJDUMP
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+SED
+LIBTOOL
+RANLIB
+EGREP
+GREP
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+LIBFA_VERSION_INFO
+LIBAUGEAS_VERSION_INFO
+ENABLE_DEBUG_FALSE
+ENABLE_DEBUG_TRUE
+WITH_FAILMALLOC_FALSE
+WITH_FAILMALLOC_TRUE
+LIBFAILMALLOC
+PDFDOCS
+PDFLATEX
+ND_FORMAT
+ND_ENABLED_FALSE
+ND_ENABLED_TRUE
+ND_PROG
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_silent_rules
+with_naturaldocs_output
+with_pdfdocs
+with_failmalloc
+enable_debug
+enable_dependency_tracking
+enable_threads
+enable_largefile
+enable_shared
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+enable_libtool_lock
+enable_compile_warnings
+enable_iso_c
+with_included_regex
+with_selinux
+enable_rpath
+with_libpth_prefix
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+YACC
+YFLAGS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures augeas 0.8.1 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking ...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/augeas]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of augeas 0.8.1:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules          less verbose build output (undo: `make V=1')
+  --disable-silent-rules         verbose build output (undo: `make V=0')
+  --enable-debug=no/yes   enable debugging output
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-threads={posix|solaris|pth|win32}
+                          specify multithreading API
+  --disable-threads       build without multithread safety
+  --disable-largefile     omit support for large files
+  --enable-shared[=PKGS]  build shared libraries [default=yes]
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-compile-warnings=[no/minimum/yes/maximum/error]
+                          Turn on compiler warnings
+  --enable-iso-c          Try to warn if code is not ISO C
+  --disable-rpath         do not hardcode runtime library paths
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-naturaldocs-output=FORMAT
+                          format of NaturalDocs output (possible values:
+                          HTML/FramedHTML, default: HTML)
+  --with-pdfdocs          whether to use pdflatex to build PDF docs
+  --with-failmalloc=FAILMALLOC
+                          enable failmalloc test targets and use the
+                          failmalloc library FAILMALLOC
+  --with-pic              try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --without-included-regex
+                          don't compile regex; this is the default on systems
+                          with recent-enough versions of the GNU C Library
+                          (use with caution on other systems).
+  --without-selinux       do not use SELinux, even on systems with SELinux
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libpth-prefix[=DIR]  search for libpth in DIR/include and DIR/lib
+  --without-libpth-prefix     don't search for libpth in includedir and libdir
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+  YACC        The `Yet Another C Compiler' implementation to use. Defaults to
+              the first program found out of: `bison -y', `byacc', `yacc'.
+  YFLAGS      The list of arguments that will be passed by default to $YACC.
+              This script will default YFLAGS to the empty string to avoid a
+              default value of `-d' given by some make applications.
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+augeas configure 0.8.1
+generated by GNU Autoconf 2.66
+
+Copyright (C) 2010 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval "test \"\${$3+set}\"" = set; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+                       if test $ac_lo -le $ac_mid; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval "test \"\${$3+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_decl
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by augeas $as_me 0.8.1, which was
+generated by GNU Autoconf 2.66.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+gl_func_list="$gl_func_list btowc"
+gl_func_list="$gl_func_list canonicalize_file_name"
+gl_func_list="$gl_func_list getcwd"
+gl_func_list="$gl_func_list readlink"
+gl_func_list="$gl_func_list realpath"
+gl_header_list="$gl_header_list sys/param.h"
+gl_func_list="$gl_func_list isblank"
+gl_func_list="$gl_func_list iswctype"
+gl_func_list="$gl_func_list mbsrtowcs"
+gl_func_list="$gl_func_list mempcpy"
+gl_func_list="$gl_func_list wmemchr"
+gl_func_list="$gl_func_list wmemcpy"
+gl_func_list="$gl_func_list wmempcpy"
+gl_header_list="$gl_header_list wctype.h"
+gl_func_list="$gl_func_list getdelim"
+gl_getopt_required=GNU
+gl_header_list="$gl_header_list getopt.h"
+gl_header_list="$gl_header_list langinfo.h"
+gl_header_list="$gl_header_list xlocale.h"
+gl_func_list="$gl_func_list lstat"
+gl_func_list="$gl_func_list mbsinit"
+gl_func_list="$gl_func_list mbrtowc"
+gl_header_list="$gl_header_list sys/mman.h"
+gl_func_list="$gl_func_list mprotect"
+gl_func_list="$gl_func_list memchr"
+gl_func_list="$gl_func_list nl_langinfo"
+gl_func_list="$gl_func_list pathconf"
+gl_func_list="$gl_func_list wcscoll"
+gl_header_list="$gl_header_list selinux/selinux.h"
+gl_header_list="$gl_header_list wchar.h"
+gl_header_list="$gl_header_list stdint.h"
+gl_func_list="$gl_func_list stpncpy"
+gl_func_list="$gl_func_list strndup"
+gl_header_list="$gl_header_list sys/stat.h"
+gl_header_list="$gl_header_list sys/wait.h"
+gl_header_list="$gl_header_list sys/time.h"
+gl_header_list="$gl_header_list unistd.h"
+gl_func_list="$gl_func_list vasnprintf"
+gl_header_list="$gl_header_list features.h"
+gl_func_list="$gl_func_list wcrtomb"
+gl_func_list="$gl_func_list iswcntrl"
+gl_func_list="$gl_func_list dup2"
+gl_func_list="$gl_func_list fcntl"
+gl_func_list="$gl_func_list newlocale"
+gl_func_list="$gl_func_list setenv"
+gl_func_list="$gl_func_list symlink"
+gl_func_list="$gl_func_list wctob"
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_aux_dir=
+for ac_dir in build/aux "$srcdir"/build/aux; do
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in build/aux \"$srcdir\"/build/aux" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+am__api_version='1.11'
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='augeas'
+ VERSION='0.8.1'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in
+yes) AM_DEFAULT_VERBOSITY=0;;
+no)  AM_DEFAULT_VERBOSITY=1;;
+*)   AM_DEFAULT_VERBOSITY=0;;
+esac
+AM_BACKSLASH='\'
+ # make --enable-silent-rules the default.
+
+
+for ac_prog in naturaldocs NaturalDocs
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ND_PROG+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ND_PROG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ND_PROG="$ND_PROG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ND_PROG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ND_PROG=$ac_cv_path_ND_PROG
+if test -n "$ND_PROG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ND_PROG" >&5
+$as_echo "$ND_PROG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ND_PROG" && break
+done
+test -n "$ND_PROG" || ND_PROG="missing"
+
+ if test "x$ND_PROG" != "xmissing"; then
+  ND_ENABLED_TRUE=
+  ND_ENABLED_FALSE='#'
+else
+  ND_ENABLED_TRUE='#'
+  ND_ENABLED_FALSE=
+fi
+
+
+ND_FORMAT=HTML
+
+# Check whether --with-naturaldocs-output was given.
+if test "${with_naturaldocs_output+set}" = set; then :
+  withval=$with_naturaldocs_output;
+    if test "x$ND_PROG" = "xmissing"; then
+      as_fn_error $? "NaturalDocs was not found on your path; there's no point in setting the output format" "$LINENO" 5
+    fi
+    case $withval in
+       HTML|FramedHTML)
+          ND_FORMAT=$withval
+         ;;
+       *)
+          as_fn_error $? "$withval is not a supported output format for NaturalDocs" "$LINENO" 5
+         ;;
+    esac
+
+fi
+
+
+
+
+PDFDOCS=""
+
+# Check whether --with-pdfdocs was given.
+if test "${with_pdfdocs+set}" = set; then :
+  withval=$with_pdfdocs; # Extract the first word of "pdflatex", so it can be a program name with args.
+set dummy pdflatex; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PDFLATEX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PDFLATEX in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PDFLATEX="$PDFLATEX" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PDFLATEX="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_PDFLATEX" && ac_cv_path_PDFLATEX="no"
+  ;;
+esac
+fi
+PDFLATEX=$ac_cv_path_PDFLATEX
+if test -n "$PDFLATEX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PDFLATEX" >&5
+$as_echo "$PDFLATEX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+   if test "x$PDFLATEX" = "xno"; then
+       as_fn_error $? "You asked to use PDFLatex but it could not be found" "$LINENO" 5
+   else
+       PDFDOCS="pdfdocs"
+   fi
+
+fi
+
+
+
+
+
+# Check whether --with-failmalloc was given.
+if test "${with_failmalloc+set}" = set; then :
+  withval=$with_failmalloc; LIBFAILMALLOC="$with_failmalloc"
+
+else
+  with_failmalloc=no
+fi
+
+
+ if test x$with_failmalloc != xno; then
+  WITH_FAILMALLOC_TRUE=
+  WITH_FAILMALLOC_FALSE='#'
+else
+  WITH_FAILMALLOC_TRUE='#'
+  WITH_FAILMALLOC_FALSE=
+fi
+
+
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then :
+  enableval=$enable_debug;
+else
+  enable_debug=yes
+fi
+
+ if test x"$enable_debug" = x"yes"; then
+  ENABLE_DEBUG_TRUE=
+  ENABLE_DEBUG_FALSE='#'
+else
+  ENABLE_DEBUG_TRUE='#'
+  ENABLE_DEBUG_FALSE=
+fi
+
+if test x"$enable_debug" = x"yes"; then
+
+$as_echo "#define ENABLE_DEBUG 1" >>confdefs.h
+
+fi
+
+LIBAUGEAS_VERSION_INFO=13:1:13
+
+LIBFA_VERSION_INFO=4:3:3
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+  ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
+if test "x$ac_cv_header_minix_config_h" = x""yes; then :
+  MINIX=yes
+else
+  MINIX=
+fi
+
+
+  if test "$MINIX" = yes; then
+
+$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h
+
+
+$as_echo "#define _MINIX 1" >>confdefs.h
+
+  fi
+
+        case "$host_os" in
+    hpux*)
+
+$as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h
+
+      ;;
+  esac
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#         define __EXTENSIONS__ 1
+          $ac_includes_default
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_safe_to_define___extensions__=yes
+else
+  ac_cv_safe_to_define___extensions__=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5
+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+  test $ac_cv_safe_to_define___extensions__ = yes &&
+    $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
+
+  $as_echo "#define _ALL_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+
+  $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+
+
+
+
+
+
+
+
+
+  # Check whether --enable-threads was given.
+if test "${enable_threads+set}" = set; then :
+  enableval=$enable_threads; gl_use_threads=$enableval
+else
+  if test -n "$gl_use_threads_default"; then
+       gl_use_threads="$gl_use_threads_default"
+     else
+       case "$host_os" in
+                                                               osf*) gl_use_threads=no ;;
+         cygwin*)
+               case `uname -r` in
+                 1.[0-5].*) gl_use_threads=no ;;
+                 *)         gl_use_threads=yes ;;
+               esac
+               ;;
+         *)    gl_use_threads=yes ;;
+       esac
+     fi
+
+fi
+
+  if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+    # For using <pthread.h>:
+    case "$host_os" in
+      osf*)
+        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
+        # groks <pthread.h>. cc also understands the flag -pthread, but
+        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
+        # 2. putting a flag into CPPFLAGS that has an effect on the linker
+        # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
+        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
+        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
+        ;;
+    esac
+    # Some systems optimize for single-threaded programs by default, and
+    # need special flags to disable these optimizations. For example, the
+    # definition of 'errno' in <errno.h>.
+    case "$host_os" in
+      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
+      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
+    esac
+  fi
+
+
+
+  # Code from module alloca:
+  # Code from module alloca-opt:
+  # Code from module alloca-opt-tests:
+  # Code from module arg-nonnull:
+  # Code from module argz:
+  # Code from module binary-io:
+  # Code from module binary-io-tests:
+  # Code from module btowc:
+  # Code from module btowc-tests:
+  # Code from module c++defs:
+  # Code from module c-ctype:
+  # Code from module c-ctype-tests:
+  # Code from module c-strcase:
+  # Code from module c-strcase-tests:
+  # Code from module canonicalize-lgpl:
+  # Code from module canonicalize-lgpl-tests:
+  # Code from module configmake:
+  # Code from module ctype:
+  # Code from module ctype-tests:
+  # Code from module dosname:
+  # Code from module dup2:
+  # Code from module dup2-tests:
+  # Code from module environ:
+  # Code from module environ-tests:
+  # Code from module errno:
+  # Code from module errno-tests:
+  # Code from module extensions:
+
+  # Code from module fcntl-h:
+  # Code from module fcntl-h-tests:
+  # Code from module float:
+  # Code from module fnmatch:
+  # Code from module fnmatch-tests:
+  # Code from module getdelim:
+  # Code from module getdelim-tests:
+  # Code from module getline:
+  # Code from module getline-tests:
+  # Code from module getopt-gnu:
+  # Code from module getopt-posix:
+  # Code from module getopt-posix-tests:
+  # Code from module getpagesize:
+  # Code from module gettext-h:
+  # Code from module gitlog-to-changelog:
+  # Code from module havelib:
+  # Code from module ignore-value:
+  # Code from module ignore-value-tests:
+  # Code from module include_next:
+  # Code from module intprops:
+  # Code from module isblank:
+  # Code from module isblank-tests:
+  # Code from module langinfo:
+  # Code from module langinfo-tests:
+  # Code from module localcharset:
+  # Code from module locale:
+  # Code from module locale-tests:
+  # Code from module localename:
+  # Code from module localename-tests:
+  # Code from module lock:
+  # Code from module lock-tests:
+  # Code from module lstat:
+  # Code from module lstat-tests:
+  # Code from module malloc-gnu:
+  # Code from module malloc-gnu-tests:
+  # Code from module malloc-posix:
+  # Code from module malloca:
+  # Code from module malloca-tests:
+  # Code from module mbrtowc:
+  # Code from module mbrtowc-tests:
+  # Code from module mbsinit:
+  # Code from module mbsinit-tests:
+  # Code from module mbsrtowcs:
+  # Code from module mbsrtowcs-tests:
+  # Code from module mbtowc:
+  # Code from module memchr:
+  # Code from module memchr-tests:
+  # Code from module mempcpy:
+  # Code from module multiarch:
+  # Code from module nl_langinfo:
+  # Code from module nl_langinfo-tests:
+  # Code from module open:
+  # Code from module open-tests:
+  # Code from module pathmax:
+  # Code from module putenv:
+  # Code from module readlink:
+  # Code from module readlink-tests:
+  # Code from module realloc-posix:
+  # Code from module regex:
+  # Code from module safe-alloc:
+  # Code from module safe-alloc-tests:
+  # Code from module same-inode:
+  # Code from module selinux-h:
+  # Code from module setenv:
+  # Code from module setenv-tests:
+  # Code from module setlocale:
+  # Code from module setlocale-tests:
+  # Code from module size_max:
+  # Code from module ssize_t:
+  # Code from module stat:
+  # Code from module stat-tests:
+  # Code from module stdbool:
+  # Code from module stdbool-tests:
+  # Code from module stddef:
+  # Code from module stddef-tests:
+  # Code from module stdint:
+  # Code from module stdint-tests:
+  # Code from module stdio:
+  # Code from module stdio-tests:
+  # Code from module stdlib:
+  # Code from module stdlib-tests:
+  # Code from module stpcpy:
+  # Code from module stpncpy:
+  # Code from module streq:
+  # Code from module string:
+  # Code from module string-tests:
+  # Code from module strndup:
+  # Code from module strnlen:
+  # Code from module strnlen-tests:
+  # Code from module strnlen1:
+  # Code from module strstr:
+  # Code from module strstr-simple:
+  # Code from module strstr-tests:
+  # Code from module symlink:
+  # Code from module symlink-tests:
+  # Code from module sys_stat:
+  # Code from module sys_stat-tests:
+  # Code from module sys_wait:
+  # Code from module sys_wait-tests:
+  # Code from module thread:
+  # Code from module threadlib:
+
+
+
+  # Code from module time:
+  # Code from module time-tests:
+  # Code from module unistd:
+  # Code from module unistd-tests:
+  # Code from module unsetenv:
+  # Code from module unsetenv-tests:
+  # Code from module unused-parameter:
+  # Code from module vasnprintf:
+  # Code from module vasnprintf-tests:
+  # Code from module vasprintf:
+  # Code from module vasprintf-tests:
+  # Code from module verify:
+  # Code from module verify-tests:
+  # Code from module warn-on-use:
+  # Code from module wchar:
+  # Code from module wchar-tests:
+  # Code from module wcrtomb:
+  # Code from module wcrtomb-tests:
+  # Code from module wctob:
+  # Code from module wctomb:
+  # Code from module wctype-h:
+  # Code from module wctype-h-tests:
+  # Code from module xsize:
+  # Code from module yield:
+
+# Check whether --enable-largefile was given.
+if test "${enable_largefile+set}" = set; then :
+  enableval=$enable_largefile;
+fi
+
+if test "$enable_largefile" != no; then
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
+$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
+if test "${ac_cv_sys_largefile_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_sys_largefile_CC=no
+     if test "$GCC" != yes; then
+       ac_save_CC=$CC
+       while :; do
+        # IRIX 6.2 and later do not support large files by default,
+        # so use the C compiler's -n32 option if that helps.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+        if ac_fn_c_try_compile "$LINENO"; then :
+  break
+fi
+rm -f core conftest.err conftest.$ac_objext
+        CC="$CC -n32"
+        if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_sys_largefile_CC=' -n32'; break
+fi
+rm -f core conftest.err conftest.$ac_objext
+        break
+       done
+       CC=$ac_save_CC
+       rm -f conftest.$ac_ext
+    fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5
+$as_echo "$ac_cv_sys_largefile_CC" >&6; }
+  if test "$ac_cv_sys_largefile_CC" != no; then
+    CC=$CC$ac_cv_sys_largefile_CC
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
+if test "${ac_cv_sys_file_offset_bits+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  while :; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_sys_file_offset_bits=no; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_sys_file_offset_bits=64; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  ac_cv_sys_file_offset_bits=unknown
+  break
+done
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5
+$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
+case $ac_cv_sys_file_offset_bits in #(
+  no | unknown) ;;
+  *)
+cat >>confdefs.h <<_ACEOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+_ACEOF
+;;
+esac
+rm -rf conftest*
+  if test $ac_cv_sys_file_offset_bits = unknown; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
+$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
+if test "${ac_cv_sys_large_files+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  while :; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_sys_large_files=no; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define _LARGE_FILES 1
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+                      && LARGE_OFF_T % 2147483647 == 1)
+                     ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_sys_large_files=1; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  ac_cv_sys_large_files=unknown
+  break
+done
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5
+$as_echo "$ac_cv_sys_large_files" >&6; }
+case $ac_cv_sys_large_files in #(
+  no | unknown) ;;
+  *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+_ACEOF
+;;
+esac
+rm -rf conftest*
+  fi
+fi
+
+
+
+
+case `pwd` in
+  *\ * | *\    *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.2.10'
+macro_revision='1.3175'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`print -r -- -n 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO ""
+}
+
+case "$ECHO" in
+  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if test "${ac_cv_path_SED+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if test "${ac_cv_path_FGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     if test -z "$FGREP"; then
+  ac_path_FGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in fgrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_FGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_FGREP"; then
+    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_FGREP=$FGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if test "${lt_cv_path_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       # Tru64's nm complains that /dev/null is an invalid object file
+       case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+       */dev/null* | *'Invalid file or object type'*)
+         lt_cv_path_NM="$tmp_nm -B"
+         break
+         ;;
+       *)
+         case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+         */dev/null*)
+           lt_cv_path_NM="$tmp_nm -p"
+           break
+           ;;
+         *)
+           lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+           continue # so that we can try to find one that supports BSD flags
+           ;;
+         esac
+         ;;
+       esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in dumpbin "link -dump"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_DUMPBIN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in dumpbin "link -dump"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
+
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
+
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
+
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if test "${lt_cv_nm_interface+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[         ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
+                = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+             test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OBJDUMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[     ]\($symcode$symcode*\)[         ][      ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+       if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+         cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+         cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&5
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+       HPUX_IA64_MODE="32"
+       ;;
+      *ELF-64*)
+       HPUX_IA64_MODE="64"
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -melf32bsmip"
+         ;;
+       *N32*)
+         LD="${LD-ld} -melf32bmipn32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -melf64bmip"
+       ;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -32"
+         ;;
+       *N32*)
+         LD="${LD-ld} -n32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -64"
+         ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_i386_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_i386"
+           ;;
+         ppc64-*linux*|powerpc64-*linux*)
+           LD="${LD-ld} -m elf32ppclinux"
+           ;;
+         s390x-*linux*)
+           LD="${LD-ld} -m elf_s390"
+           ;;
+         sparc64-*linux*)
+           LD="${LD-ld} -m elf32_sparc"
+           ;;
+       esac
+       ;;
+      *64-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_x86_64_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_x86_64"
+           ;;
+         ppc*-*linux*|powerpc*-*linux*)
+           LD="${LD-ld} -m elf64ppc"
+           ;;
+         s390*-*linux*|s390*-*tpf*)
+           LD="${LD-ld} -m elf64_s390"
+           ;;
+         sparc*-*linux*)
+           LD="${LD-ld} -m elf64_sparc"
+           ;;
+       esac
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+       if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+         LD="${LD-ld} -64"
+       fi
+       ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_DSYMUTIL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_NMEDIT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_LIPO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OTOOL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OTOOL64+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+       # By default we will add the -single_module flag. You can override
+       # by either setting the environment variable LT_MULTI_MODULE
+       # non-empty at configure time, or by adding -multi_module to the
+       # link flags.
+       rm -rf libconftest.dylib*
+       echo "int foo(void){return 1;}" > conftest.c
+       echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+       $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+         -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+       if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+         lt_cv_apple_cc_single_mod=yes
+       else
+         cat conftest.err >&5
+       fi
+       rm -rf libconftest.dylib*
+       rm -f conftest.*
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_ld_exported_symbols_list=yes
+else
+  lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+       LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if test "${lt_cv_ld_force_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+      echo "$AR cru libconftest.a conftest.o" >&5
+      $AR cru libconftest.a conftest.o 2>&5
+      echo "$RANLIB libconftest.a" >&5
+      $RANLIB libconftest.a 2>&5
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
+       lt_cv_ld_force_load=yes
+      else
+       cat conftest.err >&5
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+       10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+       10.[012]*)
+         _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+       10.*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+# Set options
+
+
+
+        enable_dlopen=no
+
+
+  enable_win32_dll=no
+
+
+            # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+  # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; pic_mode="$withval"
+else
+  pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if test "${lt_cv_objdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+  *)
+    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+  esac
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+
+
+
+
+
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static=
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='-fPIC'
+       ;;
+      esac
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      lt_prog_compiler_wl='-Xlinker '
+      lt_prog_compiler_pic='-Xcompiler -fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      else
+       lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-KPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='--shared'
+       lt_prog_compiler_static='--static'
+       ;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fpic'
+       lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+       # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-qpic'
+       lt_prog_compiler_static='-qstaticlink'
+       ;;
+      *)
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ F* | *Sun*Fortran*)
+         # Sun Fortran 8.3 passes all unrecognized flags to the linker
+         lt_prog_compiler_pic='-KPIC'
+         lt_prog_compiler_static='-Bstatic'
+         lt_prog_compiler_wl=''
+         ;;
+       *Sun\ C*)
+         # Sun C 5.9
+         lt_prog_compiler_pic='-KPIC'
+         lt_prog_compiler_static='-Bstatic'
+         lt_prog_compiler_wl='-Wl,'
+         ;;
+       esac
+       ;;
+      esac
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+       lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic='-Kconform_pic'
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+
+
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
+    case $host_os in
+      aix*)
+       # The AIX port of GNU ld has always aspired to compatibility
+       # with the native linker.  However, as the warning in the GNU ld
+       # block says, versions before 2.19.5* couldn't really create working
+       # shared libraries, regardless of the interface used.
+       case `$LD -v 2>&1` in
+         *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+         *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+         *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+         *)
+           lt_use_gnu_ld_interface=yes
+           ;;
+       esac
+       ;;
+      *)
+       lt_use_gnu_ld_interface=yes
+       ;;
+    esac
+  fi
+
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    haiku*)
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      link_all_deplibs=yes
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+       case $cc_basename in
+         diet\ *) tmp_diet=yes;;       # linux-dietlibc with static linking (!diet-dyn)
+       esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+        && test "$tmp_diet" = no
+      then
+       tmp_addflag=
+       tmp_sharedflag='-shared'
+       case $cc_basename,$host_cpu in
+        pgcc*)                         # Portland Group C compiler
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95* | pgfortran*)
+                                       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)        # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       lf95*)                          # Lahey Fortran 8.1
+         whole_archive_flag_spec=
+         tmp_sharedflag='--shared' ;;
+       xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+         tmp_sharedflag='-qmkshrobj'
+         tmp_addflag= ;;
+       nvcc*)  # Cuda Compiler Driver 2.2
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         compiler_needs_object=yes
+         ;;
+       esac
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ C*)                       # Sun C 5.9
+         whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         compiler_needs_object=yes
+         tmp_sharedflag='-G' ;;
+       *Sun\ F*)                       # Sun Fortran 8.3
+         tmp_sharedflag='-G' ;;
+       esac
+       archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+           cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+           echo "local: *; };" >> $output_objdir/$libname.ver~
+           $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+       case $cc_basename in
+       xlf* | bgf* | bgxlf* | mpixlf*)
+         # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+         whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+         hardcode_libdir_flag_spec=
+         hardcode_libdir_flag_spec_ld='-rpath $libdir'
+         archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+         if test "x$supports_anon_versioning" = xyes; then
+           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+             cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+             echo "local: *; };" >> $output_objdir/$libname.ver~
+             $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+         fi
+         ;;
+       esac
+      else
+        ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+       ld_shlibs=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+       ;;
+       *)
+         # For security reasons, it is highly recommended that you always
+         # use absolute paths for naming shared libraries, and exclude the
+         # DT_RUNPATH tag from executables and libraries.  But doing so
+         # requires that you compile everything twice, which is a pain.
+         if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+           hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+           archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         else
+           ld_shlibs=no
+         fi
+       ;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       # Also, AIX nm treats weak defined symbols like other global
+       # defined symbols, whereas GNU nm marks them as "W".
+       if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+         export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+         ;;
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='${wl}-f,'
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+          strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         :
+         else
+         # We have old collect2
+         hardcode_direct=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L=yes
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_libdir_separator=
+         fi
+         ;;
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+         fi
+       fi
+      fi
+
+      export_dynamic_flag_spec='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+       /^0/ {
+           s/^0  *\(.*\)$/\1/
+           p
+       }
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag="-z nodefs"
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+       /^0/ {
+           s/^0  *\(.*\)$/\1/
+           p
+       }
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag=' ${wl}-bernotok'
+         allow_undefined_flag=' ${wl}-berok'
+         if test "$with_gnu_ld" = yes; then
+           # We only use this code for GNU lds that support --whole-archive.
+           whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+         else
+           # Exported symbols can be pulled into shared objects from archives
+           whole_archive_flag_spec='$convenience'
+         fi
+         archive_cmds_need_lc=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      allow_undefined_flag=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  else
+    whole_archive_flag_spec=''
+  fi
+  link_all_deplibs=yes
+  allow_undefined_flag="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs=no
+  fi
+
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+       hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+       hardcode_libdir_flag_spec_ld='+b $libdir'
+       hardcode_libdir_separator=:
+       hardcode_direct=yes
+       hardcode_direct_absolute=yes
+       export_dynamic_flag_spec='${wl}-E'
+       # hardcode_minus_L: Not really in the search PATH,
+       # but as the default location of the library.
+       hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*)
+         archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+
+         # Older versions of the 11.00 compiler do not understand -b yet
+         # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+         { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+$as_echo_n "checking if $CC understands -b... " >&6; }
+if test "${lt_cv_prog_compiler__b+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler__b=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS -b"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler__b=yes
+       fi
+     else
+       lt_cv_prog_compiler__b=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+$as_echo "$lt_cv_prog_compiler__b" >&6; }
+
+if test x"$lt_cv_prog_compiler__b" = xyes; then
+    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
+
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+       hardcode_libdir_separator=:
+
+       case $host_cpu in
+       hppa*64*|ia64*)
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+         ;;
+       *)
+         hardcode_direct=yes
+         hardcode_direct_absolute=yes
+         export_dynamic_flag_spec='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       # Try to use the -exported_symbol ld option, if it does not
+       # work, assume that -exports_file does not work either and
+       # implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo(void) {}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+       hardcode_direct=yes
+       hardcode_shlibpath_var=no
+       hardcode_direct_absolute=yes
+       if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+         archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+         export_dynamic_flag_spec='${wl}-E'
+       else
+         case $host_os in
+          openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+            archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+            hardcode_libdir_flag_spec='-R$libdir'
+            ;;
+          *)
+            archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+            hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+            ;;
+         esac
+       fi
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+       $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+       case `$CC -V 2>&1` in
+       *"Compilers 5.0"*)
+         wlarc=''
+         archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+         ;;
+       *)
+         wlarc='${wl}'
+         archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+         archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+         ;;
+       esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine and reorder linker options,
+       # but understands `-z linker_flag'.  GCC discards it without `$wl',
+       # but is careful enough not to reorder.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       if test "$GCC" = yes; then
+         whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+       else
+         whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+       fi
+       ;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds='$CC -r -o $output$reload_objs'
+         hardcode_direct=no
+        ;;
+       motorola)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+       export_dynamic_flag_spec='${wl}-Blargedynsym'
+       ;;
+      esac
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if test "${lt_cv_archive_cmds_need_lc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  $RM conftest*
+       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+       if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+         soname=conftest
+         lib=conftest
+         libobjs=conftest.$ac_objext
+         deplibs=
+         wl=$lt_prog_compiler_wl
+         pic_flag=$lt_prog_compiler_pic
+         compiler_flags=-v
+         linker_flags=-v
+         verstring=
+         output_objdir=.
+         libname=conftest
+         lt_save_allow_undefined_flag=$allow_undefined_flag
+         allow_undefined_flag=
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+         then
+           lt_cv_archive_cmds_need_lc=no
+         else
+           lt_cv_archive_cmds_need_lc=yes
+         fi
+         allow_undefined_flag=$lt_save_allow_undefined_flag
+       else
+         cat conftest.err 1>&5
+       fi
+       $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+       lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+        LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+
+fi
+
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Add ABI-specific directories to the system library path.
+  sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[      ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+       ;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+   test "$inherit_rpath" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+  if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+    ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+void fnord () __attribute__((visibility("default")));
+#endif
+
+void fnord () { int i=42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+void fnord () __attribute__((visibility("default")));
+#endif
+
+void fnord () { int i=42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+  # Report which library types will actually be built
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+for ac_prog in 'bison -y' byacc
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_YACC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$YACC"; then
+  ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_YACC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+YACC=$ac_cv_prog_YACC
+if test -n "$YACC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
+$as_echo "$YACC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="yacc"
+
+for ac_prog in flex lex
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_LEX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LEX"; then
+  ac_cv_prog_LEX="$LEX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_LEX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+LEX=$ac_cv_prog_LEX
+if test -n "$LEX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5
+$as_echo "$LEX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$LEX" && break
+done
+test -n "$LEX" || LEX=":"
+
+if test "x$LEX" != "x:"; then
+  cat >conftest.l <<_ACEOF
+%%
+a { ECHO; }
+b { REJECT; }
+c { yymore (); }
+d { yyless (1); }
+e { yyless (input () != 0); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
+%%
+#ifdef YYTEXT_POINTER
+extern char *yytext;
+#endif
+int
+main (void)
+{
+  return ! yylex () + ! yywrap ();
+}
+_ACEOF
+{ { ac_try="$LEX conftest.l"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$LEX conftest.l") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5
+$as_echo_n "checking lex output file root... " >&6; }
+if test "${ac_cv_prog_lex_root+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+if test -f lex.yy.c; then
+  ac_cv_prog_lex_root=lex.yy
+elif test -f lexyy.c; then
+  ac_cv_prog_lex_root=lexyy
+else
+  as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
+$as_echo "$ac_cv_prog_lex_root" >&6; }
+LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
+
+if test -z "${LEXLIB+set}"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5
+$as_echo_n "checking lex library... " >&6; }
+if test "${ac_cv_lib_lex+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    ac_save_LIBS=$LIBS
+    ac_cv_lib_lex='none needed'
+    for ac_lib in '' -lfl -ll; do
+      LIBS="$ac_lib $ac_save_LIBS"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_lex=$ac_lib
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+      test "$ac_cv_lib_lex" != 'none needed' && break
+    done
+    LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5
+$as_echo "$ac_cv_lib_lex" >&6; }
+  test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5
+$as_echo_n "checking whether yytext is a pointer... " >&6; }
+if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # POSIX says lex can declare yytext either as a pointer or an array; the
+# default is implementation-dependent.  Figure out which it is, since
+# not all implementations provide the %pointer and %array declarations.
+ac_cv_prog_lex_yytext_pointer=no
+ac_save_LIBS=$LIBS
+LIBS="$LEXLIB $ac_save_LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_prog_lex_yytext_pointer=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5
+$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; }
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
+
+$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h
+
+fi
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
+
+fi
+
+
+
+    # Check whether --enable-compile-warnings was given.
+if test "${enable_compile_warnings+set}" = set; then :
+  enableval=$enable_compile_warnings;
+else
+  enable_compile_warnings="maximum"
+fi
+
+
+    warnCFLAGS=
+
+    common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
+
+    case "$enable_compile_warnings" in
+    no)
+        try_compiler_flags=""
+       ;;
+    minimum)
+       try_compiler_flags="-Wall -Wformat -Wformat-security $common_flags"
+       ;;
+    yes)
+       try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
+       ;;
+    maximum|error)
+       try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+       try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
+       try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
+       try_compiler_flags="$try_compiler_flags $common_flags"
+       if test "$enable_compile_warnings" = "error" ; then
+           try_compiler_flags="$try_compiler_flags -Werror"
+       fi
+       ;;
+    *)
+       as_fn_error $? "Unknown argument '$enable_compile_warnings' to --enable-compile-warnings" "$LINENO" 5
+       ;;
+    esac
+
+    compiler_flags=
+    for option in $try_compiler_flags; do
+       SAVE_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $option"
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands $option" >&5
+$as_echo_n "checking whether gcc understands $option... " >&6; }
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  has_option=yes
+else
+  has_option=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+       CFLAGS="$SAVE_CFLAGS"
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_option" >&5
+$as_echo "$has_option" >&6; }
+       if test $has_option = yes; then
+         compiler_flags="$compiler_flags $option"
+       fi
+       unset has_option
+       unset SAVE_CFLAGS
+    done
+    unset option
+    unset try_compiler_flags
+
+    # Check whether --enable-iso-c was given.
+if test "${enable_iso_c+set}" = set; then :
+  enableval=$enable_iso_c;
+else
+  enable_iso_c=no
+fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking what language compliance flags to pass to the C compiler" >&5
+$as_echo_n "checking what language compliance flags to pass to the C compiler... " >&6; }
+    complCFLAGS=
+    if test "x$enable_iso_c" != "xno"; then
+       if test "x$GCC" = "xyes"; then
+       case " $CFLAGS " in
+           *\ \        -ansi\ \        *) ;;
+           *) complCFLAGS="$complCFLAGS -ansi" ;;
+       esac
+       case " $CFLAGS " in
+           *\ \        -pedantic\ \    *) ;;
+           *) complCFLAGS="$complCFLAGS -pedantic" ;;
+       esac
+       fi
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $complCFLAGS" >&5
+$as_echo "$complCFLAGS" >&6; }
+
+    WARN_CFLAGS="$compiler_flags $complCFLAGS"
+
+
+
+## Compiler flags to be used everywhere
+AUGEAS_CFLAGS=-std=gnu99
+
+
+
+  for ac_header in readline/readline.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default"
+if test "x$ac_cv_header_readline_readline_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_READLINE_READLINE_H 1
+_ACEOF
+
+fi
+
+done
+
+
+  # Check for readline.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
+$as_echo_n "checking for readline in -lreadline... " >&6; }
+if test "${ac_cv_lib_readline_readline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char readline ();
+int
+main ()
+{
+return readline ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_readline_readline=yes
+else
+  ac_cv_lib_readline_readline=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
+$as_echo "$ac_cv_lib_readline_readline" >&6; }
+if test "x$ac_cv_lib_readline_readline" = x""yes; then :
+  use_readline=yes; READLINE_LIBS=-lreadline
+else
+  use_readline=no
+fi
+
+
+  # If the above test failed, it may simply be that -lreadline requires
+  # some termcap-related code, e.g., from one of the following libraries.
+  # See if adding one of them to LIBS helps.
+  if test $use_readline = no; then
+      saved_libs=$LIBS
+      LIBS=
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
+$as_echo_n "checking for library containing tgetent... " >&6; }
+if test "${ac_cv_search_tgetent+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char tgetent ();
+int
+main ()
+{
+return tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' ncurses curses termcap termlib; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_tgetent=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_tgetent+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_tgetent+set}" = set; then :
+
+else
+  ac_cv_search_tgetent=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetent" >&5
+$as_echo "$ac_cv_search_tgetent" >&6; }
+ac_res=$ac_cv_search_tgetent
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+      case $LIBS in
+        no*) ;;  # handle "no" and "none required"
+        *) # anything else is a -lLIBRARY
+          # Now, check for -lreadline again, also using $LIBS.
+          # Note: this time we use a different function, so that
+          # we don't get a cached "no" result.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_initialize in -lreadline" >&5
+$as_echo_n "checking for rl_initialize in -lreadline... " >&6; }
+if test "${ac_cv_lib_readline_rl_initialize+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline $LIBS $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char rl_initialize ();
+int
+main ()
+{
+return rl_initialize ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_readline_rl_initialize=yes
+else
+  ac_cv_lib_readline_rl_initialize=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_initialize" >&5
+$as_echo "$ac_cv_lib_readline_rl_initialize" >&6; }
+if test "x$ac_cv_lib_readline_rl_initialize" = x""yes; then :
+  use_readline=yes
+                   READLINE_LIBS="-lreadline $LIBS"
+fi
+
+          ;;
+      esac
+      test $use_readline = no &&
+          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: readline library not found" >&5
+$as_echo "$as_me: WARNING: readline library not found" >&2;}
+      LIBS=$saved_libs
+  fi
+
+  if test $use_readline = no; then
+    as_fn_error $? "Could not find a working readline library (see config.log for details)." "$LINENO" 5
+  fi
+
+
+
+  if test $use_readline = yes; then
+      saved_libs=$LIBS
+      LIBS=$READLINE_LIBS
+      for ac_func in rl_completion_matches
+do :
+  ac_fn_c_check_func "$LINENO" "rl_completion_matches" "ac_cv_func_rl_completion_matches"
+if test "x$ac_cv_func_rl_completion_matches" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_RL_COMPLETION_MATCHES 1
+_ACEOF
+
+fi
+done
+
+      LIBS=$saved_libs
+  fi
+
+for ac_func in open_memstream uselocale
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+VERSION_SCRIPT_FLAGS=
+$(/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null) && \
+    VERSION_SCRIPT_FLAGS=-Wl,--version-script=
+test "`uname`" == "SunOS" && \
+    VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
+
+ if test -n "$VERSION_SCRIPT_FLAGS"; then
+  USE_VERSION_SCRIPT_TRUE=
+  USE_VERSION_SCRIPT_FALSE='#'
+else
+  USE_VERSION_SCRIPT_TRUE='#'
+  USE_VERSION_SCRIPT_FALSE=
+fi
+
+
+
+
+
+
+          LIBC_FATAL_STDERR_=1
+  export LIBC_FATAL_STDERR_
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments.  Useless!
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
+$as_echo_n "checking for working alloca.h... " >&6; }
+if test "${ac_cv_working_alloca_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+                         if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_working_alloca_h=yes
+else
+  ac_cv_working_alloca_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
+$as_echo "$ac_cv_working_alloca_h" >&6; }
+if test $ac_cv_working_alloca_h = yes; then
+
+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
+$as_echo_n "checking for alloca... " >&6; }
+if test "${ac_cv_func_alloca_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
+# else
+#  ifdef HAVE_ALLOCA_H
+#   include <alloca.h>
+#  else
+#   ifdef _AIX
+ #pragma alloca
+#   else
+#    ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+int
+main ()
+{
+char *p = (char *) alloca (1);
+                                   if (p) return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_func_alloca_works=yes
+else
+  ac_cv_func_alloca_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
+$as_echo "$ac_cv_func_alloca_works" >&6; }
+
+if test $ac_cv_func_alloca_works = yes; then
+
+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
+
+else
+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+# that cause trouble.  Some versions do not even contain alloca or
+# contain a buggy version.  If you still want to use their alloca,
+# use ar to extract alloca.o from them instead of compiling alloca.c.
+
+
+
+
+
+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
+
+$as_echo "#define C_ALLOCA 1" >>confdefs.h
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
+if test "${ac_cv_os_cray+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined CRAY && ! defined CRAY2
+webecray
+#else
+wenotbecray
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "webecray" >/dev/null 2>&1; then :
+  ac_cv_os_cray=yes
+else
+  ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
+$as_echo "$ac_cv_os_cray" >&6; }
+if test $ac_cv_os_cray = yes; then
+  for ac_func in _getb67 GETB67 getb67; do
+    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define CRAY_STACKSEG_END $ac_func
+_ACEOF
+
+    break
+fi
+
+  done
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
+$as_echo_n "checking stack direction for C alloca... " >&6; }
+if test "${ac_cv_c_stack_direction+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_c_stack_direction=0
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+find_stack_direction ()
+{
+  static char *addr = 0;
+  auto char dummy;
+  if (addr == 0)
+    {
+      addr = &dummy;
+      return find_stack_direction ();
+    }
+  else
+    return (&dummy > addr) ? 1 : -1;
+}
+
+int
+main ()
+{
+  return find_stack_direction () < 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_c_stack_direction=1
+else
+  ac_cv_c_stack_direction=-1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
+$as_echo "$ac_cv_c_stack_direction" >&6; }
+cat >>confdefs.h <<_ACEOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+_ACEOF
+
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
+$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
+if test "${ac_cv_c_restrict+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_restrict=no
+   # The order here caters to the fact that C++ does not require restrict.
+   for ac_kw in __restrict __restrict__ _Restrict restrict; do
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+typedef int * int_ptr;
+       int foo (int_ptr $ac_kw ip) {
+       return ip[0];
+       }
+int
+main ()
+{
+int s[1];
+       int * $ac_kw t = s;
+       t[0] = 0;
+       return foo(t)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_restrict=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     test "$ac_cv_c_restrict" != no && break
+   done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
+$as_echo "$ac_cv_c_restrict" >&6; }
+
+ case $ac_cv_c_restrict in
+   restrict) ;;
+   no) $as_echo "#define restrict /**/" >>confdefs.h
+ ;;
+   *)  cat >>confdefs.h <<_ACEOF
+#define restrict $ac_cv_c_restrict
+_ACEOF
+ ;;
+ esac
+
+
+  GNULIB_BTOWC=0;
+  GNULIB_WCTOB=0;
+  GNULIB_MBSINIT=0;
+  GNULIB_MBRTOWC=0;
+  GNULIB_MBRLEN=0;
+  GNULIB_MBSRTOWCS=0;
+  GNULIB_MBSNRTOWCS=0;
+  GNULIB_WCRTOMB=0;
+  GNULIB_WCSRTOMBS=0;
+  GNULIB_WCSNRTOMBS=0;
+  GNULIB_WCWIDTH=0;
+  GNULIB_WMEMCHR=0;
+  GNULIB_WMEMCMP=0;
+  GNULIB_WMEMCPY=0;
+  GNULIB_WMEMMOVE=0;
+  GNULIB_WMEMSET=0;
+  GNULIB_WCSLEN=0;
+  GNULIB_WCSNLEN=0;
+  GNULIB_WCSCPY=0;
+  GNULIB_WCPCPY=0;
+  GNULIB_WCSNCPY=0;
+  GNULIB_WCPNCPY=0;
+  GNULIB_WCSCAT=0;
+  GNULIB_WCSNCAT=0;
+  GNULIB_WCSCMP=0;
+  GNULIB_WCSNCMP=0;
+  GNULIB_WCSCASECMP=0;
+  GNULIB_WCSNCASECMP=0;
+  GNULIB_WCSCOLL=0;
+  GNULIB_WCSXFRM=0;
+  GNULIB_WCSDUP=0;
+  GNULIB_WCSCHR=0;
+  GNULIB_WCSRCHR=0;
+  GNULIB_WCSCSPN=0;
+  GNULIB_WCSSPN=0;
+  GNULIB_WCSPBRK=0;
+  GNULIB_WCSSTR=0;
+  GNULIB_WCSTOK=0;
+  GNULIB_WCSWIDTH=0;
+    HAVE_BTOWC=1;
+  HAVE_MBSINIT=1;
+  HAVE_MBRTOWC=1;
+  HAVE_MBRLEN=1;
+  HAVE_MBSRTOWCS=1;
+  HAVE_MBSNRTOWCS=1;
+  HAVE_WCRTOMB=1;
+  HAVE_WCSRTOMBS=1;
+  HAVE_WCSNRTOMBS=1;
+  HAVE_WMEMCHR=1;
+  HAVE_WMEMCMP=1;
+  HAVE_WMEMCPY=1;
+  HAVE_WMEMMOVE=1;
+  HAVE_WMEMSET=1;
+  HAVE_WCSLEN=1;
+  HAVE_WCSNLEN=1;
+  HAVE_WCSCPY=1;
+  HAVE_WCPCPY=1;
+  HAVE_WCSNCPY=1;
+  HAVE_WCPNCPY=1;
+  HAVE_WCSCAT=1;
+  HAVE_WCSNCAT=1;
+  HAVE_WCSCMP=1;
+  HAVE_WCSNCMP=1;
+  HAVE_WCSCASECMP=1;
+  HAVE_WCSNCASECMP=1;
+  HAVE_WCSCOLL=1;
+  HAVE_WCSXFRM=1;
+  HAVE_WCSDUP=1;
+  HAVE_WCSCHR=1;
+  HAVE_WCSRCHR=1;
+  HAVE_WCSCSPN=1;
+  HAVE_WCSSPN=1;
+  HAVE_WCSPBRK=1;
+  HAVE_WCSSTR=1;
+  HAVE_WCSTOK=1;
+  HAVE_WCSWIDTH=1;
+  HAVE_DECL_WCTOB=1;
+  HAVE_DECL_WCWIDTH=1;
+  REPLACE_MBSTATE_T=0;
+  REPLACE_BTOWC=0;
+  REPLACE_WCTOB=0;
+  REPLACE_MBSINIT=0;
+  REPLACE_MBRTOWC=0;
+  REPLACE_MBRLEN=0;
+  REPLACE_MBSRTOWCS=0;
+  REPLACE_MBSNRTOWCS=0;
+  REPLACE_WCRTOMB=0;
+  REPLACE_WCSRTOMBS=0;
+  REPLACE_WCSNRTOMBS=0;
+  REPLACE_WCWIDTH=0;
+  REPLACE_WCSWIDTH=0;
+
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <wchar.h> uses 'inline' correctly" >&5
+$as_echo_n "checking whether <wchar.h> uses 'inline' correctly... " >&6; }
+if test "${gl_cv_header_wchar_h_correct_inline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gl_cv_header_wchar_h_correct_inline=yes
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+       #define wcstod renamed_wcstod
+/* 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>
+extern int zero (void);
+int main () { return zero(); }
+
+_ACEOF
+     if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+       mv conftest.$ac_objext conftest1.$ac_objext
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+         #define wcstod renamed_wcstod
+/* 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>
+int zero (void) { return 0; }
+
+_ACEOF
+       if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+         mv conftest.$ac_objext conftest2.$ac_objext
+         if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&5 2>&1; then
+           :
+         else
+           gl_cv_header_wchar_h_correct_inline=no
+         fi
+       fi
+     fi
+     rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_correct_inline" >&5
+$as_echo "$gl_cv_header_wchar_h_correct_inline" >&6; }
+  if test $gl_cv_header_wchar_h_correct_inline = no; then
+    as_fn_error $? "<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
+This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
+C99 mode. You have four options:
+  - Add the flag -fgnu89-inline to CC and reconfigure, or
+  - Fix your include files, using parts of
+    <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
+  - Use a gcc version older than 4.3, or
+  - Don't use the flags -std=c99 or -std=gnu99.
+Configuration aborted." "$LINENO" 5
+  fi
+
+
+
+
+
+  for ac_func in $gl_func_list
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
+$as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
+if test "${am_cv_langinfo_codeset+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET); return !cs;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  am_cv_langinfo_codeset=yes
+else
+  am_cv_langinfo_codeset=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5
+$as_echo "$am_cv_langinfo_codeset" >&6; }
+  if test $am_cv_langinfo_codeset = yes; then
+
+$as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
+
+  fi
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5
+$as_echo_n "checking whether // is distinct from /... " >&6; }
+if test "${gl_cv_double_slash_root+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+   if test x"$cross_compiling" = xyes ; then
+        # When cross-compiling, there is no way to tell whether // is special
+        # short of a list of hosts.  However, the only known hosts to date
+        # that have a distinct // are Apollo DomainOS (too old to port to),
+        # Cygwin, and z/OS.  If anyone knows of another system for which // has
+        # special semantics and is distinct from /, please report it to
+        # <bug-gnulib@gnu.org>.
+        case $host in
+          *-cygwin | i370-ibm-openedition)
+            gl_cv_double_slash_root=yes ;;
+          *)
+            # Be optimistic and assume that / and // are the same when we
+            # don't know.
+            gl_cv_double_slash_root='unknown, assuming no' ;;
+        esac
+      else
+        set x `ls -di / // 2>/dev/null`
+        if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then
+          gl_cv_double_slash_root=no
+        else
+          gl_cv_double_slash_root=yes
+        fi
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5
+$as_echo "$gl_cv_double_slash_root" >&6; }
+  if test "$gl_cv_double_slash_root" = yes; then
+
+$as_echo "#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1" >>confdefs.h
+
+  fi
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether realpath works" >&5
+$as_echo_n "checking whether realpath works... " >&6; }
+if test "${gl_cv_func_realpath_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    touch conftest.a
+    if test "$cross_compiling" = yes; then :
+  gl_cv_func_realpath_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+        #include <stdlib.h>
+
+int
+main ()
+{
+
+        int result = 0;
+        {
+          char *name = realpath ("conftest.a", NULL);
+          if (!(name && *name == '/'))
+            result |= 1;
+        }
+        {
+          char *name = realpath ("conftest.b/../conftest.a", NULL);
+          if (name != NULL)
+            result |= 2;
+        }
+        {
+          char *name = realpath ("conftest.a/", NULL);
+          if (name != NULL)
+            result |= 4;
+        }
+        return result;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_realpath_works=yes
+else
+  gl_cv_func_realpath_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_realpath_works" >&5
+$as_echo "$gl_cv_func_realpath_works" >&6; }
+  if test "$gl_cv_func_realpath_works" = yes; then
+
+$as_echo "#define FUNC_REALPATH_WORKS 1" >>confdefs.h
+
+  fi
+
+
+
+
+
+  for ac_header in $gl_header_list
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+  GNULIB__EXIT=0;
+  GNULIB_ATOLL=0;
+  GNULIB_CALLOC_POSIX=0;
+  GNULIB_CANONICALIZE_FILE_NAME=0;
+  GNULIB_GETLOADAVG=0;
+  GNULIB_GETSUBOPT=0;
+  GNULIB_GRANTPT=0;
+  GNULIB_MALLOC_POSIX=0;
+  GNULIB_MBTOWC=0;
+  GNULIB_MKDTEMP=0;
+  GNULIB_MKOSTEMP=0;
+  GNULIB_MKOSTEMPS=0;
+  GNULIB_MKSTEMP=0;
+  GNULIB_MKSTEMPS=0;
+  GNULIB_PTSNAME=0;
+  GNULIB_PUTENV=0;
+  GNULIB_RANDOM_R=0;
+  GNULIB_REALLOC_POSIX=0;
+  GNULIB_REALPATH=0;
+  GNULIB_RPMATCH=0;
+  GNULIB_SETENV=0;
+  GNULIB_STRTOD=0;
+  GNULIB_STRTOLL=0;
+  GNULIB_STRTOULL=0;
+  GNULIB_SYSTEM_POSIX=0;
+  GNULIB_UNLOCKPT=0;
+  GNULIB_UNSETENV=0;
+  GNULIB_WCTOMB=0;
+    HAVE__EXIT=1;
+  HAVE_ATOLL=1;
+  HAVE_CANONICALIZE_FILE_NAME=1;
+  HAVE_DECL_GETLOADAVG=1;
+  HAVE_GETSUBOPT=1;
+  HAVE_GRANTPT=1;
+  HAVE_MKDTEMP=1;
+  HAVE_MKOSTEMP=1;
+  HAVE_MKOSTEMPS=1;
+  HAVE_MKSTEMP=1;
+  HAVE_MKSTEMPS=1;
+  HAVE_PTSNAME=1;
+  HAVE_RANDOM_H=1;
+  HAVE_RANDOM_R=1;
+  HAVE_REALPATH=1;
+  HAVE_RPMATCH=1;
+  HAVE_SETENV=1;
+  HAVE_DECL_SETENV=1;
+  HAVE_STRTOD=1;
+  HAVE_STRTOLL=1;
+  HAVE_STRTOULL=1;
+  HAVE_STRUCT_RANDOM_DATA=1;
+  HAVE_SYS_LOADAVG_H=0;
+  HAVE_UNLOCKPT=1;
+  HAVE_DECL_UNSETENV=1;
+  REPLACE_CALLOC=0;
+  REPLACE_CANONICALIZE_FILE_NAME=0;
+  REPLACE_MALLOC=0;
+  REPLACE_MBTOWC=0;
+  REPLACE_MKSTEMP=0;
+  REPLACE_PUTENV=0;
+  REPLACE_REALLOC=0;
+  REPLACE_REALPATH=0;
+  REPLACE_SETENV=0;
+  REPLACE_STRTOD=0;
+  REPLACE_UNSETENV=0;
+  REPLACE_WCTOMB=0;
+
+
+  GNULIB_ISBLANK=0;
+    HAVE_ISBLANK=1;
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5
+$as_echo_n "checking whether the preprocessor supports include_next... " >&6; }
+if test "${gl_cv_have_include_next+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -rf conftestd1a conftestd1b conftestd2
+     mkdir conftestd1a conftestd1b conftestd2
+                                                  cat <<EOF > conftestd1a/conftest.h
+#define DEFINED_IN_CONFTESTD1
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd1b/conftest.h
+#define DEFINED_IN_CONFTESTD1
+#include <stdio.h>
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd2/conftest.h
+#ifndef DEFINED_IN_CONFTESTD1
+#error "include_next test doesn't work"
+#endif
+#define DEFINED_IN_CONFTESTD2
+EOF
+     gl_save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <conftest.h>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_have_include_next=yes
+else
+  CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <conftest.h>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_have_include_next=buggy
+else
+  gl_cv_have_include_next=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     CPPFLAGS="$gl_save_CPPFLAGS"
+     rm -rf conftestd1a conftestd1b conftestd2
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5
+$as_echo "$gl_cv_have_include_next" >&6; }
+  PRAGMA_SYSTEM_HEADER=
+  if test $gl_cv_have_include_next = yes; then
+    INCLUDE_NEXT=include_next
+    INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    if test -n "$GCC"; then
+      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
+    fi
+  else
+    if test $gl_cv_have_include_next = buggy; then
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    else
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
+    fi
+  fi
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5
+$as_echo_n "checking whether system header files limit the line length... " >&6; }
+if test "${gl_cv_pragma_columns+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef __TANDEM
+choke me
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "choke me" >/dev/null 2>&1; then :
+  gl_cv_pragma_columns=yes
+else
+  gl_cv_pragma_columns=no
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5
+$as_echo "$gl_cv_pragma_columns" >&6; }
+  if test $gl_cv_pragma_columns = yes; then
+    PRAGMA_COLUMNS="#pragma COLUMNS 10000"
+  else
+    PRAGMA_COLUMNS=
+  fi
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for complete errno.h" >&5
+$as_echo_n "checking for complete errno.h... " >&6; }
+if test "${gl_cv_header_errno_h_complete+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <errno.h>
+#if !defined ENOMSG
+booboo
+#endif
+#if !defined EIDRM
+booboo
+#endif
+#if !defined ENOLINK
+booboo
+#endif
+#if !defined EPROTO
+booboo
+#endif
+#if !defined EMULTIHOP
+booboo
+#endif
+#if !defined EBADMSG
+booboo
+#endif
+#if !defined EOVERFLOW
+booboo
+#endif
+#if !defined ENOTSUP
+booboo
+#endif
+#if !defined ESTALE
+booboo
+#endif
+#if !defined EDQUOT
+booboo
+#endif
+#if !defined ECANCELED
+booboo
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "booboo" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_complete=no
+else
+  gl_cv_header_errno_h_complete=yes
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_complete" >&5
+$as_echo "$gl_cv_header_errno_h_complete" >&6; }
+  if test $gl_cv_header_errno_h_complete = yes; then
+    ERRNO_H=''
+  else
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_errno_h='<'errno.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <errno.h>" >&5
+$as_echo_n "checking absolute name of <errno.h>... " >&6; }
+if test "${gl_cv_next_errno_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <errno.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/errno.h#{
+                    s#.*"\(.*/errno.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_errno_h" >&5
+$as_echo "$gl_cv_next_errno_h" >&6; }
+     fi
+     NEXT_ERRNO_H=$gl_cv_next_errno_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'errno.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_errno_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_ERRNO_H=$gl_next_as_first_directive
+
+
+
+
+    ERRNO_H='errno.h'
+  fi
+
+
+  if test -n "$ERRNO_H"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EMULTIHOP value" >&5
+$as_echo_n "checking for EMULTIHOP value... " >&6; }
+if test "${gl_cv_header_errno_h_EMULTIHOP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <errno.h>
+#ifdef EMULTIHOP
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_EMULTIHOP=yes
+else
+  gl_cv_header_errno_h_EMULTIHOP=no
+fi
+rm -f conftest*
+
+      if test $gl_cv_header_errno_h_EMULTIHOP = no; then
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef EMULTIHOP
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_EMULTIHOP=hidden
+fi
+rm -f conftest*
+
+        if test $gl_cv_header_errno_h_EMULTIHOP = hidden; then
+                              if ac_fn_c_compute_int "$LINENO" "EMULTIHOP" "gl_cv_header_errno_h_EMULTIHOP"        "
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+"; then :
+
+fi
+
+        fi
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EMULTIHOP" >&5
+$as_echo "$gl_cv_header_errno_h_EMULTIHOP" >&6; }
+    case $gl_cv_header_errno_h_EMULTIHOP in
+      yes | no)
+        EMULTIHOP_HIDDEN=0; EMULTIHOP_VALUE=
+        ;;
+      *)
+        EMULTIHOP_HIDDEN=1; EMULTIHOP_VALUE="$gl_cv_header_errno_h_EMULTIHOP"
+        ;;
+    esac
+
+
+  fi
+
+
+  if test -n "$ERRNO_H"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ENOLINK value" >&5
+$as_echo_n "checking for ENOLINK value... " >&6; }
+if test "${gl_cv_header_errno_h_ENOLINK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <errno.h>
+#ifdef ENOLINK
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_ENOLINK=yes
+else
+  gl_cv_header_errno_h_ENOLINK=no
+fi
+rm -f conftest*
+
+      if test $gl_cv_header_errno_h_ENOLINK = no; then
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef ENOLINK
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_ENOLINK=hidden
+fi
+rm -f conftest*
+
+        if test $gl_cv_header_errno_h_ENOLINK = hidden; then
+                              if ac_fn_c_compute_int "$LINENO" "ENOLINK" "gl_cv_header_errno_h_ENOLINK"        "
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+"; then :
+
+fi
+
+        fi
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_ENOLINK" >&5
+$as_echo "$gl_cv_header_errno_h_ENOLINK" >&6; }
+    case $gl_cv_header_errno_h_ENOLINK in
+      yes | no)
+        ENOLINK_HIDDEN=0; ENOLINK_VALUE=
+        ;;
+      *)
+        ENOLINK_HIDDEN=1; ENOLINK_VALUE="$gl_cv_header_errno_h_ENOLINK"
+        ;;
+    esac
+
+
+  fi
+
+
+  if test -n "$ERRNO_H"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EOVERFLOW value" >&5
+$as_echo_n "checking for EOVERFLOW value... " >&6; }
+if test "${gl_cv_header_errno_h_EOVERFLOW+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <errno.h>
+#ifdef EOVERFLOW
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_EOVERFLOW=yes
+else
+  gl_cv_header_errno_h_EOVERFLOW=no
+fi
+rm -f conftest*
+
+      if test $gl_cv_header_errno_h_EOVERFLOW = no; then
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef EOVERFLOW
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  gl_cv_header_errno_h_EOVERFLOW=hidden
+fi
+rm -f conftest*
+
+        if test $gl_cv_header_errno_h_EOVERFLOW = hidden; then
+                              if ac_fn_c_compute_int "$LINENO" "EOVERFLOW" "gl_cv_header_errno_h_EOVERFLOW"        "
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+"; then :
+
+fi
+
+        fi
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EOVERFLOW" >&5
+$as_echo "$gl_cv_header_errno_h_EOVERFLOW" >&6; }
+    case $gl_cv_header_errno_h_EOVERFLOW in
+      yes | no)
+        EOVERFLOW_HIDDEN=0; EOVERFLOW_VALUE=
+        ;;
+      *)
+        EOVERFLOW_HIDDEN=1; EOVERFLOW_VALUE="$gl_cv_header_errno_h_EOVERFLOW"
+        ;;
+    esac
+
+
+  fi
+
+
+
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5
+$as_echo_n "checking for mbstate_t... " >&6; }
+if test "${ac_cv_type_mbstate_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+/* 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>
+int
+main ()
+{
+mbstate_t x; return sizeof x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_type_mbstate_t=yes
+else
+  ac_cv_type_mbstate_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_mbstate_t" >&5
+$as_echo "$ac_cv_type_mbstate_t" >&6; }
+   if test $ac_cv_type_mbstate_t = yes; then
+
+$as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h
+
+   else
+
+$as_echo "#define mbstate_t int" >>confdefs.h
+
+   fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  GNULIB_DPRINTF=0;
+  GNULIB_FCLOSE=0;
+  GNULIB_FFLUSH=0;
+  GNULIB_FOPEN=0;
+  GNULIB_FPRINTF=0;
+  GNULIB_FPRINTF_POSIX=0;
+  GNULIB_FPURGE=0;
+  GNULIB_FPUTC=0;
+  GNULIB_FPUTS=0;
+  GNULIB_FREOPEN=0;
+  GNULIB_FSEEK=0;
+  GNULIB_FSEEKO=0;
+  GNULIB_FTELL=0;
+  GNULIB_FTELLO=0;
+  GNULIB_FWRITE=0;
+  GNULIB_GETDELIM=0;
+  GNULIB_GETLINE=0;
+  GNULIB_OBSTACK_PRINTF=0;
+  GNULIB_OBSTACK_PRINTF_POSIX=0;
+  GNULIB_PERROR=0;
+  GNULIB_POPEN=0;
+  GNULIB_PRINTF=0;
+  GNULIB_PRINTF_POSIX=0;
+  GNULIB_PUTC=0;
+  GNULIB_PUTCHAR=0;
+  GNULIB_PUTS=0;
+  GNULIB_REMOVE=0;
+  GNULIB_RENAME=0;
+  GNULIB_RENAMEAT=0;
+  GNULIB_SNPRINTF=0;
+  GNULIB_SPRINTF_POSIX=0;
+  GNULIB_STDIO_H_SIGPIPE=0;
+  GNULIB_TMPFILE=0;
+  GNULIB_VASPRINTF=0;
+  GNULIB_VDPRINTF=0;
+  GNULIB_VFPRINTF=0;
+  GNULIB_VFPRINTF_POSIX=0;
+  GNULIB_VPRINTF=0;
+  GNULIB_VPRINTF_POSIX=0;
+  GNULIB_VSNPRINTF=0;
+  GNULIB_VSPRINTF_POSIX=0;
+    HAVE_DECL_FPURGE=1;
+  HAVE_DECL_FSEEKO=1;
+  HAVE_DECL_FTELLO=1;
+  HAVE_DECL_GETDELIM=1;
+  HAVE_DECL_GETLINE=1;
+  HAVE_DECL_OBSTACK_PRINTF=1;
+  HAVE_DECL_SNPRINTF=1;
+  HAVE_DECL_VSNPRINTF=1;
+  HAVE_DPRINTF=1;
+  HAVE_FSEEKO=1;
+  HAVE_FTELLO=1;
+  HAVE_RENAMEAT=1;
+  HAVE_VASPRINTF=1;
+  HAVE_VDPRINTF=1;
+  REPLACE_DPRINTF=0;
+  REPLACE_FCLOSE=0;
+  REPLACE_FFLUSH=0;
+  REPLACE_FOPEN=0;
+  REPLACE_FPRINTF=0;
+  REPLACE_FPURGE=0;
+  REPLACE_FREOPEN=0;
+  REPLACE_FSEEK=0;
+  REPLACE_FSEEKO=0;
+  REPLACE_FTELL=0;
+  REPLACE_FTELLO=0;
+  REPLACE_GETDELIM=0;
+  REPLACE_GETLINE=0;
+  REPLACE_OBSTACK_PRINTF=0;
+  REPLACE_PERROR=0;
+  REPLACE_POPEN=0;
+  REPLACE_PRINTF=0;
+  REPLACE_REMOVE=0;
+  REPLACE_RENAME=0;
+  REPLACE_RENAMEAT=0;
+  REPLACE_SNPRINTF=0;
+  REPLACE_SPRINTF=0;
+  REPLACE_STDIO_WRITE_FUNCS=0;
+  REPLACE_TMPFILE=0;
+  REPLACE_VASPRINTF=0;
+  REPLACE_VDPRINTF=0;
+  REPLACE_VFPRINTF=0;
+  REPLACE_VPRINTF=0;
+  REPLACE_VSNPRINTF=0;
+  REPLACE_VSPRINTF=0;
+
+
+      ac_fn_c_check_decl "$LINENO" "getdelim" "ac_cv_have_decl_getdelim" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getdelim" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETDELIM $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+      ac_fn_c_check_decl "$LINENO" "getline" "ac_cv_have_decl_getline" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getline" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETLINE $ac_have_decl
+_ACEOF
+
+
+
+  GNULIB_CHOWN=0;
+  GNULIB_CLOSE=0;
+  GNULIB_DUP2=0;
+  GNULIB_DUP3=0;
+  GNULIB_ENVIRON=0;
+  GNULIB_EUIDACCESS=0;
+  GNULIB_FACCESSAT=0;
+  GNULIB_FCHDIR=0;
+  GNULIB_FCHOWNAT=0;
+  GNULIB_FSYNC=0;
+  GNULIB_FTRUNCATE=0;
+  GNULIB_GETCWD=0;
+  GNULIB_GETDOMAINNAME=0;
+  GNULIB_GETDTABLESIZE=0;
+  GNULIB_GETGROUPS=0;
+  GNULIB_GETHOSTNAME=0;
+  GNULIB_GETLOGIN=0;
+  GNULIB_GETLOGIN_R=0;
+  GNULIB_GETPAGESIZE=0;
+  GNULIB_GETUSERSHELL=0;
+  GNULIB_LCHOWN=0;
+  GNULIB_LINK=0;
+  GNULIB_LINKAT=0;
+  GNULIB_LSEEK=0;
+  GNULIB_PIPE=0;
+  GNULIB_PIPE2=0;
+  GNULIB_PREAD=0;
+  GNULIB_PWRITE=0;
+  GNULIB_READLINK=0;
+  GNULIB_READLINKAT=0;
+  GNULIB_RMDIR=0;
+  GNULIB_SLEEP=0;
+  GNULIB_SYMLINK=0;
+  GNULIB_SYMLINKAT=0;
+  GNULIB_TTYNAME_R=0;
+  GNULIB_UNISTD_H_GETOPT=0;
+  GNULIB_UNISTD_H_SIGPIPE=0;
+  GNULIB_UNLINK=0;
+  GNULIB_UNLINKAT=0;
+  GNULIB_USLEEP=0;
+  GNULIB_WRITE=0;
+    HAVE_CHOWN=1;
+  HAVE_DUP2=1;
+  HAVE_DUP3=1;
+  HAVE_EUIDACCESS=1;
+  HAVE_FACCESSAT=1;
+  HAVE_FCHDIR=1;
+  HAVE_FCHOWNAT=1;
+  HAVE_FSYNC=1;
+  HAVE_FTRUNCATE=1;
+  HAVE_GETDTABLESIZE=1;
+  HAVE_GETGROUPS=1;
+  HAVE_GETHOSTNAME=1;
+  HAVE_GETLOGIN=1;
+  HAVE_GETPAGESIZE=1;
+  HAVE_LCHOWN=1;
+  HAVE_LINK=1;
+  HAVE_LINKAT=1;
+  HAVE_PIPE=1;
+  HAVE_PIPE2=1;
+  HAVE_PREAD=1;
+  HAVE_PWRITE=1;
+  HAVE_READLINK=1;
+  HAVE_READLINKAT=1;
+  HAVE_SLEEP=1;
+  HAVE_SYMLINK=1;
+  HAVE_SYMLINKAT=1;
+  HAVE_UNLINKAT=1;
+  HAVE_USLEEP=1;
+  HAVE_DECL_ENVIRON=1;
+  HAVE_DECL_FCHDIR=1;
+  HAVE_DECL_GETDOMAINNAME=1;
+  HAVE_DECL_GETLOGIN_R=1;
+  HAVE_DECL_GETPAGESIZE=1;
+  HAVE_DECL_GETUSERSHELL=1;
+  HAVE_DECL_TTYNAME_R=1;
+  HAVE_OS_H=0;
+  HAVE_SYS_PARAM_H=0;
+  REPLACE_CHOWN=0;
+  REPLACE_CLOSE=0;
+  REPLACE_DUP=0;
+  REPLACE_DUP2=0;
+  REPLACE_FCHOWNAT=0;
+  REPLACE_GETCWD=0;
+  REPLACE_GETDOMAINNAME=0;
+  REPLACE_GETLOGIN_R=0;
+  REPLACE_GETGROUPS=0;
+  REPLACE_GETPAGESIZE=0;
+  REPLACE_LCHOWN=0;
+  REPLACE_LINK=0;
+  REPLACE_LINKAT=0;
+  REPLACE_LSEEK=0;
+  REPLACE_PREAD=0;
+  REPLACE_PWRITE=0;
+  REPLACE_READLINK=0;
+  REPLACE_RMDIR=0;
+  REPLACE_SLEEP=0;
+  REPLACE_SYMLINK=0;
+  REPLACE_TTYNAME_R=0;
+  REPLACE_UNLINK=0;
+  REPLACE_UNLINKAT=0;
+  REPLACE_USLEEP=0;
+  REPLACE_WRITE=0;
+  UNISTD_H_HAVE_WINSOCK2_H=0;
+  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_getopt_h='<'getopt.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <getopt.h>" >&5
+$as_echo_n "checking absolute name of <getopt.h>... " >&6; }
+if test "${gl_cv_next_getopt_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_getopt_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <getopt.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/getopt.h#{
+                    s#.*"\(.*/getopt.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_getopt_h='<'getopt.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5
+$as_echo "$gl_cv_next_getopt_h" >&6; }
+     fi
+     NEXT_GETOPT_H=$gl_cv_next_getopt_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'getopt.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_getopt_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_GETOPT_H=$gl_next_as_first_directive
+
+
+
+
+  if test $ac_cv_header_getopt_h = yes; then
+    HAVE_GETOPT_H=1
+  else
+    HAVE_GETOPT_H=0
+  fi
+
+
+  gl_replace_getopt=
+
+    if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    for ac_header in getopt.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
+if test "x$ac_cv_header_getopt_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETOPT_H 1
+_ACEOF
+
+else
+  gl_replace_getopt=yes
+fi
+
+done
+
+  fi
+
+    if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    for ac_func in getopt_long_only
+do :
+  ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only"
+if test "x$ac_cv_func_getopt_long_only" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETOPT_LONG_ONLY 1
+_ACEOF
+
+else
+  gl_replace_getopt=yes
+fi
+done
+
+  fi
+
+                    if test -z "$gl_replace_getopt"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5
+$as_echo_n "checking whether getopt is POSIX compatible... " >&6; }
+if test "${gl_cv_func_getopt_posix+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                                                                        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+int
+main ()
+{
+int *p = &optreset; return optreset;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_optind_min=1
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <getopt.h>
+int
+main ()
+{
+return !getopt_clip;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_optind_min=1
+else
+  gl_optind_min=0
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+                gl_save_CPPFLAGS=$CPPFLAGS
+        CPPFLAGS="$CPPFLAGS -DOPTIND_MIN=$gl_optind_min"
+        if test "$cross_compiling" = yes; then :
+  case "$host_os" in
+             mingw*)         gl_cv_func_getopt_posix="guessing no";;
+             darwin* | aix*) gl_cv_func_getopt_posix="guessing no";;
+             *)              gl_cv_func_getopt_posix="guessing yes";;
+           esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+  {
+    int argc = 0;
+    char *argv[10];
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-a";
+    argv[argc++] = "foo";
+    argv[argc++] = "bar";
+    argv[argc] = NULL;
+    optind = OPTIND_MIN;
+    opterr = 0;
+
+    c = getopt (argc, argv, "ab");
+    if (!(c == 'a'))
+      return 1;
+    c = getopt (argc, argv, "ab");
+    if (!(c == -1))
+      return 2;
+    if (!(optind == 2))
+      return 3;
+  }
+  /* Some internal state exists at this point.  */
+  {
+    int argc = 0;
+    char *argv[10];
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "donald";
+    argv[argc++] = "-p";
+    argv[argc++] = "billy";
+    argv[argc++] = "duck";
+    argv[argc++] = "-a";
+    argv[argc++] = "bar";
+    argv[argc] = NULL;
+    optind = OPTIND_MIN;
+    opterr = 0;
+
+    c = getopt (argc, argv, "+abp:q:");
+    if (!(c == -1))
+      return 4;
+    if (!(strcmp (argv[0], "program") == 0))
+      return 5;
+    if (!(strcmp (argv[1], "donald") == 0))
+      return 6;
+    if (!(strcmp (argv[2], "-p") == 0))
+      return 7;
+    if (!(strcmp (argv[3], "billy") == 0))
+      return 8;
+    if (!(strcmp (argv[4], "duck") == 0))
+      return 9;
+    if (!(strcmp (argv[5], "-a") == 0))
+      return 10;
+    if (!(strcmp (argv[6], "bar") == 0))
+      return 11;
+    if (!(optind == 1))
+      return 12;
+  }
+  /* Detect MacOS 10.5, AIX 7.1 bug.  */
+  {
+    char *argv[3] = { "program", "-ab", NULL };
+    optind = OPTIND_MIN;
+    opterr = 0;
+    if (getopt (2, argv, "ab:") != 'a')
+      return 13;
+    if (getopt (2, argv, "ab:") != '?')
+      return 14;
+    if (optopt != 'b')
+      return 15;
+    if (optind != 2)
+      return 16;
+  }
+
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_getopt_posix=yes
+else
+  gl_cv_func_getopt_posix=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+        CPPFLAGS=$gl_save_CPPFLAGS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_posix" >&5
+$as_echo "$gl_cv_func_getopt_posix" >&6; }
+    case "$gl_cv_func_getopt_posix" in
+      *no) gl_replace_getopt=yes ;;
+    esac
+  fi
+
+  if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5
+$as_echo_n "checking for working GNU getopt function... " >&6; }
+if test "${gl_cv_func_getopt_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
+       # optstring is necessary for programs like m4 that have POSIX-mandated
+       # semantics for supporting options interspersed with files.
+       # Also, since getopt_long is a GNU extension, we require optind=0.
+       # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
+       # so take care to revert to the correct (non-)export state.
+       gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
+       case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
+         xx) gl_had_POSIXLY_CORRECT=exported ;;
+         x)  gl_had_POSIXLY_CORRECT=yes      ;;
+         *)  gl_had_POSIXLY_CORRECT=         ;;
+       esac
+       POSIXLY_CORRECT=1
+       export POSIXLY_CORRECT
+       if test "$cross_compiling" = yes; then :
+           case $host_os:$ac_cv_have_decl_optreset in
+           *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
+           *:yes)               gl_cv_func_getopt_gnu=no;;
+           *)                   gl_cv_func_getopt_gnu=yes;;
+         esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <getopt.h>
+                           #include <stddef.h>
+                           #include <string.h>
+
+int
+main ()
+{
+
+             int result = 0;
+             /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
+                and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
+                OSF/1 5.1, Solaris 10.  */
+             {
+               char *myargv[3];
+               myargv[0] = "conftest";
+               myargv[1] = "-+";
+               myargv[2] = 0;
+               opterr = 0;
+               if (getopt (2, myargv, "+a") != '?')
+                 result |= 1;
+             }
+             /* This code succeeds on glibc 2.8, mingw,
+                and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
+                IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x.  */
+             {
+               char *argv[] = { "program", "-p", "foo", "bar", NULL };
+
+               optind = 1;
+               if (getopt (4, argv, "p::") != 'p')
+                 result |= 2;
+               else if (optarg != NULL)
+                 result |= 4;
+               else if (getopt (4, argv, "p::") != -1)
+                 result |= 6;
+               else if (optind != 2)
+                 result |= 8;
+             }
+             /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0.  */
+             {
+               char *argv[] = { "program", "foo", "-p", NULL };
+               optind = 0;
+               if (getopt (3, argv, "-p") != 1)
+                 result |= 16;
+               else if (getopt (3, argv, "-p") != 'p')
+                 result |= 32;
+             }
+             /* This code fails on glibc 2.11.  */
+             {
+               char *argv[] = { "program", "-b", "-a", NULL };
+               optind = opterr = 0;
+               if (getopt (3, argv, "+:a:b") != 'b')
+                 result |= 64;
+               else if (getopt (3, argv, "+:a:b") != ':')
+                 result |= 64;
+             }
+             return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_getopt_gnu=yes
+else
+  gl_cv_func_getopt_gnu=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+       case $gl_had_POSIXLY_CORRECT in
+         exported) ;;
+         yes) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;}; POSIXLY_CORRECT=1 ;;
+         *) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;} ;;
+       esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5
+$as_echo "$gl_cv_func_getopt_gnu" >&6; }
+    if test "$gl_cv_func_getopt_gnu" = "no"; then
+      gl_replace_getopt=yes
+    fi
+  fi
+
+
+      ac_fn_c_check_decl "$LINENO" "getenv" "ac_cv_have_decl_getenv" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getenv" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETENV $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+  if test -n "$gl_replace_getopt"; then :
+
+
+
+  GETOPT_H=getopt.h
+
+$as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
+
+
+
+    GNULIB_UNISTD_H_GETOPT=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
+
+
+
+  :
+
+
+
+
+
+
+
+
+fi
+
+
+
+  GNULIB_NL_LANGINFO=0;
+    HAVE_NL_LANGINFO=1;
+  REPLACE_NL_LANGINFO=0;
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fcntl.h" >&5
+$as_echo_n "checking for working fcntl.h... " >&6; }
+if test "${gl_cv_header_working_fcntl_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  gl_cv_header_working_fcntl_h=cross-compiling
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+           #include <sys/stat.h>
+           #include <unistd.h>
+           #include <fcntl.h>
+           #ifndef O_NOATIME
+            #define O_NOATIME 0
+           #endif
+           #ifndef O_NOFOLLOW
+            #define O_NOFOLLOW 0
+           #endif
+           static int const constants[] =
+            {
+              O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+              O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+            };
+
+int
+main ()
+{
+
+            int result = !constants;
+            {
+              static char const sym[] = "conftest.sym";
+              if (symlink (".", sym) != 0)
+                result |= 2;
+              else
+                {
+                  int fd = open (sym, O_RDONLY | O_NOFOLLOW);
+                  if (fd >= 0)
+                    {
+                      close (fd);
+                      result |= 4;
+                    }
+                }
+              unlink (sym);
+            }
+            {
+              static char const file[] = "confdefs.h";
+              int fd = open (file, O_RDONLY | O_NOATIME);
+              if (fd < 0)
+                result |= 8;
+              else
+                {
+                  struct stat st0;
+                  if (fstat (fd, &st0) != 0)
+                    result |= 16;
+                  else
+                    {
+                      char c;
+                      sleep (1);
+                      if (read (fd, &c, 1) != 1)
+                        result |= 24;
+                      else
+                        {
+                          if (close (fd) != 0)
+                            result |= 32;
+                          else
+                            {
+                              struct stat st1;
+                              if (stat (file, &st1) != 0)
+                                result |= 40;
+                              else
+                                if (st0.st_atime != st1.st_atime)
+                                  result |= 64;
+                            }
+                        }
+                    }
+                }
+            }
+            return result;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_header_working_fcntl_h=yes
+else
+  case $? in #(
+        4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+        64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
+        68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+         *) gl_cv_header_working_fcntl_h='no';;
+        esac
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_fcntl_h" >&5
+$as_echo "$gl_cv_header_working_fcntl_h" >&6; }
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_WORKING_O_NOATIME $ac_val
+_ACEOF
+
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_WORKING_O_NOFOLLOW $ac_val
+_ACEOF
+
+
+
+      ac_fn_c_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getc_unlocked" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETC_UNLOCKED $ac_have_decl
+_ACEOF
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library >= 2.1 or uClibc" >&5
+$as_echo_n "checking whether we are using the GNU C Library >= 2.1 or uClibc... " >&6; }
+if test "${ac_cv_gnu_library_2_1+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
+  Lucky GNU user
+ #endif
+#endif
+#ifdef __UCLIBC__
+ Lucky user
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky" >/dev/null 2>&1; then :
+  ac_cv_gnu_library_2_1=yes
+else
+  ac_cv_gnu_library_2_1=no
+fi
+rm -f conftest*
+
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2_1" >&5
+$as_echo "$ac_cv_gnu_library_2_1" >&6; }
+
+    GLIBC21="$ac_cv_gnu_library_2_1"
+
+
+
+  GNULIB_SETLOCALE=0;
+  GNULIB_DUPLOCALE=0;
+    HAVE_DUPLOCALE=1;
+  REPLACE_SETLOCALE=0;
+  REPLACE_DUPLOCALE=0;
+
+
+    REPLACE_NULL=0;
+  HAVE_WCHAR_T=1;
+  STDDEF_H='';
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5
+$as_echo_n "checking for wchar_t... " >&6; }
+if test "${gt_cv_c_wchar_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+            wchar_t foo = (wchar_t)'\0';
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_c_wchar_t=yes
+else
+  gt_cv_c_wchar_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5
+$as_echo "$gt_cv_c_wchar_t" >&6; }
+  if test $gt_cv_c_wchar_t = yes; then
+
+$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h
+
+  fi
+
+
+
+
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5
+$as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; }
+if test "${gl_cv_decl_null_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_decl_null_works=yes
+else
+  gl_cv_decl_null_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5
+$as_echo "$gl_cv_decl_null_works" >&6; }
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_stddef_h='<'stddef.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stddef.h>" >&5
+$as_echo_n "checking absolute name of <stddef.h>... " >&6; }
+if test "${gl_cv_next_stddef_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/stddef.h#{
+                    s#.*"\(.*/stddef.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5
+$as_echo "$gl_cv_next_stddef_h" >&6; }
+     fi
+     NEXT_STDDEF_H=$gl_cv_next_stddef_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'stddef.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_stddef_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive
+
+
+
+
+  fi
+
+
+
+
+
+
+
+     GNULIB_FCHMODAT=0;
+  GNULIB_FSTATAT=0;
+  GNULIB_FUTIMENS=0;
+  GNULIB_LCHMOD=0;
+  GNULIB_LSTAT=0;
+  GNULIB_MKDIRAT=0;
+  GNULIB_MKFIFO=0;
+  GNULIB_MKFIFOAT=0;
+  GNULIB_MKNOD=0;
+  GNULIB_MKNODAT=0;
+  GNULIB_STAT=0;
+  GNULIB_UTIMENSAT=0;
+    HAVE_FCHMODAT=1;
+  HAVE_FSTATAT=1;
+  HAVE_FUTIMENS=1;
+  HAVE_LCHMOD=1;
+  HAVE_LSTAT=1;
+  HAVE_MKDIRAT=1;
+  HAVE_MKFIFO=1;
+  HAVE_MKFIFOAT=1;
+  HAVE_MKNOD=1;
+  HAVE_MKNODAT=1;
+  HAVE_UTIMENSAT=1;
+  REPLACE_FSTAT=0;
+  REPLACE_FSTATAT=0;
+  REPLACE_FUTIMENS=0;
+  REPLACE_LSTAT=0;
+  REPLACE_MKDIR=0;
+  REPLACE_MKFIFO=0;
+  REPLACE_MKNOD=0;
+  REPLACE_STAT=0;
+  REPLACE_UTIMENSAT=0;
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5
+$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; }
+if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f conftest.sym conftest.file
+     echo >conftest.file
+     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
+       if test "$cross_compiling" = yes; then :
+  # When cross-compiling, be pessimistic so we will end up using the
+          # replacement version of lstat that checks for trailing slashes and
+          # calls lstat a second time when necessary.
+          ac_cv_func_lstat_dereferences_slashed_symlink=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+struct stat sbuf;
+              /* Linux will dereference the symlink and fail, as required by
+                 POSIX.  That is better in the sense that it means we will not
+                 have to compile and use the lstat wrapper.  */
+              return lstat ("conftest.sym/", &sbuf) == 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_lstat_dereferences_slashed_symlink=yes
+else
+  ac_cv_func_lstat_dereferences_slashed_symlink=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+     else
+       # If the 'ln -s' command failed, then we probably don't even
+       # have an lstat function.
+       ac_cv_func_lstat_dereferences_slashed_symlink=no
+     fi
+     rm -f conftest.sym conftest.file
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5
+$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; }
+  test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
+
+cat >>confdefs.h <<_ACEOF
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+_ACEOF
+
+  if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext"
+
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if test "${ac_cv_c_inline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether malloc, realloc, calloc are POSIX compliant" >&5
+$as_echo_n "checking whether malloc, realloc, calloc are POSIX compliant... " >&6; }
+if test "${gl_cv_func_malloc_posix+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+             choke me
+             #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_func_malloc_posix=yes
+else
+  gl_cv_func_malloc_posix=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_malloc_posix" >&5
+$as_echo "$gl_cv_func_malloc_posix" >&6; }
+
+
+  for ac_header in stdlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdlib_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
+$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
+if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_malloc_0_nonnull=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *malloc ();
+#endif
+
+int
+main ()
+{
+return ! malloc (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_malloc_0_nonnull=yes
+else
+  ac_cv_func_malloc_0_nonnull=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
+$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
+if test $ac_cv_func_malloc_0_nonnull = yes; then :
+  gl_cv_func_malloc_0_nonnull=1
+else
+  gl_cv_func_malloc_0_nonnull=0
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define MALLOC_0_IS_NONNULL $gl_cv_func_malloc_0_nonnull
+_ACEOF
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5
+$as_echo_n "checking for unsigned long long int... " >&6; }
+if test "${ac_cv_type_unsigned_long_long_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_type_unsigned_long_long_int=yes
+     if test "x${ac_cv_prog_cc_c99-no}" = xno; then
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+  /* For now, do not test the preprocessor; as of 2007 there are too many
+         implementations with broken preprocessors.  Perhaps this can
+         be revisited in 2012.  In the meantime, code should not expect
+         #if to work with literals wider than 32 bits.  */
+      /* Test literals.  */
+      long long int ll = 9223372036854775807ll;
+      long long int nll = -9223372036854775807LL;
+      unsigned long long int ull = 18446744073709551615ULL;
+      /* Test constant expressions.   */
+      typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
+                     ? 1 : -1)];
+      typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
+                     ? 1 : -1)];
+      int i = 63;
+int
+main ()
+{
+/* Test availability of runtime routines for shift and division.  */
+      long long int llmax = 9223372036854775807ll;
+      unsigned long long int ullmax = 18446744073709551615ull;
+      return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
+              | (llmax / ll) | (llmax % ll)
+              | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
+              | (ullmax / ull) | (ullmax % ull));
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+  ac_cv_type_unsigned_long_long_int=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5
+$as_echo "$ac_cv_type_unsigned_long_long_int" >&6; }
+  if test $ac_cv_type_unsigned_long_long_int = yes; then
+
+$as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h
+
+  fi
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5
+$as_echo_n "checking for long long int... " >&6; }
+if test "${ac_cv_type_long_long_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  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
+                                        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+                 #ifndef LLONG_MAX
+                 # define HALF \
+                          (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+                 # define LLONG_MAX (HALF - 1 + HALF)
+                 #endif
+int
+main ()
+{
+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;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_type_long_long_int=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+        fi
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5
+$as_echo "$ac_cv_type_long_long_int" >&6; }
+  if test $ac_cv_type_long_long_int = yes; then
+
+$as_echo "#define HAVE_LONG_LONG_INT 1" >>confdefs.h
+
+  fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5
+$as_echo_n "checking for a traditional japanese locale... " >&6; }
+if test "${gt_cv_locale_ja+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5
+$as_echo "$gt_cv_locale_ja" >&6; }
+  LOCALE_JA=$gt_cv_locale_ja
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5
+$as_echo_n "checking for a transitional chinese locale... " >&6; }
+if test "${gt_cv_locale_zh_CN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5
+$as_echo "$gt_cv_locale_zh_CN" >&6; }
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+
+
+
+
+
+
+
+
+  GNULIB_MEMCHR=0;
+  GNULIB_MEMMEM=0;
+  GNULIB_MEMPCPY=0;
+  GNULIB_MEMRCHR=0;
+  GNULIB_RAWMEMCHR=0;
+  GNULIB_STPCPY=0;
+  GNULIB_STPNCPY=0;
+  GNULIB_STRCHRNUL=0;
+  GNULIB_STRDUP=0;
+  GNULIB_STRNCAT=0;
+  GNULIB_STRNDUP=0;
+  GNULIB_STRNLEN=0;
+  GNULIB_STRPBRK=0;
+  GNULIB_STRSEP=0;
+  GNULIB_STRSTR=0;
+  GNULIB_STRCASESTR=0;
+  GNULIB_STRTOK_R=0;
+  GNULIB_MBSLEN=0;
+  GNULIB_MBSNLEN=0;
+  GNULIB_MBSCHR=0;
+  GNULIB_MBSRCHR=0;
+  GNULIB_MBSSTR=0;
+  GNULIB_MBSCASECMP=0;
+  GNULIB_MBSNCASECMP=0;
+  GNULIB_MBSPCASECMP=0;
+  GNULIB_MBSCASESTR=0;
+  GNULIB_MBSCSPN=0;
+  GNULIB_MBSPBRK=0;
+  GNULIB_MBSSPN=0;
+  GNULIB_MBSSEP=0;
+  GNULIB_MBSTOK_R=0;
+  GNULIB_STRERROR=0;
+  GNULIB_STRERROR_R=0;
+  GNULIB_STRSIGNAL=0;
+  GNULIB_STRVERSCMP=0;
+  HAVE_MBSLEN=0;
+    HAVE_MEMCHR=1;
+  HAVE_DECL_MEMMEM=1;
+  HAVE_MEMPCPY=1;
+  HAVE_DECL_MEMRCHR=1;
+  HAVE_RAWMEMCHR=1;
+  HAVE_STPCPY=1;
+  HAVE_STPNCPY=1;
+  HAVE_STRCHRNUL=1;
+  HAVE_DECL_STRDUP=1;
+  HAVE_DECL_STRNDUP=1;
+  HAVE_DECL_STRNLEN=1;
+  HAVE_STRPBRK=1;
+  HAVE_STRSEP=1;
+  HAVE_STRCASESTR=1;
+  HAVE_DECL_STRTOK_R=1;
+  HAVE_DECL_STRERROR_R=1;
+  HAVE_DECL_STRSIGNAL=1;
+  HAVE_STRVERSCMP=1;
+  REPLACE_MEMCHR=0;
+  REPLACE_MEMMEM=0;
+  REPLACE_STPNCPY=0;
+  REPLACE_STRDUP=0;
+  REPLACE_STRSTR=0;
+  REPLACE_STRCASESTR=0;
+  REPLACE_STRERROR=0;
+  REPLACE_STRERROR_R=0;
+  REPLACE_STRNCAT=0;
+  REPLACE_STRNDUP=0;
+  REPLACE_STRNLEN=0;
+  REPLACE_STRSIGNAL=0;
+  REPLACE_STRTOK_R=0;
+  UNDEFINE_STRTOK_R=0;
+
+
+
+
+
+
+
+
+
+
+  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
+  # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
+  # irrelevant for anonymous mappings.
+  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = x""yes; then :
+  gl_have_mmap=yes
+else
+  gl_have_mmap=no
+fi
+
+
+  # Try to allow MAP_ANONYMOUS.
+  gl_have_mmap_anonymous=no
+  if test $gl_have_mmap = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANONYMOUS" >&5
+$as_echo_n "checking for MAP_ANONYMOUS... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANONYMOUS
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+  gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    if test $gl_have_mmap_anonymous != yes; then
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANON
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+
+$as_echo "#define MAP_ANONYMOUS MAP_ANON" >>confdefs.h
+
+         gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_mmap_anonymous" >&5
+$as_echo "$gl_have_mmap_anonymous" >&6; }
+    if test $gl_have_mmap_anonymous = yes; then
+
+$as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h
+
+    fi
+  fi
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_memchr = yes; then
+    # Detect platform-specific bugs in some versions of glibc:
+    # memchr should not dereference anything with length 0
+    #   http://bugzilla.redhat.com/499689
+    # memchr should not dereference overestimated length after a match
+    #   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
+    #   http://sourceware.org/bugzilla/show_bug.cgi?id=10162
+    # Assume that memchr works on platforms that lack mprotect.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memchr works" >&5
+$as_echo_n "checking whether memchr works... " >&6; }
+if test "${gl_cv_func_memchr_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+         gl_cv_func_memchr_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <string.h>
+#if HAVE_SYS_MMAN_H
+# include <fcntl.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/mman.h>
+# ifndef MAP_FILE
+#  define MAP_FILE 0
+# endif
+#endif
+
+int
+main ()
+{
+
+  int result = 0;
+  char *fence = NULL;
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+# if HAVE_MAP_ANONYMOUS
+  const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+  const int fd = -1;
+# else /* !HAVE_MAP_ANONYMOUS */
+  const int flags = MAP_FILE | MAP_PRIVATE;
+  int fd = open ("/dev/zero", O_RDONLY, 0666);
+  if (fd >= 0)
+# endif
+    {
+      int pagesize = getpagesize ();
+      char *two_pages =
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
+      if (two_pages != (char *)(-1)
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        fence = two_pages + pagesize;
+    }
+#endif
+  if (fence)
+    {
+      if (memchr (fence, 0, 0))
+        result |= 1;
+      strcpy (fence - 9, "12345678");
+      if (memchr (fence - 9, 0, 79) != fence - 1)
+        result |= 2;
+      if (memchr (fence - 1, 0, 3) != fence - 1)
+        result |= 4;
+    }
+  return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_memchr_works=yes
+else
+  gl_cv_func_memchr_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_memchr_works" >&5
+$as_echo "$gl_cv_func_memchr_works" >&6; }
+    if test "$gl_cv_func_memchr_works" != yes; then
+      REPLACE_MEMCHR=1
+    fi
+  else
+    HAVE_MEMCHR=0
+  fi
+  if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS memchr.$ac_objext"
+
+
+  for ac_header in bp-sym.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "bp-sym.h" "ac_cv_header_bp_sym_h" "$ac_includes_default"
+if test "x$ac_cv_header_bp_sym_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_BP_SYM_H 1
+_ACEOF
+
+fi
+
+done
+
+
+  fi
+
+
+    gl_cv_c_multiarch=no
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __APPLE_CC__
+         not a universal capable compiler
+        #endif
+        typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+               arch=
+     prev=
+     for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
+       if test -n "$prev"; then
+         case $word in
+           i?86 | x86_64 | ppc | ppc64)
+             if test -z "$arch" || test "$arch" = "$word"; then
+               arch="$word"
+             else
+               gl_cv_c_multiarch=yes
+             fi
+             ;;
+         esac
+         prev=
+       else
+         if test "x$word" = "x-arch"; then
+           prev=arch
+         fi
+       fi
+     done
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  if test $gl_cv_c_multiarch = yes; then
+    APPLE_UNIVERSAL_BUILD=1
+  else
+    APPLE_UNIVERSAL_BUILD=0
+  fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-selinux was given.
+if test "${with_selinux+set}" = set; then :
+  withval=$with_selinux;
+else
+  with_selinux=maybe
+fi
+
+
+  LIB_SELINUX=
+  if test "$with_selinux" != no; then
+    gl_save_LIBS=$LIBS
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setfilecon" >&5
+$as_echo_n "checking for library containing setfilecon... " >&6; }
+if test "${ac_cv_search_setfilecon+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char setfilecon ();
+int
+main ()
+{
+return setfilecon ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' selinux; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_setfilecon=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_setfilecon+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_setfilecon+set}" = set; then :
+
+else
+  ac_cv_search_setfilecon=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_setfilecon" >&5
+$as_echo "$ac_cv_search_setfilecon" >&6; }
+ac_res=$ac_cv_search_setfilecon
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  test "$ac_cv_search_setfilecon" = "none required" ||
+                    LIB_SELINUX=$ac_cv_search_setfilecon
+fi
+
+    LIBS=$gl_save_LIBS
+  fi
+
+
+  # Warn if SELinux is found but libselinux is absent;
+  if test "$ac_cv_search_setfilecon" = no &&
+     test "$host" = "$build" && test -d /selinux; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This system supports SELinux but libselinux is missing." >&5
+$as_echo "$as_me: WARNING: This system supports SELinux but libselinux is missing." >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: augeas will be compiled without SELinux support." >&5
+$as_echo "$as_me: WARNING: augeas will be compiled without SELinux support." >&2;}
+  fi
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
+if test "${ac_cv_header_stdbool_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+             #include <stdbool.h>
+             #ifndef bool
+              "error: bool is not defined"
+             #endif
+             #ifndef false
+              "error: false is not defined"
+             #endif
+             #if false
+              "error: false is not 0"
+             #endif
+             #ifndef true
+              "error: true is not defined"
+             #endif
+             #if true != 1
+              "error: true is not 1"
+             #endif
+             #ifndef __bool_true_false_are_defined
+              "error: __bool_true_false_are_defined is not defined"
+             #endif
+
+             struct s { _Bool s: 1; _Bool t; } s;
+
+             char a[true == 1 ? 1 : -1];
+             char b[false == 0 ? 1 : -1];
+             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+             char d[(bool) 0.5 == true ? 1 : -1];
+             /* See body of main program for 'e'.  */
+             char f[(_Bool) 0.0 == false ? 1 : -1];
+             char g[true];
+             char h[sizeof (_Bool)];
+             char i[sizeof s.t];
+             enum { j = false, k = true, l = false * true, m = true * 256 };
+             /* The following fails for
+                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+             _Bool n[m];
+             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+             /* Catch a bug in an HP-UX C compiler.  See
+                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+              */
+             _Bool q = true;
+             _Bool *pq = &q;
+
+int
+main ()
+{
+
+             bool e = &s;
+             *pq |= q;
+             *pq |= ! q;
+             /* Refer to every declared value, to avoid compiler optimizations.  */
+             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                     + !m + !n + !o + !p + !q + !pq);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdbool_h=yes
+else
+  ac_cv_header_stdbool_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+   ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+if test "x$ac_cv_type__Bool" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+      ac_fn_c_check_decl "$LINENO" "stpncpy" "ac_cv_have_decl_stpncpy" "$ac_includes_default"
+if test "x$ac_cv_have_decl_stpncpy" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STPNCPY $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_string_h='<'string.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <string.h>" >&5
+$as_echo_n "checking absolute name of <string.h>... " >&6; }
+if test "${gl_cv_next_string_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/string.h#{
+                    s#.*"\(.*/string.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_string_h" >&5
+$as_echo "$gl_cv_next_string_h" >&6; }
+     fi
+     NEXT_STRING_H=$gl_cv_next_string_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'string.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_string_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STRING_H=$gl_next_as_first_directive
+
+
+
+
+
+
+    for gl_func in memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup      strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r      strsignal strverscmp; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+
+      ac_fn_c_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strndup" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNDUP $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+      ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
+
+
+
+
+  if test "$gl_cv_func_memchr_works" != yes; then
+    REPLACE_STRSTR=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext"
+
+  else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works" >&5
+$as_echo_n "checking whether strstr works... " >&6; }
+if test "${gl_cv_func_strstr_works_always+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+                                               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef __GNU_LIBRARY__
+ #include <features.h>
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
+     || defined __UCLIBC__
+  Lucky user
+ #endif
+#elif defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#else
+  Lucky user
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky user" >/dev/null 2>&1; then :
+  gl_cv_func_strstr_works_always=yes
+else
+  gl_cv_func_strstr_works_always="guessing no"
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <string.h> /* for strstr */
+#define P "_EF_BF_BD"
+#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
+#define NEEDLE P P P P P
+
+int
+main ()
+{
+return !!strstr (HAYSTACK, NEEDLE);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_strstr_works_always=yes
+else
+  gl_cv_func_strstr_works_always=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_works_always" >&5
+$as_echo "$gl_cv_func_strstr_works_always" >&6; }
+    if test "$gl_cv_func_strstr_works_always" != yes; then
+      REPLACE_STRSTR=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext"
+
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5
+$as_echo_n "checking whether stat file-mode macros are broken... " >&6; }
+if test "${ac_cv_header_stat_broken+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined S_ISBLK && defined S_IFDIR
+extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
+#endif
+
+#if defined S_ISBLK && defined S_IFCHR
+extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
+#endif
+
+#if defined S_ISLNK && defined S_IFREG
+extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
+#endif
+
+#if defined S_ISSOCK && defined S_IFREG
+extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stat_broken=no
+else
+  ac_cv_header_stat_broken=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5
+$as_echo "$ac_cv_header_stat_broken" >&6; }
+if test $ac_cv_header_stat_broken = yes; then
+
+$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h
+
+fi
+
+
+
+
+
+
+
+  GNULIB_WAITPID=0;
+
+
+
+
+
+
+
+  GNULIB_MKTIME=0;
+  GNULIB_NANOSLEEP=0;
+  GNULIB_STRPTIME=0;
+  GNULIB_TIMEGM=0;
+  GNULIB_TIME_R=0;
+    HAVE_DECL_LOCALTIME_R=1;
+  HAVE_NANOSLEEP=1;
+  HAVE_STRPTIME=1;
+  HAVE_TIMEGM=1;
+        REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;
+  REPLACE_MKTIME=GNULIB_PORTCHECK;
+  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;
+  REPLACE_TIMEGM=GNULIB_PORTCHECK;
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <time.h>" >&5
+$as_echo_n "checking for struct timespec in <time.h>... " >&6; }
+if test "${gl_cv_sys_struct_timespec_in_time_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <time.h>
+
+int
+main ()
+{
+static struct timespec x; x.tv_sec = x.tv_nsec;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_sys_struct_timespec_in_time_h=yes
+else
+  gl_cv_sys_struct_timespec_in_time_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_time_h" >&5
+$as_echo "$gl_cv_sys_struct_timespec_in_time_h" >&6; }
+
+  TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
+  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
+    TIME_H_DEFINES_STRUCT_TIMESPEC=1
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <sys/time.h>" >&5
+$as_echo_n "checking for struct timespec in <sys/time.h>... " >&6; }
+if test "${gl_cv_sys_struct_timespec_in_sys_time_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/time.h>
+
+int
+main ()
+{
+static struct timespec x; x.tv_sec = x.tv_nsec;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_sys_struct_timespec_in_sys_time_h=yes
+else
+  gl_cv_sys_struct_timespec_in_sys_time_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_sys_time_h" >&5
+$as_echo "$gl_cv_sys_struct_timespec_in_sys_time_h" >&6; }
+    if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
+      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <pthread.h>" >&5
+$as_echo_n "checking for struct timespec in <pthread.h>... " >&6; }
+if test "${gl_cv_sys_struct_timespec_in_pthread_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <pthread.h>
+
+int
+main ()
+{
+static struct timespec x; x.tv_sec = x.tv_nsec;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_sys_struct_timespec_in_pthread_h=yes
+else
+  gl_cv_sys_struct_timespec_in_pthread_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_pthread_h" >&5
+$as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; }
+      if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
+        PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
+      fi
+    fi
+  fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_time_h='<'time.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <time.h>" >&5
+$as_echo_n "checking absolute name of <time.h>... " >&6; }
+if test "${gl_cv_next_time_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <time.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/time.h#{
+                    s#.*"\(.*/time.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5
+$as_echo "$gl_cv_next_time_h" >&6; }
+     fi
+     NEXT_TIME_H=$gl_cv_next_time_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'time.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_time_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_TIME_H=$gl_next_as_first_directive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t" >&5
+$as_echo_n "checking for wint_t... " >&6; }
+if test "${gt_cv_c_wint_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
+   before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+            wint_t foo = (wchar_t)'\0';
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_c_wint_t=yes
+else
+  gt_cv_c_wint_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wint_t" >&5
+$as_echo "$gt_cv_c_wint_t" >&6; }
+  if test $gt_cv_c_wint_t = yes; then
+
+$as_echo "#define HAVE_WINT_T 1" >>confdefs.h
+
+  fi
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_header_features_h = yes; then
+    HAVE_FEATURES_H=1
+  else
+    HAVE_FEATURES_H=0
+  fi
+
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5
+$as_echo_n "checking for inttypes.h... " >&6; }
+if test "${gl_cv_header_inttypes_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <inttypes.h>
+
+int
+main ()
+{
+uintmax_t i = (uintmax_t) -1; return !i;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_inttypes_h=yes
+else
+  gl_cv_header_inttypes_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_inttypes_h" >&5
+$as_echo "$gl_cv_header_inttypes_h" >&6; }
+  if test $gl_cv_header_inttypes_h = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTTYPES_H_WITH_UINTMAX 1
+_ACEOF
+
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5
+$as_echo_n "checking for stdint.h... " >&6; }
+if test "${gl_cv_header_stdint_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+            #include <stdint.h>
+int
+main ()
+{
+uintmax_t i = (uintmax_t) -1; return !i;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_stdint_h=yes
+else
+  gl_cv_header_stdint_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_h" >&5
+$as_echo "$gl_cv_header_stdint_h" >&6; }
+  if test $gl_cv_header_stdint_h = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STDINT_H_WITH_UINTMAX 1
+_ACEOF
+
+  fi
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for intmax_t" >&5
+$as_echo_n "checking for intmax_t... " >&6; }
+if test "${gt_cv_c_intmax_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stddef.h>
+#include <stdlib.h>
+#if HAVE_STDINT_H_WITH_UINTMAX
+#include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H_WITH_UINTMAX
+#include <inttypes.h>
+#endif
+
+int
+main ()
+{
+intmax_t x = -1; return !x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_c_intmax_t=yes
+else
+  gt_cv_c_intmax_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_intmax_t" >&5
+$as_echo "$gt_cv_c_intmax_t" >&6; }
+  if test $gt_cv_c_intmax_t = yes; then
+
+$as_echo "#define HAVE_INTMAX_T 1" >>confdefs.h
+
+  else
+
+    test $ac_cv_type_long_long_int = yes \
+      && ac_type='long long' \
+      || ac_type='long'
+
+cat >>confdefs.h <<_ACEOF
+#define intmax_t $ac_type
+_ACEOF
+
+  fi
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf returns a byte count as in C99" >&5
+$as_echo_n "checking whether snprintf returns a byte count as in C99... " >&6; }
+if test "${gl_cv_func_snprintf_retval_c99+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      if test "$cross_compiling" = yes; then :
+
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_snprintf_retval_c99="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_snprintf_retval_c99="guessing no";;
+           darwin*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on OpenBSD >= 3.9.
+           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
+                                 gl_cv_func_snprintf_retval_c99="guessing no";;
+           openbsd*)             gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on Solaris >= 2.10.
+           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
+           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
+                                 # Guess yes on AIX >= 4.
+           aix[1-3]*)            gl_cv_func_snprintf_retval_c99="guessing no";;
+           aix*)                 gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_snprintf_retval_c99="guessing no";;
+           netbsd*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_snprintf_retval_c99="guessing no";;
+         esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  strcpy (buf, "ABCDEF");
+  if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
+    return 1;
+  if (snprintf (buf, 0, "%d %d", 4567, 89) != 7)
+    return 2;
+  if (snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
+    return 3;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_snprintf_retval_c99=yes
+else
+  gl_cv_func_snprintf_retval_c99=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_snprintf_retval_c99" >&5
+$as_echo "$gl_cv_func_snprintf_retval_c99" >&6; }
+
+
+
+
+
+
+
+  for ac_func in snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+      ac_fn_c_check_decl "$LINENO" "_snprintf" "ac_cv_have_decl__snprintf" "#include <stdio.h>
+"
+if test "x$ac_cv_have_decl__snprintf" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__SNPRINTF $ac_have_decl
+_ACEOF
+
+
+  case "$gl_cv_func_snprintf_retval_c99" in
+    *yes)
+
+$as_echo "#define HAVE_SNPRINTF_RETVAL_C99 1" >>confdefs.h
+
+      ;;
+  esac
+
+
+  XGETTEXT_EXTRA_OPTIONS=
+
+
+
+
+
+
+
+  GNULIB_ISWBLANK=0;
+  GNULIB_WCTYPE=0;
+  GNULIB_ISWCTYPE=0;
+  GNULIB_WCTRANS=0;
+  GNULIB_TOWCTRANS=0;
+    HAVE_ISWBLANK=1;
+  HAVE_WCTYPE_T=1;
+  HAVE_WCTRANS_T=1;
+  REPLACE_ISWBLANK=0;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5
+$as_echo_n "checking if environ is properly declared... " >&6; }
+  if test "${gt_cv_var_environ_declaration+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+           extern struct { int foo; } environ;
+int
+main ()
+{
+environ.foo = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_var_environ_declaration=no
+else
+  gt_cv_var_environ_declaration=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_var_environ_declaration" >&5
+$as_echo "$gt_cv_var_environ_declaration" >&6; }
+  if test $gt_cv_var_environ_declaration = yes; then
+
+$as_echo "#define HAVE_ENVIRON_DECL 1" >>confdefs.h
+
+  fi
+
+
+  if test $gt_cv_var_environ_declaration != yes; then
+    HAVE_DECL_ENVIRON=0
+  fi
+
+
+  GNULIB_FCNTL=0;
+  GNULIB_OPEN=0;
+  GNULIB_OPENAT=0;
+    HAVE_FCNTL=1;
+  HAVE_OPENAT=1;
+  REPLACE_FCNTL=0;
+  REPLACE_OPEN=0;
+  REPLACE_OPENAT=0;
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LC_MESSAGES" >&5
+$as_echo_n "checking for LC_MESSAGES... " >&6; }
+if test "${gt_cv_val_LC_MESSAGES+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <locale.h>
+int
+main ()
+{
+return LC_MESSAGES
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gt_cv_val_LC_MESSAGES=yes
+else
+  gt_cv_val_LC_MESSAGES=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_val_LC_MESSAGES" >&5
+$as_echo "$gt_cv_val_LC_MESSAGES" >&6; }
+  if test $gt_cv_val_LC_MESSAGES = yes; then
+
+$as_echo "#define HAVE_LC_MESSAGES 1" >>confdefs.h
+
+  fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5
+$as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; }
+if test "${gt_cv_func_CFPreferencesCopyAppValue+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <CoreFoundation/CFPreferences.h>
+int
+main ()
+{
+CFPreferencesCopyAppValue(NULL, NULL)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gt_cv_func_CFPreferencesCopyAppValue=yes
+else
+  gt_cv_func_CFPreferencesCopyAppValue=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     LIBS="$gt_save_LIBS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5
+$as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; }
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
+
+$as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h
+
+  fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5
+$as_echo_n "checking for CFLocaleCopyCurrent... " >&6; }
+if test "${gt_cv_func_CFLocaleCopyCurrent+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <CoreFoundation/CFLocale.h>
+int
+main ()
+{
+CFLocaleCopyCurrent();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gt_cv_func_CFLocaleCopyCurrent=yes
+else
+  gt_cv_func_CFLocaleCopyCurrent=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     LIBS="$gt_save_LIBS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5
+$as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; }
+  if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+
+$as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h
+
+  fi
+  INTL_MACOSX_LIBS=
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+    INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
+  fi
+
+
+
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
+  # contains only /bin. Note that ksh looks also at the FPATH variable,
+  # so we have to set that as well for the test.
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+           || PATH_SEPARATOR=';'
+       }
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+      *GNU* | *'with BFD'*)
+        test "$with_gnu_ld" != no && break ;;
+      *)
+        test "$with_gnu_ld" != yes && break ;;
+      esac
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  acl_cv_prog_gnu_ld=yes ;;
+*)
+  acl_cv_prog_gnu_ld=no ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  acl_libext="$acl_cv_libext"
+  acl_shlibext="$acl_cv_shlibext"
+  acl_libname_spec="$acl_cv_libname_spec"
+  acl_library_names_spec="$acl_cv_library_names_spec"
+  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  acl_hardcode_direct="$acl_cv_hardcode_direct"
+  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
+
+  acl_libdirstem=lib
+  acl_libdirstem2=
+  case "$host_os" in
+    solaris*)
+                                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5
+$as_echo_n "checking for 64-bit host... " >&6; }
+if test "${gl_cv_solaris_64bit+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef _LP64
+sixtyfour bits
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "sixtyfour bits" >/dev/null 2>&1; then :
+  gl_cv_solaris_64bit=yes
+else
+  gl_cv_solaris_64bit=no
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5
+$as_echo "$gl_cv_solaris_64bit" >&6; }
+      if test $gl_cv_solaris_64bit = yes; then
+        acl_libdirstem=lib/64
+        case "$host_cpu" in
+          sparc*)        acl_libdirstem2=lib/sparcv9 ;;
+          i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+        esac
+      fi
+      ;;
+    *)
+      searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+      if test -n "$searchpath"; then
+        acl_save_IFS="${IFS=   }"; IFS=":"
+        for searchdir in $searchpath; do
+          if test -d "$searchdir"; then
+            case "$searchdir" in
+              */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
+              */../ | */.. )
+                # Better ignore directories of this form. They are misleading.
+                ;;
+              *) searchdir=`cd "$searchdir" && pwd`
+                 case "$searchdir" in
+                   */lib64 ) acl_libdirstem=lib64 ;;
+                 esac ;;
+            esac
+          fi
+        done
+        IFS="$acl_save_IFS"
+      fi
+      ;;
+  esac
+  test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
+
+
+
+  gl_threads_api=none
+  LIBTHREAD=
+  LTLIBTHREAD=
+  LIBMULTITHREAD=
+  LTLIBMULTITHREAD=
+  if test "$gl_use_threads" != no; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5
+$as_echo_n "checking whether imported symbols can be declared weak... " >&6; }
+if test "${gl_cv_have_weak+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gl_cv_have_weak=no
+              cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+extern void xyzzy ();
+#pragma weak xyzzy
+int
+main ()
+{
+xyzzy();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gl_cv_have_weak=maybe
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+       if test $gl_cv_have_weak = maybe; then
+                           if test "$cross_compiling" = yes; then :
+                          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __ELF__
+               Extensible Linking Format
+               #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Extensible Linking Format" >/dev/null 2>&1; then :
+  gl_cv_have_weak="guessing yes"
+else
+  gl_cv_have_weak="guessing no"
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#pragma weak fputs
+int main ()
+{
+  return (fputs == NULL);
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_have_weak=yes
+else
+  gl_cv_have_weak=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+       fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_weak" >&5
+$as_echo "$gl_cv_have_weak" >&6; }
+    if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+      # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
+      # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
+      ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
+if test "x$ac_cv_header_pthread_h" = x""yes; then :
+  gl_have_pthread_h=yes
+else
+  gl_have_pthread_h=no
+fi
+
+
+      if test "$gl_have_pthread_h" = yes; then
+        # Other possible tests:
+        #   -lpthreads (FSU threads, PCthreads)
+        #   -lgthreads
+        gl_have_pthread=
+        # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
+        # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
+        # the second one only in libpthread, and lock.c needs it.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <pthread.h>
+int
+main ()
+{
+pthread_mutex_lock((pthread_mutex_t*)0);
+               pthread_mutexattr_init((pthread_mutexattr_t*)0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gl_have_pthread=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        # Test for libpthread by looking for pthread_kill. (Not pthread_self,
+        # since it is defined as a macro on OSF/1.)
+        if test -n "$gl_have_pthread"; then
+          # The program links fine without libpthread. But it may actually
+          # need to link with libpthread in order to create multiple threads.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5
+$as_echo_n "checking for pthread_kill in -lpthread... " >&6; }
+if test "${ac_cv_lib_pthread_pthread_kill+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_kill ();
+int
+main ()
+{
+return pthread_kill ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pthread_pthread_kill=yes
+else
+  ac_cv_lib_pthread_pthread_kill=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_kill" = x""yes; then :
+  LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
+             # On Solaris and HP-UX, most pthread functions exist also in libc.
+             # Therefore pthread_in_use() needs to actually try to create a
+             # thread: pthread_create from libc will fail, whereas
+             # pthread_create will actually create a thread.
+             case "$host_os" in
+               solaris* | hpux*)
+
+$as_echo "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h
+
+             esac
+
+fi
+
+        else
+          # Some library is needed. Try libpthread and libc_r.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5
+$as_echo_n "checking for pthread_kill in -lpthread... " >&6; }
+if test "${ac_cv_lib_pthread_pthread_kill+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_kill ();
+int
+main ()
+{
+return pthread_kill ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pthread_pthread_kill=yes
+else
+  ac_cv_lib_pthread_pthread_kill=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_kill" = x""yes; then :
+  gl_have_pthread=yes
+             LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
+             LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
+fi
+
+          if test -z "$gl_have_pthread"; then
+            # For FreeBSD 4.
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5
+$as_echo_n "checking for pthread_kill in -lc_r... " >&6; }
+if test "${ac_cv_lib_c_r_pthread_kill+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lc_r  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_kill ();
+int
+main ()
+{
+return pthread_kill ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_c_r_pthread_kill=yes
+else
+  ac_cv_lib_c_r_pthread_kill=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5
+$as_echo "$ac_cv_lib_c_r_pthread_kill" >&6; }
+if test "x$ac_cv_lib_c_r_pthread_kill" = x""yes; then :
+  gl_have_pthread=yes
+               LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
+               LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r
+fi
+
+          fi
+        fi
+        if test -n "$gl_have_pthread"; then
+          gl_threads_api=posix
+
+$as_echo "#define USE_POSIX_THREADS 1" >>confdefs.h
+
+          if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+            if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+
+$as_echo "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h
+
+              LIBTHREAD=
+              LTLIBTHREAD=
+            fi
+          fi
+        fi
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
+        gl_have_solaristhread=
+        gl_save_LIBS="$LIBS"
+        LIBS="$LIBS -lthread"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <thread.h>
+#include <synch.h>
+
+int
+main ()
+{
+thr_self();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gl_have_solaristhread=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LIBS="$gl_save_LIBS"
+        if test -n "$gl_have_solaristhread"; then
+          gl_threads_api=solaris
+          LIBTHREAD=-lthread
+          LTLIBTHREAD=-lthread
+          LIBMULTITHREAD="$LIBTHREAD"
+          LTLIBMULTITHREAD="$LTLIBTHREAD"
+
+$as_echo "#define USE_SOLARIS_THREADS 1" >>confdefs.h
+
+          if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+
+$as_echo "#define USE_SOLARIS_THREADS_WEAK 1" >>confdefs.h
+
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      fi
+    fi
+    if test "$gl_use_threads" = pth; then
+      gl_save_CPPFLAGS="$CPPFLAGS"
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libpth" >&5
+$as_echo_n "checking how to link with libpth... " >&6; }
+if test "${ac_cv_libpth_libs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libpth-prefix was given.
+if test "${with_libpth_prefix+set}" = set; then :
+  withval=$with_libpth_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/$acl_libdirstem"
+        if test "$acl_libdirstem2" != "$acl_libdirstem" \
+           && ! test -d "$withval/$acl_libdirstem"; then
+          additional_libdir="$withval/$acl_libdirstem2"
+        fi
+      fi
+    fi
+
+fi
+
+      LIBPTH=
+  LTLIBPTH=
+  INCPTH=
+  LIBPTH_PREFIX=
+      HAVE_LIBPTH=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='pth '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBPTH="${LIBPTH}${LIBPTH:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
+          if test -n "$acl_shlibext"; then
+            shrext=".$acl_shlibext"             # typically: shrext=.so
+          else
+            shrext=
+          fi
+          if test $use_additional = yes; then
+            dir="$additional_libdir"
+                                    if test -n "$acl_shlibext"; then
+              if test -f "$dir/$libname$shrext"; then
+                found_dir="$dir"
+                found_so="$dir/$libname$shrext"
+              else
+                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                  ver=`(cd "$dir" && \
+                        for f in "$libname$shrext".*; do echo "$f"; done \
+                        | sed -e "s,^$libname$shrext\\\\.,," \
+                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                        | sed 1q ) 2>/dev/null`
+                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                    found_dir="$dir"
+                    found_so="$dir/$libname$shrext.$ver"
+                  fi
+                else
+                  eval library_names=\"$acl_library_names_spec\"
+                  for f in $library_names; do
+                    if test -f "$dir/$f"; then
+                      found_dir="$dir"
+                      found_so="$dir/$f"
+                      break
+                    fi
+                  done
+                fi
+              fi
+            fi
+                        if test "X$found_dir" = "X"; then
+              if test -f "$dir/$libname.$acl_libext"; then
+                found_dir="$dir"
+                found_a="$dir/$libname.$acl_libext"
+              fi
+            fi
+            if test "X$found_dir" != "X"; then
+              if test -f "$dir/$libname.la"; then
+                found_la="$dir/$libname.la"
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBPTH; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                                    if test -n "$acl_shlibext"; then
+                    if test -f "$dir/$libname$shrext"; then
+                      found_dir="$dir"
+                      found_so="$dir/$libname$shrext"
+                    else
+                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                        ver=`(cd "$dir" && \
+                              for f in "$libname$shrext".*; do echo "$f"; done \
+                              | sed -e "s,^$libname$shrext\\\\.,," \
+                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                              | sed 1q ) 2>/dev/null`
+                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                          found_dir="$dir"
+                          found_so="$dir/$libname$shrext.$ver"
+                        fi
+                      else
+                        eval library_names=\"$acl_library_names_spec\"
+                        for f in $library_names; do
+                          if test -f "$dir/$f"; then
+                            found_dir="$dir"
+                            found_so="$dir/$f"
+                            break
+                          fi
+                        done
+                      fi
+                    fi
+                  fi
+                                    if test "X$found_dir" = "X"; then
+                    if test -f "$dir/$libname.$acl_libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/$libname.$acl_libext"
+                    fi
+                  fi
+                  if test "X$found_dir" != "X"; then
+                    if test -f "$dir/$libname.la"; then
+                      found_la="$dir/$libname.la"
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
+                                LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$acl_hardcode_direct" = yes; then
+                                                      LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so"
+                else
+                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
+                                                            LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBPTH; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir"
+                    fi
+                    if test "$acl_hardcode_minus_L" != no; then
+                                                                                        LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBPTH="${LIBPTH}${LIBPTH:+ }$found_a"
+              else
+                                                LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */$acl_libdirstem | */$acl_libdirstem/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
+                if test "$name" = 'pth'; then
+                  LIBPTH_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+              */$acl_libdirstem2 | */$acl_libdirstem2/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
+                if test "$name" = 'pth'; then
+                  LIBPTH_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCPTH; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCPTH="${INCPTH}${INCPTH:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
+                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
+                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBPTH; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBPTH="${LIBPTH}${LIBPTH:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBPTH; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBPTH="${LIBPTH}${LIBPTH:+ }$dep"
+                    LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name"
+            LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$acl_hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$acl_hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBPTH="${LIBPTH}${LIBPTH:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$acl_hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBPTH="${LIBPTH}${LIBPTH:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-R$found_dir"
+    done
+  fi
+
+
+
+
+
+
+    ac_cv_libpth_libs="$LIBPTH"
+    ac_cv_libpth_ltlibs="$LTLIBPTH"
+    ac_cv_libpth_cppflags="$INCPTH"
+    ac_cv_libpth_prefix="$LIBPTH_PREFIX"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libpth_libs" >&5
+$as_echo "$ac_cv_libpth_libs" >&6; }
+  LIBPTH="$ac_cv_libpth_libs"
+  LTLIBPTH="$ac_cv_libpth_ltlibs"
+  INCPTH="$ac_cv_libpth_cppflags"
+  LIBPTH_PREFIX="$ac_cv_libpth_prefix"
+
+  for element in $INCPTH; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+
+
+      HAVE_LIBPTH=yes
+
+
+
+      gl_have_pth=
+      gl_save_LIBS="$LIBS"
+      LIBS="$LIBS $LIBPTH"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <pth.h>
+int
+main ()
+{
+pth_self();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  gl_have_pth=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+      LIBS="$gl_save_LIBS"
+      if test -n "$gl_have_pth"; then
+        gl_threads_api=pth
+        LIBTHREAD="$LIBPTH"
+        LTLIBTHREAD="$LTLIBPTH"
+        LIBMULTITHREAD="$LIBTHREAD"
+        LTLIBMULTITHREAD="$LTLIBTHREAD"
+
+$as_echo "#define USE_PTH_THREADS 1" >>confdefs.h
+
+        if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+          if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+
+$as_echo "#define USE_PTH_THREADS_WEAK 1" >>confdefs.h
+
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      else
+        CPPFLAGS="$gl_save_CPPFLAGS"
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
+        if { case "$host_os" in
+               mingw*) true;;
+               *) false;;
+             esac
+           }; then
+          gl_threads_api=win32
+
+$as_echo "#define USE_WIN32_THREADS 1" >>confdefs.h
+
+        fi
+      fi
+    fi
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5
+$as_echo_n "checking for multithread API to use... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5
+$as_echo "$gl_threads_api" >&6; }
+
+
+
+
+
+
+
+
+
+ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
+if test "x$ac_cv_type_mode_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for promoted mode_t type" >&5
+$as_echo_n "checking for promoted mode_t type... " >&6; }
+if test "${gl_cv_promoted_mode_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+int
+main ()
+{
+typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_promoted_mode_t='int'
+else
+  gl_cv_promoted_mode_t='mode_t'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_promoted_mode_t" >&5
+$as_echo "$gl_cv_promoted_mode_t" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define PROMOTED_MODE_T $gl_cv_promoted_mode_t
+_ACEOF
+
+
+
+      ac_fn_c_check_decl "$LINENO" "setenv" "ac_cv_have_decl_setenv" "$ac_includes_default"
+if test "x$ac_cv_have_decl_setenv" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SETENV $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_have_decl_setenv = no; then
+    HAVE_DECL_SETENV=0
+  fi
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_setenv = no; then
+    HAVE_SETENV=0
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setenv validates arguments" >&5
+$as_echo_n "checking whether setenv validates arguments... " >&6; }
+if test "${gl_cv_func_setenv_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  gl_cv_func_setenv_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+       #include <stdlib.h>
+       #include <errno.h>
+       #include <string.h>
+
+int
+main ()
+{
+
+       int result = 0;
+       {
+         if (setenv ("", "", 0) != -1)
+           result |= 1;
+         else if (errno != EINVAL)
+           result |= 2;
+       }
+       {
+         if (setenv ("a", "=", 1) != 0)
+           result |= 4;
+         else if (strcmp (getenv ("a"), "=") != 0)
+           result |= 8;
+       }
+       return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_setenv_works=yes
+else
+  gl_cv_func_setenv_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_setenv_works" >&5
+$as_echo "$gl_cv_func_setenv_works" >&6; }
+    if test "$gl_cv_func_setenv_works" != yes; then
+      REPLACE_SETENV=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS setenv.$ac_objext"
+
+    fi
+  fi
+
+
+
+
+  :
+
+
+
+
+
+  for ac_header in search.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "search.h" "ac_cv_header_search_h" "$ac_includes_default"
+if test "x$ac_cv_header_search_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SEARCH_H 1
+_ACEOF
+
+fi
+
+done
+
+  for ac_func in tsearch
+do :
+  ac_fn_c_check_func "$LINENO" "tsearch" "ac_cv_func_tsearch"
+if test "x$ac_cv_func_tsearch" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_TSEARCH 1
+_ACEOF
+
+fi
+done
+
+
+
+
+      ac_fn_c_check_decl "$LINENO" "alarm" "ac_cv_have_decl_alarm" "$ac_includes_default"
+if test "x$ac_cv_have_decl_alarm" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ALARM $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+      ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" "$ac_includes_default"
+if test "x$ac_cv_have_decl_unsetenv" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_UNSETENV $ac_have_decl
+_ACEOF
+
+
+
+
+
+
+
+
+   if true; then
+  GL_COND_LIBTOOL_TRUE=
+  GL_COND_LIBTOOL_FALSE='#'
+else
+  GL_COND_LIBTOOL_TRUE='#'
+  GL_COND_LIBTOOL_FALSE=
+fi
+
+  gl_cond_libtool=true
+  gl_m4_base='gnulib/m4'
+
+
+
+
+
+
+
+
+
+  gl_source_base='gnulib/lib'
+  # Code from module alloca:
+LTALLOCA=`echo "$ALLOCA" | sed -e 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
+
+  # Code from module alloca-opt:
+
+
+  if test $ac_cv_func_alloca_works = no; then
+    :
+  fi
+
+  # Define an additional variable used in the Makefile substitution.
+  if test $ac_cv_working_alloca_h = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca as a compiler built-in" >&5
+$as_echo_n "checking for alloca as a compiler built-in... " >&6; }
+if test "${gl_cv_rpl_alloca+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#if defined __GNUC__ || defined _AIX || defined _MSC_VER
+        Need own alloca
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Need own alloca" >/dev/null 2>&1; then :
+  gl_cv_rpl_alloca=yes
+else
+  gl_cv_rpl_alloca=no
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_rpl_alloca" >&5
+$as_echo "$gl_cv_rpl_alloca" >&6; }
+    if test $gl_cv_rpl_alloca = yes; then
+
+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
+
+      ALLOCA_H=alloca.h
+    else
+                  ALLOCA_H=
+    fi
+  else
+    ALLOCA_H=alloca.h
+  fi
+
+
+  # Code from module arg-nonnull:
+  # Code from module argz:
+  :
+
+
+
+for ac_header in argz.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "argz.h" "ac_cv_header_argz_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_argz_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ARGZ_H 1
+_ACEOF
+
+fi
+
+done
+
+
+ac_fn_c_check_type "$LINENO" "error_t" "ac_cv_type_error_t" "#if defined(HAVE_ARGZ_H)
+#  include <argz.h>
+#endif
+"
+if test "x$ac_cv_type_error_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_ERROR_T 1
+_ACEOF
+
+
+else
+
+$as_echo "#define error_t int" >>confdefs.h
+
+
+$as_echo "#define __error_t_defined 1" >>confdefs.h
+
+fi
+
+
+ARGZ_H=
+ac_fn_c_check_func "$LINENO" "argz_replace" "ac_cv_func_argz_replace"
+if test "x$ac_cv_func_argz_replace" = x""yes; then :
+
+else
+  ARGZ_H=argz.h;
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS argz.$ac_objext"
+
+fi
+
+
+if test -z "$ARGZ_H"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if argz actually works" >&5
+$as_echo_n "checking if argz actually works... " >&6; }
+if test "${lt_cv_sys_argz_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $host_os in #(
+         *cygwin*)
+           lt_cv_sys_argz_works=no
+           if test "$cross_compiling" != no; then
+             lt_cv_sys_argz_works="guessing no"
+           else
+             lt_sed_extract_leading_digits='s/^\([0-9\.]*\).*/\1/'
+             save_IFS=$IFS
+             IFS=-.
+             set x `uname -r | sed -e "$lt_sed_extract_leading_digits"`
+             IFS=$save_IFS
+             lt_os_major=${2-0}
+             lt_os_minor=${3-0}
+             lt_os_micro=${4-0}
+             if test "$lt_os_major" -gt 1 \
+                || { test "$lt_os_major" -eq 1 \
+                  && { test "$lt_os_minor" -gt 5 \
+                    || { test "$lt_os_minor" -eq 5 \
+                      && test "$lt_os_micro" -gt 24; }; }; }; then
+               lt_cv_sys_argz_works=yes
+             fi
+           fi
+           ;; #(
+         *) lt_cv_sys_argz_works=yes ;;
+         esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_argz_works" >&5
+$as_echo "$lt_cv_sys_argz_works" >&6; }
+     if test "$lt_cv_sys_argz_works" = yes; then :
+
+$as_echo "#define HAVE_WORKING_ARGZ 1" >>confdefs.h
+
+else
+  ARGZ_H=argz.h
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS argz.$ac_objext"
+
+fi
+fi
+
+
+
+  # Code from module btowc:
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_btowc = no; then
+    HAVE_BTOWC=0
+  else
+
+
+
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether btowc(0) is correct" >&5
+$as_echo_n "checking whether btowc(0) is correct... " >&6; }
+if test "${gl_cv_func_btowc_nul+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        if test "$cross_compiling" = yes; then :
+
+           case "$host_os" in
+                      # Guess no on Cygwin.
+             cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
+                      # Guess yes otherwise.
+             *)       gl_cv_func_btowc_nul="guessing yes" ;;
+           esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (btowc ('\0') != 0)
+    return 1;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_btowc_nul=yes
+else
+  gl_cv_func_btowc_nul=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_btowc_nul" >&5
+$as_echo "$gl_cv_func_btowc_nul" >&6; }
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether btowc(EOF) is correct" >&5
+$as_echo_n "checking whether btowc(EOF) is correct... " >&6; }
+if test "${gl_cv_func_btowc_eof+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                        case "$host_os" in
+                 # Guess no on IRIX.
+          irix*) gl_cv_func_btowc_eof="guessing no" ;;
+                 # Guess yes otherwise.
+          *)     gl_cv_func_btowc_eof="guessing yes" ;;
+        esac
+        if test $LOCALE_FR != none; then
+          if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (btowc (EOF) != WEOF)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_btowc_eof=yes
+else
+  gl_cv_func_btowc_eof=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+        fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_btowc_eof" >&5
+$as_echo "$gl_cv_func_btowc_eof" >&6; }
+
+    case "$gl_cv_func_btowc_nul" in
+      *yes) ;;
+      *) REPLACE_BTOWC=1 ;;
+    esac
+    case "$gl_cv_func_btowc_eof" in
+      *yes) ;;
+      *) REPLACE_BTOWC=1 ;;
+    esac
+  fi
+  if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS btowc.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_BTOWC=1
+
+
+
+$as_echo "#define GNULIB_TEST_BTOWC 1" >>confdefs.h
+
+
+
+  # Code from module c++defs:
+  # Code from module canonicalize-lgpl:
+
+
+  if test $ac_cv_func_canonicalize_file_name = no; then
+    HAVE_CANONICALIZE_FILE_NAME=0
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS canonicalize-lgpl.$ac_objext"
+
+    if test $ac_cv_func_realpath = no; then
+      HAVE_REALPATH=0
+    elif test "$gl_cv_func_realpath_works" != yes; then
+      REPLACE_REALPATH=1
+    fi
+  elif test "$gl_cv_func_realpath_works" != yes; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS canonicalize-lgpl.$ac_objext"
+
+    REPLACE_REALPATH=1
+    REPLACE_CANONICALIZE_FILE_NAME=1
+  fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GNULIB_CANONICALIZE_LGPL 1
+_ACEOF
+
+
+
+
+
+  GNULIB_CANONICALIZE_FILE_NAME=1
+
+
+
+$as_echo "#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1" >>confdefs.h
+
+
+
+
+
+
+  GNULIB_REALPATH=1
+
+
+
+$as_echo "#define GNULIB_TEST_REALPATH 1" >>confdefs.h
+
+
+
+  # Code from module configmake:
+
+          if test "x$datarootdir" = x; then
+    datarootdir='${datadir}'
+
+  fi
+    if test "x$docdir" = x; then
+    docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+
+  fi
+    if test "x$htmldir" = x; then
+    htmldir='${docdir}'
+
+  fi
+  if test "x$dvidir" = x; then
+    dvidir='${docdir}'
+
+  fi
+  if test "x$pdfdir" = x; then
+    pdfdir='${docdir}'
+
+  fi
+  if test "x$psdir" = x; then
+    psdir='${docdir}'
+
+  fi
+  if test "x$lispdir" = x; then
+    lispdir='${datarootdir}/emacs/site-lisp'
+
+  fi
+  if test "x$localedir" = x; then
+    localedir='${datarootdir}/locale'
+
+  fi
+
+      pkglibexecdir='${libexecdir}/${PACKAGE}'
+
+
+  # Code from module ctype:
+
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_ctype_h='<'ctype.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <ctype.h>" >&5
+$as_echo_n "checking absolute name of <ctype.h>... " >&6; }
+if test "${gl_cv_next_ctype_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_ctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/ctype.h#{
+                    s#.*"\(.*/ctype.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_ctype_h" >&5
+$as_echo "$gl_cv_next_ctype_h" >&6; }
+     fi
+     NEXT_CTYPE_H=$gl_cv_next_ctype_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'ctype.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_ctype_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_CTYPE_H=$gl_next_as_first_directive
+
+
+
+
+
+
+    for gl_func in isblank; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module dosname:
+  # Code from module errno:
+
+  # Code from module extensions:
+  # Code from module float:
+
+
+
+  FLOAT_H=
+  case "$host_os" in
+    beos* | openbsd* | mirbsd*)
+      FLOAT_H=float.h
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_float_h='<'float.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <float.h>" >&5
+$as_echo_n "checking absolute name of <float.h>... " >&6; }
+if test "${gl_cv_next_float_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <float.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_float_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/float.h#{
+                    s#.*"\(.*/float.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_float_h" >&5
+$as_echo "$gl_cv_next_float_h" >&6; }
+     fi
+     NEXT_FLOAT_H=$gl_cv_next_float_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'float.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_float_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_FLOAT_H=$gl_next_as_first_directive
+
+
+
+
+      ;;
+  esac
+
+
+  # Code from module fnmatch:
+
+
+
+
+
+  FNMATCH_H=
+  gl_fnmatch_required_lowercase=`
+    echo $gl_fnmatch_required | tr '[A-Z]' '[a-z]'
+  `
+  gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working $gl_fnmatch_required fnmatch" >&5
+$as_echo_n "checking for working $gl_fnmatch_required fnmatch... " >&6; }
+if eval "test \"\${$gl_fnmatch_cache_var+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+                           if test $gl_fnmatch_required = GNU; then
+       gl_fnmatch_gnu_start=
+       gl_fnmatch_gnu_end=
+     else
+       gl_fnmatch_gnu_start='#if 0'
+       gl_fnmatch_gnu_end='#endif'
+     fi
+     if test "$cross_compiling" = yes; then :
+  eval "$gl_fnmatch_cache_var=\"guessing no\""
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fnmatch.h>
+            static int
+            y (char const *pattern, char const *string, int flags)
+            {
+              return fnmatch (pattern, string, flags) == 0;
+            }
+            static int
+            n (char const *pattern, char const *string, int flags)
+            {
+              return fnmatch (pattern, string, flags) == FNM_NOMATCH;
+            }
+
+int
+main ()
+{
+char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]";
+            char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]";
+            static char const A_1[] = { 'A' - 1, 0 };
+            static char const A01[] = { 'A' + 1, 0 };
+            static char const a_1[] = { 'a' - 1, 0 };
+            static char const a01[] = { 'a' + 1, 0 };
+            static char const bs_1[] = { '\\\\' - 1, 0 };
+            static char const bs01[] = { '\\\\' + 1, 0 };
+            int result = 0;
+            if (!n ("a*", "", 0))
+              return 1;
+            if (!y ("a*", "abc", 0))
+              return 1;
+            if (!n ("d*/*1", "d/s/1", FNM_PATHNAME))
+              return 2;
+            if (!y ("a\\\\bc", "abc", 0))
+              return 3;
+            if (!n ("a\\\\bc", "abc", FNM_NOESCAPE))
+              return 3;
+            if (!y ("*x", ".x", 0))
+              return 4;
+            if (!n ("*x", ".x", FNM_PERIOD))
+              return 4;
+            if (!y (Apat, "\\\\", 0))
+              return 5;
+            if (!y (Apat, "A", 0))
+              return 5;
+            if (!y (apat, "\\\\", 0))
+              return 5;
+            if (!y (apat, "a", 0))
+              return 5;
+            if (!(n (Apat, A_1, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(n (apat, a_1, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(y (Apat, A01, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(y (apat, a01, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(y (Apat, bs_1, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(y (apat, bs_1, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(n (Apat, bs01, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(n (apat, bs01, 0) == ('a' < '\\\\')))
+              return 5;
+            $gl_fnmatch_gnu_start
+            if (!y ("xxXX", "xXxX", FNM_CASEFOLD))
+              result |= 8;
+            if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH))
+              result |= 16;
+            if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME))
+              result |= 32;
+            if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            $gl_fnmatch_gnu_end
+            return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  eval "$gl_fnmatch_cache_var=yes"
+else
+  eval "$gl_fnmatch_cache_var=no"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+eval ac_res=\$$gl_fnmatch_cache_var
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\""
+  if test "$gl_fnmatch_result" = yes; then
+            rm -f "$gl_source_base/fnmatch.h"
+  else
+    FNMATCH_H=fnmatch.h
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS fnmatch.$ac_objext"
+
+
+cat >>confdefs.h <<_ACEOF
+#define fnmatch ${gl_fnmatch_required_lowercase}_fnmatch
+_ACEOF
+
+
+    ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include <ctype.h>
+"
+if test "x$ac_cv_have_decl_isblank" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ISBLANK $ac_have_decl
+_ACEOF
+
+
+  :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  fi
+
+
+  # Code from module getdelim:
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_getdelim = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getdelim function" >&5
+$as_echo_n "checking for working getdelim function... " >&6; }
+if test "${gl_cv_func_working_getdelim+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+    if test "$cross_compiling" = yes; then :
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2) && !defined __UCLIBC__
+  Lucky GNU user
+ #endif
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky GNU user" >/dev/null 2>&1; then :
+  gl_cv_func_working_getdelim=yes
+else
+  gl_cv_func_working_getdelim=no
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+    int main ()
+    {
+      FILE *in = fopen ("./conftest.data", "r");
+      if (!in)
+        return 1;
+      {
+        /* Test result for a NULL buffer and a zero size.
+           Based on a test program from Karl Heuer.  */
+        char *line = NULL;
+        size_t siz = 0;
+        int len = getdelim (&line, &siz, '\n', in);
+        if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+          return 2;
+      }
+      {
+        /* Test result for a NULL buffer and a non-zero size.
+           This crashes on FreeBSD 8.0.  */
+        char *line = NULL;
+        size_t siz = (size_t)(~0) / 4;
+        if (getdelim (&line, &siz, '\n', in) == -1)
+          return 3;
+      }
+      return 0;
+    }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_working_getdelim=yes
+else
+  gl_cv_func_working_getdelim=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_getdelim" >&5
+$as_echo "$gl_cv_func_working_getdelim" >&6; }
+  else
+    gl_cv_func_working_getdelim=no
+  fi
+
+  if test $ac_cv_have_decl_getdelim = no; then
+    HAVE_DECL_GETDELIM=0
+  fi
+
+  if test $gl_cv_func_working_getdelim = no; then
+    if test $ac_cv_func_getdelim = yes; then
+      REPLACE_GETDELIM=1
+    fi
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getdelim.$ac_objext"
+
+
+  for ac_func in flockfile funlockfile
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  ac_fn_c_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getc_unlocked" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETC_UNLOCKED $ac_have_decl
+_ACEOF
+
+
+  fi
+
+
+
+
+  GNULIB_GETDELIM=1
+
+
+
+$as_echo "#define GNULIB_TEST_GETDELIM 1" >>confdefs.h
+
+
+
+  # Code from module getline:
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  gl_getline_needs_run_time_check=no
+  ac_fn_c_check_func "$LINENO" "getline" "ac_cv_func_getline"
+if test "x$ac_cv_func_getline" = x""yes; then :
+                   gl_getline_needs_run_time_check=yes
+else
+  am_cv_func_working_getline=no
+fi
+
+  if test $gl_getline_needs_run_time_check = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getline function" >&5
+$as_echo_n "checking for working getline function... " >&6; }
+if test "${am_cv_func_working_getline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+    if test "$cross_compiling" = yes; then :
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2) && !defined __UCLIBC__
+  Lucky GNU user
+ #endif
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky GNU user" >/dev/null 2>&1; then :
+  am_cv_func_working_getline=yes
+else
+  am_cv_func_working_getline=no
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+    int main ()
+    {
+      FILE *in = fopen ("./conftest.data", "r");
+      if (!in)
+        return 1;
+      {
+        /* Test result for a NULL buffer and a zero size.
+           Based on a test program from Karl Heuer.  */
+        char *line = NULL;
+        size_t siz = 0;
+        int len = getline (&line, &siz, in);
+        if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+          return 2;
+      }
+      {
+        /* Test result for a NULL buffer and a non-zero size.
+           This crashes on FreeBSD 8.0.  */
+        char *line = NULL;
+        size_t siz = (size_t)(~0) / 4;
+        if (getline (&line, &siz, in) == -1)
+          return 3;
+      }
+      return 0;
+    }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  am_cv_func_working_getline=yes
+else
+  am_cv_func_working_getline=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_working_getline" >&5
+$as_echo "$am_cv_func_working_getline" >&6; }
+  fi
+
+  if test $ac_cv_have_decl_getline = no; then
+    HAVE_DECL_GETLINE=0
+  fi
+
+  if test $am_cv_func_working_getline = no; then
+                REPLACE_GETLINE=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getline.$ac_objext"
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_getdelim = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getdelim function" >&5
+$as_echo_n "checking for working getdelim function... " >&6; }
+if test "${gl_cv_func_working_getdelim+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+    if test "$cross_compiling" = yes; then :
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2) && !defined __UCLIBC__
+  Lucky GNU user
+ #endif
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky GNU user" >/dev/null 2>&1; then :
+  gl_cv_func_working_getdelim=yes
+else
+  gl_cv_func_working_getdelim=no
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+    int main ()
+    {
+      FILE *in = fopen ("./conftest.data", "r");
+      if (!in)
+        return 1;
+      {
+        /* Test result for a NULL buffer and a zero size.
+           Based on a test program from Karl Heuer.  */
+        char *line = NULL;
+        size_t siz = 0;
+        int len = getdelim (&line, &siz, '\n', in);
+        if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+          return 2;
+      }
+      {
+        /* Test result for a NULL buffer and a non-zero size.
+           This crashes on FreeBSD 8.0.  */
+        char *line = NULL;
+        size_t siz = (size_t)(~0) / 4;
+        if (getdelim (&line, &siz, '\n', in) == -1)
+          return 3;
+      }
+      return 0;
+    }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_working_getdelim=yes
+else
+  gl_cv_func_working_getdelim=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_getdelim" >&5
+$as_echo "$gl_cv_func_working_getdelim" >&6; }
+  else
+    gl_cv_func_working_getdelim=no
+  fi
+
+  if test $ac_cv_have_decl_getdelim = no; then
+    HAVE_DECL_GETDELIM=0
+  fi
+
+  if test $gl_cv_func_working_getdelim = no; then
+    if test $ac_cv_func_getdelim = yes; then
+      REPLACE_GETDELIM=1
+    fi
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getdelim.$ac_objext"
+
+
+  for ac_func in flockfile funlockfile
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  ac_fn_c_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getc_unlocked" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETC_UNLOCKED $ac_have_decl
+_ACEOF
+
+
+  fi
+
+
+  fi
+
+
+
+
+  GNULIB_GETLINE=1
+
+
+
+$as_echo "#define GNULIB_TEST_GETLINE 1" >>confdefs.h
+
+
+
+  # Code from module getopt-gnu:
+
+
+
+
+
+
+
+$as_echo "#define GNULIB_TEST_GETOPT_GNU 1" >>confdefs.h
+
+
+  # Code from module getopt-posix:
+
+
+
+
+
+  if test -n "$gl_replace_getopt"; then :
+
+
+
+  GETOPT_H=getopt.h
+
+$as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
+
+
+
+    GNULIB_UNISTD_H_GETOPT=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
+
+
+
+  :
+
+
+
+
+
+
+
+
+fi
+
+
+  # Code from module gettext-h:
+
+
+  # Code from module gitlog-to-changelog:
+  # Code from module include_next:
+  # Code from module isblank:
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_isblank = no; then
+    HAVE_ISBLANK=0
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS isblank.$ac_objext"
+
+  fi
+
+
+
+
+  GNULIB_ISBLANK=1
+
+
+  # Code from module langinfo:
+
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_langinfo_h='<'langinfo.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <langinfo.h>" >&5
+$as_echo_n "checking absolute name of <langinfo.h>... " >&6; }
+if test "${gl_cv_next_langinfo_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_langinfo_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_langinfo_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/langinfo.h#{
+                    s#.*"\(.*/langinfo.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_langinfo_h='<'langinfo.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_langinfo_h" >&5
+$as_echo "$gl_cv_next_langinfo_h" >&6; }
+     fi
+     NEXT_LANGINFO_H=$gl_cv_next_langinfo_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'langinfo.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_langinfo_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H=$gl_next_as_first_directive
+
+
+
+
+
+    HAVE_LANGINFO_CODESET=0
+  HAVE_LANGINFO_T_FMT_AMPM=0
+  HAVE_LANGINFO_ERA=0
+  HAVE_LANGINFO_YESEXPR=0
+
+  :
+
+
+
+
+
+  if test $ac_cv_header_langinfo_h = yes; then
+    HAVE_LANGINFO_H=1
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines CODESET" >&5
+$as_echo_n "checking whether langinfo.h defines CODESET... " >&6; }
+if test "${gl_cv_header_langinfo_codeset+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int a = CODESET;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_langinfo_codeset=yes
+else
+  gl_cv_header_langinfo_codeset=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_codeset" >&5
+$as_echo "$gl_cv_header_langinfo_codeset" >&6; }
+    if test $gl_cv_header_langinfo_codeset = yes; then
+      HAVE_LANGINFO_CODESET=1
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines T_FMT_AMPM" >&5
+$as_echo_n "checking whether langinfo.h defines T_FMT_AMPM... " >&6; }
+if test "${gl_cv_header_langinfo_t_fmt_ampm+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int a = T_FMT_AMPM;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_langinfo_t_fmt_ampm=yes
+else
+  gl_cv_header_langinfo_t_fmt_ampm=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_t_fmt_ampm" >&5
+$as_echo "$gl_cv_header_langinfo_t_fmt_ampm" >&6; }
+    if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
+      HAVE_LANGINFO_T_FMT_AMPM=1
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines ERA" >&5
+$as_echo_n "checking whether langinfo.h defines ERA... " >&6; }
+if test "${gl_cv_header_langinfo_era+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int a = ERA;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_langinfo_era=yes
+else
+  gl_cv_header_langinfo_era=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_era" >&5
+$as_echo "$gl_cv_header_langinfo_era" >&6; }
+    if test $gl_cv_header_langinfo_era = yes; then
+      HAVE_LANGINFO_ERA=1
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines YESEXPR" >&5
+$as_echo_n "checking whether langinfo.h defines YESEXPR... " >&6; }
+if test "${gl_cv_header_langinfo_yesexpr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int a = YESEXPR;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_langinfo_yesexpr=yes
+else
+  gl_cv_header_langinfo_yesexpr=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_yesexpr" >&5
+$as_echo "$gl_cv_header_langinfo_yesexpr" >&6; }
+    if test $gl_cv_header_langinfo_yesexpr = yes; then
+      HAVE_LANGINFO_YESEXPR=1
+    fi
+  else
+    HAVE_LANGINFO_H=0
+  fi
+
+
+
+
+
+
+
+    for gl_func in nl_langinfo; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module localcharset:
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+
+  LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
+
+  # Code from module locale:
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h conforms to POSIX:2001" >&5
+$as_echo_n "checking whether locale.h conforms to POSIX:2001... " >&6; }
+if test "${gl_cv_header_locale_h_posix2001+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <locale.h>
+            int x = LC_MESSAGES;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_locale_h_posix2001=yes
+else
+  gl_cv_header_locale_h_posix2001=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_h_posix2001" >&5
+$as_echo "$gl_cv_header_locale_h_posix2001" >&6; }
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_header_xlocale_h = yes; then
+    HAVE_XLOCALE_H=1
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h defines locale_t" >&5
+$as_echo_n "checking whether locale.h defines locale_t... " >&6; }
+if test "${gl_cv_header_locale_has_locale_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <locale.h>
+              locale_t x;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_header_locale_has_locale_t=yes
+else
+  gl_cv_header_locale_has_locale_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_has_locale_t" >&5
+$as_echo "$gl_cv_header_locale_has_locale_t" >&6; }
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      gl_cv_header_locale_h_needs_xlocale_h=no
+    else
+      gl_cv_header_locale_h_needs_xlocale_h=yes
+    fi
+  else
+    HAVE_XLOCALE_H=0
+    gl_cv_header_locale_h_needs_xlocale_h=no
+  fi
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_locale_h='<'locale.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <locale.h>" >&5
+$as_echo_n "checking absolute name of <locale.h>... " >&6; }
+if test "${gl_cv_next_locale_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <locale.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_locale_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/locale.h#{
+                    s#.*"\(.*/locale.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_locale_h" >&5
+$as_echo "$gl_cv_next_locale_h" >&6; }
+     fi
+     NEXT_LOCALE_H=$gl_cv_next_locale_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'locale.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_locale_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_LOCALE_H=$gl_next_as_first_directive
+
+
+
+
+
+  if test -n "$STDDEF_H" \
+     || test $gl_cv_header_locale_h_posix2001 = no \
+     || test $gl_cv_header_locale_h_needs_xlocale_h = yes; then
+
+    :
+
+  fi
+
+
+    for gl_func in setlocale duplocale; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <locale.h>
+/* Some systems provide declarations in a non-standard header.  */
+#if HAVE_XLOCALE_H
+# include <xlocale.h>
+#endif
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module lstat:
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_lstat = yes; then
+
+    if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
+            REPLACE_LSTAT=1
+    fi
+    # Prerequisites of lib/lstat.c.
+
+  else
+    HAVE_LSTAT=0
+  fi
+
+
+
+
+  GNULIB_LSTAT=1
+
+
+
+$as_echo "#define GNULIB_TEST_LSTAT 1" >>confdefs.h
+
+
+
+  # Code from module malloc-gnu:
+
+
+    for ac_header in stdlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdlib_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
+$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
+if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_malloc_0_nonnull=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *malloc ();
+#endif
+
+int
+main ()
+{
+return ! malloc (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_malloc_0_nonnull=yes
+else
+  ac_cv_func_malloc_0_nonnull=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
+$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
+if test $ac_cv_func_malloc_0_nonnull = yes; then :
+
+$as_echo "#define HAVE_MALLOC_GNU 1" >>confdefs.h
+
+else
+  $as_echo "#define HAVE_MALLOC_GNU 0" >>confdefs.h
+
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS malloc.$ac_objext"
+
+  REPLACE_MALLOC=1
+
+
+fi
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define GNULIB_MALLOC_GNU 1
+_ACEOF
+
+
+  # Code from module malloc-posix:
+
+
+
+  if test $gl_cv_func_malloc_posix = yes; then
+
+$as_echo "#define HAVE_MALLOC_POSIX 1" >>confdefs.h
+
+  else
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS malloc.$ac_objext"
+
+  REPLACE_MALLOC=1
+
+  fi
+
+
+
+
+  GNULIB_MALLOC_POSIX=1
+
+
+
+$as_echo "#define GNULIB_TEST_MALLOC_POSIX 1" >>confdefs.h
+
+
+
+  # Code from module malloca:
+
+
+
+
+  # Code from module mbrtowc:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5
+$as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; }
+if test "${gl_cv_func_mbrtowc_incomplete_state+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                     # Guess no on AIX and OSF/1.
+        aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+                     # Guess yes otherwise.
+        *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+      if test $LOCALE_JA != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_incomplete_state=yes
+else
+  gl_cv_func_mbrtowc_incomplete_state=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5
+$as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5
+$as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; }
+if test "${gl_cv_func_mbrtowc_sanitycheck+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+      if test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_sanitycheck=yes
+else
+  gl_cv_func_mbrtowc_sanitycheck=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5
+$as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; }
+
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+
+    :
+
+  fi
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbrtowc = no; then
+    HAVE_MBRTOWC=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_MBRTOWC=1
+    else
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles a NULL pwc argument" >&5
+$as_echo_n "checking whether mbrtowc handles a NULL pwc argument... " >&6; }
+if test "${gl_cv_func_mbrtowc_null_arg1+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                  # Guess no on Solaris.
+        solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
+                  # Guess yes otherwise.
+        *)        gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
+      esac
+      if test $LOCALE_FR_UTF8 != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      char input[] = "\303\237er";
+      mbstate_t state;
+      wchar_t wc;
+      size_t ret;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      wc = (wchar_t) 0xBADFACE;
+      ret = mbrtowc (&wc, input, 5, &state);
+      if (ret != 2)
+        result |= 1;
+      if (!mbsinit (&state))
+        result |= 2;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      ret = mbrtowc (NULL, input, 5, &state);
+      if (ret != 2) /* Solaris 7 fails here: ret is -1.  */
+        result |= 4;
+      if (!mbsinit (&state))
+        result |= 8;
+    }
+  return result;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_null_arg1=yes
+else
+  gl_cv_func_mbrtowc_null_arg1=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_null_arg1" >&5
+$as_echo "$gl_cv_func_mbrtowc_null_arg1" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles a NULL string argument" >&5
+$as_echo_n "checking whether mbrtowc handles a NULL string argument... " >&6; }
+if test "${gl_cv_func_mbrtowc_null_arg2+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+              # Guess no on OSF/1.
+        osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
+              # Guess yes otherwise.
+        *)    gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
+      esac
+      if test $LOCALE_FR_UTF8 != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+      int ret;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      wc = (wchar_t) 0xBADFACE;
+      mbrtowc (&wc, NULL, 5, &state);
+      /* Check that wc was not modified.  */
+      if (wc != (wchar_t) 0xBADFACE)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_null_arg2=yes
+else
+  gl_cv_func_mbrtowc_null_arg2=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_null_arg2" >&5
+$as_echo "$gl_cv_func_mbrtowc_null_arg2" >&6; }
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc has a correct return value" >&5
+$as_echo_n "checking whether mbrtowc has a correct return value... " >&6; }
+if test "${gl_cv_func_mbrtowc_retval+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                                   # 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
+      if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
+         || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+  int found_some_locale = 0;
+  /* This fails on Solaris.  */
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      char input[] = "B\303\274\303\237er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 1)
+            result |= 1;
+        }
+      found_some_locale = 1;
+    }
+  /* This fails on HP-UX 11.11.  */
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 2)
+            result |= 2;
+        }
+      found_some_locale = 1;
+    }
+  /* 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);
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_retval=yes
+else
+  if test $? != 77; then
+             gl_cv_func_mbrtowc_retval=no
+           fi
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_retval" >&5
+$as_echo "$gl_cv_func_mbrtowc_retval" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc returns 0 when parsing a NUL character" >&5
+$as_echo_n "checking whether mbrtowc returns 0 when parsing a NUL character... " >&6; }
+if test "${gl_cv_func_mbrtowc_nul_retval+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                       # Guess no on Solaris 8 and 9.
+        solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
+                       # Guess yes otherwise.
+        *)             gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
+      esac
+      if test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8 and 9.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, "", 1, &state) != 0)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_nul_retval=yes
+else
+  gl_cv_func_mbrtowc_nul_retval=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_nul_retval" >&5
+$as_echo "$gl_cv_func_mbrtowc_nul_retval" >&6; }
+
+      case "$gl_cv_func_mbrtowc_null_arg1" in
+        *yes) ;;
+        *)
+$as_echo "#define MBRTOWC_NULL_ARG1_BUG 1" >>confdefs.h
+
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_null_arg2" in
+        *yes) ;;
+        *)
+$as_echo "#define MBRTOWC_NULL_ARG2_BUG 1" >>confdefs.h
+
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_retval" in
+        *yes) ;;
+        *)
+$as_echo "#define MBRTOWC_RETVAL_BUG 1" >>confdefs.h
+
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_nul_retval" in
+        *yes) ;;
+        *)
+$as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h
+
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+    fi
+  fi
+  if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS mbrtowc.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_MBRTOWC=1
+
+
+
+$as_echo "#define GNULIB_TEST_MBRTOWC 1" >>confdefs.h
+
+
+
+  # Code from module mbsinit:
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5
+$as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; }
+if test "${gl_cv_func_mbrtowc_incomplete_state+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                     # Guess no on AIX and OSF/1.
+        aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+                     # Guess yes otherwise.
+        *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+      if test $LOCALE_JA != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_incomplete_state=yes
+else
+  gl_cv_func_mbrtowc_incomplete_state=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5
+$as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5
+$as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; }
+if test "${gl_cv_func_mbrtowc_sanitycheck+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+      if test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_sanitycheck=yes
+else
+  gl_cv_func_mbrtowc_sanitycheck=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5
+$as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; }
+
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+
+    :
+
+  fi
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsinit = no; then
+    HAVE_MBSINIT=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_MBSINIT=1
+    else
+                        case "$host_os" in
+        mingw*) REPLACE_MBSINIT=1 ;;
+      esac
+    fi
+  fi
+  if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS mbsinit.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_MBSINIT=1
+
+
+
+$as_echo "#define GNULIB_TEST_MBSINIT 1" >>confdefs.h
+
+
+
+  # Code from module mbsrtowcs:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5
+$as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; }
+if test "${gl_cv_func_mbrtowc_incomplete_state+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                     # Guess no on AIX and OSF/1.
+        aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+                     # Guess yes otherwise.
+        *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+      if test $LOCALE_JA != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_incomplete_state=yes
+else
+  gl_cv_func_mbrtowc_incomplete_state=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5
+$as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5
+$as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; }
+if test "${gl_cv_func_mbrtowc_sanitycheck+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+      if test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_sanitycheck=yes
+else
+  gl_cv_func_mbrtowc_sanitycheck=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5
+$as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; }
+
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+
+    :
+
+  fi
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsrtowcs = no; then
+    HAVE_MBSRTOWCS=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_MBSRTOWCS=1
+    else
+
+
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbsrtowcs works" >&5
+$as_echo_n "checking whether mbsrtowcs works... " >&6; }
+if test "${gl_cv_func_mbsrtowcs_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                                   # 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
+      if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+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)
+    {
+      const char input[] = "B\303\274\303\237er";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 2;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 4)
+              result |= 2;
+          }
+    }
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "<\306\374\313\334\270\354>";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 4;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 3)
+              result |= 4;
+          }
+    }
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      const char input[] = "B\250\271\201\060\211\070er";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 2;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 4)
+              result |= 8;
+          }
+    }
+  return result;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbsrtowcs_works=yes
+else
+  gl_cv_func_mbsrtowcs_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbsrtowcs_works" >&5
+$as_echo "$gl_cv_func_mbsrtowcs_works" >&6; }
+
+      case "$gl_cv_func_mbsrtowcs_works" in
+        *yes) ;;
+        *) REPLACE_MBSRTOWCS=1 ;;
+      esac
+    fi
+  fi
+  if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS mbsrtowcs.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS mbsrtowcs-state.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_MBSRTOWCS=1
+
+
+
+$as_echo "#define GNULIB_TEST_MBSRTOWCS 1" >>confdefs.h
+
+
+
+  # Code from module mbtowc:
+
+
+
+  if false; then
+    REPLACE_MBTOWC=1
+  fi
+  if test $REPLACE_MBTOWC = 1; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS mbtowc.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_MBTOWC=1
+
+
+
+$as_echo "#define GNULIB_TEST_MBTOWC 1" >>confdefs.h
+
+
+
+  # Code from module memchr:
+
+
+
+
+  GNULIB_MEMCHR=1
+
+
+
+$as_echo "#define GNULIB_TEST_MEMCHR 1" >>confdefs.h
+
+
+
+  # Code from module mempcpy:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  for ac_func in mempcpy
+do :
+  ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy"
+if test "x$ac_cv_func_mempcpy" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMPCPY 1
+_ACEOF
+
+else
+
+    gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
+
+fi
+done
+
+
+  if test $ac_cv_func_mempcpy = no; then
+    HAVE_MEMPCPY=0
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_MEMPCPY=1
+
+
+
+$as_echo "#define GNULIB_TEST_MEMPCPY 1" >>confdefs.h
+
+
+
+  # Code from module multiarch:
+
+  # Code from module nl_langinfo:
+
+
+
+
+  :
+
+
+
+
+
+     if test $ac_cv_func_nl_langinfo = yes; then
+    # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether YESEXPR works" >&5
+$as_echo_n "checking whether YESEXPR works... " >&6; }
+if test "${gl_cv_func_nl_langinfo_yesexpr_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+
+         case "$host_os" in
+                   # Guess no on irix systems.
+           irix*)  gl_cv_func_nl_langinfo_yesexpr_works="guessing no";;
+                   # Guess yes elsewhere.
+           *)      gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";;
+         esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+
+int
+main ()
+{
+return !*nl_langinfo(YESEXPR);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_nl_langinfo_yesexpr_works=yes
+else
+  gl_cv_func_nl_langinfo_yesexpr_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_nl_langinfo_yesexpr_works" >&5
+$as_echo "$gl_cv_func_nl_langinfo_yesexpr_works" >&6; }
+    case $gl_cv_func_nl_langinfo_yesexpr_works in
+      *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;;
+      *)    FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;;
+    esac
+
+cat >>confdefs.h <<_ACEOF
+#define FUNC_NL_LANGINFO_YESEXPR_WORKS $FUNC_NL_LANGINFO_YESEXPR_WORKS
+_ACEOF
+
+    if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \
+        && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then
+      :
+    else
+      REPLACE_NL_LANGINFO=1
+
+$as_echo "#define REPLACE_NL_LANGINFO 1" >>confdefs.h
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS nl_langinfo.$ac_objext"
+
+    fi
+  else
+    HAVE_NL_LANGINFO=0
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS nl_langinfo.$ac_objext"
+
+  fi
+
+
+
+
+  GNULIB_NL_LANGINFO=1
+
+
+
+$as_echo "#define GNULIB_TEST_NL_LANGINFO 1" >>confdefs.h
+
+
+
+  # Code from module pathmax:
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  # Code from module readlink:
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_readlink = no; then
+    HAVE_READLINK=0
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext"
+
+
+  :
+
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink signature is correct" >&5
+$as_echo_n "checking whether readlink signature is correct... " >&6; }
+if test "${gl_cv_decl_readlink_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+      /* Cause compilation failure if original declaration has wrong type.  */
+      ssize_t readlink (const char *, char *, size_t);
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_decl_readlink_works=yes
+else
+  gl_cv_decl_readlink_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_readlink_works" >&5
+$as_echo "$gl_cv_decl_readlink_works" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink handles trailing slash correctly" >&5
+$as_echo_n "checking whether readlink handles trailing slash correctly... " >&6; }
+if test "${gl_cv_func_readlink_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # We have readlink, so assume ln -s works.
+       ln -s conftest.no-such conftest.link
+       ln -s conftest.link conftest.lnk2
+       if test "$cross_compiling" = yes; then :
+  gl_cv_func_readlink_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+
+int
+main ()
+{
+char buf[20];
+      return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_readlink_works=yes
+else
+  gl_cv_func_readlink_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      rm -f conftest.link conftest.lnk2
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_readlink_works" >&5
+$as_echo "$gl_cv_func_readlink_works" >&6; }
+    if test "$gl_cv_func_readlink_works" != yes; then
+
+$as_echo "#define READLINK_TRAILING_SLASH_BUG 1" >>confdefs.h
+
+      REPLACE_READLINK=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext"
+
+    elif test "$gl_cv_decl_readlink_works" != yes; then
+      REPLACE_READLINK=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext"
+
+    fi
+  fi
+
+
+
+
+  GNULIB_READLINK=1
+
+
+
+$as_echo "#define GNULIB_TEST_READLINK 1" >>confdefs.h
+
+
+
+  # Code from module realloc-posix:
+
+
+
+  if test $gl_cv_func_malloc_posix = yes; then
+
+$as_echo "#define HAVE_REALLOC_POSIX 1" >>confdefs.h
+
+  else
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS realloc.$ac_objext"
+
+  REPLACE_REALLOC=1
+
+  fi
+
+
+
+
+  GNULIB_REALLOC_POSIX=1
+
+
+
+$as_echo "#define GNULIB_TEST_REALLOC_POSIX 1" >>confdefs.h
+
+
+
+  # Code from module regex:
+
+
+# Check whether --with-included-regex was given.
+if test "${with_included_regex+set}" = set; then :
+  withval=$with_included_regex;
+fi
+
+
+  case $with_included_regex in #(
+  yes|no) ac_use_included_regex=$with_included_regex
+        ;;
+  '')
+    # If the system regex support is good enough that it passes the
+    # following run test, then default to *not* using the included regex.c.
+    # If cross compiling, assume the test would fail and use the included
+    # regex.c.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working re_compile_pattern" >&5
+$as_echo_n "checking for working re_compile_pattern... " >&6; }
+if test "${gl_cv_func_re_compile_pattern_working+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+         gl_cv_func_re_compile_pattern_working=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+           #include <locale.h>
+           #include <limits.h>
+           #include <regex.h>
+
+int
+main ()
+{
+int result = 0;
+            static struct re_pattern_buffer regex;
+            unsigned char folded_chars[UCHAR_MAX + 1];
+            int i;
+            const char *s;
+            struct re_registers regs;
+
+            /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
+               This test needs valgrind to catch the bug on Debian
+               GNU/Linux 3.1 x86, but it might catch the bug better
+               on other platforms and it shouldn't hurt to try the
+               test here.  */
+            if (setlocale (LC_ALL, "en_US.UTF-8"))
+              {
+                static char const pat[] = "insert into";
+                static char const data[] =
+                  "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
+                re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
+                               | RE_ICASE);
+                memset (&regex, 0, sizeof regex);
+                s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+                if (s)
+                  result |= 1;
+                else if (re_search (&regex, data, sizeof data - 1,
+                                    0, sizeof data - 1, &regs)
+                         != -1)
+                  result |= 1;
+                if (! setlocale (LC_ALL, "C"))
+                  return 1;
+              }
+
+            /* This test is from glibc bug 3957, reported by Andrew Mackey.  */
+            re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("a[^x]b", 6, &regex);
+            if (s)
+              result |= 2;
+            /* This should fail, but succeeds for glibc-2.5.  */
+            else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
+              result |= 2;
+
+            /* This regular expression is from Spencer ere test number 75
+               in grep-2.3.  */
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+            memset (&regex, 0, sizeof regex);
+            for (i = 0; i <= UCHAR_MAX; i++)
+              folded_chars[i] = i;
+            regex.translate = folded_chars;
+            s = re_compile_pattern ("a[[:]:]]b\n", 11, &regex);
+            /* This should fail with _Invalid character class name_ error.  */
+            if (!s)
+              result |= 4;
+
+            /* Ensure that [b-a] is diagnosed as invalid, when
+               using RE_NO_EMPTY_RANGES. */
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("a[b-a]", 6, &regex);
+            if (s == 0)
+              result |= 8;
+
+            /* This should succeed, but does not for glibc-2.1.3.  */
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("{1", 2, &regex);
+            if (s)
+              result |= 8;
+
+            /* The following example is derived from a problem report
+               against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("[an\371]*n", 7, &regex);
+            if (s)
+              result |= 8;
+            /* This should match, but does not for glibc-2.2.1.  */
+            else if (re_match (&regex, "an", 2, 0, &regs) != 2)
+              result |= 8;
+
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("x", 1, &regex);
+            if (s)
+              result |= 8;
+            /* glibc-2.2.93 does not work with a negative RANGE argument.  */
+            else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
+              result |= 8;
+
+            /* The version of regex.c in older versions of gnulib
+               ignored RE_ICASE.  Detect that problem too.  */
+            re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("x", 1, &regex);
+            if (s)
+              result |= 16;
+            else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
+              result |= 16;
+
+            /* Catch a bug reported by Vin Shelton in
+               http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html
+               */
+            re_set_syntax (RE_SYNTAX_POSIX_BASIC
+                           & ~RE_CONTEXT_INVALID_DUP
+                           & ~RE_NO_EMPTY_RANGES);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex);
+            if (s)
+              result |= 32;
+
+            /* REG_STARTEND was added to glibc on 2004-01-15.
+               Reject older versions.  */
+            if (! REG_STARTEND)
+              result |= 64;
+
+#if 0
+            /* It would be nice to reject hosts whose regoff_t values are too
+               narrow (including glibc on hosts with 64-bit ptrdiff_t and
+               32-bit int), but we should wait until glibc implements this
+               feature.  Otherwise, support for equivalence classes and
+               multibyte collation symbols would always be broken except
+               when compiling --without-included-regex.   */
+            if (sizeof (regoff_t) < sizeof (ptrdiff_t)
+                || sizeof (regoff_t) < sizeof (ssize_t))
+              result |= 64;
+#endif
+
+            return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_re_compile_pattern_working=yes
+else
+  gl_cv_func_re_compile_pattern_working=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_re_compile_pattern_working" >&5
+$as_echo "$gl_cv_func_re_compile_pattern_working" >&6; }
+    case $gl_cv_func_re_compile_pattern_working in #(
+    yes) ac_use_included_regex=no;; #(
+    no) ac_use_included_regex=yes;;
+    esac
+    ;;
+  *) as_fn_error $? "Invalid value for --with-included-regex: $with_included_regex" "$LINENO" 5
+    ;;
+  esac
+
+  if test $ac_use_included_regex = yes; then
+
+$as_echo "#define _REGEX_LARGE_OFFSETS 1" >>confdefs.h
+
+
+$as_echo "#define re_syntax_options rpl_re_syntax_options" >>confdefs.h
+
+
+$as_echo "#define re_set_syntax rpl_re_set_syntax" >>confdefs.h
+
+
+$as_echo "#define re_compile_pattern rpl_re_compile_pattern" >>confdefs.h
+
+
+$as_echo "#define re_compile_fastmap rpl_re_compile_fastmap" >>confdefs.h
+
+
+$as_echo "#define re_search rpl_re_search" >>confdefs.h
+
+
+$as_echo "#define re_search_2 rpl_re_search_2" >>confdefs.h
+
+
+$as_echo "#define re_match rpl_re_match" >>confdefs.h
+
+
+$as_echo "#define re_match_2 rpl_re_match_2" >>confdefs.h
+
+
+$as_echo "#define re_set_registers rpl_re_set_registers" >>confdefs.h
+
+
+$as_echo "#define re_comp rpl_re_comp" >>confdefs.h
+
+
+$as_echo "#define re_exec rpl_re_exec" >>confdefs.h
+
+
+$as_echo "#define regcomp rpl_regcomp" >>confdefs.h
+
+
+$as_echo "#define regexec rpl_regexec" >>confdefs.h
+
+
+$as_echo "#define regerror rpl_regerror" >>confdefs.h
+
+
+$as_echo "#define regfree rpl_regfree" >>confdefs.h
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS regex.$ac_objext"
+
+
+
+
+
+
+  for ac_header in libintl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default"
+if test "x$ac_cv_header_libintl_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBINTL_H 1
+_ACEOF
+
+fi
+
+done
+
+
+  :
+
+
+
+
+
+
+
+
+
+
+
+  ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include <ctype.h>
+"
+if test "x$ac_cv_have_decl_isblank" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ISBLANK $ac_have_decl
+_ACEOF
+
+
+  fi
+
+  # Code from module safe-alloc:
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS safe-alloc.$ac_objext"
+
+
+  # Code from module selinux-h:
+
+
+  if test "$with_selinux" != no; then
+    for ac_header in selinux/selinux.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default"
+if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SELINUX_SELINUX_H 1
+_ACEOF
+
+fi
+
+done
+
+
+    if test "$ac_cv_header_selinux_selinux_h" = yes; then
+      # We do have <selinux/selinux.h>, so do compile getfilecon.c
+      # and arrange to use its wrappers.
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS getfilecon.$ac_objext"
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_selinux_selinux_h='<'selinux/selinux.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <selinux/selinux.h>" >&5
+$as_echo_n "checking absolute name of <selinux/selinux.h>... " >&6; }
+if test "${gl_cv_next_selinux_selinux_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_selinux_selinux_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <selinux/selinux.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_selinux_selinux_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/selinux/selinux.h#{
+                    s#.*"\(.*/selinux/selinux.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_selinux_selinux_h='<'selinux/selinux.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_selinux_selinux_h" >&5
+$as_echo "$gl_cv_next_selinux_selinux_h" >&6; }
+     fi
+     NEXT_SELINUX_SELINUX_H=$gl_cv_next_selinux_selinux_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'selinux/selinux.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_selinux_selinux_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H=$gl_next_as_first_directive
+
+
+
+
+
+$as_echo "#define getfilecon rpl_getfilecon" >>confdefs.h
+
+
+$as_echo "#define lgetfilecon rpl_lgetfilecon" >>confdefs.h
+
+
+$as_echo "#define fgetfilecon rpl_fgetfilecon" >>confdefs.h
+
+    fi
+
+    case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
+      no:*) # already warned
+        ;;
+      *:no)
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libselinux was found but selinux/selinux.h is missing." >&5
+$as_echo "$as_me: WARNING: libselinux was found but selinux/selinux.h is missing." >&2;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: augeas will be compiled without SELinux support." >&5
+$as_echo "$as_me: WARNING: augeas will be compiled without SELinux support." >&2;}
+    esac
+  else
+    # Do as if <selinux/selinux.h> does not exist, even if
+    # AC_CHECK_HEADERS_ONCE has already determined that it exists.
+    $as_echo "#define HAVE_SELINUX_SELINUX_H 0" >>confdefs.h
+
+  fi
+
+
+
+  if test "$with_selinux" != no; then
+    for ac_header in selinux/context.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "selinux/context.h" "ac_cv_header_selinux_context_h" "$ac_includes_default"
+if test "x$ac_cv_header_selinux_context_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SELINUX_CONTEXT_H 1
+_ACEOF
+ SELINUX_CONTEXT_H=
+else
+  SELINUX_CONTEXT_H=selinux/context.h
+fi
+
+done
+
+  else
+    SELINUX_CONTEXT_H=selinux/context.h
+  fi
+
+
+
+  # Code from module size_max:
+
+  for ac_header in stdint.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdint_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDINT_H 1
+_ACEOF
+
+fi
+
+done
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SIZE_MAX" >&5
+$as_echo_n "checking for SIZE_MAX... " >&6; }
+if test "${gl_cv_size_max+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    gl_cv_size_max=
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <limits.h>
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef SIZE_MAX
+Found it
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Found it" >/dev/null 2>&1; then :
+  gl_cv_size_max=yes
+fi
+rm -f conftest*
+
+    if test -z "$gl_cv_size_max"; then
+                        if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) * CHAR_BIT - 1" "size_t_bits_minus_1"        "#include <stddef.h>
+#include <limits.h>"; then :
+
+else
+  size_t_bits_minus_1=
+fi
+
+      if ac_fn_c_compute_int "$LINENO" "sizeof (size_t) <= sizeof (unsigned int)" "fits_in_uint"        "#include <stddef.h>"; then :
+
+else
+  fits_in_uint=
+fi
+
+      if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
+        if test $fits_in_uint = 1; then
+                              cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+                 extern size_t foo;
+                 extern unsigned long foo;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  fits_in_uint=0
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+        fi
+                                if test $fits_in_uint = 1; then
+          gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
+        else
+          gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
+        fi
+      else
+                gl_cv_size_max='((size_t)~(size_t)0)'
+      fi
+    fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_size_max" >&5
+$as_echo "$gl_cv_size_max" >&6; }
+  if test "$gl_cv_size_max" != yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define SIZE_MAX $gl_cv_size_max
+_ACEOF
+
+  fi
+
+
+  # Code from module ssize_t:
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssize_t" >&5
+$as_echo_n "checking for ssize_t... " >&6; }
+if test "${gt_cv_ssize_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+int
+main ()
+{
+int x = sizeof (ssize_t *) + sizeof (ssize_t);
+            return !x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_ssize_t=yes
+else
+  gt_cv_ssize_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_ssize_t" >&5
+$as_echo "$gt_cv_ssize_t" >&6; }
+  if test $gt_cv_ssize_t = no; then
+
+$as_echo "#define ssize_t int" >>confdefs.h
+
+  fi
+
+  # Code from module stat:
+
+
+
+  :
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on directories" >&5
+$as_echo_n "checking whether stat handles trailing slashes on directories... " >&6; }
+if test "${gl_cv_func_stat_dir_slash+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  case $host_os in
+            mingw*) gl_cv_func_stat_dir_slash="guessing no";;
+            *) gl_cv_func_stat_dir_slash="guessing yes";;
+          esac
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+int
+main ()
+{
+struct stat st; return stat (".", &st) != stat ("./", &st);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_stat_dir_slash=yes
+else
+  gl_cv_func_stat_dir_slash=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_dir_slash" >&5
+$as_echo "$gl_cv_func_stat_dir_slash" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5
+$as_echo_n "checking whether stat handles trailing slashes on files... " >&6; }
+if test "${gl_cv_func_stat_file_slash+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  touch conftest.tmp
+       # Assume that if we have lstat, we can also check symlinks.
+       if test $ac_cv_func_lstat = yes; then
+         ln -s conftest.tmp conftest.lnk
+       fi
+       if test "$cross_compiling" = yes; then :
+  gl_cv_func_stat_file_slash="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+int
+main ()
+{
+int result = 0;
+      struct stat st;
+      if (!stat ("conftest.tmp/", &st))
+        result |= 1;
+#if HAVE_LSTAT
+      if (!stat ("conftest.lnk/", &st))
+        result |= 2;
+#endif
+      return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_stat_file_slash=yes
+else
+  gl_cv_func_stat_file_slash=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+       rm -f conftest.tmp conftest.lnk
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_file_slash" >&5
+$as_echo "$gl_cv_func_stat_file_slash" >&6; }
+  case $gl_cv_func_stat_dir_slash in
+    *no) REPLACE_STAT=1
+
+$as_echo "#define REPLACE_FUNC_STAT_DIR 1" >>confdefs.h
+;;
+  esac
+  case $gl_cv_func_stat_file_slash in
+    *no) REPLACE_STAT=1
+
+$as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h
+;;
+  esac
+  if test $REPLACE_STAT = 1; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS stat.$ac_objext"
+
+
+  fi
+
+
+
+
+  GNULIB_STAT=1
+
+
+
+$as_echo "#define GNULIB_TEST_STAT 1" >>confdefs.h
+
+
+
+  # Code from module stdbool:
+
+
+
+  # Define two additional variables used in the Makefile substitution.
+
+  if test "$ac_cv_header_stdbool_h" = yes; then
+    STDBOOL_H=''
+  else
+    STDBOOL_H='stdbool.h'
+  fi
+
+
+  if test "$ac_cv_type__Bool" = yes; then
+    HAVE__BOOL=1
+  else
+    HAVE__BOOL=0
+  fi
+
+
+  # Code from module stddef:
+
+
+
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5
+$as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; }
+if test "${gl_cv_decl_null_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_decl_null_works=yes
+else
+  gl_cv_decl_null_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5
+$as_echo "$gl_cv_decl_null_works" >&6; }
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_stddef_h='<'stddef.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stddef.h>" >&5
+$as_echo_n "checking absolute name of <stddef.h>... " >&6; }
+if test "${gl_cv_next_stddef_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/stddef.h#{
+                    s#.*"\(.*/stddef.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5
+$as_echo "$gl_cv_next_stddef_h" >&6; }
+     fi
+     NEXT_STDDEF_H=$gl_cv_next_stddef_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'stddef.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_stddef_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive
+
+
+
+
+  fi
+
+  # Code from module stdint:
+
+
+
+  if test $ac_cv_type_long_long_int = yes; then
+    HAVE_LONG_LONG_INT=1
+  else
+    HAVE_LONG_LONG_INT=0
+  fi
+
+
+  if test $ac_cv_type_unsigned_long_long_int = yes; then
+    HAVE_UNSIGNED_LONG_LONG_INT=1
+  else
+    HAVE_UNSIGNED_LONG_LONG_INT=0
+  fi
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_header_wchar_h = yes; then
+    HAVE_WCHAR_H=1
+  else
+    HAVE_WCHAR_H=0
+  fi
+
+
+      if test $ac_cv_header_inttypes_h = yes; then
+    HAVE_INTTYPES_H=1
+  else
+    HAVE_INTTYPES_H=0
+  fi
+
+
+      if test $ac_cv_header_sys_types_h = yes; then
+    HAVE_SYS_TYPES_H=1
+  else
+    HAVE_SYS_TYPES_H=0
+  fi
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_stdint_h='<'stdint.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdint.h>" >&5
+$as_echo_n "checking absolute name of <stdint.h>... " >&6; }
+if test "${gl_cv_next_stdint_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_stdint_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdint.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/stdint.h#{
+                    s#.*"\(.*/stdint.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_stdint_h='<'stdint.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5
+$as_echo "$gl_cv_next_stdint_h" >&6; }
+     fi
+     NEXT_STDINT_H=$gl_cv_next_stdint_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'stdint.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_stdint_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STDINT_H=$gl_next_as_first_directive
+
+
+
+
+  if test $ac_cv_header_stdint_h = yes; then
+    HAVE_STDINT_H=1
+  else
+    HAVE_STDINT_H=0
+  fi
+
+
+    if test $ac_cv_header_stdint_h = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h conforms to C99" >&5
+$as_echo_n "checking whether stdint.h conforms to C99... " >&6; }
+if test "${gl_cv_header_working_stdint_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gl_cv_header_working_stdint_h=no
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
+#if !(defined WCHAR_MIN && defined WCHAR_MAX)
+#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
+#endif
+
+
+  /* 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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+
+#ifdef INT8_MAX
+int8_t a1 = INT8_MAX;
+int8_t a1min = INT8_MIN;
+#endif
+#ifdef INT16_MAX
+int16_t a2 = INT16_MAX;
+int16_t a2min = INT16_MIN;
+#endif
+#ifdef INT32_MAX
+int32_t a3 = INT32_MAX;
+int32_t a3min = INT32_MIN;
+#endif
+#ifdef INT64_MAX
+int64_t a4 = INT64_MAX;
+int64_t a4min = INT64_MIN;
+#endif
+#ifdef UINT8_MAX
+uint8_t b1 = UINT8_MAX;
+#else
+typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
+#endif
+#ifdef UINT16_MAX
+uint16_t b2 = UINT16_MAX;
+#endif
+#ifdef UINT32_MAX
+uint32_t b3 = UINT32_MAX;
+#endif
+#ifdef UINT64_MAX
+uint64_t b4 = UINT64_MAX;
+#endif
+int_least8_t c1 = INT8_C (0x7f);
+int_least8_t c1max = INT_LEAST8_MAX;
+int_least8_t c1min = INT_LEAST8_MIN;
+int_least16_t c2 = INT16_C (0x7fff);
+int_least16_t c2max = INT_LEAST16_MAX;
+int_least16_t c2min = INT_LEAST16_MIN;
+int_least32_t c3 = INT32_C (0x7fffffff);
+int_least32_t c3max = INT_LEAST32_MAX;
+int_least32_t c3min = INT_LEAST32_MIN;
+int_least64_t c4 = INT64_C (0x7fffffffffffffff);
+int_least64_t c4max = INT_LEAST64_MAX;
+int_least64_t c4min = INT_LEAST64_MIN;
+uint_least8_t d1 = UINT8_C (0xff);
+uint_least8_t d1max = UINT_LEAST8_MAX;
+uint_least16_t d2 = UINT16_C (0xffff);
+uint_least16_t d2max = UINT_LEAST16_MAX;
+uint_least32_t d3 = UINT32_C (0xffffffff);
+uint_least32_t d3max = UINT_LEAST32_MAX;
+uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
+uint_least64_t d4max = UINT_LEAST64_MAX;
+int_fast8_t e1 = INT_FAST8_MAX;
+int_fast8_t e1min = INT_FAST8_MIN;
+int_fast16_t e2 = INT_FAST16_MAX;
+int_fast16_t e2min = INT_FAST16_MIN;
+int_fast32_t e3 = INT_FAST32_MAX;
+int_fast32_t e3min = INT_FAST32_MIN;
+int_fast64_t e4 = INT_FAST64_MAX;
+int_fast64_t e4min = INT_FAST64_MIN;
+uint_fast8_t f1 = UINT_FAST8_MAX;
+uint_fast16_t f2 = UINT_FAST16_MAX;
+uint_fast32_t f3 = UINT_FAST32_MAX;
+uint_fast64_t f4 = UINT_FAST64_MAX;
+#ifdef INTPTR_MAX
+intptr_t g = INTPTR_MAX;
+intptr_t gmin = INTPTR_MIN;
+#endif
+#ifdef UINTPTR_MAX
+uintptr_t h = UINTPTR_MAX;
+#endif
+intmax_t i = INTMAX_MAX;
+uintmax_t j = UINTMAX_MAX;
+
+#include <limits.h> /* for CHAR_BIT */
+#define TYPE_MINIMUM(t) \
+  ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
+#define TYPE_MAXIMUM(t) \
+  ((t) ((t) 0 < (t) -1 \
+        ? (t) -1 \
+        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+struct s {
+  int check_PTRDIFF:
+      PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
+      && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
+      ? 1 : -1;
+  /* Detect bug in FreeBSD 6.0 / ia64.  */
+  int check_SIG_ATOMIC:
+      SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
+      && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
+      ? 1 : -1;
+  int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
+  int check_WCHAR:
+      WCHAR_MIN == TYPE_MINIMUM (wchar_t)
+      && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
+      ? 1 : -1;
+  /* Detect bug in mingw.  */
+  int check_WINT:
+      WINT_MIN == TYPE_MINIMUM (wint_t)
+      && WINT_MAX == TYPE_MAXIMUM (wint_t)
+      ? 1 : -1;
+
+  /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
+  int check_UINT8_C:
+        (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
+  int check_UINT16_C:
+        (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
+
+  /* Detect bugs in OpenBSD 3.9 stdint.h.  */
+#ifdef UINT8_MAX
+  int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
+#endif
+#ifdef UINT16_MAX
+  int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
+#endif
+#ifdef UINT32_MAX
+  int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
+#endif
+#ifdef UINT64_MAX
+  int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
+#endif
+  int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
+  int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
+  int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
+  int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
+  int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
+  int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
+  int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
+  int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
+  int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
+  int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
+  int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
+};
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+                                                    if test "$cross_compiling" = yes; then :
+                 gl_cv_header_working_stdint_h=yes
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+
+
+  /* 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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+
+#include <stdio.h>
+#include <string.h>
+#define MVAL(macro) MVAL1(macro)
+#define MVAL1(expression) #expression
+static const char *macro_values[] =
+  {
+#ifdef INT8_MAX
+    MVAL (INT8_MAX),
+#endif
+#ifdef INT16_MAX
+    MVAL (INT16_MAX),
+#endif
+#ifdef INT32_MAX
+    MVAL (INT32_MAX),
+#endif
+#ifdef INT64_MAX
+    MVAL (INT64_MAX),
+#endif
+#ifdef UINT8_MAX
+    MVAL (UINT8_MAX),
+#endif
+#ifdef UINT16_MAX
+    MVAL (UINT16_MAX),
+#endif
+#ifdef UINT32_MAX
+    MVAL (UINT32_MAX),
+#endif
+#ifdef UINT64_MAX
+    MVAL (UINT64_MAX),
+#endif
+    NULL
+  };
+
+int
+main ()
+{
+
+  const char **mv;
+  for (mv = macro_values; *mv != NULL; mv++)
+    {
+      const char *value = *mv;
+      /* Test whether it looks like a cast expression.  */
+      if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
+          || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
+          || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
+          || strncmp (value, "((int)"/*)*/, 6) == 0
+          || strncmp (value, "((signed short)"/*)*/, 15) == 0
+          || strncmp (value, "((signed char)"/*)*/, 14) == 0)
+        return mv - macro_values + 1;
+    }
+  return 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_header_working_stdint_h=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdint_h" >&5
+$as_echo "$gl_cv_header_working_stdint_h" >&6; }
+  fi
+  if test "$gl_cv_header_working_stdint_h" = yes; then
+    STDINT_H=
+  else
+            for ac_header in sys/inttypes.h sys/bitypes.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+    if test $ac_cv_header_sys_inttypes_h = yes; then
+      HAVE_SYS_INTTYPES_H=1
+    else
+      HAVE_SYS_INTTYPES_H=0
+    fi
+
+    if test $ac_cv_header_sys_bitypes_h = yes; then
+      HAVE_SYS_BITYPES_H=1
+    else
+      HAVE_SYS_BITYPES_H=0
+    fi
+
+
+
+
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+
+
+  for gltype in ptrdiff_t size_t ; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5
+$as_echo_n "checking for bit size of $gltype... " >&6; }
+if eval "test \"\${gl_cv_bitsizeof_${gltype}+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result"        "
+  /* 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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+#include <limits.h>"; then :
+
+else
+  result=unknown
+fi
+
+       eval gl_cv_bitsizeof_${gltype}=\$result
+
+fi
+eval ac_res=\$gl_cv_bitsizeof_${gltype}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+    eval result=\$gl_cv_bitsizeof_${gltype}
+    if test $result = unknown; then
+                                                result=0
+    fi
+    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    cat >>confdefs.h <<_ACEOF
+#define BITSIZEOF_${GLTYPE} $result
+_ACEOF
+
+    eval BITSIZEOF_${GLTYPE}=\$result
+  done
+
+
+  fi
+
+
+  for gltype in sig_atomic_t wchar_t wint_t ; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5
+$as_echo_n "checking for bit size of $gltype... " >&6; }
+if eval "test \"\${gl_cv_bitsizeof_${gltype}+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result"        "
+  /* 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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+#include <limits.h>"; then :
+
+else
+  result=unknown
+fi
+
+       eval gl_cv_bitsizeof_${gltype}=\$result
+
+fi
+eval ac_res=\$gl_cv_bitsizeof_${gltype}
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+    eval result=\$gl_cv_bitsizeof_${gltype}
+    if test $result = unknown; then
+                                                result=0
+    fi
+    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    cat >>confdefs.h <<_ACEOF
+#define BITSIZEOF_${GLTYPE} $result
+_ACEOF
+
+    eval BITSIZEOF_${GLTYPE}=\$result
+  done
+
+
+
+
+  for gltype in sig_atomic_t wchar_t wint_t ; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gltype is signed" >&5
+$as_echo_n "checking whether $gltype is signed... " >&6; }
+if eval "test \"\${gl_cv_type_${gltype}_signed+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+            int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  result=yes
+else
+  result=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       eval gl_cv_type_${gltype}_signed=\$result
+
+fi
+eval ac_res=\$gl_cv_type_${gltype}_signed
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+    eval result=\$gl_cv_type_${gltype}_signed
+    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    if test "$result" = yes; then
+      cat >>confdefs.h <<_ACEOF
+#define HAVE_SIGNED_${GLTYPE} 1
+_ACEOF
+
+      eval HAVE_SIGNED_${GLTYPE}=1
+    else
+      eval HAVE_SIGNED_${GLTYPE}=0
+    fi
+  done
+
+
+  gl_cv_type_ptrdiff_t_signed=yes
+  gl_cv_type_size_t_signed=no
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+
+
+  for gltype in ptrdiff_t size_t ; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5
+$as_echo_n "checking for $gltype integer literal suffix... " >&6; }
+if eval "test \"\${gl_cv_type_${gltype}_suffix+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval gl_cv_type_${gltype}_suffix=no
+       eval result=\$gl_cv_type_${gltype}_signed
+       if test "$result" = yes; then
+         glsufu=
+       else
+         glsufu=u
+       fi
+       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
+         case $glsuf in
+           '')  gltype1='int';;
+           l)   gltype1='long int';;
+           ll)  gltype1='long long int';;
+           i64) gltype1='__int64';;
+           u)   gltype1='unsigned int';;
+           ul)  gltype1='unsigned long int';;
+           ull) gltype1='unsigned long long int';;
+           ui64)gltype1='unsigned __int64';;
+         esac
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+              extern $gltype foo;
+              extern $gltype1 foo;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval gl_cv_type_${gltype}_suffix=\$glsuf
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         eval result=\$gl_cv_type_${gltype}_suffix
+         test "$result" != no && break
+       done
+fi
+eval ac_res=\$gl_cv_type_${gltype}_suffix
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    eval result=\$gl_cv_type_${gltype}_suffix
+    test "$result" = no && result=
+    eval ${GLTYPE}_SUFFIX=\$result
+    cat >>confdefs.h <<_ACEOF
+#define ${GLTYPE}_SUFFIX $result
+_ACEOF
+
+  done
+
+
+  fi
+
+
+  for gltype in sig_atomic_t wchar_t wint_t ; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5
+$as_echo_n "checking for $gltype integer literal suffix... " >&6; }
+if eval "test \"\${gl_cv_type_${gltype}_suffix+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval gl_cv_type_${gltype}_suffix=no
+       eval result=\$gl_cv_type_${gltype}_signed
+       if test "$result" = yes; then
+         glsufu=
+       else
+         glsufu=u
+       fi
+       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
+         case $glsuf in
+           '')  gltype1='int';;
+           l)   gltype1='long int';;
+           ll)  gltype1='long long int';;
+           i64) gltype1='__int64';;
+           u)   gltype1='unsigned int';;
+           ul)  gltype1='unsigned long int';;
+           ull) gltype1='unsigned long long int';;
+           ui64)gltype1='unsigned __int64';;
+         esac
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+
+              extern $gltype foo;
+              extern $gltype1 foo;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval gl_cv_type_${gltype}_suffix=\$glsuf
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         eval result=\$gl_cv_type_${gltype}_suffix
+         test "$result" != no && break
+       done
+fi
+eval ac_res=\$gl_cv_type_${gltype}_suffix
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    eval result=\$gl_cv_type_${gltype}_suffix
+    test "$result" = no && result=
+    eval ${GLTYPE}_SUFFIX=\$result
+    cat >>confdefs.h <<_ACEOF
+#define ${GLTYPE}_SUFFIX $result
+_ACEOF
+
+  done
+
+
+
+    STDINT_H=stdint.h
+  fi
+
+
+  # Code from module stdio:
+
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_stdio_h='<'stdio.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdio.h>" >&5
+$as_echo_n "checking absolute name of <stdio.h>... " >&6; }
+if test "${gl_cv_next_stdio_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/stdio.h#{
+                    s#.*"\(.*/stdio.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdio_h" >&5
+$as_echo "$gl_cv_next_stdio_h" >&6; }
+     fi
+     NEXT_STDIO_H=$gl_cv_next_stdio_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'stdio.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_stdio_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STDIO_H=$gl_next_as_first_directive
+
+
+
+
+      GNULIB_FPRINTF=1
+  GNULIB_PRINTF=1
+  GNULIB_VFPRINTF=1
+  GNULIB_VPRINTF=1
+  GNULIB_FPUTC=1
+  GNULIB_PUTC=1
+  GNULIB_PUTCHAR=1
+  GNULIB_FPUTS=1
+  GNULIB_PUTS=1
+  GNULIB_FWRITE=1
+
+
+
+    for gl_func in dprintf fpurge fseeko ftello getdelim getline popen renameat     snprintf tmpfile vdprintf vsnprintf; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module stdlib:
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_stdlib_h='<'stdlib.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdlib.h>" >&5
+$as_echo_n "checking absolute name of <stdlib.h>... " >&6; }
+if test "${gl_cv_next_stdlib_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/stdlib.h#{
+                    s#.*"\(.*/stdlib.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5
+$as_echo "$gl_cv_next_stdlib_h" >&6; }
+     fi
+     NEXT_STDLIB_H=$gl_cv_next_stdlib_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'stdlib.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_stdlib_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_STDLIB_H=$gl_next_as_first_directive
+
+
+
+
+
+
+    for gl_func in _Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp     mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r     setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt     unsetenv; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#if HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+#endif
+#if HAVE_RANDOM_H
+# include <random.h>
+#endif
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module stpcpy:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  for ac_func in stpcpy
+do :
+  ac_fn_c_check_func "$LINENO" "stpcpy" "ac_cv_func_stpcpy"
+if test "x$ac_cv_func_stpcpy" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STPCPY 1
+_ACEOF
+
+else
+
+    gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
+
+fi
+done
+
+
+  if test $ac_cv_func_stpcpy = no; then
+    HAVE_STPCPY=0
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_STPCPY=1
+
+
+
+$as_echo "#define GNULIB_TEST_STPCPY 1" >>confdefs.h
+
+
+
+  # Code from module stpncpy:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_stpncpy = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working stpncpy" >&5
+$as_echo_n "checking for working stpncpy... " >&6; }
+if test "${gl_cv_func_stpncpy+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      if test "$cross_compiling" = yes; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+  Thanks for using GNU
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Thanks for using GNU" >/dev/null 2>&1; then :
+  gl_cv_func_stpncpy=yes
+else
+  gl_cv_func_stpncpy=no
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stdlib.h>
+#include <string.h> /* for strcpy */
+/* The stpncpy prototype is missing in <string.h> on AIX 4.  */
+#if !HAVE_DECL_STPNCPY
+extern char *stpncpy (char *dest, const char *src, size_t n);
+#endif
+int main ()
+{
+  int result = 0;
+  const char *src = "Hello";
+  char dest[10];
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+1 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 2) != dest + 2)
+      result |= 1;
+  }
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+4 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 5) != dest + 5)
+      result |= 2;
+  }
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+6 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 7) != dest + 5)
+      result |= 4;
+  }
+  return result;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_stpncpy=yes
+else
+  gl_cv_func_stpncpy=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stpncpy" >&5
+$as_echo "$gl_cv_func_stpncpy" >&6; }
+    if test $gl_cv_func_stpncpy = yes; then
+
+$as_echo "#define HAVE_STPNCPY 1" >>confdefs.h
+
+    else
+      REPLACE_STPNCPY=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS stpncpy.$ac_objext"
+
+
+  :
+
+    fi
+  else
+    HAVE_STPNCPY=0
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS stpncpy.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_STPNCPY=1
+
+
+
+$as_echo "#define GNULIB_TEST_STPNCPY 1" >>confdefs.h
+
+
+
+  # Code from module streq:
+  # Code from module string:
+
+
+
+  # Code from module strndup:
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_have_decl_strndup = no; then
+    HAVE_DECL_STRNDUP=0
+  fi
+
+  if test $ac_cv_func_strndup = yes; then
+    # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strndup" >&5
+$as_echo_n "checking for working strndup... " >&6; }
+if test "${gl_cv_func_strndup_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+
+          case $host_os in
+            aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
+            *)               gl_cv_func_strndup_works="guessing yes";;
+          esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+         #include <string.h>
+                           #include <stdlib.h>
+int
+main ()
+{
+
+#ifndef HAVE_DECL_STRNDUP
+  extern char *strndup (const char *, size_t);
+#endif
+  char *s;
+  s = strndup ("some longer string", 15);
+  free (s);
+  s = strndup ("shorter string", 13);
+  return s[13] != '\0';
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_strndup_works=yes
+else
+  gl_cv_func_strndup_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strndup_works" >&5
+$as_echo "$gl_cv_func_strndup_works" >&6; }
+    case $gl_cv_func_strndup_works in
+      *no)
+        REPLACE_STRNDUP=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strndup.$ac_objext"
+
+        ;;
+    esac
+  else
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strndup.$ac_objext"
+
+  fi
+
+
+
+
+  GNULIB_STRNDUP=1
+
+
+
+$as_echo "#define GNULIB_TEST_STRNDUP 1" >>confdefs.h
+
+
+
+  # Code from module strnlen:
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_have_decl_strnlen = no; then
+    HAVE_DECL_STRNLEN=0
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strnlen" >&5
+$as_echo_n "checking for working strnlen... " >&6; }
+if test "${ac_cv_func_strnlen_working+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_strnlen_working=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+
+#define S "foobar"
+#define S_LEN (sizeof S - 1)
+
+  /* At least one implementation is buggy: that of AIX 4.3 would
+     give strnlen (S, 1) == 3.  */
+
+  int i;
+  for (i = 0; i < S_LEN + 1; ++i)
+    {
+      int expected = i <= S_LEN ? i : S_LEN;
+      if (strnlen (S, i) != expected)
+       return 1;
+    }
+  return 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_strnlen_working=yes
+else
+  ac_cv_func_strnlen_working=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strnlen_working" >&5
+$as_echo "$ac_cv_func_strnlen_working" >&6; }
+test $ac_cv_func_strnlen_working = no &&
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strnlen.$ac_objext"
+
+
+        if test $ac_cv_func_strnlen_working = no; then
+      REPLACE_STRNLEN=1
+    fi
+  fi
+  if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strnlen.$ac_objext"
+
+    :
+  fi
+
+
+
+
+  GNULIB_STRNLEN=1
+
+
+
+$as_echo "#define GNULIB_TEST_STRNLEN 1" >>confdefs.h
+
+
+
+  # Code from module strnlen1:
+  # Code from module strstr:
+
+
+  if test $REPLACE_STRSTR = 0; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works in linear time" >&5
+$as_echo_n "checking whether strstr works in linear time... " >&6; }
+if test "${gl_cv_func_strstr_linear+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
+     && !defined __UCLIBC__
+  Lucky user
+ #endif
+#endif
+#ifdef __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky user" >/dev/null 2>&1; then :
+  gl_cv_func_strstr_linear=yes
+else
+  gl_cv_func_strstr_linear="guessing no"
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <signal.h> /* for signal */
+#include <string.h> /* for strstr */
+#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for alarm */
+static void quit (int sig) { exit (sig + 128); }
+
+int
+main ()
+{
+
+    int result = 0;
+    size_t m = 1000000;
+    char *haystack = (char *) malloc (2 * m + 2);
+    char *needle = (char *) malloc (m + 2);
+    /* Failure to compile this test due to missing alarm is okay,
+       since all such platforms (mingw) also have quadratic strstr.  */
+    signal (SIGALRM, quit);
+    alarm (5);
+    /* Check for quadratic performance.  */
+    if (haystack && needle)
+      {
+        memset (haystack, 'A', 2 * m);
+        haystack[2 * m] = 'B';
+        haystack[2 * m + 1] = 0;
+        memset (needle, 'A', m);
+        needle[m] = 'B';
+        needle[m + 1] = 0;
+        if (!strstr (haystack, needle))
+          result |= 1;
+      }
+    return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_strstr_linear=yes
+else
+  gl_cv_func_strstr_linear=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_linear" >&5
+$as_echo "$gl_cv_func_strstr_linear" >&6; }
+    if test "$gl_cv_func_strstr_linear" != yes; then
+      REPLACE_STRSTR=1
+    fi
+  fi
+  if test $REPLACE_STRSTR = 1; then
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext"
+
+  fi
+
+  # Code from module strstr-simple:
+
+
+
+  if test "$gl_cv_func_memchr_works" != yes; then
+    REPLACE_STRSTR=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext"
+
+  else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strstr works" >&5
+$as_echo_n "checking whether strstr works... " >&6; }
+if test "${gl_cv_func_strstr_works_always+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+                                               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef __GNU_LIBRARY__
+ #include <features.h>
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
+     || defined __UCLIBC__
+  Lucky user
+ #endif
+#elif defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#else
+  Lucky user
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Lucky user" >/dev/null 2>&1; then :
+  gl_cv_func_strstr_works_always=yes
+else
+  gl_cv_func_strstr_works_always="guessing no"
+fi
+rm -f conftest*
+
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <string.h> /* for strstr */
+#define P "_EF_BF_BD"
+#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
+#define NEEDLE P P P P P
+
+int
+main ()
+{
+return !!strstr (HAYSTACK, NEEDLE);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_strstr_works_always=yes
+else
+  gl_cv_func_strstr_works_always=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strstr_works_always" >&5
+$as_echo "$gl_cv_func_strstr_works_always" >&6; }
+    if test "$gl_cv_func_strstr_works_always" != yes; then
+      REPLACE_STRSTR=1
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS strstr.$ac_objext"
+
+    fi
+  fi
+
+
+
+
+  GNULIB_STRSTR=1
+
+
+
+$as_echo "#define GNULIB_TEST_STRSTR 1" >>confdefs.h
+
+
+
+  # Code from module sys_stat:
+
+
+
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_sys_stat_h='<'sys/stat.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/stat.h>" >&5
+$as_echo_n "checking absolute name of <sys/stat.h>... " >&6; }
+if test "${gl_cv_next_sys_stat_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_sys_stat_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/sys/stat.h#{
+                    s#.*"\(.*/sys/stat.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_sys_stat_h='<'sys/stat.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5
+$as_echo "$gl_cv_next_sys_stat_h" >&6; }
+     fi
+     NEXT_SYS_STAT_H=$gl_cv_next_sys_stat_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'sys/stat.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_sys_stat_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H=$gl_next_as_first_directive
+
+
+
+
+
+      ac_fn_c_check_type "$LINENO" "nlink_t" "ac_cv_type_nlink_t" "#include <sys/types.h>
+     #include <sys/stat.h>
+"
+if test "x$ac_cv_type_nlink_t" = x""yes; then :
+
+else
+
+$as_echo "#define nlink_t int" >>confdefs.h
+
+fi
+
+
+
+    for gl_func in fchmodat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat     mknod mknodat stat utimensat; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/stat.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+
+  # Code from module sys_wait:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_sys_wait_h='<'sys/wait.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/wait.h>" >&5
+$as_echo_n "checking absolute name of <sys/wait.h>... " >&6; }
+if test "${gl_cv_next_sys_wait_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_sys_wait_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/wait.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_sys_wait_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/sys/wait.h#{
+                    s#.*"\(.*/sys/wait.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_sys_wait_h='<'sys/wait.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_wait_h" >&5
+$as_echo "$gl_cv_next_sys_wait_h" >&6; }
+     fi
+     NEXT_SYS_WAIT_H=$gl_cv_next_sys_wait_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'sys/wait.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_sys_wait_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H=$gl_next_as_first_directive
+
+
+
+
+
+
+    for gl_func in waitpid; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/wait.h>
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+
+  # Code from module time:
+
+
+
+  # Code from module unistd:
+
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_unistd_h='<'unistd.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <unistd.h>" >&5
+$as_echo_n "checking absolute name of <unistd.h>... " >&6; }
+if test "${gl_cv_next_unistd_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_unistd_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/unistd.h#{
+                    s#.*"\(.*/unistd.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_unistd_h='<'unistd.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5
+$as_echo "$gl_cv_next_unistd_h" >&6; }
+     fi
+     NEXT_UNISTD_H=$gl_cv_next_unistd_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'unistd.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_unistd_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_UNISTD_H=$gl_next_as_first_directive
+
+
+
+
+  if test $ac_cv_header_unistd_h = yes; then
+    HAVE_UNISTD_H=1
+  else
+    HAVE_UNISTD_H=0
+  fi
+
+
+
+    for gl_func in chown dup2 dup3 environ euidaccess faccessat fchdir fchownat     fsync ftruncate getcwd getdomainname getdtablesize getgroups     gethostname getlogin getlogin_r getpagesize getusershell setusershell     endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink     readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat     usleep; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+/* Some systems declare various items in the wrong headers.  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <fcntl.h>
+# include <stdio.h>
+# include <stdlib.h>
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#  include <io.h>
+# endif
+#endif
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module unused-parameter:
+  # Code from module vasnprintf:
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_vasnprintf = no; then
+
+
+  :
+
+
+
+
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS vasnprintf.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS printf-args.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS printf-parse.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS asnprintf.$ac_objext"
+
+  if test $ac_cv_func_vasnprintf = yes; then
+
+$as_echo "#define REPLACE_VASNPRINTF 1" >>confdefs.h
+
+  fi
+
+
+
+
+
+
+
+
+
+
+
+  ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default"
+if test "x$ac_cv_type_ptrdiff_t" = x""yes; then :
+
+else
+
+$as_echo "#define ptrdiff_t long" >>confdefs.h
+
+
+fi
+
+
+
+
+
+
+
+  fi
+
+  # Code from module vasprintf:
+
+  for ac_func in vasprintf
+do :
+  ac_fn_c_check_func "$LINENO" "vasprintf" "ac_cv_func_vasprintf"
+if test "x$ac_cv_func_vasprintf" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VASPRINTF 1
+_ACEOF
+
+fi
+done
+
+  if test $ac_cv_func_vasprintf = no; then
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS vasprintf.$ac_objext"
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS asprintf.$ac_objext"
+
+
+  if test $ac_cv_func_vasprintf = yes; then
+    REPLACE_VASPRINTF=1
+  else
+    HAVE_VASPRINTF=0
+  fi
+
+
+
+
+
+
+
+
+  fi
+
+
+
+
+  GNULIB_VASPRINTF=1
+
+
+
+$as_echo "#define GNULIB_TEST_VASPRINTF 1" >>confdefs.h
+
+
+
+
+
+  XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --flag=asprintf:2:c-format"
+
+
+
+  XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --flag=vasprintf:2:c-format"
+
+  # Code from module verify:
+  # Code from module warn-on-use:
+  # Code from module wchar:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_wchar_h='<'wchar.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <wchar.h>" >&5
+$as_echo_n "checking absolute name of <wchar.h>... " >&6; }
+if test "${gl_cv_next_wchar_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_wchar_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <wchar.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_wchar_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/wchar.h#{
+                    s#.*"\(.*/wchar.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_wchar_h='<'wchar.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wchar_h" >&5
+$as_echo "$gl_cv_next_wchar_h" >&6; }
+     fi
+     NEXT_WCHAR_H=$gl_cv_next_wchar_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'wchar.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_wchar_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_WCHAR_H=$gl_next_as_first_directive
+
+
+
+
+  if test $ac_cv_header_wchar_h = yes; then
+    HAVE_WCHAR_H=1
+  else
+    HAVE_WCHAR_H=0
+  fi
+
+
+
+
+
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+
+
+
+    for gl_func in 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     ; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+#endif
+#include <wchar.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module wcrtomb:
+
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc handles incomplete characters" >&5
+$as_echo_n "checking whether mbrtowc handles incomplete characters... " >&6; }
+if test "${gl_cv_func_mbrtowc_incomplete_state+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                     # Guess no on AIX and OSF/1.
+        aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+                     # Guess yes otherwise.
+        *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+      if test $LOCALE_JA != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_incomplete_state=yes
+else
+  gl_cv_func_mbrtowc_incomplete_state=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_incomplete_state" >&5
+$as_echo "$gl_cv_func_mbrtowc_incomplete_state" >&6; }
+
+
+
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc works as well as mbtowc" >&5
+$as_echo_n "checking whether mbrtowc works as well as mbtowc... " >&6; }
+if test "${gl_cv_func_mbrtowc_sanitycheck+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                  case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+      if test $LOCALE_ZH_CN != none; then
+        if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_mbrtowc_sanitycheck=yes
+else
+  gl_cv_func_mbrtowc_sanitycheck=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mbrtowc_sanitycheck" >&5
+$as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; }
+
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+
+    :
+
+  fi
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_wcrtomb = no; then
+    HAVE_WCRTOMB=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_WCRTOMB=1
+    else
+
+
+
+
+
+             { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wcrtomb return value is correct" >&5
+$as_echo_n "checking whether wcrtomb return value is correct... " >&6; }
+if test "${gl_cv_func_wcrtomb_retval+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                              case "$host_os" in
+                                     # Guess no on AIX 4, OSF/1 and Solaris.
+            aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
+                                     # Guess yes otherwise.
+            *)                       gl_cv_func_wcrtomb_retval="guessing yes" ;;
+          esac
+          if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
+            if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 1;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 2;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 4;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 8;
+    }
+  return result;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_wcrtomb_retval=yes
+else
+  gl_cv_func_wcrtomb_retval=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+          fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wcrtomb_retval" >&5
+$as_echo "$gl_cv_func_wcrtomb_retval" >&6; }
+      case "$gl_cv_func_wcrtomb_retval" in
+        *yes) ;;
+        *) REPLACE_WCRTOMB=1 ;;
+      esac
+    fi
+  fi
+  if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gl_LIBOBJS="$gl_LIBOBJS wcrtomb.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_WCRTOMB=1
+
+
+
+$as_echo "#define GNULIB_TEST_WCRTOMB 1" >>confdefs.h
+
+
+
+  # Code from module wctype-h:
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_iswcntrl = yes; then
+    HAVE_ISWCNTRL=1
+  else
+    HAVE_ISWCNTRL=0
+  fi
+
+
+
+
+
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_wctype_h='<'wctype.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <wctype.h>" >&5
+$as_echo_n "checking absolute name of <wctype.h>... " >&6; }
+if test "${gl_cv_next_wctype_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+             if test $ac_cv_header_wctype_h = yes; then
+
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <wctype.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_wctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/wctype.h#{
+                    s#.*"\(.*/wctype.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+          else
+               gl_cv_next_wctype_h='<'wctype.h'>'
+             fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wctype_h" >&5
+$as_echo "$gl_cv_next_wctype_h" >&6; }
+     fi
+     NEXT_WCTYPE_H=$gl_cv_next_wctype_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'wctype.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_wctype_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H=$gl_next_as_first_directive
+
+
+
+
+  if test $ac_cv_header_wctype_h = yes; then
+    if test $ac_cv_func_iswcntrl = yes; then
+                  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iswcntrl works" >&5
+$as_echo_n "checking whether iswcntrl works... " >&6; }
+if test "${gl_cv_func_iswcntrl_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+          if test "$cross_compiling" = yes; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+                          #if __GNU_LIBRARY__ == 1
+                          Linux libc5 i18n is broken.
+                          #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_func_iswcntrl_works=yes
+else
+  gl_cv_func_iswcntrl_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+               /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
+                  included before <wchar.h>.
+                  BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
+                  must be included before <wchar.h>.  */
+               #include <stddef.h>
+               #include <stdio.h>
+               #include <time.h>
+               #include <wchar.h>
+               #include <wctype.h>
+               int main () { return iswprint ('x') == 0; }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_iswcntrl_works=yes
+else
+  gl_cv_func_iswcntrl_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_iswcntrl_works" >&5
+$as_echo "$gl_cv_func_iswcntrl_works" >&6; }
+    fi
+    HAVE_WCTYPE_H=1
+  else
+    HAVE_WCTYPE_H=0
+  fi
+
+
+  if test "$gl_cv_func_iswcntrl_works" = no; then
+    REPLACE_ISWCNTRL=1
+  else
+    REPLACE_ISWCNTRL=0
+  fi
+
+
+  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
+        :
+  fi
+
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype_t" >&5
+$as_echo_n "checking for wctype_t... " >&6; }
+if test "${gl_cv_type_wctype_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
+               included before <wchar.h>.
+               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
+               must be 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;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_type_wctype_t=yes
+else
+  gl_cv_type_wctype_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wctype_t" >&5
+$as_echo "$gl_cv_type_wctype_t" >&6; }
+  if test $gl_cv_type_wctype_t = no; then
+    HAVE_WCTYPE_T=0
+  fi
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctrans_t" >&5
+$as_echo_n "checking for wctrans_t... " >&6; }
+if test "${gl_cv_type_wctrans_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
+               included before <wchar.h>.
+               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
+               must be included before <wchar.h>.  */
+            #include <stddef.h>
+            #include <stdio.h>
+            #include <time.h>
+            #include <wchar.h>
+            #include <wctype.h>
+            wctrans_t a;
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gl_cv_type_wctrans_t=yes
+else
+  gl_cv_type_wctrans_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_wctrans_t" >&5
+$as_echo "$gl_cv_type_wctrans_t" >&6; }
+  if test $gl_cv_type_wctrans_t = no; then
+    HAVE_WCTRANS_T=0
+  fi
+
+
+    for gl_func in wctype iswctype wctrans towctrans     ; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   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>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+  # Code from module xsize:
+
+
+
+  for ac_header in stdint.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdint_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDINT_H 1
+_ACEOF
+
+fi
+
+done
+
+
+  # End of code from modules
+
+
+
+
+
+
+
+
+
+  gltests_libdeps=
+  gltests_ltlibdeps=
+
+
+
+
+
+
+
+
+
+  gl_source_base='gnulib/tests'
+  gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
+
+  gl_module_indicator_condition=$gltests_WITNESS
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a turkish Unicode locale" >&5
+$as_echo_n "checking for a turkish Unicode locale... " >&6; }
+if test "${gt_cv_locale_tr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  But BeOS does not
+     implement the Turkish upper-/lowercase mappings.  Therefore, let this
+     program return 1 on BeOS.  */
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the eighth month, the second
+     character (should be U+011F: LATIN SMALL LETTER G WITH BREVE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1992 - 1900; t.tm_mon = 8 - 1; t.tm_mday = 19;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc4 || buf[2] != (char) 0x9f)
+    return 1;
+  /* Check whether the upper-/lowercase mappings are as expected for
+     Turkish.  */
+  if (towupper ('i') != 0x0130 || towlower (0x0130) != 'i'
+      || towupper(0x0131) != 'I' || towlower ('I') != 0x0131)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_tr_utf8" >&5
+$as_echo "$gt_cv_locale_tr_utf8" >&6; }
+  LOCALE_TR_UTF8=$gt_cv_locale_tr_utf8
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  if test $ac_cv_func_dup2 = no; then
+    HAVE_DUP2=0
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS dup2.$ac_objext"
+
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dup2 works" >&5
+$as_echo_n "checking whether dup2 works... " >&6; }
+if test "${gl_cv_func_dup2_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  case "$host_os" in
+           mingw*) # on this platform, dup2 always returns 0 for success
+             gl_cv_func_dup2_works=no;;
+           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+             gl_cv_func_dup2_works=no;;
+           linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
+                   # closed fd may yield -EBADF instead of -1 / errno=EBADF.
+             gl_cv_func_dup2_works=no;;
+           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
+             gl_cv_func_dup2_works=no;;
+           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
+             gl_cv_func_dup2_works=no;;
+           *) gl_cv_func_dup2_works=yes;;
+         esac
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+         #include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+int
+main ()
+{
+int result = 0;
+#if HAVE_FCNTL
+            if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
+              result |= 1;
+#endif HAVE_FCNTL
+            if (dup2 (1, 1) == 0)
+              result |= 2;
+#if HAVE_FCNTL
+            if (fcntl (1, F_GETFD) != FD_CLOEXEC)
+              result |= 4;
+#endif
+            close (0);
+            if (dup2 (0, 0) != -1)
+              result |= 8;
+            /* Many gnulib modules require POSIX conformance of EBADF.  */
+            if (dup2 (2, 1000000) == -1 && errno != EBADF)
+              result |= 16;
+            return result;
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_dup2_works=yes
+else
+  gl_cv_func_dup2_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dup2_works" >&5
+$as_echo "$gl_cv_func_dup2_works" >&6; }
+    if test "$gl_cv_func_dup2_works" = no; then
+
+
+  if test $ac_cv_func_dup2 = yes; then
+    REPLACE_DUP2=1
+  fi
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS dup2.$ac_objext"
+
+
+    fi
+  fi
+
+
+
+
+  GNULIB_DUP2=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_DUP2 1" >>confdefs.h
+
+
+
+
+
+
+
+  GNULIB_ENVIRON=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_ENVIRON 1" >>confdefs.h
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+     if test $gl_cv_have_include_next = yes; then
+       gl_cv_next_fcntl_h='<'fcntl.h'>'
+     else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <fcntl.h>" >&5
+$as_echo_n "checking absolute name of <fcntl.h>... " >&6; }
+if test "${gl_cv_next_fcntl_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fcntl.h>
+
+_ACEOF
+                                                                                                                        case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+                                                            gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+                  sed -n '\#/fcntl.h#{
+                    s#.*"\(.*/fcntl.h\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_fcntl_h" >&5
+$as_echo "$gl_cv_next_fcntl_h" >&6; }
+     fi
+     NEXT_FCNTL_H=$gl_cv_next_fcntl_h
+
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'fcntl.h'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=$gl_cv_next_fcntl_h
+     fi
+     NEXT_AS_FIRST_DIRECTIVE_FCNTL_H=$gl_next_as_first_directive
+
+
+
+
+
+
+    for gl_func in fcntl openat; do
+    as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
+$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
+if eval "test \"\${$as_gl_Symbol+set}\"" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fcntl.h>
+
+int
+main ()
+{
+#undef $gl_func
+  (void) $gl_func;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_gl_Symbol=yes"
+else
+  eval "$as_gl_Symbol=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_gl_Symbol
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+     if eval test \"x\$"$as_gl_Symbol"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
+_ACEOF
+
+                     eval ac_cv_have_decl_$gl_func=yes
+fi
+      done
+
+
+
+
+
+  for ac_func in getpagesize
+do :
+  ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize"
+if test "x$ac_cv_func_getpagesize" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETPAGESIZE 1
+_ACEOF
+
+fi
+done
+
+  if test $ac_cv_func_getpagesize = no; then
+    HAVE_GETPAGESIZE=0
+    for ac_header in OS.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "OS.h" "ac_cv_header_OS_h" "$ac_includes_default"
+if test "x$ac_cv_header_OS_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_OS_H 1
+_ACEOF
+
+fi
+
+done
+
+    if test $ac_cv_header_OS_h = yes; then
+      HAVE_OS_H=1
+    fi
+    for ac_header in sys/param.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_param_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_PARAM_H 1
+_ACEOF
+
+fi
+
+done
+
+    if test $ac_cv_header_sys_param_h = yes; then
+      HAVE_SYS_PARAM_H=1
+    fi
+  fi
+  case "$host_os" in
+    mingw*)
+      REPLACE_GETPAGESIZE=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS getpagesize.$ac_objext"
+
+      ;;
+  esac
+      ac_fn_c_check_decl "$LINENO" "getpagesize" "ac_cv_have_decl_getpagesize" "$ac_includes_default"
+if test "x$ac_cv_have_decl_getpagesize" = x""yes; then :
+
+else
+  HAVE_DECL_GETPAGESIZE=0
+fi
+
+
+
+
+
+  GNULIB_GETPAGESIZE=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_GETPAGESIZE 1" >>confdefs.h
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  for ac_func in setlocale uselocale
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+  :
+
+
+
+
+
+
+
+  if test "$gl_threads_api" = posix; then
+    # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
+    # pthread_rwlock_* functions.
+    ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include <pthread.h>
+"
+if test "x$ac_cv_type_pthread_rwlock_t" = x""yes; then :
+
+$as_echo "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h
+
+fi
+
+    # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #include <pthread.h>
+int
+main ()
+{
+
+#if __FreeBSD__ == 4
+error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
+#else
+int x = (int)PTHREAD_MUTEX_RECURSIVE;
+return !x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  fi
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5
+$as_echo_n "checking for a traditional japanese locale... " >&6; }
+if test "${gt_cv_locale_ja+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5
+$as_echo "$gt_cv_locale_ja" >&6; }
+  LOCALE_JA=$gt_cv_locale_ja
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5
+$as_echo_n "checking for a transitional chinese locale... " >&6; }
+if test "${gt_cv_locale_zh_CN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5
+$as_echo "$gt_cv_locale_zh_CN" >&6; }
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5
+$as_echo_n "checking for a traditional japanese locale... " >&6; }
+if test "${gt_cv_locale_ja+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5
+$as_echo "$gt_cv_locale_ja" >&6; }
+  LOCALE_JA=$gt_cv_locale_ja
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5
+$as_echo_n "checking for a transitional chinese locale... " >&6; }
+if test "${gt_cv_locale_zh_CN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5
+$as_echo "$gt_cv_locale_zh_CN" >&6; }
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+
+
+
+
+
+  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
+  # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
+  # irrelevant for anonymous mappings.
+  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = x""yes; then :
+  gl_have_mmap=yes
+else
+  gl_have_mmap=no
+fi
+
+
+  # Try to allow MAP_ANONYMOUS.
+  gl_have_mmap_anonymous=no
+  if test $gl_have_mmap = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANONYMOUS" >&5
+$as_echo_n "checking for MAP_ANONYMOUS... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANONYMOUS
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+  gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    if test $gl_have_mmap_anonymous != yes; then
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANON
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+
+$as_echo "#define MAP_ANONYMOUS MAP_ANON" >>confdefs.h
+
+         gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_mmap_anonymous" >&5
+$as_echo "$gl_have_mmap_anonymous" >&6; }
+    if test $gl_have_mmap_anonymous = yes; then
+
+$as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h
+
+    fi
+  fi
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+  case "$host_os" in
+    mingw* | pw*)
+
+
+  REPLACE_OPEN=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS open.$ac_objext"
+
+
+
+
+  :
+
+
+      ;;
+    *)
+
+  :
+
+
+
+
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5
+$as_echo_n "checking whether open recognizes a trailing slash... " >&6; }
+if test "${gl_cv_func_open_slash+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # Assume that if we have lstat, we can also check symlinks.
+          if test $ac_cv_func_lstat = yes; then
+            touch conftest.tmp
+            ln -s conftest.tmp conftest.lnk
+          fi
+          if test "$cross_compiling" = yes; then :
+
+             case "$host_os" in
+               freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
+                 gl_cv_func_open_slash="guessing no" ;;
+               *)
+                 gl_cv_func_open_slash="guessing yes" ;;
+             esac
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+int main ()
+{
+  int result = 0;
+#if HAVE_LSTAT
+  if (open ("conftest.lnk/", O_RDONLY) != -1)
+    result |= 1;
+#endif
+  if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
+    result |= 2;
+  return result;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_open_slash=yes
+else
+  gl_cv_func_open_slash=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+          rm -f conftest.sl conftest.tmp conftest.lnk
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_slash" >&5
+$as_echo "$gl_cv_func_open_slash" >&6; }
+      case "$gl_cv_func_open_slash" in
+        *no)
+
+$as_echo "#define OPEN_TRAILING_SLASH_BUG 1" >>confdefs.h
+
+
+
+  REPLACE_OPEN=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS open.$ac_objext"
+
+
+
+
+  :
+
+
+          ;;
+      esac
+      ;;
+  esac
+
+
+
+
+  GNULIB_OPEN=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_OPEN 1" >>confdefs.h
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for putenv compatible with GNU and SVID" >&5
+$as_echo_n "checking for putenv compatible with GNU and SVID... " >&6; }
+if test "${gl_cv_func_svid_putenv+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+               gl_cv_func_svid_putenv=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+
+    /* Put it in env.  */
+    if (putenv ("CONFTEST_putenv=val"))
+      return 1;
+
+    /* Try to remove it.  */
+    if (putenv ("CONFTEST_putenv"))
+      return 2;
+
+    /* Make sure it was deleted.  */
+    if (getenv ("CONFTEST_putenv") != 0)
+      return 3;
+
+    return 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_svid_putenv=yes
+else
+  gl_cv_func_svid_putenv=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_svid_putenv" >&5
+$as_echo "$gl_cv_func_svid_putenv" >&6; }
+  if test $gl_cv_func_svid_putenv = no; then
+    REPLACE_PUTENV=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS putenv.$ac_objext"
+
+  fi
+
+
+
+
+  GNULIB_PUTENV=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_PUTENV 1" >>confdefs.h
+
+
+
+
+
+  if test $HAVE_SETENV$REPLACE_SETENV != 10; then
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS setenv.$ac_objext"
+
+  fi
+
+
+
+
+  GNULIB_SETENV=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_SETENV 1" >>confdefs.h
+
+
+
+
+
+
+  case "$host_os" in
+            mingw*) REPLACE_SETLOCALE=1 ;;
+  esac
+  if test $REPLACE_SETLOCALE = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS setlocale.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_SETLOCALE=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_SETLOCALE 1" >>confdefs.h
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5
+$as_echo_n "checking for a traditional japanese locale... " >&6; }
+if test "${gt_cv_locale_ja+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5
+$as_echo "$gt_cv_locale_ja" >&6; }
+  LOCALE_JA=$gt_cv_locale_ja
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5
+$as_echo_n "checking for a transitional chinese locale... " >&6; }
+if test "${gt_cv_locale_zh_CN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5
+$as_echo "$gt_cv_locale_zh_CN" >&6; }
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5
+$as_echo_n "checking for wchar_t... " >&6; }
+if test "${gt_cv_c_wchar_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stddef.h>
+            wchar_t foo = (wchar_t)'\0';
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_c_wchar_t=yes
+else
+  gt_cv_c_wchar_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5
+$as_echo "$gt_cv_c_wchar_t" >&6; }
+  if test $gt_cv_c_wchar_t = yes; then
+
+$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h
+
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t" >&5
+$as_echo_n "checking for wint_t... " >&6; }
+if test "${gt_cv_c_wint_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
+   before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+            wint_t foo = (wchar_t)'\0';
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_c_wint_t=yes
+else
+  gt_cv_c_wint_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wint_t" >&5
+$as_echo "$gt_cv_c_wint_t" >&6; }
+  if test $gt_cv_c_wint_t = yes; then
+
+$as_echo "#define HAVE_WINT_T 1" >>confdefs.h
+
+  fi
+
+
+
+
+  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
+  # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
+  # irrelevant for anonymous mappings.
+  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = x""yes; then :
+  gl_have_mmap=yes
+else
+  gl_have_mmap=no
+fi
+
+
+  # Try to allow MAP_ANONYMOUS.
+  gl_have_mmap_anonymous=no
+  if test $gl_have_mmap = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANONYMOUS" >&5
+$as_echo_n "checking for MAP_ANONYMOUS... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANONYMOUS
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+  gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    if test $gl_have_mmap_anonymous != yes; then
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANON
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+
+$as_echo "#define MAP_ANONYMOUS MAP_ANON" >>confdefs.h
+
+         gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_mmap_anonymous" >&5
+$as_echo "$gl_have_mmap_anonymous" >&6; }
+    if test $gl_have_mmap_anonymous = yes; then
+
+$as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h
+
+    fi
+  fi
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
+  # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
+  # irrelevant for anonymous mappings.
+  ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = x""yes; then :
+  gl_have_mmap=yes
+else
+  gl_have_mmap=no
+fi
+
+
+  # Try to allow MAP_ANONYMOUS.
+  gl_have_mmap_anonymous=no
+  if test $gl_have_mmap = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANONYMOUS" >&5
+$as_echo_n "checking for MAP_ANONYMOUS... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANONYMOUS
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+  gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    if test $gl_have_mmap_anonymous != yes; then
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/mman.h>
+#ifdef MAP_ANON
+    I cant identify this map.
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "I cant identify this map." >/dev/null 2>&1; then :
+
+$as_echo "#define MAP_ANONYMOUS MAP_ANON" >>confdefs.h
+
+         gl_have_mmap_anonymous=yes
+fi
+rm -f conftest*
+
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_mmap_anonymous" >&5
+$as_echo "$gl_have_mmap_anonymous" >&6; }
+    if test $gl_have_mmap_anonymous = yes; then
+
+$as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h
+
+    fi
+  fi
+
+
+  :
+
+
+
+
+
+
+  :
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+        if test $ac_cv_func_symlink = no; then
+    HAVE_SYMLINK=0
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS symlink.$ac_objext"
+
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether symlink handles trailing slash correctly" >&5
+$as_echo_n "checking whether symlink handles trailing slash correctly... " >&6; }
+if test "${gl_cv_func_symlink_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  gl_cv_func_symlink_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <unistd.h>
+
+int
+main ()
+{
+int result = 0;
+             if (!symlink ("a", "conftest.link/"))
+               result |= 1;
+             if (symlink ("conftest.f", "conftest.lnk2"))
+               result |= 2;
+             else if (!symlink ("a", "conftest.lnk2/"))
+               result |= 4;
+             return result;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_symlink_works=yes
+else
+  gl_cv_func_symlink_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+      rm -f conftest.f conftest.link conftest.lnk2
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_symlink_works" >&5
+$as_echo "$gl_cv_func_symlink_works" >&6; }
+    if test "$gl_cv_func_symlink_works" != yes; then
+      REPLACE_SYMLINK=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS symlink.$ac_objext"
+
+    fi
+  fi
+
+
+
+
+  GNULIB_SYMLINK=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_SYMLINK 1" >>confdefs.h
+
+
+
+
+
+
+
+  if test $gl_threads_api = posix; then
+    gl_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBMULTITHREAD"
+    for ac_func in pthread_atfork
+do :
+  ac_fn_c_check_func "$LINENO" "pthread_atfork" "ac_cv_func_pthread_atfork"
+if test "x$ac_cv_func_pthread_atfork" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PTHREAD_ATFORK 1
+_ACEOF
+
+fi
+done
+
+    LIBS="$gl_save_LIBS"
+  fi
+
+
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_have_decl_unsetenv = no; then
+    HAVE_DECL_UNSETENV=0
+  fi
+  for ac_func in unsetenv
+do :
+  ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv"
+if test "x$ac_cv_func_unsetenv" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UNSETENV 1
+_ACEOF
+
+fi
+done
+
+  if test $ac_cv_func_unsetenv = no; then
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS unsetenv.$ac_objext"
+
+
+
+
+  :
+
+
+
+
+
+
+  else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsetenv() return type" >&5
+$as_echo_n "checking for unsetenv() return type... " >&6; }
+if test "${gt_cv_func_unsetenv_ret+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#undef _BSD
+#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
+#include <stdlib.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+int unsetenv (const char *name);
+#else
+int unsetenv();
+#endif
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gt_cv_func_unsetenv_ret='int'
+else
+  gt_cv_func_unsetenv_ret='void'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_unsetenv_ret" >&5
+$as_echo "$gt_cv_func_unsetenv_ret" >&6; }
+    if test $gt_cv_func_unsetenv_ret = 'void'; then
+
+$as_echo "#define VOID_UNSETENV 1" >>confdefs.h
+
+      REPLACE_UNSETENV=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS unsetenv.$ac_objext"
+
+    fi
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unsetenv obeys POSIX" >&5
+$as_echo_n "checking whether unsetenv obeys POSIX... " >&6; }
+if test "${gl_cv_func_unsetenv_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  gl_cv_func_unsetenv_works="guessing no"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+       #include <stdlib.h>
+       #include <errno.h>
+       extern char **environ;
+
+int
+main ()
+{
+
+       char entry1[] = "a=1";
+       char entry2[] = "b=2";
+       char *env[] = { entry1, entry2, NULL };
+       if (putenv ((char *) "a=1")) return 1;
+       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;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_unsetenv_works=yes
+else
+  gl_cv_func_unsetenv_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unsetenv_works" >&5
+$as_echo "$gl_cv_func_unsetenv_works" >&6; }
+    if test "$gl_cv_func_unsetenv_works" != yes; then
+      REPLACE_UNSETENV=1
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS unsetenv.$ac_objext"
+
+    fi
+  fi
+
+
+
+
+  GNULIB_UNSETENV=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_UNSETENV 1" >>confdefs.h
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5
+$as_echo_n "checking for a traditional french locale... " >&6; }
+if test "${gt_cv_locale_fr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5
+$as_echo "$gt_cv_locale_fr" >&6; }
+  LOCALE_FR=$gt_cv_locale_fr
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5
+$as_echo_n "checking for a french Unicode locale... " >&6; }
+if test "${gt_cv_locale_fr_utf8+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5
+$as_echo "$gt_cv_locale_fr_utf8" >&6; }
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional japanese locale" >&5
+$as_echo_n "checking for a traditional japanese locale... " >&6; }
+if test "${gt_cv_locale_ja+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_ja" >&5
+$as_echo "$gt_cv_locale_ja" >&6; }
+  LOCALE_JA=$gt_cv_locale_ja
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a transitional chinese locale" >&5
+$as_echo_n "checking for a transitional chinese locale... " >&6; }
+if test "${gt_cv_locale_zh_CN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+
+_ACEOF
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_zh_CN" >&5
+$as_echo "$gt_cv_locale_zh_CN" >&6; }
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+
+
+
+
+
+
+  :
+
+
+
+
+
+  if test $ac_cv_func_wctob = no; then
+    HAVE_DECL_WCTOB=0
+
+    :
+
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS wctob.$ac_objext"
+
+
+  :
+
+  else
+
+
+
+         { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wctob works" >&5
+$as_echo_n "checking whether wctob works... " >&6; }
+if test "${gl_cv_func_wctob_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+                        case "$host_os" in
+            # Guess no on Solaris <= 9 and Cygwin.
+          solaris2.[1-9] | solaris2.[1-9].* | cygwin*)
+            gl_cv_func_wctob_works="guessing no" ;;
+            # Guess yes otherwise.
+          *) gl_cv_func_wctob_works="guessing yes" ;;
+        esac
+        case "$host_os" in
+          cygwin*)
+            if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+
+register long global __asm__ ("%ebx");
+
+int main ()
+{
+  setlocale (LC_ALL, "en_US.UTF-8");
+
+  global = 0x12345678;
+  if (wctob (0x00FC) != -1)
+    return 1;
+  if (global != 0x12345678)
+    return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  :
+else
+  gl_cv_func_wctob_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+            ;;
+        esac
+        if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then
+          if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      wchar_t wc;
+
+      if (mbtowc (&wc, "\374", 1) == 1)
+        if (wctob (wc) != (unsigned char) '\374')
+          return 1;
+    }
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  gl_cv_func_wctob_works=yes
+else
+  gl_cv_func_wctob_works=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+        fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wctob_works" >&5
+$as_echo "$gl_cv_func_wctob_works" >&6; }
+    case "$gl_cv_func_wctob_works" in
+      *yes) ;;
+      *) REPLACE_WCTOB=1 ;;
+    esac
+    if test $REPLACE_WCTOB = 1; then
+
+    :
+
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS wctob.$ac_objext"
+
+
+  :
+
+    else
+
+            ac_fn_c_check_decl "$LINENO" "wctob" "ac_cv_have_decl_wctob" "
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
+   before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+
+"
+if test "x$ac_cv_have_decl_wctob" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_WCTOB $ac_have_decl
+_ACEOF
+
+      if test $ac_cv_have_decl_wctob != yes; then
+        HAVE_DECL_WCTOB=0
+
+    :
+
+      fi
+    fi
+  fi
+
+
+
+
+  GNULIB_WCTOB=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_WCTOB 1" >>confdefs.h
+
+
+
+
+
+
+  if false; then
+    REPLACE_WCTOMB=1
+  fi
+  if test $REPLACE_WCTOMB = 1; then
+
+
+
+
+
+
+
+
+  gltests_LIBOBJS="$gltests_LIBOBJS wctomb.$ac_objext"
+
+
+  :
+
+  fi
+
+
+
+
+  GNULIB_WCTOMB=$gl_module_indicator_condition
+
+
+
+$as_echo "#define GNULIB_TEST_WCTOMB 1" >>confdefs.h
+
+
+
+
+
+    YIELD_LIB=
+  if test $gl_threads_api = posix; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5
+$as_echo_n "checking for sched_yield in -lrt... " >&6; }
+if test "${ac_cv_lib_rt_sched_yield+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sched_yield ();
+int
+main ()
+{
+return sched_yield ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_rt_sched_yield=yes
+else
+  ac_cv_lib_rt_sched_yield=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_yield" >&5
+$as_echo "$ac_cv_lib_rt_sched_yield" >&6; }
+if test "x$ac_cv_lib_rt_sched_yield" = x""yes; then :
+  YIELD_LIB=-lrt
+else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lposix4" >&5
+$as_echo_n "checking for sched_yield in -lposix4... " >&6; }
+if test "${ac_cv_lib_posix4_sched_yield+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix4  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sched_yield ();
+int
+main ()
+{
+return sched_yield ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_posix4_sched_yield=yes
+else
+  ac_cv_lib_posix4_sched_yield=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_sched_yield" >&5
+$as_echo "$ac_cv_lib_posix4_sched_yield" >&6; }
+if test "x$ac_cv_lib_posix4_sched_yield" = x""yes; then :
+  YIELD_LIB=-lposix4
+fi
+
+fi
+
+  fi
+
+
+
+
+
+
+
+
+
+
+
+
+  LIBTESTS_LIBDEPS="$gltests_libdeps"
+
+
+
+for ac_func in strerror_r fsync
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ac_config_files="$ac_config_files Makefile gnulib/lib/Makefile gnulib/tests/Makefile src/Makefile man/Makefile tests/Makefile examples/Makefile doc/Makefile doc/naturaldocs/Makefile augeas.pc augeas.spec"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${ND_ENABLED_TRUE}" && test -z "${ND_ENABLED_FALSE}"; then
+  as_fn_error $? "conditional \"ND_ENABLED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${WITH_FAILMALLOC_TRUE}" && test -z "${WITH_FAILMALLOC_FALSE}"; then
+  as_fn_error $? "conditional \"WITH_FAILMALLOC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ENABLE_DEBUG_TRUE}" && test -z "${ENABLE_DEBUG_FALSE}"; then
+  as_fn_error $? "conditional \"ENABLE_DEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error $? "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${USE_VERSION_SCRIPT_TRUE}" && test -z "${USE_VERSION_SCRIPT_FALSE}"; then
+  as_fn_error $? "conditional \"USE_VERSION_SCRIPT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${GL_COND_LIBTOOL_TRUE}" && test -z "${GL_COND_LIBTOOL_FALSE}"; then
+  as_fn_error $? "conditional \"GL_COND_LIBTOOL\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+    gl_libobjs=
+    gl_ltlibobjs=
+    if test -n "$gl_LIBOBJS"; then
+      # Remove the extension.
+      sed_drop_objext='s/\.o$//;s/\.obj$//'
+      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
+        gl_libobjs="$gl_libobjs $i.$ac_objext"
+        gl_ltlibobjs="$gl_ltlibobjs $i.lo"
+      done
+    fi
+    gl_LIBOBJS=$gl_libobjs
+
+    gl_LTLIBOBJS=$gl_ltlibobjs
+
+
+
+    gltests_libobjs=
+    gltests_ltlibobjs=
+    if test -n "$gltests_LIBOBJS"; then
+      # Remove the extension.
+      sed_drop_objext='s/\.o$//;s/\.obj$//'
+      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
+        gltests_libobjs="$gltests_libobjs $i.$ac_objext"
+        gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
+      done
+    fi
+    gltests_LIBOBJS=$gltests_libobjs
+
+    gltests_LTLIBOBJS=$gltests_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by augeas $as_me 0.8.1, which was
+generated by GNU Autoconf 2.66.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+augeas config.status 0.8.1
+configured by $0, generated by GNU Autoconf 2.66,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2010 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "$fix_srcfile_path" | $SED "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in SHELL \
+ECHO \
+SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+install_override_mode \
+finish_eval \
+old_striplib \
+striplib; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "gnulib/lib/Makefile") CONFIG_FILES="$CONFIG_FILES gnulib/lib/Makefile" ;;
+    "gnulib/tests/Makefile") CONFIG_FILES="$CONFIG_FILES gnulib/tests/Makefile" ;;
+    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+    "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
+    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
+    "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
+    "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
+    "doc/naturaldocs/Makefile") CONFIG_FILES="$CONFIG_FILES doc/naturaldocs/Makefile" ;;
+    "augeas.pc") CONFIG_FILES="$CONFIG_FILES augeas.pc" ;;
+    "augeas.spec") CONFIG_FILES="$CONFIG_FILES augeas.spec" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=[    ]*/{
+h
+s///
+s/^/:/
+s/[     ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[  ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+    "libtool":C)
+
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
+#                 Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool 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 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags=""
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that protects backslashes.
+ECHO=$lt_ECHO
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Whether to use a lock for old archive extraction.
+lock_old_archive_extraction=$lock_old_archive_extraction
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Permission mode override for installation of shared libraries.
+install_override_mode=$lt_install_override_mode
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $* ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+}
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$@"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1+=\$2"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1=\$$1\$2"
+}
+
+_LT_EOF
+    ;;
+  esac
+
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..e29eb59
--- /dev/null
@@ -0,0 +1,118 @@
+AC_INIT(augeas, 0.8.1)
+AC_CONFIG_SRCDIR([src/augeas.c])
+AC_CONFIG_AUX_DIR([build/aux])
+AM_CONFIG_HEADER([config.h])
+AM_INIT_AUTOMAKE([-Wno-portability 1.11 color-tests parallel-tests])
+AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
+
+
+dnl Check for NaturalDocs
+AC_PATH_PROGS([ND_PROG], [naturaldocs NaturalDocs], missing)
+AM_CONDITIONAL([ND_ENABLED], [test "x$ND_PROG" != "xmissing"])
+
+dnl NaturalDocs output format, defaults to HTML
+ND_FORMAT=HTML
+AC_ARG_WITH([naturaldocs-output],
+  [AS_HELP_STRING([--with-naturaldocs-output=FORMAT],
+    [format of NaturalDocs output (possible values: HTML/FramedHTML, default: HTML)])],
+  [
+    if test "x$ND_PROG" = "xmissing"; then
+      AC_MSG_ERROR([NaturalDocs was not found on your path; there's no point in setting the output format])
+    fi
+    case $withval in
+       HTML|FramedHTML)
+          ND_FORMAT=$withval
+         ;;
+       *)
+          AC_MSG_ERROR($withval is not a supported output format for NaturalDocs)
+         ;;
+    esac
+  ])
+AC_SUBST(ND_FORMAT)
+
+
+dnl Check for pdflatex
+PDFDOCS=""
+AC_ARG_WITH([pdfdocs],
+  [AS_HELP_STRING([--with-pdfdocs],
+    [whether to use pdflatex to build PDF docs])],
+  [AC_PATH_PROG(PDFLATEX, pdflatex, no)
+   if test "x$PDFLATEX" = "xno"; then
+       AC_MSG_ERROR(You asked to use PDFLatex but it could not be found)
+   else
+       PDFDOCS="pdfdocs"
+   fi
+  ])
+AC_SUBST(PDFLATEX)
+AC_SUBST(PDFDOCS)
+
+dnl Support for memory tests with failmalloc
+AC_ARG_WITH([failmalloc],
+  [AS_HELP_STRING([--with-failmalloc=FAILMALLOC],
+     [enable failmalloc test targets and use the failmalloc library FAILMALLOC])],
+  [AC_SUBST([LIBFAILMALLOC], ["$with_failmalloc"])],
+  [with_failmalloc=no])
+
+AM_CONDITIONAL([WITH_FAILMALLOC], [test x$with_failmalloc != xno])
+
+dnl --enable-debug=(yes|no)
+AC_ARG_ENABLE([debug],
+              [AC_HELP_STRING([--enable-debug=no/yes],
+                             [enable debugging output])],[],[enable_debug=yes])
+AM_CONDITIONAL([ENABLE_DEBUG], test x"$enable_debug" = x"yes")
+if test x"$enable_debug" = x"yes"; then
+   AC_DEFINE([ENABLE_DEBUG], [1], [whether debugging is enabled])
+fi
+
+dnl Version info in libtool's notation
+AC_SUBST([LIBAUGEAS_VERSION_INFO], [13:1:13])
+AC_SUBST([LIBFA_VERSION_INFO], [4:3:3])
+
+AC_GNU_SOURCE
+
+AC_PROG_CC
+gl_EARLY
+AC_SYS_LARGEFILE
+
+dnl gl_INIT uses m4_foreach_w, yet that is not defined in autoconf-2.59.
+dnl In order to accommodate developers with such old tools, here's a
+dnl replacement definition.
+m4_ifndef([m4_foreach_w],
+  [m4_define([m4_foreach_w],
+    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
+
+AC_PROG_LIBTOOL
+AC_PROG_YACC
+AC_PROG_LEX
+
+AUGEAS_COMPILE_WARNINGS(maximum)
+
+## Compiler flags to be used everywhere
+AUGEAS_CFLAGS=-std=gnu99
+AC_SUBST(AUGEAS_CFLAGS)
+
+AUGEAS_CHECK_READLINE
+AC_CHECK_FUNCS([open_memstream uselocale])
+
+VERSION_SCRIPT_FLAGS=
+$(/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null) && \
+    VERSION_SCRIPT_FLAGS=-Wl,--version-script=
+test "`uname`" == "SunOS" && \
+    VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
+AC_SUBST(VERSION_SCRIPT_FLAGS)
+AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"])
+
+gl_INIT
+
+AC_CHECK_FUNCS([strerror_r fsync])
+
+AC_OUTPUT(Makefile \
+          gnulib/lib/Makefile \
+          gnulib/tests/Makefile \
+          src/Makefile \
+          man/Makefile \
+          tests/Makefile \
+          examples/Makefile \
+         doc/Makefile \
+         doc/naturaldocs/Makefile \
+          augeas.pc augeas.spec)
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644 (file)
index 0000000..b43f97a
--- /dev/null
@@ -0,0 +1,19 @@
+
+SUBDIRS = naturaldocs
+
+EXTRA_DIST = lenses.tex unambig.tex syntax/augeas.vim ftdetect/augeas.vim bcprules.sty xpath.txt
+
+vimdir = $(datadir)/vim/vimfiles
+nobase_vim_DATA = syntax/augeas.vim ftdetect/augeas.vim
+
+# PDF targets
+PDFTARGETS=lenses.pdf unambig.pdf
+
+all-local: $(PDFDOCS)
+
+pdfdocs: $(PDFTARGETS)
+%.pdf: %.tex
+       $(PDFLATEX) $<
+
+clean-local:
+       rm -f *.pdf *.aux *.log
diff --git a/doc/Makefile.in b/doc/Makefile.in
new file mode 100644 (file)
index 0000000..0766fd9
--- /dev/null
@@ -0,0 +1,1362 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = doc
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(vimdir)"
+DATA = $(nobase_vim_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = naturaldocs
+EXTRA_DIST = lenses.tex unambig.tex syntax/augeas.vim ftdetect/augeas.vim bcprules.sty xpath.txt
+vimdir = $(datadir)/vim/vimfiles
+nobase_vim_DATA = syntax/augeas.vim ftdetect/augeas.vim
+
+# PDF targets
+PDFTARGETS = lenses.pdf unambig.pdf
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu doc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-nobase_vimDATA: $(nobase_vim_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(vimdir)" || $(MKDIR_P) "$(DESTDIR)$(vimdir)"
+       @list='$(nobase_vim_DATA)'; test -n "$(vimdir)" || list=; \
+       $(am__nobase_list) | while read dir files; do \
+         xfiles=; for file in $$files; do \
+           if test -f "$$file"; then xfiles="$$xfiles $$file"; \
+           else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
+         test -z "$$xfiles" || { \
+           test "x$$dir" = x. || { \
+             echo "$(MKDIR_P) '$(DESTDIR)$(vimdir)/$$dir'"; \
+             $(MKDIR_P) "$(DESTDIR)$(vimdir)/$$dir"; }; \
+           echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(vimdir)/$$dir'"; \
+           $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(vimdir)/$$dir" || exit $$?; }; \
+       done
+
+uninstall-nobase_vimDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(nobase_vim_DATA)'; test -n "$(vimdir)" || list=; \
+       $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(vimdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(vimdir)" && rm -f $$files
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(DATA) all-local
+installdirs: installdirs-recursive
+installdirs-am:
+       for dir in "$(DESTDIR)$(vimdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-nobase_vimDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-nobase_vimDATA
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am all-local check check-am clean clean-generic \
+       clean-libtool clean-local ctags ctags-recursive distclean \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man \
+       install-nobase_vimDATA install-pdf install-pdf-am install-ps \
+       install-ps-am install-strip installcheck installcheck-am \
+       installdirs installdirs-am maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+       uninstall uninstall-am uninstall-nobase_vimDATA
+
+
+all-local: $(PDFDOCS)
+
+pdfdocs: $(PDFTARGETS)
+%.pdf: %.tex
+       $(PDFLATEX) $<
+
+clean-local:
+       rm -f *.pdf *.aux *.log
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/doc/bcprules.sty b/doc/bcprules.sty
new file mode 100644 (file)
index 0000000..8da0fe2
--- /dev/null
@@ -0,0 +1,317 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%                                                                   %%%
+%%%        BCP's latex tricks for typesetting inference rules         %%%
+%%%                                                                   %%%
+%%%                         Version 1.4                               %%%
+%%%                                                                   %%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%
+%%% This package supports two styles of rules: named and unnamed.
+%%% Unnamed rules are centered on the page.  Named rules are set so
+%%% that a series of them will have the rules centered in a vertical
+%%% column taking most of the page and the labels right-justified.
+%%% When a label would overlap its rule, the label is moved down.
+%%%
+%%% The width of the column of labels can be varied using a command of the
+%%% form
+%%%
+%%%   \typicallabel{T-Arrow-I}
+%%%
+%%% The default setting is:
+%%%
+%%%   \typicallabel{}
+%%%
+%%% In other words, the column of rules takes up the whole width of
+%%% the page: rules are centered on the centerline of the text, and no
+%%% extra space is left for the labels.
+%%%
+%%% The minimum distance between a rule and its label can be altered by a
+%%% command of the form
+%%%
+%%%   \setlength{\labelminsep}{0.5em}
+%%%
+%%% (This is the default value.)
+%%%
+%%% Examples:
+%%%
+%%% An axiom with a label in the right-hand column:
+%%%
+%%%   \infax[The name]{x - x = 0}
+%%%
+%%% An inference rule with a name:
+%%%
+%%%   \infrule[Another name]
+%%%     {\mbox{false}}
+%%%     {x - x = 1}
+%%%
+%%% A rule with multiple premises on the same line:
+%%%
+%%%   \infrule[Wide premises]
+%%%     {x > 0  \andalso y > 0  \andalso z > 0}
+%%%     {x + y + z > 0}
+%%%
+%%% A rule with several lines of premises:
+%%%
+%%%   \infrule[Long premises]
+%%%     {x > 0  \\ y > 0  \\ z > 0}
+%%%     {x + y + z > 0}
+%%%
+%%% A rule without a name, but centered on the same vertical line as rules
+%%% and axioms with names:
+%%%
+%%%   \infrule[]
+%%%     {x - y = 5}
+%%%     {y - x = -5}
+%%%
+%%% A rule without a name, centered on the page:
+%%%
+%%%   \infrule
+%%%     {x = 5}
+%%%     {x - 1 > 0}
+%%%
+%%%
+%%% Setting the flag \indexrulestrue causes an index entry to be
+%%% generated for each named rule.
+%%%
+%%% Setting the flag \suppressrulenamestrue causes the names of all rules
+%%% to be left blank
+%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%% A switch controlling the sizes of rule names
+\newif\ifsmallrulenames  \smallrulenamesfalse
+\newcommand{\smallrulenames}{\smallrulenamestrue}
+\newcommand{\choosernsize}[2]{\ifsmallrulenames#1\else#2\fi}
+
+%%% The font for setting inference rule names
+\newcommand{\rn}[1]{%
+  \ifmmode
+    \mathchoice
+      {\mbox{\choosernsize{\small}{}\sc #1}}
+      {\mbox{\choosernsize{\small}{}\sc #1}}
+      {\mbox{\choosernsize{\tiny}{\small}\sc #1}}
+      {\mbox{\choosernsize{\tiny}{\tiny}\uppercase{#1}}}%
+  \else
+    \hbox{\choosernsize{\small}{}\sc #1}%
+  \fi}
+
+\newif\ifsuppressrulenames
+\suppressrulenamesfalse
+
+\newif\ifbcprulessavespace
+\bcprulessavespacefalse
+
+\newif\ifbcprulestwocol
+\bcprulestwocolfalse
+
+%%% How to display a rule's name to the right of the rule
+\newcommand{\inflabel}[1]{%
+  \ifsuppressrulenames\else
+    \def\lab{#1}%
+    \ifx\lab\empty
+      \relax
+    \else
+      (\rn{\lab})%
+  \fi\fi
+}
+
+%%% Amount of extra space to add before and after a rule
+\newlength{\afterruleskip}
+\setlength{\afterruleskip}{\bigskipamount}
+
+%%% Minimum distance between a rule and its label
+\newlength{\labelminsep}
+\setlength{\labelminsep}{0.2em}
+
+%%% The ``typical'' width of the column of labels: labels are allowed
+%%% to project further to the left if necessary; the rules will be
+%%% centered in a column of width \linewidth - \labelcolwidth
+\newdimen\labelcolwidth
+
+%%% Set the label column width by providing a ``typical'' label --
+%%% i.e. a label of average length
+\newcommand{\typicallabel}[1]{
+  \setbox \@tempboxa \hbox{\inflabel{#1}}
+  \labelcolwidth \wd\@tempboxa
+  }
+\typicallabel{}
+
+%%% A flag controlling generation of index entries
+\newif  \ifindexrules   \indexrulesfalse
+
+%%% Allocate some temporary registers
+\newbox\@labelbox
+\newbox\rulebox
+\newdimen\ruledim
+\newdimen\labeldim
+
+%%% Put a rule and its label on the same line if this can be done
+%%% without overlapping them; otherwise, put the label on the next
+%%% line.  Put a small amount of vertical space above and below.
+\newcommand{\layoutruleverbose}[2]%
+  {\unvbox\voidb@x  % to make sure we're in vmode
+   \addvspace{\afterruleskip}%
+
+   \setbox \rulebox \hbox{$\displaystyle #2$}
+
+   \setbox \@labelbox \hbox{#1}
+   \ruledim \wd \rulebox
+   \labeldim \wd \@labelbox
+
+   %%% Will it all fit comfortably on one line?
+   \@tempdima \linewidth
+   \advance \@tempdima -\labelcolwidth
+   \ifdim \@tempdima < \ruledim
+     \@tempdima \ruledim
+   \else
+     \advance \@tempdima by \ruledim
+     \divide \@tempdima by 2
+   \fi
+   \advance \@tempdima by \labelminsep
+   \advance \@tempdima by \labeldim
+   \ifdim \@tempdima < \linewidth
+     % Yes, everything fits on a line
+     \@tempdima \linewidth
+     \advance \@tempdima -\labelcolwidth
+     \hbox to \linewidth{%
+       \hbox to \@tempdima{%
+         \hfil
+         \box\rulebox
+         \hfil}%
+       \hfill
+       \hbox to 0pt{\hss\box\@labelbox}%
+     }%
+   \else
+   %
+   % Will it all fit _UN_comfortably on one line?
+   \@tempdima 0pt
+   \advance \@tempdima by \ruledim
+   \advance \@tempdima by \labelminsep
+   \advance \@tempdima by \labeldim
+   \ifdim \@tempdima < \linewidth
+     % Yes, everything fits, but not centered
+     \hbox to \linewidth{%
+         \hfil
+         \box\rulebox
+         \hskip \labelminsep
+         \box\@labelbox}%
+   \else
+   %
+   % Better put the label on the next line
+     \@tempdima \linewidth
+     \advance \@tempdima -\labelcolwidth
+     \hbox to \linewidth{%
+       \hbox to \@tempdima{%
+          \hfil
+          \box\rulebox
+          \hfil}
+       \hfil}%
+     \penalty10000
+     \hbox to \linewidth{%
+         \hfil
+         \box\@labelbox}%
+   \fi\fi
+
+   \addvspace{\afterruleskip}%
+   \@doendpe  % use LaTeX's trick of inhibiting paragraph indent for
+              % text immediately following a rule
+   \ignorespaces
+   }
+
+% Simplified form for when there is no label
+\newcommand{\layoutrulenolabel}[1]%
+  {\unvbox\voidb@x  % to make sure we're in vmode
+   \addvspace{\afterruleskip}%
+
+   \setbox \rulebox \hbox{$\displaystyle #1$}
+
+   \@tempdima \linewidth
+   \advance \@tempdima -\labelcolwidth
+   \hbox to \@tempdima{%
+      \hfil
+      \box\rulebox
+      \hfil}%
+
+   \addvspace{\afterruleskip}%
+   \@doendpe  % use LaTeX's trick of inhibiting paragraph indent for
+              % text immediately following a rule
+   \ignorespaces
+   }
+
+% Alternate form, for when we need to save space
+%\newcommand{\layoutruleterse}[2]%
+%  {\noindent
+%   \parbox[b]{0.5\linewidth}{\layoutruleverbose{#1}{#2}}}
+
+\newcommand{\layoutruleterse}[2]%
+  {\setbox \rulebox \hbox{$\displaystyle #2$}
+   \noindent
+   \parbox[b]{0.5\linewidth}
+    {\vspace*{0.4em} \hfill\box\rulebox\hfill~}
+   }
+
+%%% Select low-level layout driver based on \bcprulessavespace flag
+\newcommand{\layoutrule}[2]{%
+      \ifbcprulessavespace
+        \layoutruleterse{#1}{#2}
+      \else
+        \layoutruleverbose{#1}{#2}
+      \fi
+}
+
+%%% Highlighting for new versions of rules
+\newif\ifnewrule   \newrulefalse
+\newcommand{\setrulebody}[1]{%
+  \ifnewrule
+     \@ifundefined{HIGHLIGHT}{%
+        \fbox{\ensuremath{#1}}%
+     }{%
+        \HIGHLIGHT{#1}}%
+  \else
+     #1
+  \fi
+}
+
+%%% Commands for setting axioms and rules
+\newcommand{\typesetax}[1]{%
+   \setrulebody{%
+     \begin{array}{@{}c@{}}#1\end{array}}}
+\newcommand{\typesetrule}[2]{%
+   \setrulebody{%
+      \frac{\begin{array}{@{}c@{}}#1\end{array}}%
+           {\begin{array}{@{}c@{}}#2\end{array}}}}
+
+%%% Indexing
+\newcommand{\ruleindexprefix}[1]{%
+  \gdef\ruleindexprefixstring{#1}}
+\ruleindexprefix{}
+\newcommand{\maybeindex}[1]{%
+  \ifindexrules
+    \index{\ruleindexprefixstring#1@\rn{#1}}%
+  \fi}
+
+%%% Setting axioms, with or without names
+\def\infax{\@ifnextchar[{\@infaxy}{\@infaxx}}
+\def\@infaxx#1{%
+  \ifbcprulessavespace $\typesetax{#1}$%
+  \else \layoutrulenolabel{\typesetax{#1}}%
+  \fi\newrulefalse\ignorespaces}
+\def\@infaxy[#1]{\maybeindex{#1}\@infax{\inflabel{#1}}}
+\def\@infax#1#2{\layoutrule{#1}{\typesetax{#2}}\ignorespaces}
+
+%%% Setting rules, with or without names
+\def\infrule{\@ifnextchar[{\@infruley}{\@infrulex}}
+\def\@infrulex#1#2{%
+  \ifbcprulessavespace $\typesetrule{#1}{#2}$%
+  \else \layoutrulenolabel{\typesetrule{#1}{#2}}%
+  \fi\newrulefalse\ignorespaces}
+\def\@infruley[#1]{\maybeindex{#1}\@infrule{\inflabel{#1}}}
+\def\@infrule#1#2#3{\layoutrule{#1}{\typesetrule{#2}{#3}}\ignorespaces}
+
+%%% Miscellaneous helpful definitions
+\newcommand{\andalso}{\quad\quad}
+
+% Abbreviations
+\newcommand{\infabbrev}[2]{\infax{#1 \quad\eqdef\quad #2}}
+
diff --git a/doc/ftdetect/augeas.vim b/doc/ftdetect/augeas.vim
new file mode 100644 (file)
index 0000000..7120691
--- /dev/null
@@ -0,0 +1 @@
+au BufNewFile,BufRead *.aug set filetype=augeas
diff --git a/doc/lenses.tex b/doc/lenses.tex
new file mode 100644 (file)
index 0000000..4559e43
--- /dev/null
@@ -0,0 +1,437 @@
+\documentclass[12pt,fleqn]{amsart}
+
+\usepackage{amsmath}
+\usepackage{xspace}
+\usepackage{amssymb}
+\usepackage{bcprules}
+
+\newcommand{\ensmath}[1]{\ensuremath{#1}\xspace}
+
+\newcommand{\opnam}[1]{\ensmath{\operatorname{\mathit{#1}}}}
+\newcommand{\nget}{\opnam{get}}
+\newcommand{\nput}{\opnam{put}}
+\newcommand{\nparse}{\opnam{parse}}
+\newcommand{\ncreate}{\opnam{create}}
+\newcommand{\nkey}{\opnam{key}}
+\newcommand{\lget}[1]{\opnam{get}{#1}}
+\newcommand{\lparse}[1]{\nparse{#1}}
+\newcommand{\lput}[2]{\opnam{put}{#1}\,{(#2)}}
+\newcommand{\lcreate}[2]{\opnam{create}{#1}\,{(#2)}}
+\newcommand{\lkey}[1]{\nkey{#1}}
+
+\newcommand{\suff}{\ensmath{\operatorname{suff}}}
+\newcommand{\pref}{\ensmath{\operatorname{pref}}}
+\newcommand{\lenstype}[3][K]{\ensmath{{#2}\stackrel{#1}{\Longleftrightarrow}{#3}}}
+\newcommand{\tree}[1]{\ensmath{[#1]}}
+\newcommand{\niltree}{\ensmath{[]}}
+\newcommand{\nildict}{\ensmath{\{\!\}}}
+\newcommand{\Regexp}{\ensmath{\mathcal R}}
+\newcommand{\reglang}[1]{\ensmath{[\![{#1}]\!]}}
+\newcommand{\lens}[1]{\opnam{#1}}
+\newcommand{\eps}{\ensmath{\epsilon}}
+\newcommand{\conc}[2]{\ensmath{#1\cdot #2}}
+\newcommand{\uaconc}[2]{\ensmath{#1\cdot^{!} #2}}
+\newcommand{\xconc}[2]{\ensmath{#1\odot #2}}
+\newcommand{\dconc}[2]{\ensmath{#1\oplus #2}}
+\newcommand{\alt}[2]{\ensmath{#1\,|\,#2}}
+\newcommand{\cstar}[1]{\ensmath{#1^*}}
+\newcommand{\uastar}[1]{\ensmath{#1^{!*}}}
+\newcommand{\Trees}{\ensmath{\mathcal T}}
+\newcommand{\Words}{\ensmath{\Sigma^*_{\rhd}}}
+\newcommand{\tmap}[2]{\ensmath{#1\mapsto #2}}
+\newcommand{\tmapv}[3]{\ensmath{#1 = #2\mapsto #3}}
+\newcommand{\tmaptt}[2]{\ensmath{{\mathtt #1}\mapsto {\mathtt #2}}}
+\newcommand{\dom}[1]{\ensmath{\mathrm{dom}(#1)}}
+\newcommand{\List}[1]{\ensmath{\mathtt{List(#1)}}}
+\newcommand{\redigits}{\ensmath{\mathtt{D}}}
+\newcommand{\Skel}{\ensmath{\mathcal{S}}}
+\newcommand{\Powerset}{\ensmath{\mathcal{P}}}
+\newcommand{\Keys}{\ensmath{\mathcal{K}}}
+\newcommand{\key}[1]{\ensmath{\kappa(#1)}}
+\newcommand{\lto}{\ensmath{\longrightarrow}}
+\newcommand{\Dictlangs}{\ensmath{\List{\Powerset(\Skel)}}}
+\newcommand{\lookup}{\opnam{lookup}}
+
+\newtheorem{theorem}{Theorem}
+\newtheorem{lemma}[theorem]{Lemma}
+{\theoremstyle{definition}
+  \newtheorem{defn}{Definition}
+  \newtheorem*{remark}{Remark}
+  \newtheorem*{example}{Example}}
+
+\begin{document}
+
+\section{Trees}
+We use trees as the abstract view for our lenses; since the concrete data
+structure, strings, is ordered, and to support some properties of lenses
+that seem sensible intuitively, the trees differ from garden-variety trees
+in a number of ways:
+\begin{itemize}
+  \item a tree node consists of three pieces of data: a \emph{label}, a
+    \emph{value} and an ordered list of \emph{children}, each of them a
+    tree by themselves.
+  \item the labels for tree nodes are either words not containing a slash
+    {\tt /} or the special symbol $\rhd$; in the implementation $\rhd$
+    corresponds to {\tt NULL}. The latter is used to indicate
+    that an entry in the tree corresponds to text that was deleted.
+  \item the children of a tree node form a list of subtrees, i.e. are
+    ordered. In addition, several subtrees in such a list may use the same
+    label. This makes it possible to accomodate concrete files where
+    entries that are logically connected are stored scattered between
+    unrelated entries like hte {\tt AcceptEnv} entries in {\tt
+      sshd\_config}.
+\end{itemize}
+
+We write $\tmapv{k}{v}{t}$ for a tree node with label $k$, value $v$ and
+children $t$. If it is clear from the context, or unimportant, $v$ will
+often be omitted.
+
+\subsection{Tree labels}
+We take the tree labels from the set of \emph{path components} $\Keys =
+(\Sigma \setminus \{ {\mathtt /} \})^+ \cup \{ \rhd \}$, that is,
+a tree label is any word not containing a backslash or the special symbol
+$\rhd$. For tree labels, we define a partial concatenation operator
+$\odot$, as
+\begin{equation*}
+  \xconc{k_1}{k_2} = \begin{cases}
+    k_1 & \text{if } k_2 = \rhd\\
+    k_2 & \text{if } k_1 = \rhd\\
+    \text{undefined} & \text{otherwise}
+  \end{cases}
+\end{equation*}
+
+Defining tree labels in this way (1) guarantees that there is a
+one--to--one correspondence between a tree label and the word it came from
+in the concrete text and (2) avoids any pain in splitting tree labels in
+the \nput direction.
+
+\subsection{Trees}
+The set of \emph{ordered trees} \Trees over $\Words$ is recursively
+defined as
+\begin{itemize}
+\item The empty tree $\rhd$
+\item For any words $k\in\Keys$, $v\in\Words$ and any tree $t\in\Trees$,
+  $\tree{\tmapv{k}{v}{t}}$ is in \Trees
+\item For any $n$ and trees $\tree{\tmapv{k_i}{v_i}{t_i}} \in Trees$,
+  the list
+  $[\tmapv{k_1}{v_1}{t_1};\tmapv{k_2}{v_2}{t_2};\ldots;\tmapv{k_n}{v_n}{t_n}]$
+  is in \Trees
+\end{itemize}
+
+Note that this allows the same key to be used multiple times in a tree; for
+example, $[\tmaptt{a}{x}; \tmaptt{a}{x}]$ is a valid tree and
+different from $[\tmaptt{a}{x}]$.
+
+The domain of a tree $\dom{t}$ is the list of all its labels, i.e. an
+element of $\List{\Keys}$; for a tree $t =
+\tree{\tmap{k_1}{t_1};\ldots;\tmap{k_n}{t_n}}$, $\dom{t} =
+     [k_1;\ldots;k_n].$
+
+%% Why ?
+%A tree $t$ can also be viewed as a total map from \Words to
+%$\List{\Trees\cup\Words}$, defined as
+%\begin{equation*}
+%  t(k) =
+%  \begin{cases}
+%    v & \text{for } t = \tree{v}\\
+%    [t_1] :: t_2(k) & \text{for } t = t' :: t_2
+%                      \text{ and } t' = \tree{\tmap{k}{t_1}}\\
+%    t_2(k) & \text{for } t = t' :: t_2
+%             \text{ and } t' = \tree{\tmap{k'}{t_1}} \text{with } k\neq k'
+%  \end{cases}
+%\end{equation*}
+%
+%Note that this definition implies that for a tree $t = \tree{\tmap{k}{v}}$
+%with $k,v\in\Words$, $t(k)=[v].$ For the tree $t_{\mathtt{aa}} = [\tmaptt{a}{x};
+%  \tmaptt{a}{x}]$, $t_{\mathtt{aa}}(\mathtt a) = [\mathtt x; \mathtt x]$.
+
+The concatenation of trees $\conc{t_1}{t_2}$ is simply list concatenation.
+
+For sets $K\subset\Keys$ and $T\subset\Trees$, $\tree{\tmap{K}{T}}$
+denotes the set of all trees $t = \tree{\tmap{k}{t'}}$ with $k\in K$, $t'
+\in T$.
+
+\subsection{Concatenation and iteration}
+For a tree $t\in \Trees$, we define its underlying \emph{key language}
+$\key{t}$ by
+\begin{equation*}
+  \key{t} = \begin{cases}
+    {\tt /} & \text{if } t = \rhd \text{ or } t = \tree{\tmap{\rhd}{t_1}}\\
+    k \cdot {\mathtt /} & \text{if } t = \tree{\tmap{k}{t_1}}\\
+    k\cdot {\mathtt /}\cdot \key{t_2} & \text{for } t = \tree{\tmap{k}{t_1};t_2}
+  \end{cases}
+\end{equation*}
+where $\conc{k_1}{k_2}$ is normal string concatenation. The key language of
+a set of trees $\key{T}$ is defined as $\{\key{t} | t \in T\}$.
+
+In analogy to languages, we call two tree sets $T_1, T_2 \subseteq \Trees$
+\emph{unambiguously concatenable} if the key languages $\key{T_1}$ and
+$\key{T_2}$ are unambiguously concatenable. A tree set $T\in\Trees$ is
+\emph{unambiguously iterable} if the underlying key language $\key{T}$ is
+unambiguously iterable.
+
+\subsection{Public tree operations}
+We need the public API to support the following operations. The set
+$P\subseteq \Sigma^*$ are paths
+
+\begin{itemize}
+  \item $\opnam{lookup}(p, t): P \times \Trees \lto \Trees$ finds the tree
+    with path $p$
+  \item $\opnam{assign}(p, v, t): P \times \Sigma^* \times \Trees \lto
+    \Trees$ assigns the value $v$ to the tree node $p$
+  \item $\opnam{remove}(p, t): P \times \Trees \lto \Trees$ removes the
+    subtree denoted by $p$
+  \item $\opnam{get}(p, t): P \times \Trees \lto \Sigma^*$ looks up the
+    value associated with $p$
+    \item $\opnam{ls}(p, t): P \times \Trees \lto \List{\Trees}$ lists all
+      the subtrees underneath $p$
+\end{itemize}
+
+\section{Lenses}
+
+Lenses map between strings in the regular language $C$ and trees
+$T\subseteq\Trees$. They can also produce keys from a regular language $K$;
+these keys are used by the $\lens{subtree}$ lens to construct new
+trees.
+
+A lens $l$ consists of the functions $\nget$, $\nput$, $\ncreate$, and
+$\nparse$.
+
+Lenses here are written as $l:\lenstype[K,S,L]{C}{T}$ where $K$ and $C$ are
+regular languages and $T\subseteq\Trees$.  The skeletons $S\subseteq\Skel$
+and dictionary type specifications $L$ are as for Boomerang (really ??)
+Intuitively, the notation says that $l$ is a lens that takes strings from
+$C$ and transforms them to trees in $T$. Generally,
+
+\infrule{C\subseteq\Words \andalso K\subseteq\List{\Keys}
+           \andalso T\subseteq\Trees
+           \andalso S\subseteq\Skel \andalso L \in \Dictlangs}
+        {\lens{l} \in \lenstype[K,S,L]{C}{T}}
+
+\begin{align*}
+  \nget &\in C \lto T\\
+  \nparse &\in C \lto K \times S \times D(L)\\
+  \nput &\in T \lto K \times S \times D(L) \lto C \times D(L)\\
+  \ncreate &\in T \lto K \times D(L) \lto C \times D(L)
+\end{align*}
+
+\subsection{const}
+
+The $\lens{const} E\,t\,v$ maps words mathcing $E$ in the \nget direction
+to a fixed tree $t$ and maps that fixed tree $t$ back in the \nput
+direction. When text needs to be created from $t$, it produces the default
+word $v$.
+
+\infrule{E\in\Regexp \andalso t\in T\andalso u\in\reglang{E} \andalso L \in \Dictlangs}
+        {\lens{const} E\,t\,u \in \lenstype[\rhd,\reglang{E},L]{\reglang{E}}{\{t\}}}
+
+\begin{align*}
+  \lget{c} &= t\\
+  \lparse{c} &= \rhd, c, \nildict\\
+  \lput{t}{k,s,d} &= s, d\\
+  \lcreate{t}{k,d} &= u, d
+\end{align*}
+
+The \lens{del} lens is syntactic sugar: $\lens{del} E\,u = \lens{const}
+E\,\niltree\,u$.
+
+\subsection{copy}
+
+Copies a word into a leaf.
+
+\infrule{E\in\Regexp \andalso L\in\Dictlangs}
+        {\lens{copy}\in\lenstype[\rhd,\reglang{E},L]{\reglang{E}}{\tree{\reglang{E}}}}
+
+\begin{align*}
+  \lget{c} &= \tree{c}\\
+  \lparse{c} &= \rhd, c, \nildict\\
+  \lput{\tree{v}}{k,s,d} &= v, d\\
+  \lcreate{\tree{v}}{k,d} &= v, d
+\end{align*}
+
+\subsection{seq}
+
+Gets the next value from a sequence as the key. We assume there's a
+generator $\mathtt{nextval}: \Sigma^* \to \mathbb{N}$ that returns
+successive numbers on each invocation. \redigits is the regular expresion
+{\tt [0-9]+} that matches positive numbers.
+
+\infrule{w\in\Sigma^* \andalso L\in\Dictlangs \andalso n = \mathtt{nextval}(w)}
+        {\lens{seq} w\in\lenstype[\reglang{\redigits},\eps,L]{\eps}{\niltree}}
+
+\begin{align*}
+  \lget{\eps} &= \niltree\\
+  \lparse{\eps} &= n, \eps, \nildict\\
+  \lput{\niltree}{k,\eps,d} &= \eps, d\\
+  \lcreate{\niltree}{k,d} &= \eps,d
+\end{align*}
+
+\subsection{label}
+
+Uses a fixed tree label
+
+\infrule{w\in\Sigma^* \andalso L\in\Dictlangs}
+        {\lens{label} w\in\lenstype[w,\eps,L]{\eps}{\niltree}}
+
+\begin{align*}
+  \lget{\eps} &= \niltree\\
+  \lparse{\eps} &= w,\eps,\nildict\\
+  \lput{\niltree}{w,\eps,d} &= \eps,d\\
+  \lcreate{\niltree}{k,d} &= \eps,d
+\end{align*}
+
+\subsection{key}
+
+Uses a parsed tree label
+
+\infrule{E\in\Regexp \andalso L\in\Dictlangs}
+        {\lens{key} E\in\lenstype[\reglang{E},\eps,L]{\reglang{E}}{\niltree}}
+
+\begin{align*}
+  \lget{c} &= \niltree\\
+  \lparse{c} &= c,\eps,\nildict\\
+  \lput{\niltree}{c,\eps,d} &= c,d\\
+  \lcreate{\niltree}{c, d} &= c,d
+\end{align*}
+
+\subsection{subtree}
+
+The subtree combinator $[l]$ constructs a subtree from $l$
+
+\infrule{l\in\lenstype[K,S,L]{C}{T}}
+        {[l]\in\lenstype[\rhd,\square,S::L]{C}{\tree{\tmap{K}{T}}}}
+
+\begin{align*}
+  \lget{c} &= \tree{\tmap{l.\lkey{c}}{l.\lget{c}}}\\
+  \lparse{c} &= \rhd, \square, \{\tmap{l.\lkey{c}}{[l.\lparse{c}]}\}\\
+  \lput{\tree{\tmap{k}{t}}}{k',\square,d} &=
+  \begin{cases}
+    \pi_1\left(l.\lput{t}{k,\bar{s},\bar{d}}\right),d' & \text{if } (\bar{k}, \bar{s}, \bar{d}), d' = \lookup(k, d)\\
+    \pi_1\left(l.\lcreate{t}{k,\nildict}\right), d & \text{if } \lookup(k,
+    d) \text{ undefined}
+  \end{cases}\\
+  \lcreate{\tree{\tmap{k}{t}}}{k',d} &= \lput{\tree{\tmap{k}{t}}}{k',\square,d}
+\end{align*}
+
+We store a triple $(k,s,d)$ in dictionaries, but we don't use the stored
+key $k$.
+
+\subsection{concat}
+
+The concat combinator $\conc{l_1}{l_2}$ joins two trees.
+
+\infrule{l_1\in\lenstype[K_1,S_1,L]{C_1}{T_1}
+         \andalso l_2\in\lenstype[K_2,S_2,L]{C_2}{T_2}
+         \andalso \uaconc{C_1}{C_2}
+         \andalso \uaconc{\key{T_1}}{\key{T_2}}}
+        {\conc{l_1}{l_2}\in\lenstype[\conc{K_1}{K_2},S_1\times S_2, L]{\conc{C_1}{C_2}}{\conc{T_1}{T_2}}}
+
+\begin{align*}
+  \lget{(\conc{c_1}{c_2})} &= \conc{(l_1.\lget{c_1})}{(l_2.\lget{c_2})}\\
+  \lparse{\conc{c_1}{c_2}} &= \xconc{k_1}{k_2}, (s_1,s_2), \dconc{d_1}{d_2} \\
+  \lput{\conc{t_1}{t_2}}{k, (s_1,s_2), d_1} &= \conc{c_1}{c_2}, d_3 \\
+  & \text{where } c_i, d_{i+1} = l_i.\lput{t_i}{k, s_i, d_i} \\
+  \lcreate{\conc{t_1}{t_2}}{k, d_1} &= \conc{c_1}{c_2}, d_3\\
+    & \text{where } c_i, d_{i+1} = l_i.\lcreate{t_i}{k, d_i}
+\end{align*}
+
+\subsection{union}
+
+The union combinator $\alt{l_1}{l_2}$ chooses.
+
+\infrule{l_i\in\lenstype[K_i,S_i,L]{C_i}{T_i}\text{ for } i=1,2
+  \andalso C_1 \cap C_2 = \emptyset
+  \andalso S_1 \cap S_2 = \emptyset
+  \andalso \key{T_1} \cap \key{T_2} = \emptyset}
+  {\alt{l_1}{l_2}\in\lenstype[K_1\cup K_2, S_1\cup S_2, L]{C_1 \cup C_2}{T_1 \cup T_2}}
+
+\begin{align*}
+  \lget{c} &=
+     \begin{cases}
+       l_1.\lget{c} & \text{if } c \in C_1\\
+       l_2.\lget{c} & \text{if } c \in C_2\\
+     \end{cases}
+  \\
+  \lparse{c} &=
+     \begin{cases}
+       l_1.\lparse{c} & \text{if } c \in C_1\\
+       l_2.\lparse{c} & \text{if } c \in C_2\\
+     \end{cases}
+  \\
+  \lput{t}{k, s, d} &=
+     \begin{cases}
+       l_1.\lput{t}{k, s, d} & \text{if } t, s \in T_1 \times S_1 \\
+       l_2.\lput{t}{k, s, d} & \text{if } t, s \in T_2 \times S_2 \\
+       l_1.\lcreate{t}{k, d} & \text{if } t, s \in (T_1\setminus T_2)
+       \times S_2\\
+       l_2.\lcreate{t}{k, d} & \text{if } t, s \in (T_2\setminus T_1)
+       \times S_1
+     \end{cases}\\
+  \lcreate{t}{k, d} &=
+     \begin{cases}
+       l_1.\lcreate{t}{k, d} & \text{if } t\in T_1\\
+       l_2.\lcreate{t}{k, d} & \text{if } t\in T_2\setminus T_1
+     \end{cases}
+\end{align*}
+
+\subsection{star}
+
+The star combinator $\cstar{l}$ iterates.
+
+\infrule{l\in\lenstype{C}{T} \andalso \uastar{C} \andalso \uastar{\key{T}}}
+        {\cstar{l}\in\lenstype[\cstar{K}]{\cstar{C}}{\cstar{T}}}
+
+\begin{align*}
+  \lget{c_1\cdots c_n} &= (l.\lget{c_1}) \cdots (l.\lget{c_n})\\
+  \lparse{c_1\cdots c_n} &= k_1\odot\ldots\odot k_n, [s_1;\ldots;s_n],
+                            d_1\oplus\ldots\oplus d_n\\
+                            & \text{where } k_i,s_i,d_i = l.\lparse{c_i}\\
+  \lput{t_1\cdots t_n}{k, [s_1;\cdots;s_m], d_1} &= (c_1 \cdots c_n), d_{n+1}\\
+  \text{where } &c_i, d_{i+1} =
+    \begin{cases}
+      l.\lput{t_i}{k, s_i, d_i} & \text{for } 1 \leq i \leq \min(m,n)\\
+      l.\lcreate{t_i}{k, d_i} & m+1 \leq i \leq n
+    \end{cases}\\
+  \lcreate{t_1 \cdots t_n}{k, d_1} &= (c_1\cdots c_n), d_{n+1}\\
+  & \text{where } c_i, d_{i+1} = l.\lcreate{t_i}{k, d_i}
+\end{align*}
+
+Want reordering and insertion in the middle to be reflected. If
+$\lget{\conc{c_1}{c_2}} = \conc{t_1}{t_2}$, want
+$\lput{(\conc{t_2}{t_1})}{\conc{c_1}{c_2}} =
+\conc{l.\lput{t_2}{c_2}}{l.\lput{t_1}{c_1}}$ This can only happen if the
+information to be reordered is in subtrees. In particular, comment lines
+need to become their own subtree, with some support from the language to
+create 'hidden' entries. Simplest: allow {\tt NULL} as the key for a
+subtree and ignore such tree entries in the public API.
+
+Need to split a tree $t\in T$ into subtrees according to ?? Keeping a fake
+'slot' $\rhd$ around for text that didn't produce a tree should help with
+that.
+
+For $K^*$ to make any sense, must have $\rhd\in K$ and the application of
+$(l^*).\nparse$ must return $\rhd$ for all except at most one application.
+
+\section{Regular expressions and languages}
+
+For type checking, we need to compute the following properties of regular
+languages $R, R_1, R_2$
+\begin{itemize}
+\item decide unamibuguous concatenation $\uaconc{R_1}{R_2}$ and compute
+  $\conc{R_1}{R_2}$
+\item decide unambiguous iteration $\uastar{R}$ and compute $R^*$
+\item disjointness $R_1 \cap R_2 = \emptyset$ (we don't need general
+  intersection, though I don't know of a quicker way to decide
+  disjointness)
+\item compute the regular language $R = \reglang{E}$ for a regular
+  expression $E\in\Regexp$
+\end{itemize}
+\end{document}
+
+%% TeX-parse-self: t
+%% TeX-auto-save: t
+
+%% Local Variables:
+%% TeX-master: "lenses.tex"
+%% compile-command: "pdflatex -file-line-error -halt-on-error lenses.tex"
+%% End:
diff --git a/doc/naturaldocs/Makefile.am b/doc/naturaldocs/Makefile.am
new file mode 100644 (file)
index 0000000..342f308
--- /dev/null
@@ -0,0 +1,54 @@
+
+EXTRA_DIST = $(wildcard conf/Augeas.css conf/c_api/*.txt) \
+             $(wildcard conf/lenses/*.txt) \
+             Modules/NaturalDocs/Languages/Augeas.pm
+
+ND_CONF=$(srcdir)/conf
+ND_OUTPUT=output
+ND_STYLE=../Augeas
+
+ND_PERL5LIB=$(abs_srcdir)/Modules
+ND_PERL5OPT='-MNaturalDocs::Languages::Augeas'
+
+if ND_ENABLED
+all-local: NaturalDocs
+endif
+
+NaturalDocs: NDLenses NDCAPI
+
+env:
+       echo LIB $(ND_PERL5LIB)
+       echo OPT $(ND_PERL5OPT)
+       test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+       test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+        PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT env | grep PERL
+
+NDLenses: NDConf
+       @mkdir -p $(ND_OUTPUT)/lenses
+       @(echo "Format lens documentation"; \
+         test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+         test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+         PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT \
+          $(ND_PROG) -p conf/lenses \
+             -i $(top_srcdir)/lenses \
+             -o $(ND_FORMAT) $(ND_OUTPUT)/lenses \
+             -s $(ND_STYLE))
+
+NDCAPI: NDConf
+       @mkdir -p $(ND_OUTPUT)/c_api
+       @(echo "Format C API documentation"; \
+         test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+         test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+         $(ND_PROG) -p conf/c_api \
+           -i $(top_srcdir)/src \
+           -o $(ND_FORMAT) $(ND_OUTPUT)/c_api \
+           -s $(ND_STYLE))
+
+NDConf:
+       @(if test ! -d $(ND_CONF); then \
+           cp -pr $(ND_CONF) conf; \
+         fi)
+
+clean-local:
+       rm -rf output conf/Data
+       rm -rf $(ND_CONF)/c_api/Data $(ND_CONF)/lenses/Data
diff --git a/doc/naturaldocs/Makefile.in b/doc/naturaldocs/Makefile.in
new file mode 100644 (file)
index 0000000..dec5bf1
--- /dev/null
@@ -0,0 +1,1145 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = doc/naturaldocs
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = $(wildcard conf/Augeas.css conf/c_api/*.txt) \
+             $(wildcard conf/lenses/*.txt) \
+             Modules/NaturalDocs/Languages/Augeas.pm
+
+ND_CONF = $(srcdir)/conf
+ND_OUTPUT = output
+ND_STYLE = ../Augeas
+ND_PERL5LIB = $(abs_srcdir)/Modules
+ND_PERL5OPT = '-MNaturalDocs::Languages::Augeas'
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/naturaldocs/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu doc/naturaldocs/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+@ND_ENABLED_FALSE@all-local:
+all-am: Makefile all-local
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am all-local check check-am clean clean-generic \
+       clean-libtool clean-local distclean distclean-generic \
+       distclean-libtool distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       uninstall uninstall-am
+
+
+@ND_ENABLED_TRUE@all-local: NaturalDocs
+
+NaturalDocs: NDLenses NDCAPI
+
+env:
+       echo LIB $(ND_PERL5LIB)
+       echo OPT $(ND_PERL5OPT)
+       test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+       test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+        PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT env | grep PERL
+
+NDLenses: NDConf
+       @mkdir -p $(ND_OUTPUT)/lenses
+       @(echo "Format lens documentation"; \
+         test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+         test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+         PERL5LIB=$$ND_PERL5LIB PERL5OPT=$$ND_PERL5OPT \
+          $(ND_PROG) -p conf/lenses \
+             -i $(top_srcdir)/lenses \
+             -o $(ND_FORMAT) $(ND_OUTPUT)/lenses \
+             -s $(ND_STYLE))
+
+NDCAPI: NDConf
+       @mkdir -p $(ND_OUTPUT)/c_api
+       @(echo "Format C API documentation"; \
+         test -n "$$PERL5OPT" && ND_PERL5OPT="$(ND_PERL5OPT) $$PERL5OPT" || ND_PERL5OPT=$(ND_PERL5OPT); \
+         test -n "$$PERL5LIB" && ND_PERL5LIB="$(ND_PERL5LIB):$$PERL5LIB" || ND_PERL5LIB=$(ND_PERL5LIB); \
+         $(ND_PROG) -p conf/c_api \
+           -i $(top_srcdir)/src \
+           -o $(ND_FORMAT) $(ND_OUTPUT)/c_api \
+           -s $(ND_STYLE))
+
+NDConf:
+       @(if test ! -d $(ND_CONF); then \
+           cp -pr $(ND_CONF) conf; \
+         fi)
+
+clean-local:
+       rm -rf output conf/Data
+       rm -rf $(ND_CONF)/c_api/Data $(ND_CONF)/lenses/Data
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/doc/naturaldocs/Modules/NaturalDocs/Languages/Augeas.pm b/doc/naturaldocs/Modules/NaturalDocs/Languages/Augeas.pm
new file mode 100644 (file)
index 0000000..42035f2
--- /dev/null
@@ -0,0 +1,82 @@
+###############################################################################
+#
+#   Class: NaturalDocs::Languages::Augeas
+#
+###############################################################################
+#
+#   A subclass to handle the language variations of Tcl.
+#
+###############################################################################
+
+# This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
+# Natural Docs is licensed under the GPL
+
+use strict;
+use integer;
+
+package NaturalDocs::Languages::Augeas;
+
+use base 'NaturalDocs::Languages::Simple';
+
+
+my $pastFirstLet;
+
+
+sub OnCode #(...)
+   {
+   my ($self, @params) = @_;
+
+   $pastFirstLet = 0;
+
+   return $self->SUPER::OnCode(@params);
+   };
+
+
+#
+#   Function: OnPrototypeEnd
+#
+#   Tcl's function syntax is shown below.
+#
+#   > proc [name] { [params] } { [code] }
+#
+#   The opening brace is one of the prototype enders.  We need to allow the first opening brace because it contains the
+#   parameters.
+#
+#   Also, the parameters may have braces within them.  I've seen one that used { seconds 20 } as a parameter.
+#
+#   Parameters:
+#
+#       type - The <TopicType> of the prototype.
+#       prototypeRef - A reference to the prototype so far, minus the ender in dispute.
+#       ender - The ender symbol.
+#
+#   Returns:
+#
+#       ENDER_ACCEPT - The ender is accepted and the prototype is finished.
+#       ENDER_IGNORE - The ender is rejected and parsing should continue.  Note that the prototype will be rejected as a whole
+#                                  if all enders are ignored before reaching the end of the code.
+#       ENDER_ACCEPT_AND_CONTINUE - The ender is accepted so the prototype may stand as is.  However, the prototype might
+#                                                          also continue on so continue parsing.  If there is no accepted ender between here and
+#                                                          the end of the code this version will be accepted instead.
+#       ENDER_REVERT_TO_ACCEPTED - The expedition from ENDER_ACCEPT_AND_CONTINUE failed.  Use the last accepted
+#                                                        version and end parsing.
+#
+sub OnPrototypeEnd #(type, prototypeRef, ender)
+   {
+   my ($self, $type, $prototypeRef, $ender) = @_;
+
+   if ($ender eq "\n")
+       {  return ::ENDER_ACCEPT_AND_CONTINUE();  }
+       elsif ( ($type eq "augeasvariable" || $type eq "augeaslens") &&
+                        $ender eq "let" &&
+                        (!$pastFirstLet || $$prototypeRef =~ /\=[ \t\r\n]*$/) )
+               {
+       $pastFirstLet = 1;
+       return ::ENDER_IGNORE();
+               }
+   else
+       {  return ::ENDER_ACCEPT();  };
+   };
+
+
+1;
diff --git a/doc/naturaldocs/conf/Augeas.css b/doc/naturaldocs/conf/Augeas.css
new file mode 100644 (file)
index 0000000..a5fee38
--- /dev/null
@@ -0,0 +1,765 @@
+/*
+   IMPORTANT: If you're editing this file in the output directory of one of
+   your projects, your changes will be overwritten the next time you run
+   Natural Docs.  Instead, copy this file to your project directory, make your
+   changes, and you can use it with -s.  Even better would be to make a CSS
+   file in your project directory with only your changes, which you can then
+   use with -s [original style] [your changes].
+
+   On the other hand, if you're editing this file in the Natural Docs styles
+   directory, the changes will automatically be applied to all your projects
+   that use this style the next time Natural Docs is run on them.
+
+   This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
+   Natural Docs is licensed under the GPL
+*/
+
+body {
+    background: white;
+    background: url('http://augeas.net/styles/augeas-logo.png');
+    background-repeat: no-repeat;
+    background-position: 3px 3px;
+    color: black;
+    font: 10pt Verdana, Arial, sans-serif;
+    margin: 0; padding: 0;
+    }
+
+.ContentPage,
+.IndexPage,
+.FramedMenuPage {
+    background-color: white;
+    }
+.FramedContentPage,
+.FramedIndexPage,
+.FramedSearchResultsPage,
+.PopupSearchResultsPage {
+    background-color: #white;
+    }
+
+
+a:link,
+a:visited { color: #900000; text-decoration: none }
+a:hover { color: #900000; text-decoration: underline }
+a:active { color: #FF0000; text-decoration: underline }
+
+td {
+    vertical-align: top }
+
+img { border: 0;  }
+
+
+/*
+    Comment out this line to use web-style paragraphs (blank line between
+    paragraphs, no indent) instead of print-style paragraphs (no blank line,
+    indented.)
+*/
+p {
+    text-indent: 5ex; margin: 0 }
+
+
+/*  Opera doesn't break with just wbr, but will if you add this.  */
+.Opera wbr:after {
+       content: "\00200B";
+       }
+
+
+/*  Blockquotes are used as containers for things that may need to scroll.  */
+blockquote {
+    padding: 0;
+    margin: 0;
+    overflow: auto;
+    }
+
+
+.Firefox1 blockquote {
+    padding-bottom: .5em;
+    }
+
+/*  Turn off scrolling when printing.  */
+@media print {
+    blockquote {
+        overflow: visible;
+        }
+    .IE blockquote {
+        width: auto;
+        }
+    }
+
+
+
+#Menu {
+    float: left;
+    padding-top: 100px;
+    left: 0px;
+    margin-bottom: 1em;
+    margin-left:10px;
+    }
+#Menu a {
+    color:black;
+    list-style: none;
+    padding: 0px;
+    font-weight: bold;
+    }
+.ContentPage #Menu,
+.IndexPage #Menu {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 31ex;
+    overflow: hidden;
+    }
+.ContentPage .Firefox #Menu,
+.IndexPage .Firefox #Menu {
+    width: 27ex;
+    }
+
+
+    .MTitle {
+        font-size: 16pt; font-weight: bold; font-variant: small-caps;
+        text-align: center;
+        padding: 5px 10px 15px 10px;
+        border-bottom: 1px dotted #000000;
+        color: #8d4a2c;
+        margin-bottom: 15px }
+
+    .MSubTitle {
+        font-size: 9pt; font-weight: normal; font-variant: normal;
+        margin-top: 1ex; margin-bottom: 5px }
+
+
+    .MEntry { }
+
+    .MEntry a:link,
+    .MEntry a:hover,
+    .MEntry a:visited { margin-right: 0 }
+    .MEntry a:active { margin-right: 0 }
+
+
+    .MGroup {
+        font-variant: small-caps; font-weight: bold;
+        margin: 1em 0 1em 10px;
+        }
+
+    .MGroupContent {
+        font-variant: normal; font-weight: normal }
+
+    .MGroup a:link,
+    .MGroup a:hover,
+    .MGroup a:visited { margin-right: 10px }
+    .MGroup a:active { margin-right: 10px }
+
+
+    .MFile,
+    .MText,
+    .MLink,
+    .MIndex {
+        padding: 5px 10px 7px 20px;
+        margin: .1em 0 .1em 0;
+       background: #c9e0a7;
+        }
+
+    .MText { }
+
+    .MLink { }
+
+    #MSelected {
+        color: #000000; background-color: #FFFFFF;
+        /*  Replace padding with border.  */
+       background: #65a703;
+        font-weight: bold;
+        }
+
+
+    #MSearchPanel {
+        padding: 0px 6px;
+        margin: .25em 0;
+        }
+
+
+    #MSearchField {
+        color: #606060;
+        background-color: #E8E8E8;
+        border: none;
+        padding: 2px 4px;
+        width: 100%;
+        }
+    /* Only Opera gets it right. */
+    .Firefox #MSearchField,
+    .IE #MSearchField,
+    .Safari #MSearchField {
+        width: 94%;
+        }
+    .Opera9 #MSearchField,
+    .Konqueror #MSearchField {
+        width: 97%;
+        }
+    .FramedMenuPage .Firefox #MSearchField,
+    .FramedMenuPage .Safari #MSearchField,
+    .FramedMenuPage .Konqueror #MSearchField {
+        width: 98%;
+        }
+
+    /* Firefox doesn't do this right in frames without #MSearchPanel added on.
+        It's presence doesn't hurt anything other browsers. */
+    #MSearchPanel.MSearchPanelInactive:hover #MSearchField {
+        background-color: #FFFFFF;
+        border: 1px solid #C0C0C0;
+        padding: 1px 3px;
+        }
+    .MSearchPanelActive #MSearchField {
+        background-color: #FFFFFF;
+        border: 1px solid #C0C0C0;
+        font-style: normal;
+        padding: 1px 3px;
+        }
+
+    #MSearchType {
+        visibility: hidden;
+        font: 8pt Verdana, sans-serif;
+        width: 98%;
+        padding: 0;
+        border: 1px solid #C0C0C0;
+        }
+    .MSearchPanelActive #MSearchType,
+    /*  As mentioned above, Firefox doesn't do this right in frames without #MSearchPanel added on. */
+    #MSearchPanel.MSearchPanelInactive:hover #MSearchType,
+    #MSearchType:focus {
+        visibility: visible;
+        color: #606060;
+        }
+    #MSearchType option#MSearchEverything {
+        font-weight: bold;
+        }
+
+    .Opera8 .MSearchPanelInactive:hover,
+    .Opera8 .MSearchPanelActive {
+        margin-left: -1px;
+        }
+
+
+    iframe#MSearchResults {
+        width: 60ex;
+        height: 15em;
+        }
+    #MSearchResultsWindow {
+        display: none;
+        position: absolute;
+        left: 0; top: 0;
+        border: 1px solid #000000;
+        background-color: #E8E8E8;
+        }
+    #MSearchResultsWindowClose {
+        font-weight: bold;
+        font-size: 8pt;
+        display: block;
+        padding: 2px 5px;
+        }
+    #MSearchResultsWindowClose:link,
+    #MSearchResultsWindowClose:visited {
+        color: #000000;
+        text-decoration: none;
+        }
+    #MSearchResultsWindowClose:active,
+    #MSearchResultsWindowClose:hover {
+        color: #800000;
+        text-decoration: none;
+        background-color: #F4F4F4;
+        }
+
+
+
+
+#Content {
+    margin-top: 100px;
+    padding-bottom: 15px;
+    }
+
+.ContentPage #Content {
+    background-color: #FFFFFF;
+    font-size: 9pt;  /* To make 31ex match the menu's 31ex. */
+    margin-left: 34ex;
+    }
+.ContentPage .Firefox #Content {
+    margin-left: 34ex;
+    }
+
+
+
+    .CTopic {
+        font-size: 10pt;
+        margin-bottom: 3em;
+        }
+
+
+    .CTitle {
+        font-size: 12pt; font-weight: bold;
+        border-width: 0 0 1px 0; border-style: solid; border-color: #A0A0A0;
+        margin: 0 15px .5em 15px }
+
+    .CGroup .CTitle {
+        font-size: 16pt; font-variant: small-caps;
+        padding-left: 15px; padding-right: 15px;
+        border-width: 0 0 2px 0; border-color: #000000;
+        margin-left: 0; margin-right: 0; color: #8d4a2c }
+
+    .CClass .CTitle,
+    .CInterface .CTitle,
+    .CDatabase .CTitle,
+    .CDatabaseTable .CTitle,
+    .CSection .CTitle {
+        font-size: 18pt;
+        font-weight: bold;
+        color: #8d4a2c;
+        padding: 10px 15px 10px 15px;
+        border-width: 2px 0; border-color: #000000;
+        margin-left: 0; margin-right: 0 }
+
+    #MainTopic .CTitle {
+        font-size: 20pt;
+        font-weight: bold;
+        color: #8d4a2c;
+        padding: 10px 15px 10px 15px;
+        border-width: 0 0 3px 0; border-color: #000000;
+        margin-left: 0; margin-right: 0 }
+
+    .CBody {
+        margin-left: 0; margin-right: 15px }
+
+
+    .CToolTip {
+        position: absolute; visibility: hidden;
+        left: 0; top: 0;
+        background-color: #FFFFE0;
+        padding: 5px;
+        border-width: 1px 2px 2px 1px; border-style: solid; border-color: #000000;
+        font-size: 8pt;
+        }
+
+    .Opera .CToolTip {
+        max-width: 98%;
+        }
+
+    /*  Scrollbars would be useless.  */
+    .CToolTip blockquote {
+        overflow: hidden;
+        }
+    .IE6 .CToolTip blockquote {
+        overflow: visible;
+        }
+
+    .CHeading {
+        font-weight: bold; font-size: 10pt;
+        margin: 1.5em 0 .5em 0;
+        }
+
+    .CBody pre {
+        font: 10pt "Courier New", Courier, monospace;
+        margin: 1em 0;
+        }
+
+    .CBody ul {
+        /*  I don't know why CBody's margin doesn't apply, but it's consistent across browsers so whatever.
+             Reapply it here as padding.  */
+        padding-left: 15px; padding-right: 15px;
+        margin: .5em 5ex .5em 5ex;
+        }
+
+    .CDescriptionList {
+        margin: .5em 5ex 0 5ex }
+
+        .CDLEntry {
+            font: 10pt "Courier New", Courier, monospace; color: #808080;
+            padding-bottom: .25em;
+            white-space: nowrap }
+
+        .CDLDescription {
+            font-size: 10pt;  /*  For browsers that don't inherit correctly, like Opera 5.  */
+            padding-bottom: .5em; padding-left: 5ex }
+
+
+    .CTopic img {
+        text-align: center;
+        display: block;
+        margin: 1em auto;
+        }
+    .CImageCaption {
+        font-variant: small-caps;
+        font-size: 8pt;
+        color: #808080;
+        text-align: center;
+        position: relative;
+        top: 1em;
+        }
+
+    .CImageLink {
+        color: #808080;
+        }
+    a.CImageLink:link,
+    a.CImageLink:visited,
+    a.CImageLink:hover { color: #808080 }
+
+
+
+
+
+.Prototype {
+    font: 10pt "Courier New", Courier, monospace;
+    padding: 5px 3ex;
+    border-width: 1px; border-style: solid;
+    margin: 0 5ex 1.5em 5ex;
+    }
+
+    .Prototype td {
+        font-size: 10pt;
+        }
+
+    .PDefaultValue,
+    .PDefaultValuePrefix,
+    .PTypePrefix {
+        color: #8F8F8F;
+        }
+    .PTypePrefix {
+        text-align: right;
+        }
+    .PAfterParameters {
+        vertical-align: bottom;
+        }
+
+    .IE .Prototype table {
+        padding: 0;
+        }
+
+    .CFunction .Prototype {
+        background-color: #F4F4F4; border-color: #D0D0D0 }
+    .CProperty .Prototype {
+        background-color: #F4F4FF; border-color: #C0C0E8 }
+    .CVariable .Prototype {
+        background-color: #FFFFF0; border-color: #E0E0A0 }
+
+    .CClass .Prototype {
+        border-width: 1px 2px 2px 1px; border-style: solid; border-color: #A0A0A0;
+        background-color: #F4F4F4;
+        }
+    .CInterface .Prototype {
+        border-width: 1px 2px 2px 1px; border-style: solid; border-color: #A0A0D0;
+        background-color: #F4F4FF;
+        }
+
+    .CDatabaseIndex .Prototype,
+    .CConstant .Prototype {
+        background-color: #D0D0D0; border-color: #000000 }
+    .CType .Prototype,
+    .CEnumeration .Prototype {
+        background-color: #FAF0F0; border-color: #E0B0B0;
+        }
+    .CDatabaseTrigger .Prototype,
+    .CEvent .Prototype,
+    .CDelegate .Prototype {
+        background-color: #F0FCF0; border-color: #B8E4B8 }
+
+    .CToolTip .Prototype {
+        margin: 0 0 .5em 0;
+        white-space: nowrap;
+        }
+
+
+
+
+
+.Summary {
+    margin: 1.5em 5ex 0 5ex }
+
+    .STitle {
+        font-size: 12pt; font-weight: bold;
+        margin-bottom: .5em;
+        color: #8d4a2c; }
+
+
+    .SBorder {
+        background-color: #FFFFF0;
+        padding: 15px;
+        border: 1px solid #C0C060 }
+
+    /* In a frame IE 6 will make them too long unless you set the width to 100%.  Without frames it will be correct without a width
+        or slightly too long (but not enough to scroll) with a width.  This arbitrary weirdness simply astounds me.  IE 7 has the same
+        problem with frames, haven't tested it without.  */
+    .FramedContentPage .IE .SBorder {
+        width: 100% }
+
+    /*  A treat for Mozilla users.  Blatantly non-standard.  Will be replaced with CSS 3 attributes when finalized/supported.  */
+    .Firefox .SBorder {
+        -moz-border-radius: 20px }
+
+
+    .STable {
+        font-size: 9pt; width: 100% }
+
+    .SEntry {
+        width: 30% }
+    .SDescription {
+        width: 70% }
+
+
+    .SMarked {
+        background-color: #F8F8D8 }
+
+    .SDescription { padding-left: 2ex }
+    .SIndent1 .SEntry { padding-left: 1.5ex }   .SIndent1 .SDescription { padding-left: 3.5ex }
+    .SIndent2 .SEntry { padding-left: 3.0ex }   .SIndent2 .SDescription { padding-left: 5.0ex }
+    .SIndent3 .SEntry { padding-left: 4.5ex }   .SIndent3 .SDescription { padding-left: 6.5ex }
+    .SIndent4 .SEntry { padding-left: 6.0ex }   .SIndent4 .SDescription { padding-left: 8.0ex }
+    .SIndent5 .SEntry { padding-left: 7.5ex }   .SIndent5 .SDescription { padding-left: 9.5ex }
+
+    .SDescription a { color: #800000}
+    .SDescription a:active { color: #A00000 }
+
+    .SGroup td {
+        padding-top: .5em; padding-bottom: .25em }
+
+    .SGroup .SEntry {
+        font-weight: bold; font-variant: small-caps }
+
+    .SGroup .SEntry a { color: #800000 }
+    .SGroup .SEntry a:active { color: #F00000 }
+
+
+    .SMain td,
+    .SClass td,
+    .SDatabase td,
+    .SDatabaseTable td,
+    .SSection td {
+        font-size: 10pt;
+        padding-bottom: .25em }
+
+    .SClass td,
+    .SDatabase td,
+    .SDatabaseTable td,
+    .SSection td {
+        padding-top: 1em }
+
+    .SMain .SEntry,
+    .SClass .SEntry,
+    .SDatabase .SEntry,
+    .SDatabaseTable .SEntry,
+    .SSection .SEntry {
+        font-weight: bold;
+        }
+
+    .SMain .SEntry a,
+    .SClass .SEntry a,
+    .SDatabase .SEntry a,
+    .SDatabaseTable .SEntry a,
+    .SSection .SEntry a { color: #000000 }
+
+    .SMain .SEntry a:active,
+    .SClass .SEntry a:active,
+    .SDatabase .SEntry a:active,
+    .SDatabaseTable .SEntry a:active,
+    .SSection .SEntry a:active { color: #A00000 }
+
+
+
+
+
+.ClassHierarchy {
+    margin: 0 15px 1em 15px }
+
+    .CHEntry {
+        border-width: 1px 2px 2px 1px; border-style: solid; border-color: #A0A0A0;
+        margin-bottom: 3px;
+        padding: 2px 2ex;
+        font-size: 10pt;
+        background-color: #F4F4F4; color: #606060;
+        }
+
+    .Firefox .CHEntry {
+        -moz-border-radius: 4px;
+        }
+
+    .CHCurrent .CHEntry {
+        font-weight: bold;
+        border-color: #000000;
+        color: #000000;
+        }
+
+    .CHChildNote .CHEntry {
+        font-style: italic;
+        font-size: 8pt;
+        }
+
+    .CHIndent {
+        margin-left: 3ex;
+        }
+
+    .CHEntry a:link,
+    .CHEntry a:visited,
+    .CHEntry a:hover {
+        color: #606060;
+        }
+    .CHEntry a:active {
+        color: #800000;
+        }
+
+
+
+
+
+#Index {
+    margin-top: 100px;
+    margin-left: 30px;
+    }
+
+/*  As opposed to .PopupSearchResultsPage #Index  */
+.IndexPage #Index,
+.FramedIndexPage #Index,
+.FramedSearchResultsPage #Index {
+    padding: 15px;
+    }
+
+.IndexPage #Index {
+    font-size: 9pt;  /* To make 27ex match the menu's 27ex. */
+    margin-left: 27ex;
+    }
+
+
+    .IPageTitle {
+        font-size: 20pt; font-weight: bold;
+        color: #8d4a2c;
+        padding: 10px 15px 10px 15px;
+        margin: -15px -15px 0 -15px }
+
+    .FramedSearchResultsPage .IPageTitle {
+        margin-bottom: 15px;
+        }
+
+    .INavigationBar {
+        font-size: 10pt;
+        text-align: center;
+        background-color: #FFFFF0;
+        padding: 5px;
+        border-bottom: solid 1px black;
+        margin: 0 -15px 15px -15px;
+        margin-left: 20px;
+        }
+
+    .INavigationBar a {
+        font-weight: bold }
+
+    .IHeading {
+        font-size: 16pt; font-weight: bold;
+        padding: 2.5em 0 .5em 0;
+        text-align: center;
+        width: 3.5ex;
+        }
+    #IFirstHeading {
+        padding-top: 0;
+        }
+
+    .IEntry {
+        font-size: 10pt;
+        padding-left: 1ex;
+        }
+    .PopupSearchResultsPage .IEntry {
+        font-size: 8pt;
+        padding: 1px 5px;
+        }
+    .PopupSearchResultsPage .Opera9 .IEntry,
+    .FramedSearchResultsPage .Opera9 .IEntry {
+        text-align: left;
+        }
+    .FramedSearchResultsPage .IEntry {
+        padding: 0;
+        }
+
+    .ISubIndex {
+        padding-left: 3ex; padding-bottom: .5em }
+    .PopupSearchResultsPage .ISubIndex {
+        display: none;
+        }
+
+    /*  While it may cause some entries to look like links when they aren't, I found it's much easier to read the
+         index if everything's the same color.  */
+    .ISymbol {
+        font-weight: bold; color: #900000  }
+
+    .IndexPage .ISymbolPrefix,
+    .FramedIndexPage .ISymbolPrefix {
+        font-size: 10pt;
+        text-align: right;
+        color: #C47C7C;
+        background-color: #F8F8F8;
+        border-right: 3px solid #E0E0E0;
+        border-left: 1px solid #E0E0E0;
+        padding: 0 1px 0 2px;
+        }
+    .PopupSearchResultsPage .ISymbolPrefix,
+    .FramedSearchResultsPage .ISymbolPrefix {
+        color: #900000;
+        }
+    .PopupSearchResultsPage .ISymbolPrefix {
+        font-size: 8pt;
+        }
+
+    .IndexPage #IFirstSymbolPrefix,
+    .FramedIndexPage #IFirstSymbolPrefix {
+        border-top: 1px solid #E0E0E0;
+        }
+    .IndexPage #ILastSymbolPrefix,
+    .FramedIndexPage #ILastSymbolPrefix {
+        border-bottom: 1px solid #E0E0E0;
+        }
+    .IndexPage #IOnlySymbolPrefix,
+    .FramedIndexPage #IOnlySymbolPrefix {
+        border-top: 1px solid #E0E0E0;
+        border-bottom: 1px solid #E0E0E0;
+        }
+
+    a.IParent,
+    a.IFile {
+        display: block;
+        }
+
+    .PopupSearchResultsPage .SRStatus {
+        padding: 2px 5px;
+        font-size: 8pt;
+        font-style: italic;
+        }
+    .FramedSearchResultsPage .SRStatus {
+        font-size: 10pt;
+        font-style: italic;
+        }
+
+    .SRResult {
+        display: none;
+        }
+
+
+
+#Footer {
+    font-size: 8pt;
+    color: #989898;
+    text-align: right;
+    }
+
+#Footer p {
+    text-indent: 0;
+    margin-bottom: .5em;
+    }
+
+.ContentPage #Footer,
+.IndexPage #Footer {
+    text-align: right;
+    margin: 2px;
+    }
+
+.FramedMenuPage #Footer {
+    text-align: center;
+    margin: 5em 10px 10px 10px;
+    padding-top: 1em;
+    border-top: 1px solid #C8C8C8;
+    }
+
+    #Footer a:link,
+    #Footer a:hover,
+    #Footer a:visited { color: #989898 }
+    #Footer a:active { color: #A00000 }
diff --git a/doc/naturaldocs/conf/c_api/Languages.txt b/doc/naturaldocs/conf/c_api/Languages.txt
new file mode 100644 (file)
index 0000000..be96913
--- /dev/null
@@ -0,0 +1,113 @@
+Format: 1.4
+
+# This is the Natural Docs languages file for this project.  If you change
+# anything here, it will apply to THIS PROJECT ONLY.  If you'd like to change
+# something for all your projects, edit the Languages.txt in Natural Docs'
+# Config directory instead.
+
+
+# You can prevent certain file extensions from being scanned like this:
+# Ignore Extensions: [extension] [extension] ...
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Unlike other Natural Docs configuration files, in this file all comments
+# MUST be alone on a line.  Some languages deal with the # character, so you
+# cannot put comments on the same line as content.
+#
+# Also, all lists are separated with spaces, not commas, again because some
+# languages may need to use them.
+#
+# Language: [name]
+# Alter Language: [name]
+#    Defines a new language or alters an existing one.  Its name can use any
+#    characters.  If any of the properties below have an add/replace form, you
+#    must use that when using Alter Language.
+#
+#    The language Shebang Script is special.  It's entry is only used for
+#    extensions, and files with those extensions have their shebang (#!) lines
+#    read to determine the real language of the file.  Extensionless files are
+#    always treated this way.
+#
+#    The language Text File is also special.  It's treated as one big comment
+#    so you can put Natural Docs content in them without special symbols.  Also,
+#    if you don't specify a package separator, ignored prefixes, or enum value
+#    behavior, it will copy those settings from the language that is used most
+#    in the source tree.
+#
+# Extensions: [extension] [extension] ...
+# [Add/Replace] Extensions: [extension] [extension] ...
+#    Defines the file extensions of the language's source files.  You can
+#    redefine extensions found in the main languages file.  You can use * to
+#    mean any undefined extension.
+#
+# Shebang Strings: [string] [string] ...
+# [Add/Replace] Shebang Strings: [string] [string] ...
+#    Defines a list of strings that can appear in the shebang (#!) line to
+#    designate that it's part of the language.  You can redefine strings found
+#    in the main languages file.
+#
+# Ignore Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored Prefixes in Index: [prefix] [prefix] ...
+#
+# Ignore [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+#    Specifies prefixes that should be ignored when sorting symbols in an
+#    index.  Can be specified in general or for a specific topic type.
+#
+#------------------------------------------------------------------------------
+# For basic language support only:
+#
+# Line Comments: [symbol] [symbol] ...
+#    Defines a space-separated list of symbols that are used for line comments,
+#    if any.
+#
+# Block Comments: [opening sym] [closing sym] [opening sym] [closing sym] ...
+#    Defines a space-separated list of symbol pairs that are used for block
+#    comments, if any.
+#
+# Package Separator: [symbol]
+#    Defines the default package separator symbol.  The default is a dot.
+#
+# [Topic Type] Prototype Enders: [symbol] [symbol] ...
+#    When defined, Natural Docs will attempt to get a prototype from the code
+#    immediately following the topic type.  It stops when it reaches one of
+#    these symbols.  Use \n for line breaks.
+#
+# Line Extender: [symbol]
+#    Defines the symbol that allows a prototype to span multiple lines if
+#    normally a line break would end it.
+#
+# Enum Values: [global|under type|under parent]
+#    Defines how enum values are referenced.  The default is global.
+#    global       - Values are always global, referenced as 'value'.
+#    under type   - Values are under the enum type, referenced as
+#               'package.enum.value'.
+#    under parent - Values are under the enum's parent, referenced as
+#               'package.value'.
+#
+# Perl Package: [perl package]
+#    Specifies the Perl package used to fine-tune the language behavior in ways
+#    too complex to do in this file.
+#
+#------------------------------------------------------------------------------
+# For full language support only:
+#
+# Full Language Support: [perl package]
+#    Specifies the Perl package that has the parsing routines necessary for full
+#    language support.
+#
+#-------------------------------------------------------------------------------
+
+# The following languages are defined in the main file, if you'd like to alter
+# them:
+#
+#    Text File, Shebang Script, C/C++, C#, Java, JavaScript, Perl, Python,
+#    PHP, SQL, Visual Basic, Pascal, Assembly, Ada, Tcl, Ruby, Makefile,
+#    ActionScript, ColdFusion, R, Fortran
+
+# If you add a language that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# languages [at] naturaldocs [dot] org.
diff --git a/doc/naturaldocs/conf/c_api/Menu.txt b/doc/naturaldocs/conf/c_api/Menu.txt
new file mode 100644 (file)
index 0000000..27d17a3
--- /dev/null
@@ -0,0 +1,66 @@
+Format: 1.4
+
+
+Title: Augeas Documentation
+SubTitle: C API
+
+# You can add a footer to your documentation like this:
+# Footer: [text]
+# If you want to add a copyright notice, this would be the place to do it.
+
+# You can add a timestamp to your documentation like one of these:
+# Timestamp: Generated on month day, year
+# Timestamp: Updated mm/dd/yyyy
+# Timestamp: Last updated mon day
+#
+#   m     - One or two digit month.  January is "1"
+#   mm    - Always two digit month.  January is "01"
+#   mon   - Short month word.  January is "Jan"
+#   month - Long month word.  January is "January"
+#   d     - One or two digit day.  1 is "1"
+#   dd    - Always two digit day.  1 is "01"
+#   day   - Day with letter extension.  1 is "1st"
+#   yy    - Two digit year.  2006 is "06"
+#   yyyy  - Four digit year.  2006 is "2006"
+#   year  - Four digit year.  2006 is "2006"
+
+
+# --------------------------------------------------------------------------
+# 
+# Cut and paste the lines below to change the order in which your files
+# appear on the menu.  Don't worry about adding or removing files, Natural
+# Docs will take care of that.
+# 
+# You can further organize the menu by grouping the entries.  Add a
+# "Group: [name] {" line to start a group, and add a "}" to end it.
+# 
+# You can add text and web links to the menu by adding "Text: [text]" and
+# "Link: [name] ([URL])" lines, respectively.
+# 
+# The formatting and comments are auto-generated, so don't worry about
+# neatness when editing the file.  Natural Docs will clean it up the next
+# time it is run.  When working with groups, just deal with the braces and
+# forget about the indentation and comments.
+# 
+# --------------------------------------------------------------------------
+
+
+Group: Main Links  {
+
+   Link: Main  (http://augeas.net)
+   Link: Documentation  (http://augeas.net/doc)
+   }  # Group: Main Links
+
+File: Public API  (no auto-title, augeas.h)
+File: Internal API  (no auto-title, internal.h)
+
+Group: Index  {
+
+   Index: Everything
+   Class Index: Classes
+   Function Index: Functions
+   File Index: Files
+   Macro Index: Macros
+   Type Index: Types
+   }  # Group: Index
+
diff --git a/doc/naturaldocs/conf/c_api/Topics.txt b/doc/naturaldocs/conf/c_api/Topics.txt
new file mode 100644 (file)
index 0000000..b1a9b93
--- /dev/null
@@ -0,0 +1,81 @@
+Format: 1.4
+
+# This is the Natural Docs topics file for this project.  If you change anything
+# here, it will apply to THIS PROJECT ONLY.  If you'd like to change something
+# for all your projects, edit the Topics.txt in Natural Docs' Config directory
+# instead.
+
+
+# If you'd like to prevent keywords from being recognized by Natural Docs, you
+# can do it like this:
+# Ignore Keywords: [keyword], [keyword], ...
+#
+# Or you can use the list syntax like how they are defined:
+# Ignore Keywords:
+#    [keyword]
+#    [keyword], [plural keyword]
+#    ...
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Topic Type: [name]
+# Alter Topic Type: [name]
+#    Creates a new topic type or alters one from the main file.  Each type gets
+#    its own index and behavior settings.  Its name can have letters, numbers,
+#    spaces, and these charaters: - / . '
+#
+# Plural: [name]
+#    Sets the plural name of the topic type, if different.
+#
+# Keywords:
+#    [keyword]
+#    [keyword], [plural keyword]
+#    ...
+#    Defines or adds to the list of keywords for the topic type.  They may only
+#    contain letters, numbers, and spaces and are not case sensitive.  Plural
+#    keywords are used for list topics.  You can redefine keywords found in the
+#    main topics file.
+#
+# Index: [yes|no]
+#    Whether the topics get their own index.  Defaults to yes.  Everything is
+#    included in the general index regardless of this setting.
+#
+# Scope: [normal|start|end|always global]
+#    How the topics affects scope.  Defaults to normal.
+#    normal        - Topics stay within the current scope.
+#    start         - Topics start a new scope for all the topics beneath it,
+#                    like class topics.
+#    end           - Topics reset the scope back to global for all the topics
+#                    beneath it.
+#    always global - Topics are defined as global, but do not change the scope
+#                    for any other topics.
+#
+# Class Hierarchy: [yes|no]
+#    Whether the topics are part of the class hierarchy.  Defaults to no.
+#
+# Page Title If First: [yes|no]
+#    Whether the topic's title becomes the page title if it's the first one in
+#    a file.  Defaults to no.
+#
+# Break Lists: [yes|no]
+#    Whether list topics should be broken into individual topics in the output.
+#    Defaults to no.
+#
+# Can Group With: [type], [type], ...
+#    Defines a list of topic types that this one can possibly be grouped with.
+#    Defaults to none.
+#-------------------------------------------------------------------------------
+
+# The following topics are defined in the main file, if you'd like to alter
+# their behavior or add keywords:
+#
+#    Generic, Class, Interface, Section, File, Group, Function, Variable,
+#    Property, Type, Constant, Enumeration, Event, Delegate, Macro,
+#    Database, Database Table, Database View, Database Index, Database
+#    Cursor, Database Trigger, Cookie, Build Target
+
+# If you add something that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# topics [at] naturaldocs [dot] org.
diff --git a/doc/naturaldocs/conf/lenses/Languages.txt b/doc/naturaldocs/conf/lenses/Languages.txt
new file mode 100644 (file)
index 0000000..da5cbdb
--- /dev/null
@@ -0,0 +1,122 @@
+Format: 1.4
+
+# This is the Natural Docs languages file for this project.  If you change
+# anything here, it will apply to THIS PROJECT ONLY.  If you'd like to change
+# something for all your projects, edit the Languages.txt in Natural Docs'
+# Config directory instead.
+
+
+# You can prevent certain file extensions from being scanned like this:
+# Ignore Extensions: [extension] [extension] ...
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Unlike other Natural Docs configuration files, in this file all comments
+# MUST be alone on a line.  Some languages deal with the # character, so you
+# cannot put comments on the same line as content.
+#
+# Also, all lists are separated with spaces, not commas, again because some
+# languages may need to use them.
+#
+# Language: [name]
+# Alter Language: [name]
+#    Defines a new language or alters an existing one.  Its name can use any
+#    characters.  If any of the properties below have an add/replace form, you
+#    must use that when using Alter Language.
+#
+#    The language Shebang Script is special.  It's entry is only used for
+#    extensions, and files with those extensions have their shebang (#!) lines
+#    read to determine the real language of the file.  Extensionless files are
+#    always treated this way.
+#
+#    The language Text File is also special.  It's treated as one big comment
+#    so you can put Natural Docs content in them without special symbols.  Also,
+#    if you don't specify a package separator, ignored prefixes, or enum value
+#    behavior, it will copy those settings from the language that is used most
+#    in the source tree.
+#
+# Extensions: [extension] [extension] ...
+# [Add/Replace] Extensions: [extension] [extension] ...
+#    Defines the file extensions of the language's source files.  You can
+#    redefine extensions found in the main languages file.  You can use * to
+#    mean any undefined extension.
+#
+# Shebang Strings: [string] [string] ...
+# [Add/Replace] Shebang Strings: [string] [string] ...
+#    Defines a list of strings that can appear in the shebang (#!) line to
+#    designate that it's part of the language.  You can redefine strings found
+#    in the main languages file.
+#
+# Ignore Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored Prefixes in Index: [prefix] [prefix] ...
+#
+# Ignore [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+# [Add/Replace] Ignored [Topic Type] Prefixes in Index: [prefix] [prefix] ...
+#    Specifies prefixes that should be ignored when sorting symbols in an
+#    index.  Can be specified in general or for a specific topic type.
+#
+#------------------------------------------------------------------------------
+# For basic language support only:
+#
+# Line Comments: [symbol] [symbol] ...
+#    Defines a space-separated list of symbols that are used for line comments,
+#    if any.
+#
+# Block Comments: [opening sym] [closing sym] [opening sym] [closing sym] ...
+#    Defines a space-separated list of symbol pairs that are used for block
+#    comments, if any.
+#
+# Package Separator: [symbol]
+#    Defines the default package separator symbol.  The default is a dot.
+#
+# [Topic Type] Prototype Enders: [symbol] [symbol] ...
+#    When defined, Natural Docs will attempt to get a prototype from the code
+#    immediately following the topic type.  It stops when it reaches one of
+#    these symbols.  Use \n for line breaks.
+#
+# Line Extender: [symbol]
+#    Defines the symbol that allows a prototype to span multiple lines if
+#    normally a line break would end it.
+#
+# Enum Values: [global|under type|under parent]
+#    Defines how enum values are referenced.  The default is global.
+#    global       - Values are always global, referenced as 'value'.
+#    under type   - Values are under the enum type, referenced as
+#               'package.enum.value'.
+#    under parent - Values are under the enum's parent, referenced as
+#               'package.value'.
+#
+# Perl Package: [perl package]
+#    Specifies the Perl package used to fine-tune the language behavior in ways
+#    too complex to do in this file.
+#
+#------------------------------------------------------------------------------
+# For full language support only:
+#
+# Full Language Support: [perl package]
+#    Specifies the Perl package that has the parsing routines necessary for full
+#    language support.
+#
+#-------------------------------------------------------------------------------
+
+# The following languages are defined in the main file, if you'd like to alter
+# them:
+#
+#    Text File, Shebang Script, C/C++, C#, Java, JavaScript, Perl, Python,
+#    PHP, SQL, Visual Basic, Pascal, Assembly, Ada, Tcl, Ruby, Makefile,
+#    ActionScript, ColdFusion, R, Fortran
+
+# If you add a language that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# languages [at] naturaldocs [dot] org.
+
+
+Language: Augeas
+
+   Extension: aug
+   Block Comment: (* *)
+   Augeas Variable Prototype Enders: \n let test module filter
+   Augeas Lens Prototype Enders: \n let test module filter
+   Perl Package: NaturalDocs::Languages::Augeas
diff --git a/doc/naturaldocs/conf/lenses/Menu.txt b/doc/naturaldocs/conf/lenses/Menu.txt
new file mode 100644 (file)
index 0000000..ea1b1d4
--- /dev/null
@@ -0,0 +1,107 @@
+Format: 1.4
+
+
+Title: Augeas Documentation
+SubTitle: Modules
+
+# You can add a footer to your documentation like this:
+# Footer: [text]
+# If you want to add a copyright notice, this would be the place to do it.
+
+# You can add a timestamp to your documentation like one of these:
+# Timestamp: Generated on month day, year
+# Timestamp: Updated mm/dd/yyyy
+# Timestamp: Last updated mon day
+#
+#   m     - One or two digit month.  January is "1"
+#   mm    - Always two digit month.  January is "01"
+#   mon   - Short month word.  January is "Jan"
+#   month - Long month word.  January is "January"
+#   d     - One or two digit day.  1 is "1"
+#   dd    - Always two digit day.  1 is "01"
+#   day   - Day with letter extension.  1 is "1st"
+#   yy    - Two digit year.  2006 is "06"
+#   yyyy  - Four digit year.  2006 is "2006"
+#   year  - Four digit year.  2006 is "2006"
+
+
+# --------------------------------------------------------------------------
+# 
+# Cut and paste the lines below to change the order in which your files
+# appear on the menu.  Don't worry about adding or removing files, Natural
+# Docs will take care of that.
+# 
+# You can further organize the menu by grouping the entries.  Add a
+# "Group: [name] {" line to start a group, and add a "}" to end it.
+# 
+# You can add text and web links to the menu by adding "Text: [text]" and
+# "Link: [name] ([URL])" lines, respectively.
+# 
+# The formatting and comments are auto-generated, so don't worry about
+# neatness when editing the file.  Natural Docs will clean it up the next
+# time it is run.  When working with groups, just deal with the braces and
+# forget about the indentation and comments.
+# 
+# --------------------------------------------------------------------------
+
+
+Group: Main Site  {
+
+   Link: Main  (/index.html)
+   Link: Documentation  (/docs/index.html)
+   }  # Group: Main Site
+
+Group: Specific Modules  {
+
+   File: Access  (access.aug)
+   File: Cgconfig  (no auto-title, cgconfig.aug)
+   File: Cgrules  (no auto-title, cgrules.aug)
+   File: Cron  (cron.aug)
+   File: crypttab.aug  (crypttab.aug)
+   File: Debctrl  (no auto-title, debctrl.aug)
+   File: Dpkg  (dpkg.aug)
+   File: Exports  (exports.aug)
+   File: Iptables  (iptables.aug)
+   File: Keepalived  (keepalived.aug)
+   File: Login_defs  (login_defs.aug)
+   File: Lokkit  (lokkit.aug)
+   File: Mke2fs  (mke2fs.aug)
+   File: Modprobe  (modprobe.aug)
+   File: Modules_conf  (modules_conf.aug)
+   File: NagiosCfg (nagioscfg.aug)
+   File: NagiosObjects (nagiosobjects.aug)
+   File: Nrpe  (nrpe.aug)
+   File: Nsswitch  (nsswitch.aug)
+   File: Pbuilder  (pbuilder.aug)
+   File: Pg_Hba  (pg_hba.aug)
+   File: PuppetFileserver  (puppetfileserver.aug)
+   File: Resolv  (resolv.aug)
+   File: Services  (services.aug)
+   File: Shells  (shells.aug)
+   File: Solaris_System  (solaris_system.aug)
+   File: Sshd  (sshd.aug)
+   File: Sudoers  (sudoers.aug)
+   File: Syslog  (syslog.aug)
+   File: Test_login_defs  (tests/test_login_defs.aug)
+   File: Xinetd  (xinetd.aug)
+   File: Xorg  (xorg.aug)
+   }  # Group: Specific Modules
+
+Group: Generic Modules  {
+
+   File: Build  (build.aug)
+   File: IniFile  (inifile.aug)
+   File: Rx  (rx.aug)
+   File: Sep  (sep.aug)
+   File: Util  (util.aug)
+   }  # Group: Generic Modules
+
+Group: Index  {
+
+   Augeas Lens Index: Lenses
+   Augeas Module Index: Modules
+   Augeas Variable Index: Variables
+   Index: Everything
+   File Index: Files
+   }  # Group: Index
+
diff --git a/doc/naturaldocs/conf/lenses/Topics.txt b/doc/naturaldocs/conf/lenses/Topics.txt
new file mode 100644 (file)
index 0000000..38fcff7
--- /dev/null
@@ -0,0 +1,98 @@
+Format: 1.4
+
+# This is the Natural Docs topics file for this project.  If you change anything
+# here, it will apply to THIS PROJECT ONLY.  If you'd like to change something
+# for all your projects, edit the Topics.txt in Natural Docs' Config directory
+# instead.
+
+
+Ignore Keywords: 
+   class
+
+
+#-------------------------------------------------------------------------------
+# SYNTAX:
+#
+# Topic Type: [name]
+# Alter Topic Type: [name]
+#    Creates a new topic type or alters one from the main file.  Each type gets
+#    its own index and behavior settings.  Its name can have letters, numbers,
+#    spaces, and these charaters: - / . '
+#
+# Plural: [name]
+#    Sets the plural name of the topic type, if different.
+#
+# Keywords:
+#    [keyword]
+#    [keyword], [plural keyword]
+#    ...
+#    Defines or adds to the list of keywords for the topic type.  They may only
+#    contain letters, numbers, and spaces and are not case sensitive.  Plural
+#    keywords are used for list topics.  You can redefine keywords found in the
+#    main topics file.
+#
+# Index: [yes|no]
+#    Whether the topics get their own index.  Defaults to yes.  Everything is
+#    included in the general index regardless of this setting.
+#
+# Scope: [normal|start|end|always global]
+#    How the topics affects scope.  Defaults to normal.
+#    normal        - Topics stay within the current scope.
+#    start         - Topics start a new scope for all the topics beneath it,
+#                    like class topics.
+#    end           - Topics reset the scope back to global for all the topics
+#                    beneath it.
+#    always global - Topics are defined as global, but do not change the scope
+#                    for any other topics.
+#
+# Class Hierarchy: [yes|no]
+#    Whether the topics are part of the class hierarchy.  Defaults to no.
+#
+# Page Title If First: [yes|no]
+#    Whether the topic's title becomes the page title if it's the first one in
+#    a file.  Defaults to no.
+#
+# Break Lists: [yes|no]
+#    Whether list topics should be broken into individual topics in the output.
+#    Defaults to no.
+#
+# Can Group With: [type], [type], ...
+#    Defines a list of topic types that this one can possibly be grouped with.
+#    Defaults to none.
+#-------------------------------------------------------------------------------
+
+# The following topics are defined in the main file, if you'd like to alter
+# their behavior or add keywords:
+#
+#    Generic, Class, Interface, Section, File, Group, Function, Variable,
+#    Property, Type, Constant, Enumeration, Event, Delegate, Macro,
+#    Database, Database Table, Database View, Database Index, Database
+#    Cursor, Database Trigger, Cookie, Build Target
+
+# If you add something that you think would be useful to other developers
+# and should be included in Natural Docs by default, please e-mail it to
+# topics [at] naturaldocs [dot] org.
+
+
+Topic Type: Augeas Lens
+
+   Plural: Augeas Lenses
+   Keywords:
+      view, views
+
+
+Topic Type: Augeas Variable
+
+   Plural: Augeas Variables
+   Keywords:
+      variable, variables
+
+
+Topic Type: Augeas Module
+
+   Plural: Augeas Modules
+   Scope: Start
+   Page Title If First: Yes
+
+   Keywords:
+      module, modules
diff --git a/doc/syntax/augeas.vim b/doc/syntax/augeas.vim
new file mode 100644 (file)
index 0000000..16c5cd1
--- /dev/null
@@ -0,0 +1,108 @@
+" Vim syntax file
+" Language:    Augeas
+" Version: 1.0
+" $Id$
+" Maintainer:  Bruno Cornec <bruno@project-builder.org>
+" Contributors:
+"  Raphaël Pinson <raphink@gmail.com>
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+
+syn case ignore
+syn sync lines=250
+
+syn keyword augeasStatement    module let incl transform autoload in rec
+syn keyword augeasTestStatement        test get after put insa insb set rm
+syn keyword augeasTodo contained       TODO FIXME XXX DEBUG NOTE
+
+if exists("augeas_symbol_operator")
+  syn match   augeasSymbolOperator      "[+\-/*=]"
+  syn match   augeasSymbolOperator      "[<>]=\="
+  syn match   augeasSymbolOperator      "<>"
+  syn match   augeasSymbolOperator      ":="
+  syn match   augeasSymbolOperator      "[()]"
+  syn match   augeasSymbolOperator      "\.\."
+  syn match   augeasSymbolOperator      "[\^.]"
+  syn match   augeasMatrixDelimiter    "[][]"
+  "if you prefer you can highlight the range
+  "syn match  augeasMatrixDelimiter    "[\d\+\.\.\d\+]"
+endif
+
+if exists("augeas_no_tabs")
+  syn match augeasShowTab "\t"
+endif
+
+syn region augeasComment       start="(\*"  end="\*)" contains=augeasTodo,augeasSpaceError
+
+
+if !exists("augeas_no_functions")
+  " functions
+  syn keyword augeasLabel      del key store label value
+  syn keyword augeasFunction   Util Build Rx Sep
+endif
+
+syn region  augeasRegexp       start="/"  end="[^\\]/"
+syn region  augeasString       start=+"+  end=+"\([ \t)\.-]\|$\)+
+
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_augeas_syn_inits")
+  if version < 508
+    let did_augeas_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  HiLink augeasAcces           augeasStatement
+  HiLink augeasBoolean         Boolean
+  HiLink augeasComment         Comment
+  HiLink augeasConditional     Conditional
+  HiLink augeasConstant                Constant
+  HiLink augeasDelimiter       Identifier
+  HiLink augeasDirective       augeasStatement
+  HiLink augeasException       Exception
+  HiLink augeasFloat           Float
+  HiLink augeasFunction                Function
+  HiLink augeasLabel           Label
+  HiLink augeasMatrixDelimiter Identifier
+  HiLink augeasModifier                Type
+  HiLink augeasNumber          Number
+  HiLink augeasOperator                Operator
+  HiLink augeasPredefined      augeasStatement
+  HiLink augeasPreProc         PreProc
+  HiLink augeasRepeat          Repeat
+  HiLink augeasSpaceError      Error
+  HiLink augeasStatement       Statement
+  HiLink augeasString          String
+  HiLink augeasStringEscape    Special
+  HiLink augeasStringEscapeGPC Special
+  HiLink augeasRegexp          Special
+  HiLink augeasStringError     Error
+  HiLink augeasStruct          augeasStatement
+  HiLink augeasSymbolOperator  augeasOperator
+  HiLink augeasTestStatement   augeasStatement
+  HiLink augeasTodo            Todo
+  HiLink augeasType            Type
+  HiLink augeasUnclassified    augeasStatement
+  "  HiLink augeasAsm          Assembler
+  HiLink augeasError           Error
+  HiLink augeasAsmKey          augeasStatement
+  HiLink augeasShowTab         Error
+
+  delcommand HiLink
+endif
+
+
+let b:current_syntax = "augeas"
+
+" vim: ts=8 sw=2
diff --git a/doc/unambig.tex b/doc/unambig.tex
new file mode 100644 (file)
index 0000000..837def8
--- /dev/null
@@ -0,0 +1,150 @@
+\documentclass{amsart}
+
+\usepackage{amsmath}
+\usepackage{xspace}
+\usepackage{amssymb}
+\usepackage{bcprules}
+
+\newcommand{\ensmath}[1]{\ensuremath{#1}\xspace}
+
+\newcommand{\opnam}[1]{\ensmath{\operatorname{\mathit{#1}}}}
+\newcommand{\nget}{\opnam{get}}
+\newcommand{\nput}{\opnam{put}}
+\newcommand{\ncreate}{\opnam{create}}
+\newcommand{\nkey}{\opnam{key}}
+\newcommand{\lget}[1]{\opnam{get}{#1}}
+\newcommand{\lput}[3]{\opnam{put}{#1}\,{#2}\,{#3}}
+\newcommand{\lcreate}[2]{\opnam{create}{#1}\,{#2}}
+\newcommand{\lkey}[1]{\nkey{#1}}
+
+\newcommand{\suff}{\ensmath{\operatorname{suff}}}
+\newcommand{\pref}{\ensmath{\operatorname{pref}}}
+\newcommand{\lenstype}[3][K]{\ensmath{{#2}\stackrel{#1}{\Longleftrightarrow}{#3}}}
+\newcommand{\tree}[1]{\ensmath{[#1]}}
+\newcommand{\niltree}{\ensmath{[]}}
+\newcommand{\Regexp}{\ensmath{\mathcal R}}
+\newcommand{\reglang}[1]{\ensmath{[\![{#1}]\!]}}
+\newcommand{\lens}[1]{\opnam{#1}}
+\newcommand{\eps}{\ensmath{\epsilon}}
+\newcommand{\conc}[2]{\ensmath{#1\cdot #2}}
+\newcommand{\uaconc}[2]{\ensmath{#1\cdot^{!} #2}}
+\newcommand{\xconc}[2]{\ensmath{#1\odot #2}}
+\newcommand{\alt}[2]{\ensmath{#1\,|\,#2}}
+\newcommand{\cstar}[1]{\ensmath{#1^*}}
+\newcommand{\uastar}[1]{\ensmath{#1^{!*}}}
+\newcommand{\Trees}{\ensmath{\mathcal T}}
+\newcommand{\Words}{\ensmath{\Sigma^*}}
+\newcommand{\Wordsrhd}{\ensmath{\Words\cup\rhd}}
+\newcommand{\tmap}[2]{\ensmath{#1\mapsto #2}}
+\newcommand{\tmaptt}[2]{\ensmath{{\mathtt #1}\mapsto {\mathtt #2}}}
+\newcommand{\dom}[1]{\ensmath{\mathrm{dom}(#1)}}
+\newcommand{\List}{\ensmath{\mathtt{List}}}
+\newcommand{\redigits}{\ensmath{\mathtt{D}}}
+
+\newcommand{\noeps}[1]{\ensmath{{#1}_{\setminus \epsilon}}}
+
+\newtheorem{theorem}{Theorem}
+\newtheorem{lemma}[theorem]{Lemma}
+{\theoremstyle{definition}
+  \newtheorem{defn}{Definition}
+  \newtheorem*{remark}{Remark}
+  \newtheorem*{example}{Example}}
+
+\begin{document}
+
+\section*{Ambiguity}
+
+\begin{defn}
+  For a language $L$ over $\Sigma$, define
+  \begin{equation*}
+    \begin{split}
+      \suff(L) = \{ p \in \Sigma^+ | \exists u \in L: up \in L \}\\
+      \pref(L) = \{ p \in \Sigma^+ | \exists v \in L: pv \in L \}
+    \end{split}
+  \end{equation*}
+\end{defn}
+Note that $\suff(L)$ and $\pref(L)$ do not contain $\eps$. Note also that
+we only take prefixes and suffixes that can be expanded to a word in $L$
+with another word in $L$, not any word in $\Sigma^*$.
+
+The set $\suff(L)$ is identical to the left quotient $L^{-1}L$ of $L$ by
+itself. Similarly, $\pref(L) = LL^{-1}$.
+
+\begin{defn}
+Two languages $L_1$ and $L_2$ are \emph{unambiguosuly concatenable},
+written \uaconc{L_1}{L_2}, iff for every $u_1, v_1 \in L_1$ and $u_2, v_2
+\in L_2$, if $u_1u_2=v_1v_2$ then $u_1=v_1$ and $u_2=v_2$.
+\end{defn}
+
+\begin{lemma}
+  The languages $L_1$ and $L_2$ are unambiguously concatenable if and only
+  if $\suff(L_1) \cap \pref(L_2) = \emptyset$.
+\end{lemma}
+\begin{proof}
+Let $L_1$ and $L_2$ not unambiguously concatenable, i.e. there exist $u_1$,
+$v_1$ in $L_1$ and $u_2$, $v_2$ in $L_2$ such that $u_1u_2=v_1v_2$ and
+$u_1\neq v_1$ and therefore $u_2 \neq v_2$. Assume $u_1$ is strictly
+shorter than $v_1$, therefore $v_1 = u_1 p, p \neq \eps$. With that $v_1v_2
+= u_1pv_2$ and $u_2 = pv_2$ and $p \in \suff(L_1) \cap \pref(L_2)$
+
+Let $p \in \suff(L_1) \cap \pref(L_2)$. That implies that
+there are $u\in L_1$ and $v\in L_2$ such that $up\in L_1$ and $pv\in
+L_2$. The word $upv$ can be split as $\conc{up}{v}$ and as $\conc{u}{pv}$
+and therefore $L_1$ and $L_2$ are not unambiguously concatenable.
+\end{proof}
+
+To ease notation we write $\noeps{L}$ for $L\setminus \{
+\epsilon \}$.
+
+\begin{defn}
+A language $L$ is \emph{unambiguously iterable}, written \uastar{L}, iff
+for every $u_1,\dots,u_m, v_1,\dots,v_n \in \noeps{L}$ with $u_1\cdots u_m
+= v_1 \cdots v_n$, $m=n$ and $u_i = v_i$.
+\end{defn}
+
+It is very important that we exclude $\epsilon$ in the definition of
+unambiguous iteration, since otherwise \emph{any} language $L$ that
+contains $\epsilon$ is trivially not ambiguously iterable, even though that
+presents no problems for our purposes, since we never split $\epsilon$ into
+more than one word.
+
+\begin{lemma}
+The language $L$ is unambiguously iterable if and only if $\noeps{L}$ and
+$\noeps{\cstar{L}}$ are unambiguously concatenable.
+\end{lemma}
+\begin{proof}
+Let $L$ be unambiguously iterable, and assume that there is $u_1v_1 =
+u_2v_2$ with $u_i \in \noeps{L}$ and $v_i \in \noeps{\cstar{L}}$ and $u_1
+\neq u_2$. This contradicts $\uastar{L}$ since $\noeps{L}\cdot
+\noeps{\cstar{L}}\subseteq \cstar{L}$.
+
+Let $\uaconc{\noeps{L}}{\noeps{\cstar{L}}}$ and assume there are
+$u_1,\dots,u_m, v_1,\dots,v_n \in \noeps{L}$ with $u_1\cdots u_m = v_1
+\cdots v_n$, but there is an $i \leq \min(m,n)$ with $u_i \neq v_i$. We can
+assume that $u_1 \neq v_1$\footnote{if $u_1 = v_1$, we simply use
+  $u_2\cdots u_m$ and $v_2 \cdots v_n$ for this argument}, and therefore
+$\min(m,n)\geq 2$. Since $u_1$ and $v_1$ are in $\noeps{L}$, we have an
+ambiguous split of a word from $\noeps{L}\cdot\noeps{\cstar{L}}$,
+contradicting the initial assumption.
+\end{proof}
+
+\begin{example}
+Using regular expression notation, the language $L=(a|b|c|abc)$ is
+unambiguously concatenable with itself, but not unambiguosly
+iterable. $\cstar{L} = (a|b|c)^*$ and the word $abcabc$ can be split into
+$abc\cdot abc$ and $a\cdot bcabc$. This example shows that $\uaconc{L}{L}$
+does not imply $\uastar{L}$, but as the previous lemma showed,
+$\uaconc{\noeps{L}}{\noeps{\cstar{L}}}$ does.
+\end{example}
+
+If you have $P = \suff(L_1) \cap \pref(L_2)$, how do you generate a word that
+is ambiguous ?
+\end{document}
+
+%% TeX-parse-self: t
+%% TeX-auto-save: t
+
+%% Local Variables:
+%% TeX-master: "unambig.tex"
+%% compile-command: "pdflatex -file-line-error -halt-on-error unambig.tex"
+%% End:
diff --git a/doc/xpath.txt b/doc/xpath.txt
new file mode 100644 (file)
index 0000000..cd12ebe
--- /dev/null
@@ -0,0 +1,335 @@
+Path expressions
+================
+
+In the public API, especially for aug_match and aug_get, tree nodes can be
+identified with a powerful syntax, that is modelled on the XPath syntax for
+XML documents.
+
+In the simplest case, a path expression just lists a path to some node in
+the tree, for example,
+
+   /files/etc/hosts/1/ipaddr
+
+If multiple nodes have the same label, one of them can be picked out by
+providing its position, either counting from the first such node (at
+position 1) or counting from the end. For example, the second alias of the
+first host entry is
+
+   /files/etc/hosts/1/alias[2]
+
+and the penultimate alias is
+
+   /files/etc/hosts/1/alias[last() - 1]
+
+For /etc/hosts, each entry can be thought of as a primary key (the ipaddr)
+and additional attributes relating to that primary key, namely the
+canonical host name and its aliases. It is therefore natural to refer to
+host entries by their ipaddr, not by the synthetic sequence number in their
+path. The canonical name of the host entry with ipaddr 127.0.0.1 can be
+found with
+
+   /files/etc/hosts/*[ipaddr = "127.0.0.1"]/canonical
+
+or, equivalently, with
+
+   /files/etc/hosts/*/canonical[../ipaddr = "127.0.0.1"]
+
+The canonical names of all hosts that have at least one alias:
+
+   /files/etc/hosts/*/canonical[../alias]
+
+It is also possible to search bigger parts of the tree by using '//'. For
+example, all nodes called 'ipaddr' underneath /files/etc can be found with
+
+   /files/etc//ipaddr
+
+This is handy for finding errors reported by Augeas underneath /augeas:
+
+   /augeas//error
+
+A lazy way to find localhost is
+
+  /files/etc//ipaddr[. = '127.0.0.1']
+
+The vardir entry in the main section of puppet.conf is at
+
+  /files/etc/puppet/puppet.conf/section[. = "main"]/vardir
+
+All pam entries that use the system-auth module:
+
+  /files/etc/pam.d/*[.//module = "system-auth"]
+
+More examples can be found in tests/xpath.tests
+
+One further extension that might be useful is to add boolean operators for
+predicates, so that we can write
+
+ /files/etc/hosts/ipaddr[../alias = 'localhost' or ../canonical = 'localhost']
+
+Grammar for path expressions
+============================
+
+Formally, path expressions are generated by this grammar. The grammar uses
+nonterminals from the XPath 1.0 grammar to point out the similarities
+between XPath and Augeas path expressions.
+
+Unfortunately, the production for PathExpr is ambiguous, since Augeas is
+too liberal in what it allows as labels for tree nodes: the expression '42'
+can either be the number 42 (a PrimaryExpr) or the RelativeLocationPath
+'child::42'. The reason for this ambiguity is that we allow node names like
+'42' in the tree; rather than forbid them, we resolve the ambiguity by
+always parsing '42' as a number, and requiring that the user write the
+RelativeLocationPath in a different form, e.g. 'child::42' or './42'.
+
+LocationPath ::= RelativeLocationPath | AbsoluteLocationPath
+
+AbsoluteLocationPath ::= '/' RelativeLocationPath?
+                       | AbbreviatedAbsoluteLocationPath
+AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath
+
+RelativeLocationPath ::= Step
+                       | RelativeLocationPath '/' Step
+                       | AbbreviatedRelativeLocationPath
+AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
+
+Step ::= AxisSpecifier NameTest Predicate* | '.' | '..'
+AxisSpecifier ::= AxisName '::' | <epsilon>
+AxisName ::= 'ancestor'
+           | 'ancestor-or-self'
+           | 'child'
+           | 'descendant'
+           | 'descendant-or-self'
+           | 'parent'
+           | 'self'
+           | 'root'
+NameTest     ::= '*' | Name
+Predicate    ::= "[" Expr "]" *
+
+PathExpr ::= LocationPath
+           | FilterExpr
+           | FilterExpr '/' RelativeLocationPath
+           | FilterExpr '//' RelativeLocationPath
+
+FilterExpr ::= PrimaryExpr Predicate
+
+PrimaryExpr ::= Literal
+              | Number
+              | FunctionCall
+              | VariableReference
+              | '(' Expr ')'
+
+FunctionCall ::= Name '(' ( Expr ( ',' Expr )* )? ')'
+
+Expr ::= EqualityExpr
+EqualityExpr ::= RelationalExpr (EqualityOp RelationalExpr)? | ReMatchExpr
+ReMatchExpr ::= RelationalExpr "=~" RelationalExpr
+EqualityOp ::= "=" | "!="
+RelationalExpr ::= AdditiveExpr (RelationalOp AdditiveExpr)?
+RelationalOp ::= ">" | "<" | ">=" | "<="
+AdditiveExpr ::= MultiplicativeExpr (AdditiveOp MultiplicativeExpr)*
+AdditiveOp   ::= '+' | '-'
+MultiplicativeExpr ::= UnionExpr ('*' UnionExpr)*
+UnionExpr ::= PathExpr ("|" PathExpr)*
+
+Literal ::= '"' /[^"]* / '"' | "'" /[^']* / "'"
+Number       ::= /[0-9]+/
+Name ::= /([^][/\= \t\n]|\\.)+/
+
+VariableReference ::= '$' /[a-zA-Z_][a-zA-Z0-9_]*/
+
+Additional stuff
+================
+
+Just for reference, not really interesting as documentation
+
+XPath 1.0 (from http://www.w3.org/TR/xpath)
+-------------------------------------------
+
+[ 1] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath
+[ 2] AbsoluteLocationPath ::= '/' RelativeLocationPath?
+                            | AbbreviatedAbsoluteLocationPath
+[ 3] RelativeLocationPath ::= Step
+                           | RelativeLocationPath '/' Step
+                           | AbbreviatedRelativeLocationPath
+[ 4] Step ::= AxisSpecifier NodeTest Predicate*
+            | AbbreviatedStep
+[ 5] AxisSpecifier ::= AxisName '::'
+                     | AbbreviatedAxisSpecifier
+[ 6] AxisName ::= 'ancestor'
+                | 'ancestor-or-self'
+                | 'attribute'
+                | 'child'
+                | 'descendant'
+                | 'descendant-or-self'
+                | 'following'
+                | 'following-sibling'
+                | 'namespace'
+                | 'parent'
+                | 'preceding'
+                | 'preceding-sibling'
+                | 'self'
+[ 7] NodeTest ::= NameTest
+                | NodeType '(' ')'
+                | 'processing-instruction' '(' Literal ')'
+[ 8] Predicate ::= '[' PredicateExpr ']'
+[ 9] PredicateExpr ::= Expr
+[10] AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath
+[11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
+[12] AbbreviatedStep ::= '.' | '..'
+[13] AbbreviatedAxisSpecifier ::= '@'?
+[14] Expr ::= OrExpr
+[15] PrimaryExpr ::= VariableReference
+                   | '(' Expr ')'
+                   | Literal
+                   | Number
+                   | FunctionCall
+[16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument )* )? ')'
+[17] Argument ::= Expr
+[18] UnionExpr ::= PathExpr
+                 | UnionExpr '|' PathExpr
+[19] PathExpr ::= LocationPath
+                | FilterExpr
+                | FilterExpr '/' RelativeLocationPath
+                | FilterExpr '//' RelativeLocationPath
+[20] FilterExpr ::= PrimaryExpr
+                  | FilterExpr Predicate
+[21] OrExpr ::= AndExpr | OrExpr 'or' AndExpr
+[22] AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr
+[23] EqualityExpr ::= RelationalExpr
+                    | EqualityExpr '=' RelationalExpr
+                    | EqualityExpr '!=' RelationalExpr
+[24] RelationalExpr ::= AdditiveExpr
+                      | RelationalExpr '<' AdditiveExpr
+                      | RelationalExpr '>' AdditiveExpr
+                      | RelationalExpr '<=' AdditiveExpr
+                      | RelationalExpr '>=' AdditiveExpr
+
+[25] AdditiveExpr ::= MultiplicativeExpr
+                    | AdditiveExpr '+' MultiplicativeExpr
+                    | AdditiveExpr '-' MultiplicativeExpr
+[26] MultiplicativeExpr ::= UnaryExpr
+                        | MultiplicativeExpr MultiplyOperator UnaryExpr
+                        | MultiplicativeExpr 'div' UnaryExpr
+                        | MultiplicativeExpr 'mod' UnaryExpr
+[27] UnaryExpr ::= UnionExpr
+                 | '-' UnaryExpr
+[28] ExprToken ::= '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
+                 | NameTest
+                 | NodeType
+                 | Operator
+                 | FunctionName
+                 | AxisName
+                 | Literal
+                 | Number
+                 | VariableReference
+[29] Literal ::= '"' [^"]* '"'
+               | "'" [^']* "'"
+[30] Number ::= Digits ('.' Digits?)? | '.' Digits
+[31] Digits ::= [0-9]+
+[32] Operator ::= OperatorName
+                | MultiplyOperator
+                | '/' | '//' | '|' | '+' | '-' | '=' | '!=' | '<' | '<=' | '>' | '>='
+[33] OperatorName ::= 'and' | 'or' | 'mod' | 'div'
+[34] MultiplyOperator ::= '*'
+[35] FunctionName ::= QName - NodeType
+[36] VariableReference ::= '$' QName
+[37] NameTest ::= '*' | NCName ':' '*' | QName
+[38] NodeType ::= 'comment' | 'text'
+                | 'processing-instruction'
+                | 'node'
+[39] ExprWhitespace ::= (#x20 | #x9 | #xD | #xA)+
+
+Useful subset
+-------------
+
+Big swath of XPath 1.0 that might be interesting for Augeas
+
+start symbol [14] Expr
+
+[14] Expr ::= OrExpr
+[21] OrExpr ::= AndExpr ('or' AndExpr)*
+[22] AndExpr ::= EqualityExpr ('and' EqualityExpr)*
+[23] EqualityExpr ::= RelationalExpr
+                    | EqualityExpr '=' RelationalExpr
+                    | EqualityExpr '!=' RelationalExpr
+[24] RelationalExpr ::= AdditiveExpr
+                      | RelationalExpr '<' AdditiveExpr
+                      | RelationalExpr '>' AdditiveExpr
+                      | RelationalExpr '<=' AdditiveExpr
+                      | RelationalExpr '>=' AdditiveExpr
+[25] AdditiveExpr ::= MultiplicativeExpr
+                    | AdditiveExpr '+' MultiplicativeExpr
+                    | AdditiveExpr '-' MultiplicativeExpr
+[26] MultiplicativeExpr ::= UnaryExpr
+                        | MultiplicativeExpr MultiplyOperator UnaryExpr
+[27] UnaryExpr ::= UnionExpr | '-' UnaryExpr
+[18] UnionExpr ::= PathExpr ('|' PathExpr)*
+
+[19] PathExpr ::= LocationPath
+                | FilterExpr
+                | FilterExpr '/' RelativeLocationPath
+                | FilterExpr '//' RelativeLocationPath
+
+[ 1] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath
+[ 3] RelativeLocationPath ::= Step
+                           | RelativeLocationPath '/' Step
+                           | AbbreviatedRelativeLocationPath
+[11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
+[ 2] AbsoluteLocationPath ::= '/' RelativeLocationPath?
+                            | AbbreviatedAbsoluteLocationPath
+[10] AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath
+
+[ 4] Step ::= AxisSpecifier NameTest Predicate* | '.' | '..'
+[ 5] AxisSpecifier ::= AxisName '::' | <epsilon>
+
+[ 6] AxisName ::= 'ancestor'
+                | 'ancestor-or-self'
+                | 'attribute'
+                | 'child'
+                | 'descendant'
+                | 'descendant-or-self'
+                | 'following'
+                | 'following-sibling'
+                | 'namespace'
+                | 'parent'
+                | 'preceding'
+                | 'preceding-sibling'
+                | 'self'
+
+[ 8] Predicate ::= '[' Expr ']'
+
+[20] FilterExpr ::= PrimaryExpr Predicate*
+[15] PrimaryExpr ::= '(' Expr ')'
+                   | Literal
+                   | Number
+                   | FunctionCall
+[16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument )* )? ')'
+[17] Argument ::= Expr
+
+Lexical structure
+
+[28] ExprToken ::= '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
+                 | NameTest
+                 | NodeType
+                 | Operator
+                 | FunctionName
+                 | AxisName
+                 | Literal
+                 | Number
+                 | VariableReference
+[29] Literal ::= '"' [^"]* '"'
+               | "'" [^']* "'"
+[30] Number ::= Digits ('.' Digits?)? | '.' Digits
+[31] Digits ::= [0-9]+
+[32] Operator ::= OperatorName
+                | MultiplyOperator
+                | '/' | '//' | '|' | '+' | '-' | '=' | '!=' | '<' | '<=' | '>' | '>='
+[33] OperatorName ::= 'and' | 'or' | 'mod' | 'div'
+[34] MultiplyOperator ::= '*'
+[35] FunctionName ::= QName - NodeType
+[36] VariableReference ::= '$' QName
+[37] NameTest ::= '*' | QName
+[38] NodeType ::= 'comment' | 'text'
+                | 'processing-instruction'
+                | 'node'
+[39] ExprWhitespace ::= (#x20 | #x9 | #xD | #xA)+
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644 (file)
index 0000000..417f91c
--- /dev/null
@@ -0,0 +1,11 @@
+
+GNULIB= ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
+
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS) \
+                       -I $(top_srcdir)/src
+
+bin_PROGRAMS = fadot
+
+fadot_SOURCES = fadot.c
+fadot_LDADD = $(top_builddir)/src/libfa.la
diff --git a/examples/Makefile.in b/examples/Makefile.in
new file mode 100644 (file)
index 0000000..489520a
--- /dev/null
@@ -0,0 +1,1267 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = fadot$(EXEEXT)
+subdir = examples
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_fadot_OBJECTS = fadot.$(OBJEXT)
+fadot_OBJECTS = $(am_fadot_OBJECTS)
+fadot_DEPENDENCIES = $(top_builddir)/src/libfa.la
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(fadot_SOURCES)
+DIST_SOURCES = $(fadot_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+GNULIB = ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS = -I $(top_srcdir)/gnulib/lib
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS) \
+                       -I $(top_srcdir)/src
+
+fadot_SOURCES = fadot.c
+fadot_LDADD = $(top_builddir)/src/libfa.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu examples/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+fadot$(EXEEXT): $(fadot_OBJECTS) $(fadot_DEPENDENCIES) 
+       @rm -f fadot$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(fadot_OBJECTS) $(fadot_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fadot.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+       pdf pdf-am ps ps-am tags uninstall uninstall-am \
+       uninstall-binPROGRAMS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/examples/fadot.c b/examples/fadot.c
new file mode 100644 (file)
index 0000000..5eb8a0b
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * fadot.c: example usage of finite automata library
+ *
+ * Copyright (C) 2009, Francis Giraldeau
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
+ */
+
+/*
+ * The purpose of this example is to show the usage of libfa
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
+
+#include "fa.h"
+
+const char *progname;
+
+static const char *const escape_chars    = "\"\a\b\t\n\v\f\r\\";
+static const char *const escape_names = "\"abtnvfr\\";
+
+__attribute__((noreturn))
+static void usage(void) {
+  fprintf(stderr, "\nUsage: %s [OPTIONS] REGEXP\n", progname);
+  fprintf(stderr, "\nCompile REGEXP and apply operation to them. By default, just print\n");
+  fprintf(stderr, "the minimized regexp.\n");
+  fprintf(stderr, "\nOptions:\n\n");
+  fprintf(stderr, "  -o OPERATION       one of : show concat union intersect\n");
+  fprintf(stderr, "                              complement minus example\n");
+  fprintf(stderr, "  -f DOT_FILE        Path of output .dot file\n");
+  fprintf(stderr, "  -n                 do not minimize resulting finite automaton\n");
+
+  exit(EXIT_FAILURE);
+}
+
+int main (int argc, char **argv) {
+
+  opterr = 0;
+
+  int reduce = 1;
+  char *file_output = NULL;
+  const char *operation = NULL;
+  FILE *fd;
+  int c;
+  int nb_regexp = 0;
+
+  progname = argv[0];
+
+  while ((c = getopt (argc, argv, "nf:o:")) != -1)
+    switch (c)
+      {
+      case 'n':
+        reduce = 0;
+        break;
+      case 'f':
+        file_output = optarg;
+        break;
+      case 'o':
+        operation = optarg;
+        break;
+      case '?':
+        if (optopt == 'o' || optopt == 'f')
+          fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+        else if (isprint (optopt))
+          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+        else
+          fprintf (stderr,
+                   "Unknown option character `\\x%x'.\n",
+                   optopt);
+        usage();
+        break;
+      default:
+        usage();
+        break;
+      }
+
+  //printf ("reduce = %d, file_output = %s, operation = %s\n",
+  //        reduce, file_output, operation);
+
+  if (operation == NULL)
+    operation = "show";
+
+  for (int i = optind; i < argc; i++) {
+    nb_regexp++;
+  }
+
+  if (nb_regexp == 0) {
+    printf("Please specify regexp to process.\n");
+    usage();
+  }
+
+  struct fa* fa_result = NULL;
+
+  if (!strcmp(operation,"show")) {
+    fa_compile(argv[optind], strlen(argv[optind]), &fa_result);
+  } else if (!strcmp(operation,"concat")) {
+
+    if (nb_regexp < 2) {
+      fprintf(stderr,"Please specify 2 or more regexp to concat");
+      return 1;
+    }
+
+    fa_result = fa_make_basic(FA_EPSILON);
+    struct fa* fa_tmp;
+    for (int i = optind; i < argc; i++) {
+      fa_compile(argv[i], strlen(argv[i]), &fa_tmp);
+      fa_result = fa_concat(fa_result, fa_tmp);
+    }
+
+  } else if (!strcmp(operation, "union")) {
+
+    if (nb_regexp < 2) {
+      fprintf(stderr,"Please specify 2 or more regexp to union");
+      return 1;
+    }
+
+    fa_result = fa_make_basic(FA_EMPTY);
+
+    struct fa* fa_tmp;
+    for (int i = optind; i < argc; i++) {
+      fa_compile(argv[i], strlen(argv[i]), &fa_tmp);
+      fa_result = fa_union(fa_result, fa_tmp);
+    }
+
+  } else if (!strcmp(operation, "intersect")) {
+
+    if (nb_regexp < 2) {
+      fprintf(stderr,"Please specify 2 or more regexp to intersect");
+      return 1;
+    }
+
+    fa_compile(argv[optind], strlen(argv[optind]), &fa_result);
+    struct fa* fa_tmp;
+
+    for (int i = optind+1; i < argc; i++) {
+      fa_compile(argv[i], strlen(argv[i]), &fa_tmp);
+      fa_result = fa_intersect(fa_result, fa_tmp);
+    }
+
+  } else if (!strcmp(operation, "complement")) {
+
+    if (nb_regexp >= 2) {
+      fprintf(stderr,"Please specify one regexp to complement");
+      return 1;
+    }
+
+    fa_compile(argv[optind], strlen(argv[optind]), &fa_result);
+    fa_result = fa_complement(fa_result);
+
+  } else if (!strcmp(operation, "minus")) {
+
+    if (nb_regexp != 2) {
+      fprintf(stderr,"Please specify 2 regexp for operation minus");
+      return 1;
+    }
+
+    struct fa* fa_tmp1;
+    struct fa* fa_tmp2;
+    fa_compile(argv[optind], strlen(argv[optind]), &fa_tmp1);
+    fa_compile(argv[optind+1], strlen(argv[optind+1]), &fa_tmp2);
+    fa_result = fa_minus(fa_tmp1, fa_tmp2);
+
+  } else if (!strcmp(operation, "example")) {
+
+    if (nb_regexp != 1) {
+      fprintf(stderr,"Please specify one regexp for operation example");
+      return 1;
+    }
+
+    char* word = NULL;
+    size_t word_len = 0;
+    fa_compile(argv[optind], strlen(argv[optind]), &fa_result);
+    fa_example(fa_result, &word, &word_len);
+    printf("Example word = %s\n", word);
+
+  }
+
+  if (reduce) {
+    fa_minimize(fa_result);
+  }
+
+  if (file_output != NULL) {
+    if ((fd = fopen(file_output, "w")) == NULL) {
+      fprintf(stderr, "Error while opening file %s \n", file_output);
+      return 1;
+    }
+
+    fa_dot(fd, fa_result);
+    fclose(fd);
+  } else {
+    int r;
+    char *rx;
+    size_t rx_len;
+
+    r = fa_as_regexp(fa_result, &rx, &rx_len);
+    if (r < 0) {
+      fprintf(stderr, "Converting FA to regexp failed\n");
+      return 1;
+    }
+
+    for (size_t i=0; i < rx_len; i++) {
+      char *p;
+      if (rx[i] && ((p = strchr(escape_chars, rx[i])) != NULL)) {
+        printf("\\%c", escape_names[p - escape_chars]);
+      } else if (! isprint(rx[i])) {
+        printf("\\%030o", (unsigned char) rx[i]);
+      } else {
+        putchar(rx[i]);
+      }
+    }
+    putchar('\n');
+  }
+
+  return 0;
+}
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
new file mode 100644 (file)
index 0000000..b299e53
--- /dev/null
@@ -0,0 +1,1652 @@
+## DO NOT EDIT! GENERATED AUTOMATICALLY!
+## Process this file with automake to produce Makefile.in.
+# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+#
+# This file is free software, distributed under the terms of the GNU
+# General Public License.  As a special exception to the GNU General
+# Public License, this file may be distributed as part of a program
+# that contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build/aux --with-tests --lgpl=2 --libtool --macro-prefix=gl argz canonicalize-lgpl fnmatch getline getopt-gnu gitlog-to-changelog isblank locale regex safe-alloc selinux-h stpcpy stpncpy strndup sys_wait vasprintf
+
+AUTOMAKE_OPTIONS = 1.5 gnits
+
+SUBDIRS =
+noinst_HEADERS =
+noinst_LIBRARIES =
+noinst_LTLIBRARIES =
+EXTRA_DIST =
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES = core *.stackdump
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
+AM_CPPFLAGS =
+AM_CFLAGS =
+
+noinst_LTLIBRARIES += libgnu.la
+
+libgnu_la_SOURCES =
+libgnu_la_LIBADD = $(gl_LTLIBOBJS)
+libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
+EXTRA_libgnu_la_SOURCES =
+libgnu_la_LDFLAGS = $(AM_LDFLAGS)
+libgnu_la_LDFLAGS += -no-undefined
+libgnu_la_LDFLAGS += $(LIB_SELINUX)
+libgnu_la_LDFLAGS += $(LTLIBINTL)
+
+## begin gnulib module alloca
+
+
+EXTRA_DIST += alloca.c
+
+EXTRA_libgnu_la_SOURCES += alloca.c
+
+libgnu_la_LIBADD += @LTALLOCA@
+libgnu_la_DEPENDENCIES += @LTALLOCA@
+## end   gnulib module alloca
+
+## begin gnulib module alloca-opt
+
+BUILT_SOURCES += $(ALLOCA_H)
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+alloca.h: alloca.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/alloca.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+MOSTLYCLEANFILES += alloca.h alloca.h-t
+
+EXTRA_DIST += alloca.in.h
+
+## end   gnulib module alloca-opt
+
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/build/aux/arg-nonnull.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/build/aux/arg-nonnull.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/arg-nonnull.h
+
+## end   gnulib module arg-nonnull
+
+## begin gnulib module argz
+
+BUILT_SOURCES += $(ARGZ_H)
+
+# We need the following in order to create <argz.h> when the system
+# doesn't have one that works with the given compiler.
+argz.h: argz.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/argz.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+MOSTLYCLEANFILES += argz.h argz.h-t
+
+EXTRA_DIST += argz.c argz.in.h
+
+EXTRA_libgnu_la_SOURCES += argz.c
+
+## end   gnulib module argz
+
+## begin gnulib module btowc
+
+
+EXTRA_DIST += btowc.c
+
+EXTRA_libgnu_la_SOURCES += btowc.c
+
+## end   gnulib module btowc
+
+## begin gnulib module c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build/aux/c++defs.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build/aux/c++defs.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/c++defs.h
+
+## end   gnulib module c++defs
+
+## begin gnulib module canonicalize-lgpl
+
+
+EXTRA_DIST += canonicalize-lgpl.c
+
+EXTRA_libgnu_la_SOURCES += canonicalize-lgpl.c
+
+## end   gnulib module canonicalize-lgpl
+
+## begin gnulib module configmake
+
+# Listed in the same order as the GNU makefile conventions, and
+# provided by autoconf 2.59c+.
+# The Automake-defined pkg* macros are appended, in the order
+# listed in the Automake 1.10a+ documentation.
+configmake.h: Makefile
+       $(AM_V_GEN)rm -f $@-t && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         echo '#define PREFIX "$(prefix)"'; \
+         echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
+         echo '#define BINDIR "$(bindir)"'; \
+         echo '#define SBINDIR "$(sbindir)"'; \
+         echo '#define LIBEXECDIR "$(libexecdir)"'; \
+         echo '#define DATAROOTDIR "$(datarootdir)"'; \
+         echo '#define DATADIR "$(datadir)"'; \
+         echo '#define SYSCONFDIR "$(sysconfdir)"'; \
+         echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
+         echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
+         echo '#define INCLUDEDIR "$(includedir)"'; \
+         echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
+         echo '#define DOCDIR "$(docdir)"'; \
+         echo '#define INFODIR "$(infodir)"'; \
+         echo '#define HTMLDIR "$(htmldir)"'; \
+         echo '#define DVIDIR "$(dvidir)"'; \
+         echo '#define PDFDIR "$(pdfdir)"'; \
+         echo '#define PSDIR "$(psdir)"'; \
+         echo '#define LIBDIR "$(libdir)"'; \
+         echo '#define LISPDIR "$(lispdir)"'; \
+         echo '#define LOCALEDIR "$(localedir)"'; \
+         echo '#define MANDIR "$(mandir)"'; \
+         echo '#define MANEXT "$(manext)"'; \
+         echo '#define PKGDATADIR "$(pkgdatadir)"'; \
+         echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
+         echo '#define PKGLIBDIR "$(pkglibdir)"'; \
+         echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
+       } | sed '/""/d' > $@-t && \
+       if test -f $@ && cmp $@-t $@ > /dev/null; then \
+         rm -f $@-t; \
+       else \
+         rm -f $@; mv $@-t $@; \
+       fi
+
+BUILT_SOURCES += configmake.h
+CLEANFILES += configmake.h configmake.h-t
+
+## end   gnulib module configmake
+
+## begin gnulib module ctype
+
+BUILT_SOURCES += ctype.h
+
+# We need the following in order to create <ctype.h> when the system
+# doesn't have one that works with the given compiler.
+ctype.h: ctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \
+             -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \
+             -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/ctype.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += ctype.h ctype.h-t
+
+EXTRA_DIST += ctype.in.h
+
+## end   gnulib module ctype
+
+## begin gnulib module dosname
+
+
+EXTRA_DIST += dosname.h
+
+## end   gnulib module dosname
+
+## begin gnulib module errno
+
+BUILT_SOURCES += $(ERRNO_H)
+
+# We need the following in order to create <errno.h> when the system
+# doesn't have one that is POSIX compliant.
+errno.h: errno.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
+             -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
+             -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
+             -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
+             -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
+             -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
+             -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
+             < $(srcdir)/errno.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += errno.h errno.h-t
+
+EXTRA_DIST += errno.in.h
+
+## end   gnulib module errno
+
+## begin gnulib module float
+
+BUILT_SOURCES += $(FLOAT_H)
+
+# We need the following in order to create <float.h> when the system
+# doesn't have one that works with the given compiler.
+float.h: float.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
+             < $(srcdir)/float.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += float.h float.h-t
+
+EXTRA_DIST += float.in.h
+
+## end   gnulib module float
+
+## begin gnulib module fnmatch
+
+BUILT_SOURCES += $(FNMATCH_H)
+
+# We need the following in order to create <fnmatch.h> when the system
+# doesn't have one that supports the required API.
+fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             < $(srcdir)/fnmatch.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
+
+EXTRA_DIST += fnmatch.c fnmatch.in.h fnmatch_loop.c
+
+EXTRA_libgnu_la_SOURCES += fnmatch.c fnmatch_loop.c
+
+## end   gnulib module fnmatch
+
+## begin gnulib module getdelim
+
+
+EXTRA_DIST += getdelim.c
+
+EXTRA_libgnu_la_SOURCES += getdelim.c
+
+## end   gnulib module getdelim
+
+## begin gnulib module getline
+
+
+EXTRA_DIST += getline.c
+
+EXTRA_libgnu_la_SOURCES += getline.c
+
+## end   gnulib module getline
+
+## begin gnulib module getopt-posix
+
+BUILT_SOURCES += $(GETOPT_H)
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+getopt.h: getopt.in.h $(ARG_NONNULL_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_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_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             < $(srcdir)/getopt.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+MOSTLYCLEANFILES += getopt.h getopt.h-t
+
+EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h
+
+EXTRA_libgnu_la_SOURCES += getopt.c getopt1.c
+
+## end   gnulib module getopt-posix
+
+## begin gnulib module gettext-h
+
+libgnu_la_SOURCES += gettext.h
+
+## end   gnulib module gettext-h
+
+## begin gnulib module gitlog-to-changelog
+
+
+EXTRA_DIST += $(top_srcdir)/build/aux/gitlog-to-changelog
+
+## end   gnulib module gitlog-to-changelog
+
+## begin gnulib module isblank
+
+
+EXTRA_DIST += isblank.c
+
+EXTRA_libgnu_la_SOURCES += isblank.c
+
+## end   gnulib module isblank
+
+## begin gnulib module langinfo
+
+BUILT_SOURCES += langinfo.h
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+             -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \
+             -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+             -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
+             -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+             -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
+             -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+             -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/langinfo.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += langinfo.h langinfo.h-t
+
+EXTRA_DIST += langinfo.in.h
+
+## end   gnulib module langinfo
+
+## begin gnulib module localcharset
+
+libgnu_la_SOURCES += localcharset.h localcharset.c
+
+# We need the following in order to install a simple file in $(libdir)
+# which is shared with other installed packages. We use a list of referencing
+# packages so that "make uninstall" will remove the file if and only if it
+# is not used by another installed package.
+# On systems with glibc-2.1 or newer, the file is redundant, therefore we
+# avoid installing it.
+
+all-local: charset.alias ref-add.sed ref-del.sed
+
+charset_alias = $(DESTDIR)$(libdir)/charset.alias
+charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
+install-exec-local: install-exec-localcharset
+install-exec-localcharset: all-local
+       if test $(GLIBC21) = no; then \
+         case '$(host_os)' in \
+           darwin[56]*) \
+             need_charset_alias=true ;; \
+           darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+             need_charset_alias=false ;; \
+           *) \
+             need_charset_alias=true ;; \
+         esac ; \
+       else \
+         need_charset_alias=false ; \
+       fi ; \
+       if $$need_charset_alias; then \
+         $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
+       fi ; \
+       if test -f $(charset_alias); then \
+         sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
+         $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
+         rm -f $(charset_tmp) ; \
+       else \
+         if $$need_charset_alias; then \
+           sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
+           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
+           rm -f $(charset_tmp) ; \
+         fi ; \
+       fi
+
+uninstall-local: uninstall-localcharset
+uninstall-localcharset: all-local
+       if test -f $(charset_alias); then \
+         sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
+         if grep '^# Packages using this file: $$' $(charset_tmp) \
+             > /dev/null; then \
+           rm -f $(charset_alias); \
+         else \
+           $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
+         fi; \
+         rm -f $(charset_tmp); \
+       fi
+
+charset.alias: config.charset
+       $(AM_V_GEN)rm -f t-$@ $@ && \
+       $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
+       mv t-$@ $@
+
+SUFFIXES += .sed .sin
+.sin.sed:
+       $(AM_V_GEN)rm -f t-$@ $@ && \
+       sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
+       mv t-$@ $@
+
+CLEANFILES += charset.alias ref-add.sed ref-del.sed
+
+EXTRA_DIST += config.charset ref-add.sin ref-del.sin
+
+## end   gnulib module localcharset
+
+## begin gnulib module locale
+
+BUILT_SOURCES += locale.h
+
+# We need the following in order to create <locale.h> when the system
+# doesn't have one that provides all definitions.
+locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''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)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/locale.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += locale.h locale.h-t
+
+EXTRA_DIST += locale.in.h
+
+## end   gnulib module locale
+
+## begin gnulib module lstat
+
+
+EXTRA_DIST += lstat.c
+
+EXTRA_libgnu_la_SOURCES += lstat.c
+
+## end   gnulib module lstat
+
+## begin gnulib module malloc-gnu
+
+
+EXTRA_DIST += malloc.c
+
+EXTRA_libgnu_la_SOURCES += malloc.c
+
+## end   gnulib module malloc-gnu
+
+## begin gnulib module malloc-posix
+
+
+EXTRA_DIST += malloc.c
+
+EXTRA_libgnu_la_SOURCES += malloc.c
+
+## end   gnulib module malloc-posix
+
+## begin gnulib module malloca
+
+libgnu_la_SOURCES += malloca.c
+
+EXTRA_DIST += malloca.h malloca.valgrind
+
+## end   gnulib module malloca
+
+## begin gnulib module mbrtowc
+
+
+EXTRA_DIST += mbrtowc.c
+
+EXTRA_libgnu_la_SOURCES += mbrtowc.c
+
+## end   gnulib module mbrtowc
+
+## begin gnulib module mbsinit
+
+
+EXTRA_DIST += mbsinit.c
+
+EXTRA_libgnu_la_SOURCES += mbsinit.c
+
+## end   gnulib module mbsinit
+
+## begin gnulib module mbsrtowcs
+
+
+EXTRA_DIST += mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c
+
+EXTRA_libgnu_la_SOURCES += mbsrtowcs-state.c mbsrtowcs.c
+
+## end   gnulib module mbsrtowcs
+
+## begin gnulib module mbtowc
+
+
+EXTRA_DIST += mbtowc-impl.h mbtowc.c
+
+EXTRA_libgnu_la_SOURCES += mbtowc.c
+
+## end   gnulib module mbtowc
+
+## begin gnulib module memchr
+
+
+EXTRA_DIST += memchr.c memchr.valgrind
+
+EXTRA_libgnu_la_SOURCES += memchr.c
+
+## end   gnulib module memchr
+
+## begin gnulib module mempcpy
+
+
+EXTRA_DIST += mempcpy.c
+
+EXTRA_libgnu_la_SOURCES += mempcpy.c
+
+## end   gnulib module mempcpy
+
+## begin gnulib module nl_langinfo
+
+
+EXTRA_DIST += nl_langinfo.c
+
+EXTRA_libgnu_la_SOURCES += nl_langinfo.c
+
+## end   gnulib module nl_langinfo
+
+## begin gnulib module pathmax
+
+
+EXTRA_DIST += pathmax.h
+
+## end   gnulib module pathmax
+
+## begin gnulib module readlink
+
+
+EXTRA_DIST += readlink.c
+
+EXTRA_libgnu_la_SOURCES += readlink.c
+
+## end   gnulib module readlink
+
+## begin gnulib module realloc-posix
+
+
+EXTRA_DIST += realloc.c
+
+EXTRA_libgnu_la_SOURCES += realloc.c
+
+## end   gnulib module realloc-posix
+
+## begin gnulib module regex
+
+
+EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c
+
+EXTRA_libgnu_la_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
+
+## end   gnulib module regex
+
+## begin gnulib module safe-alloc
+
+
+EXTRA_DIST += safe-alloc.c safe-alloc.h
+
+EXTRA_libgnu_la_SOURCES += safe-alloc.c
+
+## end   gnulib module safe-alloc
+
+## begin gnulib module selinux-h
+
+libgnu_la_SOURCES += se-context.in.h se-selinux.in.h
+
+BUILT_SOURCES += selinux/selinux.h
+selinux/selinux.h: se-selinux.in.h $(UNUSED_PARAMETER_H)
+       $(AM_V_at)$(MKDIR_P) selinux
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \
+             -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
+             < $(srcdir)/se-selinux.in.h; \
+       } > $@-t && \
+       chmod a-x $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
+
+BUILT_SOURCES += $(SELINUX_CONTEXT_H)
+selinux/context.h: se-context.in.h $(UNUSED_PARAMETER_H)
+       $(AM_V_at)$(MKDIR_P) selinux
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
+             < $(srcdir)/se-context.in.h; \
+       } > $@-t && \
+       chmod a-x $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
+MOSTLYCLEANDIRS += selinux
+
+EXTRA_DIST += getfilecon.c
+
+EXTRA_libgnu_la_SOURCES += getfilecon.c
+
+## end   gnulib module selinux-h
+
+## begin gnulib module size_max
+
+libgnu_la_SOURCES += size_max.h
+
+## end   gnulib module size_max
+
+## begin gnulib module stat
+
+
+EXTRA_DIST += stat.c
+
+EXTRA_libgnu_la_SOURCES += stat.c
+
+## end   gnulib module stat
+
+## begin gnulib module stdbool
+
+BUILT_SOURCES += $(STDBOOL_H)
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+stdbool.h: stdbool.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += stdbool.h stdbool.h-t
+
+EXTRA_DIST += stdbool.in.h
+
+## end   gnulib module stdbool
+
+## begin gnulib module stddef
+
+BUILT_SOURCES += $(STDDEF_H)
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+stddef.h: stddef.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+             -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+             -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+             < $(srcdir)/stddef.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += stddef.h stddef.h-t
+
+EXTRA_DIST += stddef.in.h
+
+## end   gnulib module stddef
+
+## begin gnulib module stdint
+
+BUILT_SOURCES += $(STDINT_H)
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+stdint.h: stdint.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+             -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
+             -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+             -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' \
+             -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
+             -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
+             -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
+             -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
+             -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
+             -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
+             -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
+             -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
+             -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
+             < $(srcdir)/stdint.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += stdint.h stdint.h-t
+
+EXTRA_DIST += stdint.in.h
+
+## end   gnulib module stdint
+
+## begin gnulib module stdio
+
+BUILT_SOURCES += stdio.h
+
+# We need the following in order to create <stdio.h> when the system
+# doesn't have one that works with the given compiler.
+stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
+             -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
+             -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
+             -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
+             -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
+             -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
+             -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
+             -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
+             -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
+             -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
+             -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
+             -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
+             -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
+             -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
+             -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \
+             -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
+             -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
+             -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
+             -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
+             -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \
+             -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \
+             -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
+             -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \
+             -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \
+             -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \
+             -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \
+             -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \
+             -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
+             -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
+             -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \
+             -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
+             -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
+             -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
+             -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
+             -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
+             -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+             < $(srcdir)/stdio.in.h | \
+         sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+             -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
+             -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
+             -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
+             -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+             -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
+             -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+             -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+             -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+             -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+             -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+             -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
+             -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
+             -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+             -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+             -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+             -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
+             -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+             -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+             -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
+             -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
+             -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
+             -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
+             -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
+             -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
+             -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \
+             -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+             -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+             -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
+             -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \
+             -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+             -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \
+             -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \
+             -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
+             -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+             -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+             -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+             -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
+             -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+             -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+             -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+             -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+             -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
+             -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+             -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)'; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += stdio.h stdio.h-t
+
+EXTRA_DIST += stdio.in.h
+
+## end   gnulib module stdio
+
+## begin gnulib module stdlib
+
+BUILT_SOURCES += stdlib.h
+
+# We need the following in order to create <stdlib.h> when the system
+# doesn't have one that works with the given compiler.
+stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
+             -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
+             -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
+             -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
+             -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
+             -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
+             -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
+             -e 's|@''GNULIB_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' \
+             -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+             -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
+             -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
+             -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
+             -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
+             -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
+             -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
+             -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
+             -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
+             -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
+             -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
+             -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
+             -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|@''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' \
+             -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
+             -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+             -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
+             -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+             -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+             -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
+             -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+             -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
+             -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
+             -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+             -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
+             -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
+             -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+             -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+             -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
+             -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+             -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
+             -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
+             -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
+             -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
+             -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' \
+             -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+             -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)'; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += stdlib.h stdlib.h-t
+
+EXTRA_DIST += stdlib.in.h
+
+## end   gnulib module stdlib
+
+## begin gnulib module stpcpy
+
+
+EXTRA_DIST += stpcpy.c
+
+EXTRA_libgnu_la_SOURCES += stpcpy.c
+
+## end   gnulib module stpcpy
+
+## begin gnulib module stpncpy
+
+
+EXTRA_DIST += stpncpy.c
+
+EXTRA_libgnu_la_SOURCES += stpncpy.c
+
+## end   gnulib module stpncpy
+
+## begin gnulib module streq
+
+
+EXTRA_DIST += streq.h
+
+## end   gnulib module streq
+
+## begin gnulib module string
+
+BUILT_SOURCES += string.h
+
+# We need the following in order to create <string.h> when the system
+# doesn't have one that works with the given compiler.
+string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
+             -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
+             -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
+             -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \
+             -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \
+             -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
+             -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \
+             -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \
+             -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \
+             -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \
+             -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \
+             -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \
+             -e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
+             -e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
+             -e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
+             -e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \
+             -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
+             -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
+             -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
+             -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \
+             -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
+             -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
+             -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
+             -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
+             -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \
+             -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
+             -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
+             -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
+             -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
+             -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
+             -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
+             -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
+             -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
+             -e 's|@''GNULIB_STRERROR_R''@|$(GNULIB_STRERROR_R)|g' \
+             -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
+             -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
+             < $(srcdir)/string.in.h | \
+         sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+             -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
+             -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
+             -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
+             -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
+             -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
+             -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
+             -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
+             -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
+             -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
+             -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
+             -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
+             -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
+             -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
+             -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
+             -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
+             -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
+             -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
+             -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+             -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
+             -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
+             -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+             -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+             -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
+             -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
+             -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+             -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
+             -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
+             -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+             -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
+             -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+             -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+             -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
+             -e '/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)/string.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += string.h string.h-t
+
+EXTRA_DIST += string.in.h
+
+## end   gnulib module string
+
+## begin gnulib module strndup
+
+
+EXTRA_DIST += strndup.c
+
+EXTRA_libgnu_la_SOURCES += strndup.c
+
+## end   gnulib module strndup
+
+## begin gnulib module strnlen
+
+
+EXTRA_DIST += strnlen.c
+
+EXTRA_libgnu_la_SOURCES += strnlen.c
+
+## end   gnulib module strnlen
+
+## begin gnulib module strnlen1
+
+libgnu_la_SOURCES += strnlen1.h strnlen1.c
+
+## end   gnulib module strnlen1
+
+## begin gnulib module strstr-simple
+
+
+EXTRA_DIST += str-two-way.h strstr.c
+
+EXTRA_libgnu_la_SOURCES += strstr.c
+
+## end   gnulib module strstr-simple
+
+## begin gnulib module sys_stat
+
+BUILT_SOURCES += sys/stat.h
+
+# We need the following in order to create <sys/stat.h> when the system
+# has one that is incomplete.
+sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+             -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
+             -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
+             -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \
+             -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
+             -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
+             -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
+             -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
+             -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
+             -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
+             -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
+             -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
+             -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
+             -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+             -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+             -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
+             -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
+             -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+             -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+             -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+             -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+             -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+             -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+             -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+             -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+             -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+             -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
+             -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
+             -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+             -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+             -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+             -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+             -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
+             -e '/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)/sys_stat.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_stat.in.h
+
+## end   gnulib module sys_stat
+
+## begin gnulib module sys_wait
+
+BUILT_SOURCES += sys/wait.h
+
+# We need the following in order to create <sys/wait.h> when the system
+# has one that is incomplete.
+sys/wait.h: sys_wait.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \
+             -e 's|@''GNULIB_WAITPID''@|$(GNULIB_WAITPID)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/sys_wait.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += sys/wait.h sys/wait.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_wait.in.h
+
+## end   gnulib module sys_wait
+
+## begin gnulib module time
+
+BUILT_SOURCES += time.h
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
+             -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
+             -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
+             -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
+             -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
+             -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
+             -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
+             -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+             -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+             -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+             -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+             -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+             -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+             -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+             -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e '/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)/time.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += time.h time.h-t
+
+EXTRA_DIST += time.in.h
+
+## end   gnulib module time
+
+## begin gnulib module unistd
+
+BUILT_SOURCES += unistd.h
+
+# We need the following in order to create an empty placeholder for
+# <unistd.h> when the system doesn't have one.
+unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+             -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
+             -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
+             -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
+             -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \
+             -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
+             -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
+             -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \
+             -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
+             -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \
+             -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
+             -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
+             -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
+             -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
+             -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
+             -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
+             -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
+             -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \
+             -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
+             -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
+             -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
+             -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
+             -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
+             -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
+             -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
+             -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \
+             -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
+             -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
+             -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \
+             -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
+             -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
+             -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
+             -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+             -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \
+             -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
+             -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \
+             -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
+             -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
+             -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
+             -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
+             -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
+             -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
+             < $(srcdir)/unistd.in.h | \
+         sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+             -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+             -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
+             -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+             -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+             -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
+             -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
+             -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
+             -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+             -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+             -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
+             -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
+             -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
+             -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+             -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
+             -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+             -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+             -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
+             -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
+             -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
+             -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
+             -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+             -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
+             -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+             -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
+             -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
+             -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+             -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
+             -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
+             -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+             -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+             -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+             -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
+             -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
+             -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' \
+         | \
+         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' \
+             -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+             -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+             -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+             -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
+             -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
+             -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
+             -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
+             -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+             -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
+             -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+             -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
+             -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
+             -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+             -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+             -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
+             -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+             -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
+             -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
+             -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+             -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
+             -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
+             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
+             -e '/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)'; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += unistd.h unistd.h-t
+
+EXTRA_DIST += unistd.in.h
+
+## end   gnulib module unistd
+
+## begin gnulib module unused-parameter
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += unused-parameter.h
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/unused-parameter.h, except that it has the copyright header cut
+# off.
+unused-parameter.h: $(top_srcdir)/build/aux/unused-parameter.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/build/aux/unused-parameter.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
+
+UNUSED_PARAMETER_H=unused-parameter.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/unused-parameter.h
+
+## end   gnulib module unused-parameter
+
+## begin gnulib module vasnprintf
+
+
+EXTRA_DIST += asnprintf.c float+.h printf-args.c printf-args.h printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h
+
+EXTRA_libgnu_la_SOURCES += asnprintf.c printf-args.c printf-parse.c vasnprintf.c
+
+## end   gnulib module vasnprintf
+
+## begin gnulib module vasprintf
+
+
+EXTRA_DIST += asprintf.c vasprintf.c
+
+EXTRA_libgnu_la_SOURCES += asprintf.c vasprintf.c
+
+## end   gnulib module vasprintf
+
+## begin gnulib module verify
+
+libgnu_la_SOURCES += verify.h
+
+## end   gnulib module verify
+
+## begin gnulib module warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build/aux/warn-on-use.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/build/aux/warn-on-use.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/warn-on-use.h
+
+## end   gnulib module warn-on-use
+
+## begin gnulib module wchar
+
+BUILT_SOURCES += wchar.h
+
+# We need the following in order to create <wchar.h> when the system
+# version does not work standalone.
+wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
+             -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
+             -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+             -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
+             -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \
+             -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \
+             -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \
+             -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \
+             -e 's|@''GNULIB_MBSRTOWCS''@|$(GNULIB_MBSRTOWCS)|g' \
+             -e 's|@''GNULIB_MBSNRTOWCS''@|$(GNULIB_MBSNRTOWCS)|g' \
+             -e 's|@''GNULIB_WCRTOMB''@|$(GNULIB_WCRTOMB)|g' \
+             -e 's|@''GNULIB_WCSRTOMBS''@|$(GNULIB_WCSRTOMBS)|g' \
+             -e 's|@''GNULIB_WCSNRTOMBS''@|$(GNULIB_WCSNRTOMBS)|g' \
+             -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
+             -e 's|@''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' \
+             -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
+             -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
+             -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
+             -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
+             -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
+             -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+             -e 's|@''HAVE_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' \
+         | \
+         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' \
+             -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
+             -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
+             -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
+             -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
+             -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
+             -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
+             -e 's|@''REPLACE_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)'; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += wchar.h wchar.h-t
+
+EXTRA_DIST += wchar.in.h
+
+## end   gnulib module wchar
+
+## begin gnulib module wcrtomb
+
+
+EXTRA_DIST += wcrtomb.c
+
+EXTRA_libgnu_la_SOURCES += wcrtomb.c
+
+## end   gnulib module wcrtomb
+
+## begin gnulib module 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/@''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
+
+EXTRA_DIST += wctype.in.h
+
+## end   gnulib module wctype-h
+
+## begin gnulib module xsize
+
+libgnu_la_SOURCES += xsize.h
+
+## end   gnulib module xsize
+
+
+mostlyclean-local: mostlyclean-generic
+       @for dir in '' $(MOSTLYCLEANDIRS); do \
+         if test -n "$$dir" && test -d $$dir; then \
+           echo "rmdir $$dir"; rmdir $$dir; \
+         fi; \
+       done; \
+       :
diff --git a/gnulib/lib/Makefile.in b/gnulib/lib/Makefile.in
new file mode 100644 (file)
index 0000000..2fac689
--- /dev/null
@@ -0,0 +1,2527 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+#
+# This file is free software, distributed under the terms of the GNU
+# General Public License.  As a special exception to the GNU General
+# Public License, this file may be distributed as part of a program
+# that contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build/aux --with-tests --lgpl=2 --libtool --macro-prefix=gl argz canonicalize-lgpl fnmatch getline getopt-gnu gitlog-to-changelog isblank locale regex safe-alloc selinux-h stpcpy stpncpy strndup sys_wait vasprintf
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = gnulib/lib
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in alloca.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am_libgnu_la_OBJECTS = localcharset.lo malloca.lo strnlen1.lo
+libgnu_la_OBJECTS = $(am_libgnu_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libgnu_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libgnu_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES)
+DIST_SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+HEADERS = $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = 1.5 gnits
+SUBDIRS = 
+noinst_HEADERS = 
+noinst_LIBRARIES = 
+noinst_LTLIBRARIES = libgnu.la
+EXTRA_DIST = alloca.c alloca.in.h \
+       $(top_srcdir)/build/aux/arg-nonnull.h argz.c argz.in.h btowc.c \
+       $(top_srcdir)/build/aux/c++defs.h canonicalize-lgpl.c \
+       ctype.in.h dosname.h errno.in.h float.in.h fnmatch.c \
+       fnmatch.in.h fnmatch_loop.c getdelim.c getline.c getopt.c \
+       getopt.in.h getopt1.c getopt_int.h \
+       $(top_srcdir)/build/aux/gitlog-to-changelog isblank.c \
+       langinfo.in.h config.charset ref-add.sin ref-del.sin \
+       locale.in.h lstat.c malloc.c malloc.c malloca.h \
+       malloca.valgrind mbrtowc.c mbsinit.c mbsrtowcs-impl.h \
+       mbsrtowcs-state.c mbsrtowcs.c mbtowc-impl.h mbtowc.c memchr.c \
+       memchr.valgrind mempcpy.c nl_langinfo.c pathmax.h readlink.c \
+       realloc.c regcomp.c regex.c regex.h regex_internal.c \
+       regex_internal.h regexec.c safe-alloc.c safe-alloc.h \
+       getfilecon.c stat.c stdbool.in.h stddef.in.h stdint.in.h \
+       stdio.in.h stdlib.in.h stpcpy.c stpncpy.c streq.h string.in.h \
+       strndup.c strnlen.c str-two-way.h strstr.c sys_stat.in.h \
+       sys_wait.in.h time.in.h unistd.in.h \
+       $(top_srcdir)/build/aux/unused-parameter.h asnprintf.c \
+       float+.h printf-args.c printf-args.h printf-parse.c \
+       printf-parse.h vasnprintf.c vasnprintf.h asprintf.c \
+       vasprintf.c $(top_srcdir)/build/aux/warn-on-use.h wchar.in.h \
+       wcrtomb.c wctype.in.h
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+BUILT_SOURCES = $(ALLOCA_H) arg-nonnull.h $(ARGZ_H) c++defs.h \
+       configmake.h ctype.h $(ERRNO_H) $(FLOAT_H) $(FNMATCH_H) \
+       $(GETOPT_H) langinfo.h locale.h selinux/selinux.h \
+       $(SELINUX_CONTEXT_H) $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) \
+       stdio.h stdlib.h string.h sys/stat.h sys/wait.h time.h \
+       unistd.h unused-parameter.h warn-on-use.h wchar.h wctype.h
+SUFFIXES = .sed .sin
+MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arg-nonnull.h \
+       arg-nonnull.h-t argz.h argz.h-t c++defs.h c++defs.h-t ctype.h \
+       ctype.h-t errno.h errno.h-t float.h float.h-t fnmatch.h \
+       fnmatch.h-t getopt.h getopt.h-t langinfo.h langinfo.h-t \
+       locale.h locale.h-t selinux/selinux.h selinux/selinux.h-t \
+       selinux/context.h selinux/context.h-t stdbool.h stdbool.h-t \
+       stddef.h stddef.h-t stdint.h stdint.h-t stdio.h stdio.h-t \
+       stdlib.h stdlib.h-t string.h string.h-t sys/stat.h \
+       sys/stat.h-t sys/wait.h sys/wait.h-t time.h time.h-t unistd.h \
+       unistd.h-t unused-parameter.h unused-parameter.h-t \
+       warn-on-use.h warn-on-use.h-t wchar.h wchar.h-t wctype.h \
+       wctype.h-t
+MOSTLYCLEANDIRS = selinux sys sys
+CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \
+       ref-del.sed
+DISTCLEANFILES = 
+MAINTAINERCLEANFILES = 
+AM_CPPFLAGS = 
+AM_CFLAGS = 
+libgnu_la_SOURCES = gettext.h localcharset.h localcharset.c malloca.c \
+       se-context.in.h se-selinux.in.h size_max.h strnlen1.h \
+       strnlen1.c verify.h xsize.h
+libgnu_la_LIBADD = $(gl_LTLIBOBJS) @LTALLOCA@
+libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) @LTALLOCA@
+EXTRA_libgnu_la_SOURCES = alloca.c argz.c btowc.c canonicalize-lgpl.c \
+       fnmatch.c fnmatch_loop.c getdelim.c getline.c getopt.c \
+       getopt1.c isblank.c lstat.c malloc.c malloc.c mbrtowc.c \
+       mbsinit.c mbsrtowcs-state.c mbsrtowcs.c mbtowc.c memchr.c \
+       mempcpy.c nl_langinfo.c readlink.c realloc.c regcomp.c regex.c \
+       regex_internal.c regexec.c safe-alloc.c getfilecon.c stat.c \
+       stpcpy.c stpncpy.c strndup.c strnlen.c strstr.c asnprintf.c \
+       printf-args.c printf-parse.c vasnprintf.c asprintf.c \
+       vasprintf.c wcrtomb.c
+libgnu_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(LIB_SELINUX) \
+       $(LTLIBINTL)
+ARG_NONNULL_H = arg-nonnull.h
+CXXDEFS_H = c++defs.h
+charset_alias = $(DESTDIR)$(libdir)/charset.alias
+charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
+UNUSED_PARAMETER_H = unused-parameter.h
+WARN_ON_USE_H = warn-on-use.h
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .sed .sin .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits gnulib/lib/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnits gnulib/lib/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+libgnu.la: $(libgnu_la_OBJECTS) $(libgnu_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(libgnu_la_LINK)  $(libgnu_la_OBJECTS) $(libgnu_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argz.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btowc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/canonicalize-lgpl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch_loop.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdelim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfilecon.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getline.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isblank.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloca.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrtowc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsinit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs-state.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsrtowcs.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbtowc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memchr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_langinfo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-args.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-parse.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlink.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regcomp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_internal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-alloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stpcpy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stpncpy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strndup.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasnprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcrtomb.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-recursive
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) all-local
+installdirs: installdirs-recursive
+installdirs-am:
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+       clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -rf $(DEPDIR) ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-exec-local
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -rf $(DEPDIR) ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool mostlyclean-local
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-local
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
+       ctags-recursive install install-am install-strip \
+       tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am all-local check check-am clean clean-generic \
+       clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
+       ctags ctags-recursive distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-exec-local install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       installdirs-am maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool mostlyclean-local pdf pdf-am ps ps-am tags \
+       tags-recursive uninstall uninstall-am uninstall-local
+
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+alloca.h: alloca.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/alloca.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/build/aux/arg-nonnull.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/build/aux/arg-nonnull.h \
+         > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <argz.h> when the system
+# doesn't have one that works with the given compiler.
+argz.h: argz.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         cat $(srcdir)/argz.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build/aux/c++defs.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build/aux/c++defs.h \
+         > $@-t && \
+       mv $@-t $@
+
+# Listed in the same order as the GNU makefile conventions, and
+# provided by autoconf 2.59c+.
+# The Automake-defined pkg* macros are appended, in the order
+# listed in the Automake 1.10a+ documentation.
+configmake.h: Makefile
+       $(AM_V_GEN)rm -f $@-t && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         echo '#define PREFIX "$(prefix)"'; \
+         echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
+         echo '#define BINDIR "$(bindir)"'; \
+         echo '#define SBINDIR "$(sbindir)"'; \
+         echo '#define LIBEXECDIR "$(libexecdir)"'; \
+         echo '#define DATAROOTDIR "$(datarootdir)"'; \
+         echo '#define DATADIR "$(datadir)"'; \
+         echo '#define SYSCONFDIR "$(sysconfdir)"'; \
+         echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
+         echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
+         echo '#define INCLUDEDIR "$(includedir)"'; \
+         echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
+         echo '#define DOCDIR "$(docdir)"'; \
+         echo '#define INFODIR "$(infodir)"'; \
+         echo '#define HTMLDIR "$(htmldir)"'; \
+         echo '#define DVIDIR "$(dvidir)"'; \
+         echo '#define PDFDIR "$(pdfdir)"'; \
+         echo '#define PSDIR "$(psdir)"'; \
+         echo '#define LIBDIR "$(libdir)"'; \
+         echo '#define LISPDIR "$(lispdir)"'; \
+         echo '#define LOCALEDIR "$(localedir)"'; \
+         echo '#define MANDIR "$(mandir)"'; \
+         echo '#define MANEXT "$(manext)"'; \
+         echo '#define PKGDATADIR "$(pkgdatadir)"'; \
+         echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
+         echo '#define PKGLIBDIR "$(pkglibdir)"'; \
+         echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
+       } | sed '/""/d' > $@-t && \
+       if test -f $@ && cmp $@-t $@ > /dev/null; then \
+         rm -f $@-t; \
+       else \
+         rm -f $@; mv $@-t $@; \
+       fi
+
+# We need the following in order to create <ctype.h> when the system
+# doesn't have one that works with the given compiler.
+ctype.h: ctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \
+             -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \
+             -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/ctype.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <errno.h> when the system
+# doesn't have one that is POSIX compliant.
+errno.h: errno.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
+             -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
+             -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
+             -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
+             -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
+             -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
+             -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
+             < $(srcdir)/errno.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <float.h> when the system
+# doesn't have one that works with the given compiler.
+float.h: float.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
+             < $(srcdir)/float.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <fnmatch.h> when the system
+# doesn't have one that supports the required API.
+fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             < $(srcdir)/fnmatch.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+
+# We need the following in order to create <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+getopt.h: getopt.in.h $(ARG_NONNULL_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_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_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             < $(srcdir)/getopt.in.h; \
+       } > $@-t && \
+       mv -f $@-t $@
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+             -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \
+             -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+             -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
+             -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+             -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
+             -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+             -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/langinfo.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to install a simple file in $(libdir)
+# which is shared with other installed packages. We use a list of referencing
+# packages so that "make uninstall" will remove the file if and only if it
+# is not used by another installed package.
+# On systems with glibc-2.1 or newer, the file is redundant, therefore we
+# avoid installing it.
+
+all-local: charset.alias ref-add.sed ref-del.sed
+install-exec-local: install-exec-localcharset
+install-exec-localcharset: all-local
+       if test $(GLIBC21) = no; then \
+         case '$(host_os)' in \
+           darwin[56]*) \
+             need_charset_alias=true ;; \
+           darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+             need_charset_alias=false ;; \
+           *) \
+             need_charset_alias=true ;; \
+         esac ; \
+       else \
+         need_charset_alias=false ; \
+       fi ; \
+       if $$need_charset_alias; then \
+         $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
+       fi ; \
+       if test -f $(charset_alias); then \
+         sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
+         $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
+         rm -f $(charset_tmp) ; \
+       else \
+         if $$need_charset_alias; then \
+           sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
+           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
+           rm -f $(charset_tmp) ; \
+         fi ; \
+       fi
+
+uninstall-local: uninstall-localcharset
+uninstall-localcharset: all-local
+       if test -f $(charset_alias); then \
+         sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
+         if grep '^# Packages using this file: $$' $(charset_tmp) \
+             > /dev/null; then \
+           rm -f $(charset_alias); \
+         else \
+           $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
+         fi; \
+         rm -f $(charset_tmp); \
+       fi
+
+charset.alias: config.charset
+       $(AM_V_GEN)rm -f t-$@ $@ && \
+       $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
+       mv t-$@ $@
+.sin.sed:
+       $(AM_V_GEN)rm -f t-$@ $@ && \
+       sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
+       mv t-$@ $@
+
+# We need the following in order to create <locale.h> when the system
+# doesn't have one that provides all definitions.
+locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''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)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/locale.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+selinux/selinux.h: se-selinux.in.h $(UNUSED_PARAMETER_H)
+       $(AM_V_at)$(MKDIR_P) selinux
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \
+             -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
+             < $(srcdir)/se-selinux.in.h; \
+       } > $@-t && \
+       chmod a-x $@-t && \
+       mv $@-t $@
+selinux/context.h: se-context.in.h $(UNUSED_PARAMETER_H)
+       $(AM_V_at)$(MKDIR_P) selinux
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
+             < $(srcdir)/se-context.in.h; \
+       } > $@-t && \
+       chmod a-x $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <stdbool.h> when the system
+# doesn't have one that works.
+stdbool.h: stdbool.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+stddef.h: stddef.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+             -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+             -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+             < $(srcdir)/stddef.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+stdint.h: stdint.in.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+             -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
+             -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+             -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' \
+             -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
+             -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
+             -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
+             -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
+             -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
+             -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
+             -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
+             -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
+             -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
+             -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
+             < $(srcdir)/stdint.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <stdio.h> when the system
+# doesn't have one that works with the given compiler.
+stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
+             -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
+             -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
+             -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
+             -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
+             -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
+             -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
+             -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
+             -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
+             -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
+             -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
+             -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
+             -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
+             -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
+             -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \
+             -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
+             -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
+             -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
+             -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
+             -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \
+             -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \
+             -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
+             -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \
+             -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \
+             -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \
+             -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \
+             -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \
+             -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
+             -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
+             -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \
+             -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
+             -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
+             -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
+             -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
+             -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
+             -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
+             -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+             < $(srcdir)/stdio.in.h | \
+         sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+             -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
+             -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
+             -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
+             -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+             -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
+             -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
+             -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
+             -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+             -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+             -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
+             -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
+             -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
+             -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+             -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+             -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+             -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
+             -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+             -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+             -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
+             -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
+             -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
+             -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
+             -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
+             -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
+             -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \
+             -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+             -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+             -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
+             -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \
+             -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+             -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \
+             -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \
+             -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
+             -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+             -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+             -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+             -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
+             -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+             -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+             -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+             -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+             -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
+             -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+             -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)'; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <stdlib.h> when the system
+# doesn't have one that works with the given compiler.
+stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
+             -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
+             -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
+             -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
+             -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
+             -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
+             -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
+             -e 's|@''GNULIB_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' \
+             -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+             -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
+             -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \
+             -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
+             -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
+             -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
+             -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
+             -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
+             -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
+             -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
+             -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
+             -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
+             -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|@''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' \
+             -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
+             -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+             -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
+             -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+             -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+             -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
+             -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+             -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
+             -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
+             -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+             -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
+             -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
+             -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+             -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+             -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
+             -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+             -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
+             -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
+             -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
+             -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
+             -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' \
+             -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+             -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)'; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <string.h> when the system
+# doesn't have one that works with the given compiler.
+string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
+             -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
+             -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
+             -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \
+             -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \
+             -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
+             -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \
+             -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \
+             -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \
+             -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \
+             -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \
+             -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \
+             -e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
+             -e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
+             -e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
+             -e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \
+             -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
+             -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
+             -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
+             -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \
+             -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
+             -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
+             -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
+             -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
+             -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \
+             -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
+             -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
+             -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
+             -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
+             -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
+             -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
+             -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
+             -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
+             -e 's|@''GNULIB_STRERROR_R''@|$(GNULIB_STRERROR_R)|g' \
+             -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
+             -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
+             < $(srcdir)/string.in.h | \
+         sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+             -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
+             -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
+             -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
+             -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
+             -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
+             -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
+             -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
+             -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
+             -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
+             -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
+             -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
+             -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
+             -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
+             -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
+             -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
+             -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
+             -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
+             -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+             -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
+             -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
+             -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+             -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+             -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
+             -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
+             -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+             -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
+             -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
+             -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+             -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
+             -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+             -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+             -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
+             -e '/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)/string.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <sys/stat.h> when the system
+# has one that is incomplete.
+sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+             -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
+             -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
+             -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \
+             -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
+             -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
+             -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
+             -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
+             -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
+             -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
+             -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
+             -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
+             -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
+             -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+             -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+             -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
+             -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
+             -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+             -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+             -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+             -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+             -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+             -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+             -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+             -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+             -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+             -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
+             -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
+             -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+             -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+             -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+             -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+             -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
+             -e '/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)/sys_stat.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <sys/wait.h> when the system
+# has one that is incomplete.
+sys/wait.h: sys_wait.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_WAIT_H''@|$(NEXT_SYS_WAIT_H)|g' \
+             -e 's|@''GNULIB_WAITPID''@|$(GNULIB_WAITPID)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/sys_wait.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
+             -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
+             -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
+             -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
+             -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
+             -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
+             -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
+             -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+             -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+             -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
+             -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+             -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+             -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+             -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+             -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             -e '/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)/time.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create an empty placeholder for
+# <unistd.h> when the system doesn't have one.
+unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+             -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
+             -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
+             -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
+             -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \
+             -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
+             -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
+             -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \
+             -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
+             -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \
+             -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
+             -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
+             -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
+             -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
+             -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
+             -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
+             -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
+             -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \
+             -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
+             -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
+             -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
+             -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
+             -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
+             -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
+             -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
+             -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \
+             -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
+             -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
+             -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \
+             -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
+             -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
+             -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
+             -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+             -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \
+             -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
+             -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \
+             -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
+             -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
+             -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
+             -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
+             -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
+             -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
+             < $(srcdir)/unistd.in.h | \
+         sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+             -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+             -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
+             -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+             -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+             -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
+             -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
+             -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
+             -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+             -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+             -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
+             -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
+             -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
+             -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+             -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
+             -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+             -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+             -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
+             -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
+             -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
+             -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
+             -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+             -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
+             -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+             -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
+             -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
+             -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+             -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
+             -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
+             -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+             -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+             -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+             -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
+             -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
+             -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' \
+         | \
+         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' \
+             -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+             -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+             -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+             -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
+             -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
+             -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
+             -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
+             -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+             -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
+             -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+             -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
+             -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
+             -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+             -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+             -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
+             -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+             -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
+             -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
+             -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+             -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
+             -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
+             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
+             -e '/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)'; \
+       } > $@-t && \
+       mv $@-t $@
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/unused-parameter.h, except that it has the copyright header cut
+# off.
+unused-parameter.h: $(top_srcdir)/build/aux/unused-parameter.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/build/aux/unused-parameter.h \
+         > $@-t && \
+       mv $@-t $@
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build/aux/warn-on-use.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/build/aux/warn-on-use.h \
+         > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <wchar.h> when the system
+# version does not work standalone.
+wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
+             -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
+             -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+             -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
+             -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \
+             -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \
+             -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \
+             -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \
+             -e 's|@''GNULIB_MBSRTOWCS''@|$(GNULIB_MBSRTOWCS)|g' \
+             -e 's|@''GNULIB_MBSNRTOWCS''@|$(GNULIB_MBSNRTOWCS)|g' \
+             -e 's|@''GNULIB_WCRTOMB''@|$(GNULIB_WCRTOMB)|g' \
+             -e 's|@''GNULIB_WCSRTOMBS''@|$(GNULIB_WCSRTOMBS)|g' \
+             -e 's|@''GNULIB_WCSNRTOMBS''@|$(GNULIB_WCSNRTOMBS)|g' \
+             -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
+             -e 's|@''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' \
+             -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
+             -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
+             -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
+             -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
+             -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
+             -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+             -e 's|@''HAVE_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' \
+         | \
+         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' \
+             -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
+             -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
+             -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
+             -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
+             -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
+             -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
+             -e 's|@''REPLACE_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)'; \
+       } > $@-t && \
+       mv $@-t $@
+
+# 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 $@
+
+mostlyclean-local: mostlyclean-generic
+       @for dir in '' $(MOSTLYCLEANDIRS); do \
+         if test -n "$$dir" && test -d $$dir; then \
+           echo "rmdir $$dir"; rmdir $$dir; \
+         fi; \
+       done; \
+       :
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/gnulib/lib/alloca.c b/gnulib/lib/alloca.c
new file mode 100644 (file)
index 0000000..0e5b796
--- /dev/null
@@ -0,0 +1,491 @@
+/* alloca.c -- allocate automatically reclaimed memory
+   (Mostly) portable public-domain implementation -- D A Gwyn
+
+   This implementation of the PWB library alloca function,
+   which is used to allocate space off the run-time stack so
+   that it is automatically reclaimed upon procedure exit,
+   was inspired by discussions with J. Q. Johnson of Cornell.
+   J.Otto Tennant <jot@cray.com> contributed the Cray support.
+
+   There are some preprocessor constants that can
+   be defined when compiling for your specific system, for
+   improved efficiency; however, the defaults should be okay.
+
+   The general concept of this implementation is to keep
+   track of all alloca-allocated blocks, and reclaim any
+   that are found to be deeper in the stack than the current
+   invocation.  This heuristic does not reclaim storage as
+   soon as it becomes invalid, but it will do so eventually.
+
+   As a special case, alloca(0) reclaims storage without
+   allocating any.  It is a good idea to use alloca(0) in
+   your main control loop, etc. to force garbage collection.  */
+
+#include <config.h>
+
+#include <alloca.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef emacs
+# include "lisp.h"
+# include "blockinput.h"
+# ifdef EMACS_FREE
+#  undef free
+#  define free EMACS_FREE
+# endif
+#else
+# define memory_full() abort ()
+#endif
+
+/* If compiling with GCC 2, this file's not needed.  */
+#if !defined (__GNUC__) || __GNUC__ < 2
+
+/* If someone has defined alloca as a macro,
+   there must be some other way alloca is supposed to work.  */
+# ifndef alloca
+
+#  ifdef emacs
+#   ifdef static
+/* actually, only want this if static is defined as ""
+   -- this is for usg, in which emacs must undefine static
+   in order to make unexec workable
+   */
+#    ifndef STACK_DIRECTION
+you
+lose
+-- must know STACK_DIRECTION at compile-time
+/* Using #error here is not wise since this file should work for
+   old and obscure compilers.  */
+#    endif /* STACK_DIRECTION undefined */
+#   endif /* static */
+#  endif /* emacs */
+
+/* If your stack is a linked list of frames, you have to
+   provide an "address metric" ADDRESS_FUNCTION macro.  */
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+long i00afunc ();
+#   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
+#  else
+#   define ADDRESS_FUNCTION(arg) &(arg)
+#  endif
+
+/* Define STACK_DIRECTION if you know the direction of stack
+   growth for your system; otherwise it will be automatically
+   deduced at run-time.
+
+   STACK_DIRECTION > 0 => grows toward higher addresses
+   STACK_DIRECTION < 0 => grows toward lower addresses
+   STACK_DIRECTION = 0 => direction of growth unknown  */
+
+#  ifndef STACK_DIRECTION
+#   define STACK_DIRECTION      0       /* Direction unknown.  */
+#  endif
+
+#  if STACK_DIRECTION != 0
+
+#   define STACK_DIR    STACK_DIRECTION /* Known at compile-time.  */
+
+#  else /* STACK_DIRECTION == 0; need run-time code.  */
+
+static int stack_dir;           /* 1 or -1 once known.  */
+#   define STACK_DIR    stack_dir
+
+static void
+find_stack_direction (char **ptr)
+{
+  auto char dummy;              /* To get stack address.  */
+
+  if (*ptr == NULL)
+    {                           /* Initial entry.  */
+      *ptr = ADDRESS_FUNCTION (dummy);
+
+      find_stack_direction (ptr);  /* Recurse once.  */
+    }
+  else
+    {
+      /* Second entry.  */
+      if (ADDRESS_FUNCTION (dummy) > *ptr)
+        stack_dir = 1;          /* Stack grew upward.  */
+      else
+        stack_dir = -1;         /* Stack grew downward.  */
+    }
+}
+
+#  endif /* STACK_DIRECTION == 0 */
+
+/* An "alloca header" is used to:
+   (a) chain together all alloca'ed blocks;
+   (b) keep track of stack depth.
+
+   It is very important that sizeof(header) agree with malloc
+   alignment chunk size.  The following default should work okay.  */
+
+#  ifndef       ALIGN_SIZE
+#   define ALIGN_SIZE   sizeof(double)
+#  endif
+
+typedef union hdr
+{
+  char align[ALIGN_SIZE];       /* To force sizeof(header).  */
+  struct
+    {
+      union hdr *next;          /* For chaining headers.  */
+      char *deep;               /* For stack depth measure.  */
+    } h;
+} header;
+
+static header *last_alloca_header = NULL;       /* -> last alloca header.  */
+
+/* Return a pointer to at least SIZE bytes of storage,
+   which will be automatically reclaimed upon exit from
+   the procedure that called alloca.  Originally, this space
+   was supposed to be taken from the current stack frame of the
+   caller, but that method cannot be made to work for some
+   implementations of C, for example under Gould's UTX/32.  */
+
+void *
+alloca (size_t size)
+{
+  auto char probe;              /* Probes stack depth: */
+  register char *depth = ADDRESS_FUNCTION (probe);
+
+#  if STACK_DIRECTION == 0
+  if (STACK_DIR == 0)           /* Unknown growth direction.  */
+    {
+      char *addr = NULL;        /* Address of first `dummy', once known.  */
+      find_stack_direction (&addr);
+    }
+#  endif
+
+  /* Reclaim garbage, defined as all alloca'd storage that
+     was allocated from deeper in the stack than currently.  */
+
+  {
+    register header *hp;        /* Traverses linked list.  */
+
+#  ifdef emacs
+    BLOCK_INPUT;
+#  endif
+
+    for (hp = last_alloca_header; hp != NULL;)
+      if ((STACK_DIR > 0 && hp->h.deep > depth)
+          || (STACK_DIR < 0 && hp->h.deep < depth))
+        {
+          register header *np = hp->h.next;
+
+          free (hp);            /* Collect garbage.  */
+
+          hp = np;              /* -> next header.  */
+        }
+      else
+        break;                  /* Rest are not deeper.  */
+
+    last_alloca_header = hp;    /* -> last valid storage.  */
+
+#  ifdef emacs
+    UNBLOCK_INPUT;
+#  endif
+  }
+
+  if (size == 0)
+    return NULL;                /* No allocation required.  */
+
+  /* Allocate combined header + user data storage.  */
+
+  {
+    /* Address of header.  */
+    register header *new;
+
+    size_t combined_size = sizeof (header) + size;
+    if (combined_size < sizeof (header))
+      memory_full ();
+
+    new = malloc (combined_size);
+
+    if (! new)
+      memory_full ();
+
+    new->h.next = last_alloca_header;
+    new->h.deep = depth;
+
+    last_alloca_header = new;
+
+    /* User storage begins just after header.  */
+
+    return (void *) (new + 1);
+  }
+}
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+
+#   ifdef DEBUG_I00AFUNC
+#    include <stdio.h>
+#   endif
+
+#   ifndef CRAY_STACK
+#    define CRAY_STACK
+#    ifndef CRAY2
+/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
+struct stack_control_header
+  {
+    long shgrow:32;             /* Number of times stack has grown.  */
+    long shaseg:32;             /* Size of increments to stack.  */
+    long shhwm:32;              /* High water mark of stack.  */
+    long shsize:32;             /* Current size of stack (all segments).  */
+  };
+
+/* The stack segment linkage control information occurs at
+   the high-address end of a stack segment.  (The stack
+   grows from low addresses to high addresses.)  The initial
+   part of the stack segment linkage control information is
+   0200 (octal) words.  This provides for register storage
+   for the routine which overflows the stack.  */
+
+struct stack_segment_linkage
+  {
+    long ss[0200];              /* 0200 overflow words.  */
+    long sssize:32;             /* Number of words in this segment.  */
+    long ssbase:32;             /* Offset to stack base.  */
+    long:32;
+    long sspseg:32;             /* Offset to linkage control of previous
+                                   segment of stack.  */
+    long:32;
+    long sstcpt:32;             /* Pointer to task common address block.  */
+    long sscsnm;                /* Private control structure number for
+                                   microtasking.  */
+    long ssusr1;                /* Reserved for user.  */
+    long ssusr2;                /* Reserved for user.  */
+    long sstpid;                /* Process ID for pid based multi-tasking.  */
+    long ssgvup;                /* Pointer to multitasking thread giveup.  */
+    long sscray[7];             /* Reserved for Cray Research.  */
+    long ssa0;
+    long ssa1;
+    long ssa2;
+    long ssa3;
+    long ssa4;
+    long ssa5;
+    long ssa6;
+    long ssa7;
+    long sss0;
+    long sss1;
+    long sss2;
+    long sss3;
+    long sss4;
+    long sss5;
+    long sss6;
+    long sss7;
+  };
+
+#    else /* CRAY2 */
+/* The following structure defines the vector of words
+   returned by the STKSTAT library routine.  */
+struct stk_stat
+  {
+    long now;                   /* Current total stack size.  */
+    long maxc;                  /* Amount of contiguous space which would
+                                   be required to satisfy the maximum
+                                   stack demand to date.  */
+    long high_water;            /* Stack high-water mark.  */
+    long overflows;             /* Number of stack overflow ($STKOFEN) calls.  */
+    long hits;                  /* Number of internal buffer hits.  */
+    long extends;               /* Number of block extensions.  */
+    long stko_mallocs;          /* Block allocations by $STKOFEN.  */
+    long underflows;            /* Number of stack underflow calls ($STKRETN).  */
+    long stko_free;             /* Number of deallocations by $STKRETN.  */
+    long stkm_free;             /* Number of deallocations by $STKMRET.  */
+    long segments;              /* Current number of stack segments.  */
+    long maxs;                  /* Maximum number of stack segments so far.  */
+    long pad_size;              /* Stack pad size.  */
+    long current_address;       /* Current stack segment address.  */
+    long current_size;          /* Current stack segment size.  This
+                                   number is actually corrupted by STKSTAT to
+                                   include the fifteen word trailer area.  */
+    long initial_address;       /* Address of initial segment.  */
+    long initial_size;          /* Size of initial segment.  */
+  };
+
+/* The following structure describes the data structure which trails
+   any stack segment.  I think that the description in 'asdef' is
+   out of date.  I only describe the parts that I am sure about.  */
+
+struct stk_trailer
+  {
+    long this_address;          /* Address of this block.  */
+    long this_size;             /* Size of this block (does not include
+                                   this trailer).  */
+    long unknown2;
+    long unknown3;
+    long link;                  /* Address of trailer block of previous
+                                   segment.  */
+    long unknown5;
+    long unknown6;
+    long unknown7;
+    long unknown8;
+    long unknown9;
+    long unknown10;
+    long unknown11;
+    long unknown12;
+    long unknown13;
+    long unknown14;
+  };
+
+#    endif /* CRAY2 */
+#   endif /* not CRAY_STACK */
+
+#   ifdef CRAY2
+/* Determine a "stack measure" for an arbitrary ADDRESS.
+   I doubt that "lint" will like this much.  */
+
+static long
+i00afunc (long *address)
+{
+  struct stk_stat status;
+  struct stk_trailer *trailer;
+  long *block, size;
+  long result = 0;
+
+  /* We want to iterate through all of the segments.  The first
+     step is to get the stack status structure.  We could do this
+     more quickly and more directly, perhaps, by referencing the
+     $LM00 common block, but I know that this works.  */
+
+  STKSTAT (&status);
+
+  /* Set up the iteration.  */
+
+  trailer = (struct stk_trailer *) (status.current_address
+                                    + status.current_size
+                                    - 15);
+
+  /* There must be at least one stack segment.  Therefore it is
+     a fatal error if "trailer" is null.  */
+
+  if (trailer == 0)
+    abort ();
+
+  /* Discard segments that do not contain our argument address.  */
+
+  while (trailer != 0)
+    {
+      block = (long *) trailer->this_address;
+      size = trailer->this_size;
+      if (block == 0 || size == 0)
+        abort ();
+      trailer = (struct stk_trailer *) trailer->link;
+      if ((block <= address) && (address < (block + size)))
+        break;
+    }
+
+  /* Set the result to the offset in this segment and add the sizes
+     of all predecessor segments.  */
+
+  result = address - block;
+
+  if (trailer == 0)
+    {
+      return result;
+    }
+
+  do
+    {
+      if (trailer->this_size <= 0)
+        abort ();
+      result += trailer->this_size;
+      trailer = (struct stk_trailer *) trailer->link;
+    }
+  while (trailer != 0);
+
+  /* We are done.  Note that if you present a bogus address (one
+     not in any segment), you will get a different number back, formed
+     from subtracting the address of the first block.  This is probably
+     not what you want.  */
+
+  return (result);
+}
+
+#   else /* not CRAY2 */
+/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
+   Determine the number of the cell within the stack,
+   given the address of the cell.  The purpose of this
+   routine is to linearize, in some sense, stack addresses
+   for alloca.  */
+
+static long
+i00afunc (long address)
+{
+  long stkl = 0;
+
+  long size, pseg, this_segment, stack;
+  long result = 0;
+
+  struct stack_segment_linkage *ssptr;
+
+  /* Register B67 contains the address of the end of the
+     current stack segment.  If you (as a subprogram) store
+     your registers on the stack and find that you are past
+     the contents of B67, you have overflowed the segment.
+
+     B67 also points to the stack segment linkage control
+     area, which is what we are really interested in.  */
+
+  stkl = CRAY_STACKSEG_END ();
+  ssptr = (struct stack_segment_linkage *) stkl;
+
+  /* If one subtracts 'size' from the end of the segment,
+     one has the address of the first word of the segment.
+
+     If this is not the first segment, 'pseg' will be
+     nonzero.  */
+
+  pseg = ssptr->sspseg;
+  size = ssptr->sssize;
+
+  this_segment = stkl - size;
+
+  /* It is possible that calling this routine itself caused
+     a stack overflow.  Discard stack segments which do not
+     contain the target address.  */
+
+  while (!(this_segment <= address && address <= stkl))
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
+#    endif
+      if (pseg == 0)
+        break;
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      this_segment = stkl - size;
+    }
+
+  result = address - this_segment;
+
+  /* If you subtract pseg from the current end of the stack,
+     you get the address of the previous stack segment's end.
+     This seems a little convoluted to me, but I'll bet you save
+     a cycle somewhere.  */
+
+  while (pseg != 0)
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o\n", pseg, size);
+#    endif
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      result += size;
+    }
+  return (result);
+}
+
+#   endif /* not CRAY2 */
+#  endif /* CRAY */
+
+# endif /* no alloca */
+#endif /* not GCC version 2.1 */
diff --git a/gnulib/lib/alloca.in.h b/gnulib/lib/alloca.in.h
new file mode 100644 (file)
index 0000000..8012ce9
--- /dev/null
@@ -0,0 +1,56 @@
+/* Memory allocation on the stack.
+
+   Copyright (C) 1995, 1999, 2001-2004, 2006-2011 Free Software Foundation,
+   Inc.
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
+   means there is a real alloca function.  */
+#ifndef _GL_ALLOCA_H
+#define _GL_ALLOCA_H
+
+/* alloca (N) returns a pointer to N bytes of memory
+   allocated on the stack, which will last until the function returns.
+   Use of alloca should be avoided:
+     - inside arguments of function calls - undefined behaviour,
+     - in inline functions - the allocation may actually last until the
+       calling function returns,
+     - for huge N (say, N >= 65536) - you never know how large (or small)
+       the stack is, and when the stack cannot fulfill the memory allocation
+       request, the program just crashes.
+ */
+
+#ifndef alloca
+# ifdef __GNUC__
+#  define alloca __builtin_alloca
+# elif defined _AIX
+#  define alloca __alloca
+# elif defined _MSC_VER
+#  include <malloc.h>
+#  define alloca _alloca
+# elif defined __DECC && defined __VMS
+#  define alloca __ALLOCA
+# else
+#  include <stddef.h>
+#  ifdef  __cplusplus
+extern "C"
+#  endif
+void *alloca (size_t);
+# endif
+#endif
+
+#endif /* _GL_ALLOCA_H */
diff --git a/gnulib/lib/argz.c b/gnulib/lib/argz.c
new file mode 100644 (file)
index 0000000..0239432
--- /dev/null
@@ -0,0 +1,407 @@
+/* Functions for dealing with '\0' separated arg vectors.
+   Copyright (C) 1995-1998, 2000-2002, 2006, 2008-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+#include <argz.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+
+/* Add BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN.  */
+error_t
+argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len)
+{
+  size_t new_argz_len = *argz_len + buf_len;
+  char *new_argz = realloc (*argz, new_argz_len);
+  if (new_argz)
+    {
+      memcpy (new_argz + *argz_len, buf, buf_len);
+      *argz = new_argz;
+      *argz_len = new_argz_len;
+      return 0;
+    }
+  else
+    return ENOMEM;
+}
+
+/* Add STR to the argz vector in ARGZ & ARGZ_LEN.  This should be moved into
+   argz.c in libshouldbelibc.  */
+error_t
+argz_add (char **argz, size_t *argz_len, const char *str)
+{
+  return argz_append (argz, argz_len, str, strlen (str) + 1);
+}
+
+
+
+error_t
+argz_add_sep (char **argz, size_t *argz_len, const char *string, int delim)
+{
+  size_t nlen = strlen (string) + 1;
+
+  if (nlen > 1)
+    {
+      const char *rp;
+      char *wp;
+
+      *argz = (char *) realloc (*argz, *argz_len + nlen);
+      if (*argz == NULL)
+        return ENOMEM;
+
+      wp = *argz + *argz_len;
+      rp = string;
+      do
+        if (*rp == delim)
+          {
+            if (wp > *argz && wp[-1] != '\0')
+              *wp++ = '\0';
+            else
+              --nlen;
+          }
+        else
+          *wp++ = *rp;
+      while (*rp++ != '\0');
+
+      *argz_len += nlen;
+    }
+
+  return 0;
+}
+
+
+
+error_t
+argz_create_sep (const char *string, int delim, char **argz, size_t *len)
+{
+  size_t nlen = strlen (string) + 1;
+
+  if (nlen > 1)
+    {
+      const char *rp;
+      char *wp;
+
+      *argz = (char *) malloc (nlen);
+      if (*argz == NULL)
+        return ENOMEM;
+
+      rp = string;
+      wp = *argz;
+      do
+        if (*rp == delim)
+          {
+            if (wp > *argz && wp[-1] != '\0')
+              *wp++ = '\0';
+            else
+              --nlen;
+          }
+        else
+          *wp++ = *rp;
+      while (*rp++ != '\0');
+
+      if (nlen == 0)
+        {
+          free (*argz);
+          *argz = NULL;
+          *len = 0;
+        }
+
+      *len = nlen;
+    }
+  else
+    {
+      *argz = NULL;
+      *len = 0;
+    }
+
+  return 0;
+}
+
+
+/* Insert ENTRY into ARGZ & ARGZ_LEN before BEFORE, which should be an
+   existing entry in ARGZ; if BEFORE is NULL, ENTRY is appended to the end.
+   Since ARGZ's first entry is the same as ARGZ, argz_insert (ARGZ, ARGZ_LEN,
+   ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ.  If BEFORE is not
+   in ARGZ, EINVAL is returned, else if memory can't be allocated for the new
+   ARGZ, ENOMEM is returned, else 0.  */
+error_t
+argz_insert (char **argz, size_t *argz_len, char *before, const char *entry)
+{
+  if (! before)
+    return argz_add (argz, argz_len, entry);
+
+  if (before < *argz || before >= *argz + *argz_len)
+    return EINVAL;
+
+  if (before > *argz)
+    /* Make sure before is actually the beginning of an entry.  */
+    while (before[-1])
+      before--;
+
+  {
+    size_t after_before = *argz_len - (before - *argz);
+    size_t entry_len = strlen  (entry) + 1;
+    size_t new_argz_len = *argz_len + entry_len;
+    char *new_argz = realloc (*argz, new_argz_len);
+
+    if (new_argz)
+      {
+        before = new_argz + (before - *argz);
+        memmove (before + entry_len, before, after_before);
+        memmove (before, entry, entry_len);
+        *argz = new_argz;
+        *argz_len = new_argz_len;
+        return 0;
+      }
+    else
+      return ENOMEM;
+  }
+}
+
+
+char *
+argz_next (const char *argz, size_t argz_len, const char *entry)
+{
+  if (entry)
+    {
+      if (entry < argz + argz_len)
+        entry = strchr (entry, '\0') + 1;
+
+      return entry >= argz + argz_len ? NULL : (char *) entry;
+    }
+  else
+    if (argz_len > 0)
+      return (char *) argz;
+    else
+      return NULL;
+}
+
+
+/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
+   except the last into the character SEP.  */
+void
+argz_stringify (char *argz, size_t len, int sep)
+{
+  if (len > 0)
+    while (1)
+      {
+        size_t part_len = strnlen (argz, len);
+        argz += part_len;
+        len -= part_len;
+        if (len-- <= 1)         /* includes final '\0' we want to stop at */
+          break;
+        *argz++ = sep;
+      }
+}
+
+
+/* Returns the number of strings in ARGZ.  */
+size_t
+argz_count (const char *argz, size_t len)
+{
+  size_t count = 0;
+  while (len > 0)
+    {
+      size_t part_len = strlen (argz);
+      argz += part_len + 1;
+      len -= part_len + 1;
+      count++;
+    }
+  return count;
+}
+
+
+/* Puts pointers to each string in ARGZ, plus a terminating 0 element, into
+   ARGV, which must be large enough to hold them all.  */
+void
+argz_extract (const char *argz, size_t len, char **argv)
+{
+  while (len > 0)
+    {
+      size_t part_len = strlen (argz);
+      *argv++ = (char *) argz;
+      argz += part_len + 1;
+      len -= part_len + 1;
+    }
+  *argv = 0;
+}
+
+
+/* Make a '\0' separated arg vector from a unix argv vector, returning it in
+   ARGZ, and the total length in LEN.  If a memory allocation error occurs,
+   ENOMEM is returned, otherwise 0.  */
+error_t
+argz_create (char *const argv[], char **argz, size_t *len)
+{
+  int argc;
+  size_t tlen = 0;
+  char *const *ap;
+  char *p;
+
+  for (argc = 0; argv[argc] != NULL; ++argc)
+    tlen += strlen (argv[argc]) + 1;
+
+  if (tlen == 0)
+    *argz = NULL;
+  else
+    {
+      *argz = malloc (tlen);
+      if (*argz == NULL)
+        return ENOMEM;
+
+      for (p = *argz, ap = argv; *ap; ++ap, ++p)
+        p = stpcpy (p, *ap);
+    }
+  *len = tlen;
+
+  return 0;
+}
+
+
+/* Delete ENTRY from ARGZ & ARGZ_LEN, if any.  */
+void
+argz_delete (char **argz, size_t *argz_len, char *entry)
+{
+  if (entry)
+    /* Get rid of the old value for NAME.  */
+    {
+      size_t entry_len = strlen (entry) + 1;
+      *argz_len -= entry_len;
+      memmove (entry, entry + entry_len, *argz_len - (entry - *argz));
+      if (*argz_len == 0)
+        {
+          free (*argz);
+          *argz = 0;
+        }
+    }
+}
+
+
+/* Append BUF, of length BUF_LEN to *TO, of length *TO_LEN, reallocating and
+   updating *TO & *TO_LEN appropriately.  If an allocation error occurs,
+   *TO's old value is freed, and *TO is set to 0.  */
+static void
+str_append (char **to, size_t *to_len, const char *buf, const size_t buf_len)
+{
+  size_t new_len = *to_len + buf_len;
+  char *new_to = realloc (*to, new_len + 1);
+
+  if (new_to)
+    {
+      *((char *) mempcpy (new_to + *to_len, buf, buf_len)) = '\0';
+      *to = new_to;
+      *to_len = new_len;
+    }
+  else
+    {
+      free (*to);
+      *to = 0;
+    }
+}
+
+/* Replace any occurrences of the string STR in ARGZ with WITH, reallocating
+   ARGZ as necessary.  If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be
+   incremented by number of replacements performed.  */
+error_t
+argz_replace (char **argz, size_t *argz_len, const char *str, const char *with,
+                unsigned *replace_count)
+{
+  error_t err = 0;
+
+  if (str && *str)
+    {
+      char *arg = 0;
+      char *src = *argz;
+      size_t src_len = *argz_len;
+      char *dst = 0;
+      size_t dst_len = 0;
+      int delayed_copy = 1;     /* True while we've avoided copying anything.  */
+      size_t str_len = strlen (str), with_len = strlen (with);
+
+      while (!err && (arg = argz_next (src, src_len, arg)))
+        {
+          char *match = strstr (arg, str);
+          if (match)
+            {
+              char *from = match + str_len;
+              size_t to_len = match - arg;
+              char *to = strndup (arg, to_len);
+
+              while (to && from)
+                {
+                  str_append (&to, &to_len, with, with_len);
+                  if (to)
+                    {
+                      match = strstr (from, str);
+                      if (match)
+                        {
+                          str_append (&to, &to_len, from, match - from);
+                          from = match + str_len;
+                        }
+                      else
+                        {
+                          str_append (&to, &to_len, from, strlen (from));
+                          from = 0;
+                        }
+                    }
+                }
+
+              if (to)
+                {
+                  if (delayed_copy)
+                    /* We avoided copying SRC to DST until we found a match;
+                       now that we've done so, copy everything from the start
+                       of SRC.  */
+                    {
+                      if (arg > src)
+                        err = argz_append (&dst, &dst_len, src, (arg - src));
+                      delayed_copy = 0;
+                    }
+                  if (! err)
+                    err = argz_add (&dst, &dst_len, to);
+                  free (to);
+                }
+              else
+                err = ENOMEM;
+
+              if (replace_count)
+                (*replace_count)++;
+            }
+          else if (! delayed_copy)
+            err = argz_add (&dst, &dst_len, arg);
+        }
+
+      if (! err)
+        {
+          if (! delayed_copy)
+            /* We never found any instances of str.  */
+            {
+              free (src);
+              *argz = dst;
+              *argz_len = dst_len;
+            }
+        }
+      else if (dst_len > 0)
+        free (dst);
+    }
+
+  return err;
+}
diff --git a/gnulib/lib/argz.in.h b/gnulib/lib/argz.in.h
new file mode 100644 (file)
index 0000000..3a5adf3
--- /dev/null
@@ -0,0 +1,160 @@
+/* Routines for dealing with '\0' separated arg vectors.
+   Copyright (C) 1995-2000, 2004, 2007, 2009-2011 Free Software Foundation,
+   Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _ARGZ_H
+#define _ARGZ_H 1
+
+
+#define __need_error_t
+#include <errno.h>
+#include <string.h>             /* Need size_t, and strchr is called below.  */
+
+#ifndef const
+# define const const
+#endif
+
+#ifndef __error_t_defined
+typedef int error_t;
+#endif
+
+
+
+/* Make a '\0' separated arg vector from a unix argv vector, returning it in
+   ARGZ, and the total length in LEN.  If a memory allocation error occurs,
+   ENOMEM is returned, otherwise 0.  The result can be destroyed using free. */
+
+extern error_t argz_create (char *const __argv[], char **restrict __argz,
+                            size_t *restrict __len);
+
+/* Make a '\0' separated arg vector from a SEP separated list in
+   STRING, returning it in ARGZ, and the total length in LEN.  If a
+   memory allocation error occurs, ENOMEM is returned, otherwise 0.
+   The result can be destroyed using free.  */
+
+extern error_t argz_create_sep (const char *restrict string,
+                                int __sep, char **restrict __argz,
+                                size_t *restrict __len);
+
+/* Returns the number of strings in ARGZ.  */
+
+extern size_t argz_count (const char *__argz, size_t __len)
+;
+
+/* Puts pointers to each string in ARGZ into ARGV, which must be large enough
+   to hold them all.  */
+
+extern void argz_extract (const char *restrict __argz, size_t __len,
+                          char **restrict __argv);
+
+/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
+   except the last into the character SEP.  */
+
+extern void argz_stringify (char *__argz, size_t __len, int __sep);
+
+/* Append BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN.  */
+
+extern error_t argz_append (char **restrict __argz,
+                            size_t *restrict __argz_len,
+                            const char *restrict __buf, size_t __buf_len)
+;
+
+/* Append STR to the argz vector in ARGZ & ARGZ_LEN.  */
+
+extern error_t argz_add (char **restrict __argz,
+                         size_t *restrict __argz_len,
+                         const char *restrict str);
+
+/* Append SEP separated list in STRING to the argz vector in ARGZ &
+   ARGZ_LEN.  */
+
+extern error_t argz_add_sep (char **restrict __argz,
+                             size_t *restrict __argz_len,
+                             const char *restrict string, int __delim)
+;
+
+/* Delete ENTRY from ARGZ & ARGZ_LEN, if it appears there.  */
+
+extern void argz_delete (char **restrict __argz,
+                         size_t *restrict __argz_len,
+                         char *restrict __entry);
+
+/* Insert ENTRY into ARGZ & ARGZ_LEN before BEFORE, which should be an
+   existing entry in ARGZ; if BEFORE is NULL, ENTRY is appended to the end.
+   Since ARGZ's first entry is the same as ARGZ, argz_insert (ARGZ, ARGZ_LEN,
+   ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ.  If BEFORE is not
+   in ARGZ, EINVAL is returned, else if memory can't be allocated for the new
+   ARGZ, ENOMEM is returned, else 0.  */
+
+extern error_t argz_insert (char **restrict __argz,
+                            size_t *restrict __argz_len,
+                            char *restrict __before,
+                            const char *restrict __entry);
+
+/* Replace any occurrences of the string STR in ARGZ with WITH, reallocating
+   ARGZ as necessary.  If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be
+   incremented by number of replacements performed.  */
+
+extern error_t argz_replace (char **restrict __argz,
+                             size_t *restrict __argz_len,
+                             const char *restrict str,
+                             const char *restrict __with,
+                             unsigned int *restrict __replace_count);
+\f
+/* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there
+   are no more.  If entry is NULL, then the first entry is returned.  This
+   behavior allows two convenient iteration styles:
+
+    char *entry = 0;
+    while ((entry = argz_next (argz, argz_len, entry)))
+      ...;
+
+   or
+
+    char *entry;
+    for (entry = argz; entry; entry = argz_next (argz, argz_len, entry))
+      ...;
+*/
+
+extern char *argz_next (const char *restrict __argz, size_t __argz_len,
+                        const char *restrict __entry);
+
+#ifdef __USE_EXTERN_INLINES
+__extern_inline char *
+__NTH (argz_next (const char *__argz, size_t __argz_len,
+                    const char *__entry))
+{
+  if (__entry)
+    {
+      if (__entry < __argz + __argz_len)
+        __entry = strchr (__entry, '\0') + 1;
+
+      return __entry >= __argz + __argz_len ? (char *) NULL : (char *) __entry;
+    }
+  else
+    return __argz_len > 0 ? (char *) __argz : 0;
+}
+__extern_inline char *
+__NTH (argz_next (const char *__argz, size_t __argz_len,
+                  const char *__entry))
+{
+  return argz_next (__argz, __argz_len, __entry);
+}
+#endif /* Use extern inlines.  */
+
+
+#endif /* argz.h */
diff --git a/gnulib/lib/asnprintf.c b/gnulib/lib/asnprintf.c
new file mode 100644 (file)
index 0000000..0239f4a
--- /dev/null
@@ -0,0 +1,35 @@
+/* Formatted output to strings.
+   Copyright (C) 1999, 2002, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "vasnprintf.h"
+
+#include <stdarg.h>
+
+char *
+asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+  va_list args;
+  char *result;
+
+  va_start (args, format);
+  result = vasnprintf (resultbuf, lengthp, format, args);
+  va_end (args);
+  return result;
+}
diff --git a/gnulib/lib/asprintf.c b/gnulib/lib/asprintf.c
new file mode 100644 (file)
index 0000000..84728b1
--- /dev/null
@@ -0,0 +1,40 @@
+/* Formatted output to strings.
+   Copyright (C) 1999, 2002, 2006-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#ifdef IN_LIBASPRINTF
+# include "vasprintf.h"
+#else
+# include <stdio.h>
+#endif
+
+#include <stdarg.h>
+
+int
+asprintf (char **resultp, const char *format, ...)
+{
+  va_list args;
+  int result;
+
+  va_start (args, format);
+  result = vasprintf (resultp, format, args);
+  va_end (args);
+  return result;
+}
diff --git a/gnulib/lib/btowc.c b/gnulib/lib/btowc.c
new file mode 100644 (file)
index 0000000..d0fe426
--- /dev/null
@@ -0,0 +1,39 @@
+/* Convert unibyte character to wide character.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+wint_t
+btowc (int c)
+{
+  if (c != EOF)
+    {
+      char buf[1];
+      wchar_t wc;
+
+      buf[0] = c;
+      if (mbtowc (&wc, buf, 1) >= 0)
+        return wc;
+    }
+  return WEOF;
+}
diff --git a/gnulib/lib/canonicalize-lgpl.c b/gnulib/lib/canonicalize-lgpl.c
new file mode 100644 (file)
index 0000000..2c5ca9a
--- /dev/null
@@ -0,0 +1,379 @@
+/* Return the canonical absolute name of a given file.
+   Copyright (C) 1996-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the name == NULL test below.  */
+#define _GL_ARG_NONNULL(params)
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <alloca.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#if HAVE_SYS_PARAM_H || defined _LIBC
+# include <sys/param.h>
+#endif
+#include <sys/stat.h>
+#include <errno.h>
+#include <stddef.h>
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+#else
+# define SHLIB_COMPAT(lib, introduced, obsoleted) 0
+# define versioned_symbol(lib, local, symbol, version) extern int dummy
+# define compat_symbol(lib, local, symbol, version)
+# define weak_alias(local, symbol)
+# define __canonicalize_file_name canonicalize_file_name
+# define __realpath realpath
+# include "pathmax.h"
+# include "malloca.h"
+# if HAVE_GETCWD
+#  if IN_RELOCWRAPPER
+    /* When building the relocatable program wrapper, use the system's getcwd
+       function, not the gnulib override, otherwise we would get a link error.
+     */
+#   undef getcwd
+#  endif
+#  ifdef VMS
+    /* We want the directory in Unix syntax, not in VMS syntax.  */
+#   define __getcwd(buf, max) getcwd (buf, max, 0)
+#  else
+#   define __getcwd getcwd
+#  endif
+# else
+#  define __getcwd(buf, max) getwd (buf)
+# endif
+# define __readlink readlink
+# define __set_errno(e) errno = (e)
+/* Use the system functions, not the gnulib overrides in this file.  */
+# undef malloc
+# ifndef MAXSYMLINKS
+#  ifdef SYMLOOP_MAX
+#   define MAXSYMLINKS SYMLOOP_MAX
+#  else
+#   define MAXSYMLINKS 20
+#  endif
+# endif
+#endif
+
+#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
+# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
+#endif
+
+#if !FUNC_REALPATH_WORKS || defined _LIBC
+/* Return the canonical absolute name of file NAME.  A canonical name
+   does not contain any `.', `..' components nor any repeated path
+   separators ('/') or symlinks.  All path components must exist.  If
+   RESOLVED is null, the result is malloc'd; otherwise, if the
+   canonical name is PATH_MAX chars or more, returns null with `errno'
+   set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+   returns the name in RESOLVED.  If the name cannot be resolved and
+   RESOLVED is non-NULL, it contains the path of the first component
+   that cannot be resolved.  If the path can be resolved, RESOLVED
+   holds the same value as the value returned.  */
+
+char *
+__realpath (const char *name, char *resolved)
+{
+  char *rpath, *dest, *extra_buf = NULL;
+  const char *start, *end, *rpath_limit;
+  long int path_max;
+  int num_links = 0;
+
+  if (name == NULL)
+    {
+      /* As per Single Unix Specification V2 we must return an error if
+         either parameter is a null pointer.  We extend this to allow
+         the RESOLVED parameter to be NULL in case the we are expected to
+         allocate the room for the return value.  */
+      __set_errno (EINVAL);
+      return NULL;
+    }
+
+  if (name[0] == '\0')
+    {
+      /* As per Single Unix Specification V2 we must return an error if
+         the name argument points to an empty string.  */
+      __set_errno (ENOENT);
+      return NULL;
+    }
+
+#ifdef PATH_MAX
+  path_max = PATH_MAX;
+#else
+  path_max = pathconf (name, _PC_PATH_MAX);
+  if (path_max <= 0)
+    path_max = 1024;
+#endif
+
+  if (resolved == NULL)
+    {
+      rpath = malloc (path_max);
+      if (rpath == NULL)
+        {
+          /* It's easier to set errno to ENOMEM than to rely on the
+             'malloc-posix' gnulib module.  */
+          errno = ENOMEM;
+          return NULL;
+        }
+    }
+  else
+    rpath = resolved;
+  rpath_limit = rpath + path_max;
+
+  if (name[0] != '/')
+    {
+      if (!__getcwd (rpath, path_max))
+        {
+          rpath[0] = '\0';
+          goto error;
+        }
+      dest = strchr (rpath, '\0');
+    }
+  else
+    {
+      rpath[0] = '/';
+      dest = rpath + 1;
+      if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/')
+        *dest++ = '/';
+    }
+
+  for (start = end = name; *start; start = end)
+    {
+#ifdef _LIBC
+      struct stat64 st;
+#else
+      struct stat st;
+#endif
+      int n;
+
+      /* Skip sequence of multiple path-separators.  */
+      while (*start == '/')
+        ++start;
+
+      /* Find end of path component.  */
+      for (end = start; *end && *end != '/'; ++end)
+        /* Nothing.  */;
+
+      if (end - start == 0)
+        break;
+      else if (end - start == 1 && start[0] == '.')
+        /* nothing */;
+      else if (end - start == 2 && start[0] == '.' && start[1] == '.')
+        {
+          /* Back up to previous component, ignore if at root already.  */
+          if (dest > rpath + 1)
+            while ((--dest)[-1] != '/');
+          if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
+              && *dest == '/')
+            dest++;
+        }
+      else
+        {
+          size_t new_size;
+
+          if (dest[-1] != '/')
+            *dest++ = '/';
+
+          if (dest + (end - start) >= rpath_limit)
+            {
+              ptrdiff_t dest_offset = dest - rpath;
+              char *new_rpath;
+
+              if (resolved)
+                {
+                  __set_errno (ENAMETOOLONG);
+                  if (dest > rpath + 1)
+                    dest--;
+                  *dest = '\0';
+                  goto error;
+                }
+              new_size = rpath_limit - rpath;
+              if (end - start + 1 > path_max)
+                new_size += end - start + 1;
+              else
+                new_size += path_max;
+              new_rpath = (char *) realloc (rpath, new_size);
+              if (new_rpath == NULL)
+                {
+                  /* It's easier to set errno to ENOMEM than to rely on the
+                     'realloc-posix' gnulib module.  */
+                  errno = ENOMEM;
+                  goto error;
+                }
+              rpath = new_rpath;
+              rpath_limit = rpath + new_size;
+
+              dest = rpath + dest_offset;
+            }
+
+#ifdef _LIBC
+          dest = __mempcpy (dest, start, end - start);
+#else
+          memcpy (dest, start, end - start);
+          dest += end - start;
+#endif
+          *dest = '\0';
+
+#ifdef _LIBC
+          if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
+#else
+          if (lstat (rpath, &st) < 0)
+#endif
+            goto error;
+
+          if (S_ISLNK (st.st_mode))
+            {
+              char *buf;
+              size_t len;
+
+              if (++num_links > MAXSYMLINKS)
+                {
+                  __set_errno (ELOOP);
+                  goto error;
+                }
+
+              buf = malloca (path_max);
+              if (!buf)
+                {
+                  errno = ENOMEM;
+                  goto error;
+                }
+
+              n = __readlink (rpath, buf, path_max - 1);
+              if (n < 0)
+                {
+                  int saved_errno = errno;
+                  freea (buf);
+                  errno = saved_errno;
+                  goto error;
+                }
+              buf[n] = '\0';
+
+              if (!extra_buf)
+                {
+                  extra_buf = malloca (path_max);
+                  if (!extra_buf)
+                    {
+                      freea (buf);
+                      errno = ENOMEM;
+                      goto error;
+                    }
+                }
+
+              len = strlen (end);
+              if ((long int) (n + len) >= path_max)
+                {
+                  freea (buf);
+                  __set_errno (ENAMETOOLONG);
+                  goto error;
+                }
+
+              /* Careful here, end may be a pointer into extra_buf... */
+              memmove (&extra_buf[n], end, len + 1);
+              name = end = memcpy (extra_buf, buf, n);
+
+              if (buf[0] == '/')
+                {
+                  dest = rpath + 1;     /* It's an absolute symlink */
+                  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/')
+                    *dest++ = '/';
+                }
+              else
+                {
+                  /* Back up to previous component, ignore if at root
+                     already: */
+                  if (dest > rpath + 1)
+                    while ((--dest)[-1] != '/');
+                  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
+                      && *dest == '/')
+                    dest++;
+                }
+            }
+          else if (!S_ISDIR (st.st_mode) && *end != '\0')
+            {
+              __set_errno (ENOTDIR);
+              goto error;
+            }
+        }
+    }
+  if (dest > rpath + 1 && dest[-1] == '/')
+    --dest;
+  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 && *dest == '/')
+    dest++;
+  *dest = '\0';
+
+  if (extra_buf)
+    freea (extra_buf);
+
+  return rpath;
+
+error:
+  {
+    int saved_errno = errno;
+    if (extra_buf)
+      freea (extra_buf);
+    if (resolved == NULL)
+      free (rpath);
+    errno = saved_errno;
+  }
+  return NULL;
+}
+versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
+#endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
+
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
+char *
+attribute_compat_text_section
+__old_realpath (const char *name, char *resolved)
+{
+  if (resolved == NULL)
+    {
+      __set_errno (EINVAL);
+      return NULL;
+    }
+
+  return __realpath (name, resolved);
+}
+compat_symbol (libc, __old_realpath, realpath, GLIBC_2_0);
+#endif
+
+
+char *
+__canonicalize_file_name (const char *name)
+{
+  return __realpath (name, NULL);
+}
+weak_alias (__canonicalize_file_name, canonicalize_file_name)
+
+#else
+
+/* This declaration is solely to ensure that after preprocessing
+   this file is never empty.  */
+typedef int dummy;
+
+#endif
diff --git a/gnulib/lib/config.charset b/gnulib/lib/config.charset
new file mode 100644 (file)
index 0000000..74f7fec
--- /dev/null
@@ -0,0 +1,683 @@
+#! /bin/sh
+# Output a system dependent table of character encoding aliases.
+#
+#   Copyright (C) 2000-2004, 2006-2011 Free Software Foundation, Inc.
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1, or (at your option)
+#   any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU Lesser General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License along
+#   with this program; if not, write to the Free Software Foundation,
+#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The table consists of lines of the form
+#    ALIAS  CANONICAL
+#
+# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
+# ALIAS is compared in a case sensitive way.
+#
+# CANONICAL is the GNU canonical name for this character encoding.
+# It must be an encoding supported by libiconv. Support by GNU libc is
+# also desirable. CANONICAL is case insensitive. Usually an upper case
+# MIME charset name is preferred.
+# The current list of GNU canonical charset names is as follows.
+#
+#       name              MIME?             used by which systems
+#   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin cygwin
+#   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+#   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+#   ISO-8859-3              Y   glibc solaris cygwin
+#   ISO-8859-4              Y   osf solaris freebsd netbsd openbsd darwin
+#   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+#   ISO-8859-6              Y   glibc aix hpux solaris cygwin
+#   ISO-8859-7              Y   glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
+#   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin
+#   ISO-8859-9              Y   glibc aix hpux irix osf solaris darwin cygwin
+#   ISO-8859-13                 glibc netbsd openbsd darwin cygwin
+#   ISO-8859-14                 glibc cygwin
+#   ISO-8859-15                 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
+#   KOI8-R                  Y   glibc solaris freebsd netbsd openbsd darwin
+#   KOI8-U                  Y   glibc freebsd netbsd openbsd darwin cygwin
+#   KOI8-T                      glibc
+#   CP437                       dos
+#   CP775                       dos
+#   CP850                       aix osf dos
+#   CP852                       dos
+#   CP855                       dos
+#   CP856                       aix
+#   CP857                       dos
+#   CP861                       dos
+#   CP862                       dos
+#   CP864                       dos
+#   CP865                       dos
+#   CP866                       freebsd netbsd openbsd darwin dos
+#   CP869                       dos
+#   CP874                       woe32 dos
+#   CP922                       aix
+#   CP932                       aix cygwin woe32 dos
+#   CP943                       aix
+#   CP949                       osf darwin woe32 dos
+#   CP950                       woe32 dos
+#   CP1046                      aix
+#   CP1124                      aix
+#   CP1125                      dos
+#   CP1129                      aix
+#   CP1131                      darwin
+#   CP1250                      woe32
+#   CP1251                      glibc solaris netbsd openbsd darwin cygwin woe32
+#   CP1252                      aix woe32
+#   CP1253                      woe32
+#   CP1254                      woe32
+#   CP1255                      glibc woe32
+#   CP1256                      woe32
+#   CP1257                      woe32
+#   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin
+#   EUC-JP                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
+#   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+#   EUC-TW                      glibc aix hpux irix osf solaris netbsd
+#   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin
+#   BIG5-HKSCS                  glibc solaris darwin
+#   GBK                         glibc aix osf solaris darwin cygwin woe32 dos
+#   GB18030                     glibc solaris netbsd darwin
+#   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
+#   JOHAB                       glibc solaris woe32
+#   TIS-620                     glibc aix hpux osf solaris cygwin
+#   VISCII                  Y   glibc
+#   TCVN5712-1                  glibc
+#   ARMSCII-8                   glibc darwin
+#   GEORGIAN-PS                 glibc cygwin
+#   PT154                       glibc
+#   HP-ROMAN8                   hpux
+#   HP-ARABIC8                  hpux
+#   HP-GREEK8                   hpux
+#   HP-HEBREW8                  hpux
+#   HP-TURKISH8                 hpux
+#   HP-KANA8                    hpux
+#   DEC-KANJI                   osf
+#   DEC-HANYU                   osf
+#   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin
+#
+# Note: Names which are not marked as being a MIME name should not be used in
+# Internet protocols for information interchange (mail, news, etc.).
+#
+# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
+# must understand both names and treat them as equivalent.
+#
+# The first argument passed to this file is the canonical host specification,
+#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+
+host="$1"
+os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
+echo "# This file contains a table of character encoding aliases,"
+echo "# suitable for operating system '${os}'."
+echo "# It was automatically generated from config.charset."
+# List of references, updated during installation:
+echo "# Packages using this file: "
+case "$os" in
+  linux-gnulibc1*)
+    # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "C ASCII"
+    echo "POSIX ASCII"
+    for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
+             en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
+             en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
+             es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
+             et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
+             fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
+             it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
+             sv_FI sv_SE; do
+      echo "$l ISO-8859-1"
+      echo "$l.iso-8859-1 ISO-8859-1"
+      echo "$l.iso-8859-15 ISO-8859-15"
+      echo "$l.iso-8859-15@euro ISO-8859-15"
+      echo "$l@euro ISO-8859-15"
+      echo "$l.cp-437 CP437"
+      echo "$l.cp-850 CP850"
+      echo "$l.cp-1252 CP1252"
+      echo "$l.cp-1252@euro CP1252"
+      #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
+      echo "$l.utf-8 UTF-8"
+      echo "$l.utf-8@euro UTF-8"
+    done
+    for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
+             sl_SI sr sr_CS sr_YU; do
+      echo "$l ISO-8859-2"
+      echo "$l.iso-8859-2 ISO-8859-2"
+      echo "$l.cp-852 CP852"
+      echo "$l.cp-1250 CP1250"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in mk mk_MK ru ru_RU; do
+      echo "$l ISO-8859-5"
+      echo "$l.iso-8859-5 ISO-8859-5"
+      echo "$l.koi8-r KOI8-R"
+      echo "$l.cp-866 CP866"
+      echo "$l.cp-1251 CP1251"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in ar ar_SA; do
+      echo "$l ISO-8859-6"
+      echo "$l.iso-8859-6 ISO-8859-6"
+      echo "$l.cp-864 CP864"
+      #echo "$l.cp-868 CP868" # not a commonly used encoding
+      echo "$l.cp-1256 CP1256"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in el el_GR gr gr_GR; do
+      echo "$l ISO-8859-7"
+      echo "$l.iso-8859-7 ISO-8859-7"
+      echo "$l.cp-869 CP869"
+      echo "$l.cp-1253 CP1253"
+      echo "$l.cp-1253@euro CP1253"
+      echo "$l.utf-8 UTF-8"
+      echo "$l.utf-8@euro UTF-8"
+    done
+    for l in he he_IL iw iw_IL; do
+      echo "$l ISO-8859-8"
+      echo "$l.iso-8859-8 ISO-8859-8"
+      echo "$l.cp-862 CP862"
+      echo "$l.cp-1255 CP1255"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in tr tr_TR; do
+      echo "$l ISO-8859-9"
+      echo "$l.iso-8859-9 ISO-8859-9"
+      echo "$l.cp-857 CP857"
+      echo "$l.cp-1254 CP1254"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in lt lt_LT lv lv_LV; do
+      #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
+      echo "$l ISO-8859-13"
+    done
+    for l in ru_UA uk uk_UA; do
+      echo "$l KOI8-U"
+    done
+    for l in zh zh_CN; do
+      #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
+      echo "$l GB2312"
+    done
+    for l in ja ja_JP ja_JP.EUC; do
+      echo "$l EUC-JP"
+    done
+    for l in ko ko_KR; do
+      echo "$l EUC-KR"
+    done
+    for l in th th_TH; do
+      echo "$l TIS-620"
+    done
+    for l in fa fa_IR; do
+      #echo "$l ISIRI-3342" # a broken encoding
+      echo "$l.utf-8 UTF-8"
+    done
+    ;;
+  linux* | *-gnu*)
+    # With glibc-2.1 or newer, we don't need any canonicalization,
+    # because glibc has iconv and both glibc and libiconv support all
+    # GNU canonical names directly. Therefore, the Makefile does not
+    # need to install the alias file at all.
+    # The following applies only to glibc-2.0.x and older libcs.
+    echo "ISO_646.IRV:1983 ASCII"
+    ;;
+  aix*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-6 ISO-8859-6"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "IBM-850 CP850"
+    echo "IBM-856 CP856"
+    echo "IBM-921 ISO-8859-13"
+    echo "IBM-922 CP922"
+    echo "IBM-932 CP932"
+    echo "IBM-943 CP943"
+    echo "IBM-1046 CP1046"
+    echo "IBM-1124 CP1124"
+    echo "IBM-1129 CP1129"
+    echo "IBM-1252 CP1252"
+    echo "IBM-eucCN GB2312"
+    echo "IBM-eucJP EUC-JP"
+    echo "IBM-eucKR EUC-KR"
+    echo "IBM-eucTW EUC-TW"
+    echo "big5 BIG5"
+    echo "GBK GBK"
+    echo "TIS-620 TIS-620"
+    echo "UTF-8 UTF-8"
+    ;;
+  hpux*)
+    echo "iso88591 ISO-8859-1"
+    echo "iso88592 ISO-8859-2"
+    echo "iso88595 ISO-8859-5"
+    echo "iso88596 ISO-8859-6"
+    echo "iso88597 ISO-8859-7"
+    echo "iso88598 ISO-8859-8"
+    echo "iso88599 ISO-8859-9"
+    echo "iso885915 ISO-8859-15"
+    echo "roman8 HP-ROMAN8"
+    echo "arabic8 HP-ARABIC8"
+    echo "greek8 HP-GREEK8"
+    echo "hebrew8 HP-HEBREW8"
+    echo "turkish8 HP-TURKISH8"
+    echo "kana8 HP-KANA8"
+    echo "tis620 TIS-620"
+    echo "big5 BIG5"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "hp15CN GB2312"
+    #echo "ccdc ?" # what is this?
+    echo "SJIS SHIFT_JIS"
+    echo "utf8 UTF-8"
+    ;;
+  irix*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "eucCN GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    ;;
+  osf*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "cp850 CP850"
+    echo "big5 BIG5"
+    echo "dechanyu DEC-HANYU"
+    echo "dechanzi GB2312"
+    echo "deckanji DEC-KANJI"
+    echo "deckorean EUC-KR"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "GBK GBK"
+    echo "KSC5601 CP949"
+    echo "sdeckanji EUC-JP"
+    echo "SJIS SHIFT_JIS"
+    echo "TACTIS TIS-620"
+    echo "UTF-8 UTF-8"
+    ;;
+  solaris*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-3 ISO-8859-3"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-6 ISO-8859-6"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "koi8-r KOI8-R"
+    echo "ansi-1251 CP1251"
+    echo "BIG5 BIG5"
+    echo "Big5-HKSCS BIG5-HKSCS"
+    echo "gb2312 GB2312"
+    echo "GBK GBK"
+    echo "GB18030 GB18030"
+    echo "cns11643 EUC-TW"
+    echo "5601 EUC-KR"
+    echo "ko_KR.johap92 JOHAB"
+    echo "eucJP EUC-JP"
+    echo "PCK SHIFT_JIS"
+    echo "TIS620.2533 TIS-620"
+    #echo "sun_eu_greek ?" # what is this?
+    echo "UTF-8 UTF-8"
+    ;;
+  freebsd* | os2*)
+    # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
+    # reuse FreeBSD's locale data for OS/2.
+    echo "C ASCII"
+    echo "US-ASCII ASCII"
+    for l in la_LN lt_LN; do
+      echo "$l.ASCII ASCII"
+    done
+    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
+             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
+             lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
+      echo "$l.ISO_8859-1 ISO-8859-1"
+      echo "$l.DIS_8859-15 ISO-8859-15"
+    done
+    for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
+      echo "$l.ISO_8859-2 ISO-8859-2"
+    done
+    for l in la_LN lt_LT; do
+      echo "$l.ISO_8859-4 ISO-8859-4"
+    done
+    for l in ru_RU ru_SU; do
+      echo "$l.KOI8-R KOI8-R"
+      echo "$l.ISO_8859-5 ISO-8859-5"
+      echo "$l.CP866 CP866"
+    done
+    echo "uk_UA.KOI8-U KOI8-U"
+    echo "zh_TW.BIG5 BIG5"
+    echo "zh_TW.Big5 BIG5"
+    echo "zh_CN.EUC GB2312"
+    echo "ja_JP.EUC EUC-JP"
+    echo "ja_JP.SJIS SHIFT_JIS"
+    echo "ja_JP.Shift_JIS SHIFT_JIS"
+    echo "ko_KR.EUC EUC-KR"
+    ;;
+  netbsd*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "eucCN GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "BIG5 BIG5"
+    echo "SJIS SHIFT_JIS"
+    ;;
+  openbsd*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    ;;
+  darwin[56]*)
+    # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "C ASCII"
+    for l in en_AU en_CA en_GB en_US la_LN; do
+      echo "$l.US-ASCII ASCII"
+    done
+    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
+             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
+             nl_NL no_NO pt_PT sv_SE; do
+      echo "$l ISO-8859-1"
+      echo "$l.ISO8859-1 ISO-8859-1"
+      echo "$l.ISO8859-15 ISO-8859-15"
+    done
+    for l in la_LN; do
+      echo "$l.ISO8859-1 ISO-8859-1"
+      echo "$l.ISO8859-15 ISO-8859-15"
+    done
+    for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
+      echo "$l.ISO8859-2 ISO-8859-2"
+    done
+    for l in la_LN lt_LT; do
+      echo "$l.ISO8859-4 ISO-8859-4"
+    done
+    for l in ru_RU; do
+      echo "$l.KOI8-R KOI8-R"
+      echo "$l.ISO8859-5 ISO-8859-5"
+      echo "$l.CP866 CP866"
+    done
+    for l in bg_BG; do
+      echo "$l.CP1251 CP1251"
+    done
+    echo "uk_UA.KOI8-U KOI8-U"
+    echo "zh_TW.BIG5 BIG5"
+    echo "zh_TW.Big5 BIG5"
+    echo "zh_CN.EUC GB2312"
+    echo "ja_JP.EUC EUC-JP"
+    echo "ja_JP.SJIS SHIFT_JIS"
+    echo "ko_KR.EUC EUC-KR"
+    ;;
+  darwin*)
+    # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
+    # useless:
+    # - It returns the empty string when LANG is set to a locale of the
+    #   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
+    #   LC_CTYPE file.
+    # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
+    #   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
+    # - The documentation says:
+    #     "... all code that calls BSD system routines should ensure
+    #      that the const *char parameters of these routines are in UTF-8
+    #      encoding. All BSD system functions expect their string
+    #      parameters to be in UTF-8 encoding and nothing else."
+    #   It also says
+    #     "An additional caveat is that string parameters for files,
+    #      paths, and other file-system entities must be in canonical
+    #      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
+    #      characters are decomposed ..."
+    #   but this is not true: You can pass non-decomposed UTF-8 strings
+    #   to file system functions, and it is the OS which will convert
+    #   them to decomposed UTF-8 before accessing the file system.
+    # - The Apple Terminal application displays UTF-8 by default.
+    # - However, other applications are free to use different encodings:
+    #   - xterm uses ISO-8859-1 by default.
+    #   - TextEdit uses MacRoman by default.
+    # We prefer UTF-8 over decomposed UTF-8-MAC because one should
+    # minimize the use of decomposed Unicode. Unfortunately, through the
+    # Darwin file system, decomposed UTF-8 strings are leaked into user
+    # space nevertheless.
+    # Then there are also the locales with encodings other than US-ASCII
+    # and UTF-8. These locales can be occasionally useful to users (e.g.
+    # when grepping through ISO-8859-1 encoded text files), when all their
+    # file names are in US-ASCII.
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "KOI8-R KOI8-R"
+    echo "KOI8-U KOI8-U"
+    echo "CP866 CP866"
+    echo "CP949 CP949"
+    echo "CP1131 CP1131"
+    echo "CP1251 CP1251"
+    echo "eucCN GB2312"
+    echo "GB2312 GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "Big5 BIG5"
+    echo "Big5HKSCS BIG5-HKSCS"
+    echo "GBK GBK"
+    echo "GB18030 GB18030"
+    echo "SJIS SHIFT_JIS"
+    echo "ARMSCII-8 ARMSCII-8"
+    echo "PT154 PT154"
+    #echo "ISCII-DEV ?"
+    echo "* UTF-8"
+    ;;
+  beos* | haiku*)
+    # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
+    echo "* UTF-8"
+    ;;
+  msdosdjgpp*)
+    # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "#"
+    echo "# The encodings given here may not all be correct."
+    echo "# If you find that the encoding given for your language and"
+    echo "# country is not the one your DOS machine actually uses, just"
+    echo "# correct it in this file, and send a mail to"
+    echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
+    echo "# and Bruno Haible <bruno@clisp.org>."
+    echo "#"
+    echo "C ASCII"
+    # ISO-8859-1 languages
+    echo "ca CP850"
+    echo "ca_ES CP850"
+    echo "da CP865"    # not CP850 ??
+    echo "da_DK CP865" # not CP850 ??
+    echo "de CP850"
+    echo "de_AT CP850"
+    echo "de_CH CP850"
+    echo "de_DE CP850"
+    echo "en CP850"
+    echo "en_AU CP850" # not CP437 ??
+    echo "en_CA CP850"
+    echo "en_GB CP850"
+    echo "en_NZ CP437"
+    echo "en_US CP437"
+    echo "en_ZA CP850" # not CP437 ??
+    echo "es CP850"
+    echo "es_AR CP850"
+    echo "es_BO CP850"
+    echo "es_CL CP850"
+    echo "es_CO CP850"
+    echo "es_CR CP850"
+    echo "es_CU CP850"
+    echo "es_DO CP850"
+    echo "es_EC CP850"
+    echo "es_ES CP850"
+    echo "es_GT CP850"
+    echo "es_HN CP850"
+    echo "es_MX CP850"
+    echo "es_NI CP850"
+    echo "es_PA CP850"
+    echo "es_PY CP850"
+    echo "es_PE CP850"
+    echo "es_SV CP850"
+    echo "es_UY CP850"
+    echo "es_VE CP850"
+    echo "et CP850"
+    echo "et_EE CP850"
+    echo "eu CP850"
+    echo "eu_ES CP850"
+    echo "fi CP850"
+    echo "fi_FI CP850"
+    echo "fr CP850"
+    echo "fr_BE CP850"
+    echo "fr_CA CP850"
+    echo "fr_CH CP850"
+    echo "fr_FR CP850"
+    echo "ga CP850"
+    echo "ga_IE CP850"
+    echo "gd CP850"
+    echo "gd_GB CP850"
+    echo "gl CP850"
+    echo "gl_ES CP850"
+    echo "id CP850"    # not CP437 ??
+    echo "id_ID CP850" # not CP437 ??
+    echo "is CP861"    # not CP850 ??
+    echo "is_IS CP861" # not CP850 ??
+    echo "it CP850"
+    echo "it_CH CP850"
+    echo "it_IT CP850"
+    echo "lt CP775"
+    echo "lt_LT CP775"
+    echo "lv CP775"
+    echo "lv_LV CP775"
+    echo "nb CP865"    # not CP850 ??
+    echo "nb_NO CP865" # not CP850 ??
+    echo "nl CP850"
+    echo "nl_BE CP850"
+    echo "nl_NL CP850"
+    echo "nn CP865"    # not CP850 ??
+    echo "nn_NO CP865" # not CP850 ??
+    echo "no CP865"    # not CP850 ??
+    echo "no_NO CP865" # not CP850 ??
+    echo "pt CP850"
+    echo "pt_BR CP850"
+    echo "pt_PT CP850"
+    echo "sv CP850"
+    echo "sv_SE CP850"
+    # ISO-8859-2 languages
+    echo "cs CP852"
+    echo "cs_CZ CP852"
+    echo "hr CP852"
+    echo "hr_HR CP852"
+    echo "hu CP852"
+    echo "hu_HU CP852"
+    echo "pl CP852"
+    echo "pl_PL CP852"
+    echo "ro CP852"
+    echo "ro_RO CP852"
+    echo "sk CP852"
+    echo "sk_SK CP852"
+    echo "sl CP852"
+    echo "sl_SI CP852"
+    echo "sq CP852"
+    echo "sq_AL CP852"
+    echo "sr CP852"    # CP852 or CP866 or CP855 ??
+    echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
+    echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
+    # ISO-8859-3 languages
+    echo "mt CP850"
+    echo "mt_MT CP850"
+    # ISO-8859-5 languages
+    echo "be CP866"
+    echo "be_BE CP866"
+    echo "bg CP866"    # not CP855 ??
+    echo "bg_BG CP866" # not CP855 ??
+    echo "mk CP866"    # not CP855 ??
+    echo "mk_MK CP866" # not CP855 ??
+    echo "ru CP866"
+    echo "ru_RU CP866"
+    echo "uk CP1125"
+    echo "uk_UA CP1125"
+    # ISO-8859-6 languages
+    echo "ar CP864"
+    echo "ar_AE CP864"
+    echo "ar_DZ CP864"
+    echo "ar_EG CP864"
+    echo "ar_IQ CP864"
+    echo "ar_IR CP864"
+    echo "ar_JO CP864"
+    echo "ar_KW CP864"
+    echo "ar_MA CP864"
+    echo "ar_OM CP864"
+    echo "ar_QA CP864"
+    echo "ar_SA CP864"
+    echo "ar_SY CP864"
+    # ISO-8859-7 languages
+    echo "el CP869"
+    echo "el_GR CP869"
+    # ISO-8859-8 languages
+    echo "he CP862"
+    echo "he_IL CP862"
+    # ISO-8859-9 languages
+    echo "tr CP857"
+    echo "tr_TR CP857"
+    # Japanese
+    echo "ja CP932"
+    echo "ja_JP CP932"
+    # Chinese
+    echo "zh_CN GBK"
+    echo "zh_TW CP950" # not CP938 ??
+    # Korean
+    echo "kr CP949"    # not CP934 ??
+    echo "kr_KR CP949" # not CP934 ??
+    # Thai
+    echo "th CP874"
+    echo "th_TH CP874"
+    # Other
+    echo "eo CP850"
+    echo "eo_EO CP850"
+    ;;
+esac
diff --git a/gnulib/lib/ctype.in.h b/gnulib/lib/ctype.in.h
new file mode 100644 (file)
index 0000000..d44d82a
--- /dev/null
@@ -0,0 +1,58 @@
+/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible.  */
+
+/*
+ * ISO C 99 <ctype.h> for platforms on which it is incomplete.
+ * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html>
+ */
+
+#ifndef _GL_CTYPE_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Include the original <ctype.h>.  */
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_CTYPE_H@
+
+#ifndef _GL_CTYPE_H
+#define _GL_CTYPE_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Return non-zero if c is a blank, i.e. a space or tab character.  */
+#if @GNULIB_ISBLANK@
+# if !@HAVE_ISBLANK@
+_GL_EXTERN_C int isblank (int c);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef isblank
+# if HAVE_RAW_DECL_ISBLANK
+_GL_WARN_ON_USE (isblank, "isblank is unportable - "
+                 "use gnulib module isblank for portability");
+# endif
+#endif
+
+#endif /* _GL_CTYPE_H */
+#endif /* _GL_CTYPE_H */
diff --git a/gnulib/lib/dosname.h b/gnulib/lib/dosname.h
new file mode 100644 (file)
index 0000000..70bb5c2
--- /dev/null
@@ -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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+   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_ */
diff --git a/gnulib/lib/errno.in.h b/gnulib/lib/errno.in.h
new file mode 100644 (file)
index 0000000..2f9ac45
--- /dev/null
@@ -0,0 +1,167 @@
+/* A POSIX-like <errno.h>.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GL_ERRNO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
+
+#ifndef _GL_ERRNO_H
+#define _GL_ERRNO_H
+
+
+/* On native Windows platforms, many macros are not defined.  */
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value.  */
+#  define EWOULDBLOCK     EAGAIN
+
+/* Values >= 100 seem safe to use.  */
+#  define ETXTBSY   100
+#  define GNULIB_defined_ETXTBSY 1
+
+/* These are intentionally the same values as the WSA* error numbers, defined
+   in <winsock2.h>.  */
+#  define EINPROGRESS     10036
+#  define EALREADY        10037
+#  define ENOTSOCK        10038
+#  define EDESTADDRREQ    10039
+#  define EMSGSIZE        10040
+#  define EPROTOTYPE      10041
+#  define ENOPROTOOPT     10042
+#  define EPROTONOSUPPORT 10043
+#  define ESOCKTNOSUPPORT 10044  /* not required by POSIX */
+#  define EOPNOTSUPP      10045
+#  define EPFNOSUPPORT    10046  /* not required by POSIX */
+#  define EAFNOSUPPORT    10047
+#  define EADDRINUSE      10048
+#  define EADDRNOTAVAIL   10049
+#  define ENETDOWN        10050
+#  define ENETUNREACH     10051
+#  define ENETRESET       10052
+#  define ECONNABORTED    10053
+#  define ECONNRESET      10054
+#  define ENOBUFS         10055
+#  define EISCONN         10056
+#  define ENOTCONN        10057
+#  define ESHUTDOWN       10058  /* not required by POSIX */
+#  define ETOOMANYREFS    10059  /* not required by POSIX */
+#  define ETIMEDOUT       10060
+#  define ECONNREFUSED    10061
+#  define ELOOP           10062
+#  define EHOSTDOWN       10064  /* not required by POSIX */
+#  define EHOSTUNREACH    10065
+#  define EPROCLIM        10067  /* not required by POSIX */
+#  define EUSERS          10068  /* not required by POSIX */
+#  define EDQUOT          10069
+#  define ESTALE          10070
+#  define EREMOTE         10071  /* not required by POSIX */
+#  define GNULIB_defined_ESOCK 1
+
+# endif
+
+
+/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
+   EMULTIHOP, ENOLINK, EOVERFLOW are not defined.  */
+# if @EMULTIHOP_HIDDEN@
+#  define EMULTIHOP @EMULTIHOP_VALUE@
+#  define GNULIB_defined_EMULTIHOP 1
+# endif
+# if @ENOLINK_HIDDEN@
+#  define ENOLINK   @ENOLINK_VALUE@
+#  define GNULIB_defined_ENOLINK 1
+# endif
+# if @EOVERFLOW_HIDDEN@
+#  define EOVERFLOW @EOVERFLOW_VALUE@
+#  define GNULIB_defined_EOVERFLOW 1
+# endif
+
+
+/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
+   EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
+   Likewise, on NonStop Kernel, EDQUOT is not defined.
+   Define them here.  Values >= 2000 seem safe to use: Solaris ESTALE = 151,
+   HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
+
+   Note: When one of these systems defines some of these macros some day,
+   binaries will have to be recompiled so that they recognizes the new
+   errno values from the system.  */
+
+# ifndef ENOMSG
+#  define ENOMSG    2000
+#  define GNULIB_defined_ENOMSG 1
+# endif
+
+# ifndef EIDRM
+#  define EIDRM     2001
+#  define GNULIB_defined_EIDRM 1
+# endif
+
+# ifndef ENOLINK
+#  define ENOLINK   2002
+#  define GNULIB_defined_ENOLINK 1
+# endif
+
+# ifndef EPROTO
+#  define EPROTO    2003
+#  define GNULIB_defined_EPROTO 1
+# endif
+
+# ifndef EMULTIHOP
+#  define EMULTIHOP 2004
+#  define GNULIB_defined_EMULTIHOP 1
+# endif
+
+# ifndef EBADMSG
+#  define EBADMSG   2005
+#  define GNULIB_defined_EBADMSG 1
+# endif
+
+# ifndef EOVERFLOW
+#  define EOVERFLOW 2006
+#  define GNULIB_defined_EOVERFLOW 1
+# endif
+
+# ifndef ENOTSUP
+#  define ENOTSUP   2007
+#  define GNULIB_defined_ENOTSUP 1
+# endif
+
+# ifndef ESTALE
+#  define ESTALE    2009
+#  define GNULIB_defined_ESTALE 1
+# endif
+
+# ifndef EDQUOT
+#  define EDQUOT 2010
+#  define GNULIB_defined_EDQUOT 1
+# endif
+
+# ifndef ECANCELED
+#  define ECANCELED 2008
+#  define GNULIB_defined_ECANCELED 1
+# endif
+
+
+#endif /* _GL_ERRNO_H */
+#endif /* _GL_ERRNO_H */
diff --git a/gnulib/lib/float+.h b/gnulib/lib/float+.h
new file mode 100644 (file)
index 0000000..f40544f
--- /dev/null
@@ -0,0 +1,148 @@
+/* Supplemental information about the floating-point formats.
+   Copyright (C) 2007, 2009-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 under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _FLOATPLUS_H
+#define _FLOATPLUS_H
+
+#include <float.h>
+#include <limits.h>
+
+/* Number of bits in the mantissa of a floating-point number, including the
+   "hidden bit".  */
+#if FLT_RADIX == 2
+# define FLT_MANT_BIT FLT_MANT_DIG
+# define DBL_MANT_BIT DBL_MANT_DIG
+# define LDBL_MANT_BIT LDBL_MANT_DIG
+#elif FLT_RADIX == 4
+# define FLT_MANT_BIT (FLT_MANT_DIG * 2)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 2)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
+#elif FLT_RADIX == 16
+# define FLT_MANT_BIT (FLT_MANT_DIG * 4)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 4)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
+#endif
+
+/* Bit mask that can be used to mask the exponent, as an unsigned number.  */
+#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
+#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
+#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
+
+/* Number of bits used for the exponent of a floating-point number, including
+   the exponent's sign.  */
+#define FLT_EXP_BIT \
+  (FLT_EXP_MASK < 0x100 ? 8 : \
+   FLT_EXP_MASK < 0x200 ? 9 : \
+   FLT_EXP_MASK < 0x400 ? 10 : \
+   FLT_EXP_MASK < 0x800 ? 11 : \
+   FLT_EXP_MASK < 0x1000 ? 12 : \
+   FLT_EXP_MASK < 0x2000 ? 13 : \
+   FLT_EXP_MASK < 0x4000 ? 14 : \
+   FLT_EXP_MASK < 0x8000 ? 15 : \
+   FLT_EXP_MASK < 0x10000 ? 16 : \
+   FLT_EXP_MASK < 0x20000 ? 17 : \
+   FLT_EXP_MASK < 0x40000 ? 18 : \
+   FLT_EXP_MASK < 0x80000 ? 19 : \
+   FLT_EXP_MASK < 0x100000 ? 20 : \
+   FLT_EXP_MASK < 0x200000 ? 21 : \
+   FLT_EXP_MASK < 0x400000 ? 22 : \
+   FLT_EXP_MASK < 0x800000 ? 23 : \
+   FLT_EXP_MASK < 0x1000000 ? 24 : \
+   FLT_EXP_MASK < 0x2000000 ? 25 : \
+   FLT_EXP_MASK < 0x4000000 ? 26 : \
+   FLT_EXP_MASK < 0x8000000 ? 27 : \
+   FLT_EXP_MASK < 0x10000000 ? 28 : \
+   FLT_EXP_MASK < 0x20000000 ? 29 : \
+   FLT_EXP_MASK < 0x40000000 ? 30 : \
+   FLT_EXP_MASK <= 0x7fffffff ? 31 : \
+   32)
+#define DBL_EXP_BIT \
+  (DBL_EXP_MASK < 0x100 ? 8 : \
+   DBL_EXP_MASK < 0x200 ? 9 : \
+   DBL_EXP_MASK < 0x400 ? 10 : \
+   DBL_EXP_MASK < 0x800 ? 11 : \
+   DBL_EXP_MASK < 0x1000 ? 12 : \
+   DBL_EXP_MASK < 0x2000 ? 13 : \
+   DBL_EXP_MASK < 0x4000 ? 14 : \
+   DBL_EXP_MASK < 0x8000 ? 15 : \
+   DBL_EXP_MASK < 0x10000 ? 16 : \
+   DBL_EXP_MASK < 0x20000 ? 17 : \
+   DBL_EXP_MASK < 0x40000 ? 18 : \
+   DBL_EXP_MASK < 0x80000 ? 19 : \
+   DBL_EXP_MASK < 0x100000 ? 20 : \
+   DBL_EXP_MASK < 0x200000 ? 21 : \
+   DBL_EXP_MASK < 0x400000 ? 22 : \
+   DBL_EXP_MASK < 0x800000 ? 23 : \
+   DBL_EXP_MASK < 0x1000000 ? 24 : \
+   DBL_EXP_MASK < 0x2000000 ? 25 : \
+   DBL_EXP_MASK < 0x4000000 ? 26 : \
+   DBL_EXP_MASK < 0x8000000 ? 27 : \
+   DBL_EXP_MASK < 0x10000000 ? 28 : \
+   DBL_EXP_MASK < 0x20000000 ? 29 : \
+   DBL_EXP_MASK < 0x40000000 ? 30 : \
+   DBL_EXP_MASK <= 0x7fffffff ? 31 : \
+   32)
+#define LDBL_EXP_BIT \
+  (LDBL_EXP_MASK < 0x100 ? 8 : \
+   LDBL_EXP_MASK < 0x200 ? 9 : \
+   LDBL_EXP_MASK < 0x400 ? 10 : \
+   LDBL_EXP_MASK < 0x800 ? 11 : \
+   LDBL_EXP_MASK < 0x1000 ? 12 : \
+   LDBL_EXP_MASK < 0x2000 ? 13 : \
+   LDBL_EXP_MASK < 0x4000 ? 14 : \
+   LDBL_EXP_MASK < 0x8000 ? 15 : \
+   LDBL_EXP_MASK < 0x10000 ? 16 : \
+   LDBL_EXP_MASK < 0x20000 ? 17 : \
+   LDBL_EXP_MASK < 0x40000 ? 18 : \
+   LDBL_EXP_MASK < 0x80000 ? 19 : \
+   LDBL_EXP_MASK < 0x100000 ? 20 : \
+   LDBL_EXP_MASK < 0x200000 ? 21 : \
+   LDBL_EXP_MASK < 0x400000 ? 22 : \
+   LDBL_EXP_MASK < 0x800000 ? 23 : \
+   LDBL_EXP_MASK < 0x1000000 ? 24 : \
+   LDBL_EXP_MASK < 0x2000000 ? 25 : \
+   LDBL_EXP_MASK < 0x4000000 ? 26 : \
+   LDBL_EXP_MASK < 0x8000000 ? 27 : \
+   LDBL_EXP_MASK < 0x10000000 ? 28 : \
+   LDBL_EXP_MASK < 0x20000000 ? 29 : \
+   LDBL_EXP_MASK < 0x40000000 ? 30 : \
+   LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
+   32)
+
+/* Number of bits used for a floating-point number: the mantissa (not
+   counting the "hidden bit", since it may or may not be explicit), the
+   exponent, and the sign.  */
+#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
+#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
+#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)
+
+/* Number of bytes used for a floating-point number.
+   This can be smaller than the 'sizeof'.  For example, on i386 systems,
+   'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
+   LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
+   sizeof (long double) = 12 or = 16.  */
+#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
+
+/* Verify that SIZEOF_FLT <= sizeof (float) etc.  */
+typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
+typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
+typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
+
+#endif /* _FLOATPLUS_H */
diff --git a/gnulib/lib/float.in.h b/gnulib/lib/float.in.h
new file mode 100644 (file)
index 0000000..f77a5ef
--- /dev/null
@@ -0,0 +1,63 @@
+/* A correct <float.h>.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GL_FLOAT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
+
+#ifndef _GL_FLOAT_H
+#define _GL_FLOAT_H
+
+/* 'long double' properties.  */
+#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
+/* Number of mantissa units, in base FLT_RADIX.  */
+# undef LDBL_MANT_DIG
+# define LDBL_MANT_DIG   64
+/* Number of decimal digits that is sufficient for representing a number.  */
+# undef LDBL_DIG
+# define LDBL_DIG        18
+/* x-1 where x is the smallest representable number > 1.  */
+# undef LDBL_EPSILON
+# define LDBL_EPSILON    1.0842021724855044340E-19L
+/* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */
+# undef LDBL_MIN_EXP
+# define LDBL_MIN_EXP    (-16381)
+/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */
+# undef LDBL_MAX_EXP
+# define LDBL_MAX_EXP    16384
+/* Minimum positive normalized number.  */
+# undef LDBL_MIN
+# define LDBL_MIN        3.3621031431120935063E-4932L
+/* Maximum representable finite number.  */
+# undef LDBL_MAX
+# define LDBL_MAX        1.1897314953572317650E+4932L
+/* Minimum e such that 10^e is in the range of normalized numbers.  */
+# undef LDBL_MIN_10_EXP
+# define LDBL_MIN_10_EXP (-4931)
+/* Maximum e such that 10^e is in the range of representable finite numbers.  */
+# undef LDBL_MAX_10_EXP
+# define LDBL_MAX_10_EXP 4932
+#endif
+
+#endif /* _GL_FLOAT_H */
+#endif /* _GL_FLOAT_H */
diff --git a/gnulib/lib/fnmatch.c b/gnulib/lib/fnmatch.c
new file mode 100644 (file)
index 0000000..83a1722
--- /dev/null
@@ -0,0 +1,353 @@
+/* Copyright (C) 1991-1993, 1996-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Enable GNU extensions in fnmatch.h.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE    1
+#endif
+
+#if ! defined __builtin_expect && __GNUC__ < 3
+# define __builtin_expect(expr, expected) (expr)
+#endif
+
+#include <fnmatch.h>
+
+#include <alloca.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define WIDE_CHAR_SUPPORT \
+  (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \
+   && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY))
+
+/* For platform which support the ISO C amendement 1 functionality we
+   support user defined character classes.  */
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+# include <wctype.h>
+# include <wchar.h>
+#endif
+
+/* We need some of the locale data (the collation sequence information)
+   but there is no interface to get this information in general.  Therefore
+   we support a correct implementation only in glibc.  */
+#ifdef _LIBC
+# include "../locale/localeinfo.h"
+# include "../locale/elem-hash.h"
+# include "../locale/coll-lookup.h"
+# include <shlib-compat.h>
+
+# define CONCAT(a,b) __CONCAT(a,b)
+# define mbsrtowcs __mbsrtowcs
+# define fnmatch __fnmatch
+extern int fnmatch (const char *pattern, const char *string, int flags);
+#endif
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set.  */
+#define NO_LEADING_PERIOD(flags) \
+  ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+   actually compiling the library itself, and have not detected a bug
+   in the library.  This code is part of the GNU C
+   Library, but also included in many other GNU distributions.  Compiling
+   and linking in this code is a waste when using the GNU C library
+   (especially if it is a shared library).  Rather than having every GNU
+   program understand `configure --with-gnu-libc' and omit the object files,
+   it is simpler to just do this in the source for each such file.  */
+
+#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
+
+
+# if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
+#  define isblank(c) ((c) == ' ' || (c) == '\t')
+# endif
+
+# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
+
+# if defined _LIBC || WIDE_CHAR_SUPPORT
+/* The GNU C library provides support for user-defined character classes
+   and the functions from ISO C amendement 1.  */
+#  ifdef CHARCLASS_NAME_MAX
+#   define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+#  else
+/* This shouldn't happen but some implementation might still have this
+   problem.  Use a reasonable default value.  */
+#   define CHAR_CLASS_MAX_LENGTH 256
+#  endif
+
+#  ifdef _LIBC
+#   define IS_CHAR_CLASS(string) __wctype (string)
+#  else
+#   define IS_CHAR_CLASS(string) wctype (string)
+#  endif
+
+#  ifdef _LIBC
+#   define ISWCTYPE(WC, WT)     __iswctype (WC, WT)
+#  else
+#   define ISWCTYPE(WC, WT)     iswctype (WC, WT)
+#  endif
+
+#  if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
+/* In this case we are implementing the multibyte character handling.  */
+#   define HANDLE_MULTIBYTE     1
+#  endif
+
+# else
+#  define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */
+
+#  define IS_CHAR_CLASS(string)                                               \
+   (STREQ (string, "alpha") || STREQ (string, "upper")                        \
+    || STREQ (string, "lower") || STREQ (string, "digit")                     \
+    || STREQ (string, "alnum") || STREQ (string, "xdigit")                    \
+    || STREQ (string, "space") || STREQ (string, "print")                     \
+    || STREQ (string, "punct") || STREQ (string, "graph")                     \
+    || STREQ (string, "cntrl") || STREQ (string, "blank"))
+# endif
+
+/* Avoid depending on library functions or files
+   whose names are inconsistent.  */
+
+/* Global variable.  */
+static int posixly_correct;
+
+# ifndef internal_function
+/* Inside GNU libc we mark some function in a special way.  In other
+   environments simply ignore the marking.  */
+#  define internal_function
+# endif
+
+/* Note that this evaluates C many times.  */
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
+# define CHAR   char
+# define UCHAR  unsigned char
+# define INT    int
+# define FCT    internal_fnmatch
+# define EXT    ext_match
+# define END    end_pattern
+# define L_(CS) CS
+# ifdef _LIBC
+#  define BTOWC(C)      __btowc (C)
+# else
+#  define BTOWC(C)      btowc (C)
+# endif
+# define STRLEN(S) strlen (S)
+# define STRCAT(D, S) strcat (D, S)
+# ifdef _LIBC
+#  define MEMPCPY(D, S, N) __mempcpy (D, S, N)
+# else
+#  if HAVE_MEMPCPY
+#   define MEMPCPY(D, S, N) mempcpy (D, S, N)
+#  else
+#   define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
+#  endif
+# endif
+# define MEMCHR(S, C, N) memchr (S, C, N)
+# define STRCOLL(S1, S2) strcoll (S1, S2)
+# include "fnmatch_loop.c"
+
+
+# if HANDLE_MULTIBYTE
+#  define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
+#  define CHAR  wchar_t
+#  define UCHAR wint_t
+#  define INT   wint_t
+#  define FCT   internal_fnwmatch
+#  define EXT   ext_wmatch
+#  define END   end_wpattern
+#  define L_(CS)        L##CS
+#  define BTOWC(C)      (C)
+#  ifdef _LIBC
+#   define STRLEN(S) __wcslen (S)
+#   define STRCAT(D, S) __wcscat (D, S)
+#   define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
+#  else
+#   define STRLEN(S) wcslen (S)
+#   define STRCAT(D, S) wcscat (D, S)
+#   if HAVE_WMEMPCPY
+#    define MEMPCPY(D, S, N) wmempcpy (D, S, N)
+#   else
+#    define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
+#   endif
+#  endif
+#  define MEMCHR(S, C, N) wmemchr (S, C, N)
+#  define STRCOLL(S1, S2) wcscoll (S1, S2)
+#  define WIDE_CHAR_VERSION 1
+
+#  undef IS_CHAR_CLASS
+/* We have to convert the wide character string in a multibyte string.  But
+   we know that the character class names consist of alphanumeric characters
+   from the portable character set, and since the wide character encoding
+   for a member of the portable character set is the same code point as
+   its single-byte encoding, we can use a simplified method to convert the
+   string to a multibyte character string.  */
+static wctype_t
+is_char_class (const wchar_t *wcs)
+{
+  char s[CHAR_CLASS_MAX_LENGTH + 1];
+  char *cp = s;
+
+  do
+    {
+      /* Test for a printable character from the portable character set.  */
+#  ifdef _LIBC
+      if (*wcs < 0x20 || *wcs > 0x7e
+          || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
+        return (wctype_t) 0;
+#  else
+      switch (*wcs)
+        {
+        case L' ': case L'!': case L'"': case L'#': case L'%':
+        case L'&': case L'\'': case L'(': case L')': case L'*':
+        case L'+': case L',': case L'-': case L'.': case L'/':
+        case L'0': case L'1': case L'2': case L'3': case L'4':
+        case L'5': case L'6': case L'7': case L'8': case L'9':
+        case L':': case L';': case L'<': case L'=': case L'>':
+        case L'?':
+        case L'A': case L'B': case L'C': case L'D': case L'E':
+        case L'F': case L'G': case L'H': case L'I': case L'J':
+        case L'K': case L'L': case L'M': case L'N': case L'O':
+        case L'P': case L'Q': case L'R': case L'S': case L'T':
+        case L'U': case L'V': case L'W': case L'X': case L'Y':
+        case L'Z':
+        case L'[': case L'\\': case L']': case L'^': case L'_':
+        case L'a': case L'b': case L'c': case L'd': case L'e':
+        case L'f': case L'g': case L'h': case L'i': case L'j':
+        case L'k': case L'l': case L'm': case L'n': case L'o':
+        case L'p': case L'q': case L'r': case L's': case L't':
+        case L'u': case L'v': case L'w': case L'x': case L'y':
+        case L'z': case L'{': case L'|': case L'}': case L'~':
+          break;
+        default:
+          return (wctype_t) 0;
+        }
+#  endif
+
+      /* Avoid overrunning the buffer.  */
+      if (cp == s + CHAR_CLASS_MAX_LENGTH)
+        return (wctype_t) 0;
+
+      *cp++ = (char) *wcs++;
+    }
+  while (*wcs != L'\0');
+
+  *cp = '\0';
+
+#  ifdef _LIBC
+  return __wctype (s);
+#  else
+  return wctype (s);
+#  endif
+}
+#  define IS_CHAR_CLASS(string) is_char_class (string)
+
+#  include "fnmatch_loop.c"
+# endif
+
+
+int
+fnmatch (const char *pattern, const char *string, int flags)
+{
+# if HANDLE_MULTIBYTE
+#  define ALLOCA_LIMIT 2000
+  if (__builtin_expect (MB_CUR_MAX, 1) != 1)
+    {
+      mbstate_t ps;
+      size_t patsize;
+      size_t strsize;
+      size_t totsize;
+      wchar_t *wpattern;
+      wchar_t *wstring;
+      int res;
+
+      /* Calculate the size needed to convert the strings to
+         wide characters.  */
+      memset (&ps, '\0', sizeof (ps));
+      patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
+      if (__builtin_expect (patsize != 0, 1))
+        {
+          assert (mbsinit (&ps));
+          strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
+          if (__builtin_expect (strsize != 0, 1))
+            {
+              assert (mbsinit (&ps));
+              totsize = patsize + strsize;
+              if (__builtin_expect (! (patsize <= totsize
+                                       && totsize <= SIZE_MAX / sizeof (wchar_t)),
+                                    0))
+                {
+                  errno = ENOMEM;
+                  return -1;
+                }
+
+              /* Allocate room for the wide characters.  */
+              if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
+                wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
+              else
+                {
+                  wpattern = malloc (totsize * sizeof (wchar_t));
+                  if (__builtin_expect (! wpattern, 0))
+                    {
+                      errno = ENOMEM;
+                      return -1;
+                    }
+                }
+              wstring = wpattern + patsize;
+
+              /* Convert the strings into wide characters.  */
+              mbsrtowcs (wpattern, &pattern, patsize, &ps);
+              assert (mbsinit (&ps));
+              mbsrtowcs (wstring, &string, strsize, &ps);
+
+              res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
+                                       flags & FNM_PERIOD, flags);
+
+              if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
+                free (wpattern);
+              return res;
+            }
+        }
+    }
+
+# endif /* HANDLE_MULTIBYTE */
+
+  return internal_fnmatch (pattern, string, string + strlen (string),
+                           flags & FNM_PERIOD, flags);
+}
+
+# ifdef _LIBC
+#  undef fnmatch
+versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
+#  if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
+strong_alias (__fnmatch, __fnmatch_old)
+compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
+#  endif
+libc_hidden_ver (__fnmatch, fnmatch)
+# endif
+
+#endif  /* _LIBC or not __GNU_LIBRARY__.  */
diff --git a/gnulib/lib/fnmatch.in.h b/gnulib/lib/fnmatch.in.h
new file mode 100644 (file)
index 0000000..d5ebd70
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2011 Free
+   Software Foundation, Inc.
+
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _FNMATCH_H
+#define _FNMATCH_H      1
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We #undef these before defining them because some losing systems
+   (HP-UX A.08.07 for example) define these in <unistd.h>.  */
+#undef  FNM_PATHNAME
+#undef  FNM_NOESCAPE
+#undef  FNM_PERIOD
+
+/* Bits set in the FLAGS argument to `fnmatch'.  */
+#define FNM_PATHNAME    (1 << 0) /* No wildcard can ever match `/'.  */
+#define FNM_NOESCAPE    (1 << 1) /* Backslashes don't quote special chars.  */
+#define FNM_PERIOD      (1 << 2) /* Leading `.' is matched only explicitly.  */
+
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
+# define FNM_FILE_NAME   FNM_PATHNAME   /* Preferred GNU name.  */
+# define FNM_LEADING_DIR (1 << 3)       /* Ignore `/...' after a match.  */
+# define FNM_CASEFOLD    (1 << 4)       /* Compare without regard to case.  */
+# define FNM_EXTMATCH    (1 << 5)       /* Use ksh-like extended matching. */
+#endif
+
+/* Value returned by `fnmatch' if STRING does not match PATTERN.  */
+#define FNM_NOMATCH     1
+
+/* This value is returned if the implementation does not support
+   `fnmatch'.  Since this is not the case here it will never be
+   returned but the conformance test suites still require the symbol
+   to be defined.  */
+#ifdef _XOPEN_SOURCE
+# define FNM_NOSYS      (-1)
+#endif
+
+/* Match NAME against the file name pattern PATTERN,
+   returning zero if it matches, FNM_NOMATCH if not.  */
+extern int fnmatch (const char *__pattern, const char *__name,
+                    int __flags)
+     _GL_ARG_NONNULL ((1, 2));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* fnmatch.h */
diff --git a/gnulib/lib/fnmatch_loop.c b/gnulib/lib/fnmatch_loop.c
new file mode 100644 (file)
index 0000000..bbeb94d
--- /dev/null
@@ -0,0 +1,1214 @@
+/* Copyright (C) 1991-1993, 1996-2006, 2009-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Match STRING against the file name pattern PATTERN, returning zero if
+   it matches, nonzero if not.  */
+static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
+                const CHAR *string_end, bool no_leading_period, int flags)
+     internal_function;
+static const CHAR *END (const CHAR *patternp) internal_function;
+
+static int
+internal_function
+FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+     bool no_leading_period, int flags)
+{
+  register const CHAR *p = pattern, *n = string;
+  register UCHAR c;
+#ifdef _LIBC
+# if WIDE_CHAR_VERSION
+  const char *collseq = (const char *)
+    _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+# else
+  const UCHAR *collseq = (const UCHAR *)
+    _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+# endif
+#endif
+
+  while ((c = *p++) != L_('\0'))
+    {
+      bool new_no_leading_period = false;
+      c = FOLD (c);
+
+      switch (c)
+        {
+        case L_('?'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period,
+                         flags);
+              if (res != -1)
+                return res;
+            }
+
+          if (n == string_end)
+            return FNM_NOMATCH;
+          else if (*n == L_('/') && (flags & FNM_FILE_NAME))
+            return FNM_NOMATCH;
+          else if (*n == L_('.') && no_leading_period)
+            return FNM_NOMATCH;
+          break;
+
+        case L_('\\'):
+          if (!(flags & FNM_NOESCAPE))
+            {
+              c = *p++;
+              if (c == L_('\0'))
+                /* Trailing \ loses.  */
+                return FNM_NOMATCH;
+              c = FOLD (c);
+            }
+          if (n == string_end || FOLD ((UCHAR) *n) != c)
+            return FNM_NOMATCH;
+          break;
+
+        case L_('*'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period,
+                         flags);
+              if (res != -1)
+                return res;
+            }
+
+          if (n != string_end && *n == L_('.') && no_leading_period)
+            return FNM_NOMATCH;
+
+          for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
+            {
+              if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
+                {
+                  const CHAR *endp = END (p);
+                  if (endp != p)
+                    {
+                      /* This is a pattern.  Skip over it.  */
+                      p = endp;
+                      continue;
+                    }
+                }
+
+              if (c == L_('?'))
+                {
+                  /* A ? needs to match one character.  */
+                  if (n == string_end)
+                    /* There isn't another character; no match.  */
+                    return FNM_NOMATCH;
+                  else if (*n == L_('/')
+                           && __builtin_expect (flags & FNM_FILE_NAME, 0))
+                    /* A slash does not match a wildcard under
+                       FNM_FILE_NAME.  */
+                    return FNM_NOMATCH;
+                  else
+                    /* One character of the string is consumed in matching
+                       this ? wildcard, so *??? won't match if there are
+                       less than three characters.  */
+                    ++n;
+                }
+            }
+
+          if (c == L_('\0'))
+            /* The wildcard(s) is/are the last element of the pattern.
+               If the name is a file name and contains another slash
+               this means it cannot match, unless the FNM_LEADING_DIR
+               flag is set.  */
+            {
+              int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH;
+
+              if (flags & FNM_FILE_NAME)
+                {
+                  if (flags & FNM_LEADING_DIR)
+                    result = 0;
+                  else
+                    {
+                      if (MEMCHR (n, L_('/'), string_end - n) == NULL)
+                        result = 0;
+                    }
+                }
+
+              return result;
+            }
+          else
+            {
+              const CHAR *endp;
+
+              endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
+                             string_end - n);
+              if (endp == NULL)
+                endp = string_end;
+
+              if (c == L_('[')
+                  || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
+                      && (c == L_('@') || c == L_('+') || c == L_('!'))
+                      && *p == L_('(')))
+                {
+                  int flags2 = ((flags & FNM_FILE_NAME)
+                                ? flags : (flags & ~FNM_PERIOD));
+                  bool no_leading_period2 = no_leading_period;
+
+                  for (--p; n < endp; ++n, no_leading_period2 = false)
+                    if (FCT (p, n, string_end, no_leading_period2, flags2)
+                        == 0)
+                      return 0;
+                }
+              else if (c == L_('/') && (flags & FNM_FILE_NAME))
+                {
+                  while (n < string_end && *n != L_('/'))
+                    ++n;
+                  if (n < string_end && *n == L_('/')
+                      && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
+                          == 0))
+                    return 0;
+                }
+              else
+                {
+                  int flags2 = ((flags & FNM_FILE_NAME)
+                                ? flags : (flags & ~FNM_PERIOD));
+                  int no_leading_period2 = no_leading_period;
+
+                  if (c == L_('\\') && !(flags & FNM_NOESCAPE))
+                    c = *p;
+                  c = FOLD (c);
+                  for (--p; n < endp; ++n, no_leading_period2 = false)
+                    if (FOLD ((UCHAR) *n) == c
+                        && (FCT (p, n, string_end, no_leading_period2, flags2)
+                            == 0))
+                      return 0;
+                }
+            }
+
+          /* If we come here no match is possible with the wildcard.  */
+          return FNM_NOMATCH;
+
+        case L_('['):
+          {
+            /* Nonzero if the sense of the character class is inverted.  */
+            register bool not;
+            CHAR cold;
+            UCHAR fn;
+
+            if (posixly_correct == 0)
+              posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+            if (n == string_end)
+              return FNM_NOMATCH;
+
+            if (*n == L_('.') && no_leading_period)
+              return FNM_NOMATCH;
+
+            if (*n == L_('/') && (flags & FNM_FILE_NAME))
+              /* `/' cannot be matched.  */
+              return FNM_NOMATCH;
+
+            not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
+            if (not)
+              ++p;
+
+            fn = FOLD ((UCHAR) *n);
+
+            c = *p++;
+            for (;;)
+              {
+                if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+                  {
+                    if (*p == L_('\0'))
+                      return FNM_NOMATCH;
+                    c = FOLD ((UCHAR) *p);
+                    ++p;
+
+                    goto normal_bracket;
+                  }
+                else if (c == L_('[') && *p == L_(':'))
+                  {
+                    /* Leave room for the null.  */
+                    CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
+                    size_t c1 = 0;
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+                    wctype_t wt;
+#endif
+                    const CHAR *startp = p;
+
+                    for (;;)
+                      {
+                        if (c1 == CHAR_CLASS_MAX_LENGTH)
+                          /* The name is too long and therefore the pattern
+                             is ill-formed.  */
+                          return FNM_NOMATCH;
+
+                        c = *++p;
+                        if (c == L_(':') && p[1] == L_(']'))
+                          {
+                            p += 2;
+                            break;
+                          }
+                        if (c < L_('a') || c >= L_('z'))
+                          {
+                            /* This cannot possibly be a character class name.
+                               Match it as a normal range.  */
+                            p = startp;
+                            c = L_('[');
+                            goto normal_bracket;
+                          }
+                        str[c1++] = c;
+                      }
+                    str[c1] = L_('\0');
+
+#if defined _LIBC || WIDE_CHAR_SUPPORT
+                    wt = IS_CHAR_CLASS (str);
+                    if (wt == 0)
+                      /* Invalid character class name.  */
+                      return FNM_NOMATCH;
+
+# if defined _LIBC && ! WIDE_CHAR_VERSION
+                    /* The following code is glibc specific but does
+                       there a good job in speeding up the code since
+                       we can avoid the btowc() call.  */
+                    if (_ISCTYPE ((UCHAR) *n, wt))
+                      goto matched;
+# else
+                    if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
+                      goto matched;
+# endif
+#else
+                    if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
+                        || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
+                        || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
+                        || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
+                        || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
+                        || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
+                        || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
+                        || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
+                        || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
+                        || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
+                        || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
+                        || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
+                      goto matched;
+#endif
+                    c = *p++;
+                  }
+#ifdef _LIBC
+                else if (c == L_('[') && *p == L_('='))
+                  {
+                    UCHAR str[1];
+                    uint32_t nrules =
+                      _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+                    const CHAR *startp = p;
+
+                    c = *++p;
+                    if (c == L_('\0'))
+                      {
+                        p = startp;
+                        c = L_('[');
+                        goto normal_bracket;
+                      }
+                    str[0] = c;
+
+                    c = *++p;
+                    if (c != L_('=') || p[1] != L_(']'))
+                      {
+                        p = startp;
+                        c = L_('[');
+                        goto normal_bracket;
+                      }
+                    p += 2;
+
+                    if (nrules == 0)
+                      {
+                        if ((UCHAR) *n == str[0])
+                          goto matched;
+                      }
+                    else
+                      {
+                        const int32_t *table;
+# if WIDE_CHAR_VERSION
+                        const int32_t *weights;
+                        const int32_t *extra;
+# else
+                        const unsigned char *weights;
+                        const unsigned char *extra;
+# endif
+                        const int32_t *indirect;
+                        int32_t idx;
+                        const UCHAR *cp = (const UCHAR *) str;
+
+                        /* This #include defines a local function!  */
+# if WIDE_CHAR_VERSION
+#  include <locale/weightwc.h>
+# else
+#  include <locale/weight.h>
+# endif
+
+# if WIDE_CHAR_VERSION
+                        table = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
+                        weights = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
+                        extra = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
+                        indirect = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
+# else
+                        table = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+                        weights = (const unsigned char *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+                        extra = (const unsigned char *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+                        indirect = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+# endif
+
+                        idx = findidx (&cp);
+                        if (idx != 0)
+                          {
+                            /* We found a table entry.  Now see whether the
+                               character we are currently at has the same
+                               equivalance class value.  */
+                            int len = weights[idx & 0xffffff];
+                            int32_t idx2;
+                            const UCHAR *np = (const UCHAR *) n;
+
+                            idx2 = findidx (&np);
+                            if (idx2 != 0
+                                && (idx >> 24) == (idx2 >> 24)
+                                && len == weights[idx2 & 0xffffff])
+                              {
+                                int cnt = 0;
+
+                                idx &= 0xffffff;
+                                idx2 &= 0xffffff;
+
+                                while (cnt < len
+                                       && (weights[idx + 1 + cnt]
+                                           == weights[idx2 + 1 + cnt]))
+                                  ++cnt;
+
+                                if (cnt == len)
+                                  goto matched;
+                              }
+                          }
+                      }
+
+                    c = *p++;
+                  }
+#endif
+                else if (c == L_('\0'))
+                  /* [ (unterminated) loses.  */
+                  return FNM_NOMATCH;
+                else
+                  {
+                    bool is_range = false;
+
+#ifdef _LIBC
+                    bool is_seqval = false;
+
+                    if (c == L_('[') && *p == L_('.'))
+                      {
+                        uint32_t nrules =
+                          _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+                        const CHAR *startp = p;
+                        size_t c1 = 0;
+
+                        while (1)
+                          {
+                            c = *++p;
+                            if (c == L_('.') && p[1] == L_(']'))
+                              {
+                                p += 2;
+                                break;
+                              }
+                            if (c == '\0')
+                              return FNM_NOMATCH;
+                            ++c1;
+                          }
+
+                        /* We have to handling the symbols differently in
+                           ranges since then the collation sequence is
+                           important.  */
+                        is_range = *p == L_('-') && p[1] != L_('\0');
+
+                        if (nrules == 0)
+                          {
+                            /* There are no names defined in the collation
+                               data.  Therefore we only accept the trivial
+                               names consisting of the character itself.  */
+                            if (c1 != 1)
+                              return FNM_NOMATCH;
+
+                            if (!is_range && *n == startp[1])
+                              goto matched;
+
+                            cold = startp[1];
+                            c = *p++;
+                          }
+                        else
+                          {
+                            int32_t table_size;
+                            const int32_t *symb_table;
+# ifdef WIDE_CHAR_VERSION
+                            char str[c1];
+                            size_t strcnt;
+# else
+#  define str (startp + 1)
+# endif
+                            const unsigned char *extra;
+                            int32_t idx;
+                            int32_t elem;
+                            int32_t second;
+                            int32_t hash;
+
+# ifdef WIDE_CHAR_VERSION
+                            /* We have to convert the name to a single-byte
+                               string.  This is possible since the names
+                               consist of ASCII characters and the internal
+                               representation is UCS4.  */
+                            for (strcnt = 0; strcnt < c1; ++strcnt)
+                              str[strcnt] = startp[1 + strcnt];
+# endif
+
+                            table_size =
+                              _NL_CURRENT_WORD (LC_COLLATE,
+                                                _NL_COLLATE_SYMB_HASH_SIZEMB);
+                            symb_table = (const int32_t *)
+                              _NL_CURRENT (LC_COLLATE,
+                                           _NL_COLLATE_SYMB_TABLEMB);
+                            extra = (const unsigned char *)
+                              _NL_CURRENT (LC_COLLATE,
+                                           _NL_COLLATE_SYMB_EXTRAMB);
+
+                            /* Locate the character in the hashing table.  */
+                            hash = elem_hash (str, c1);
+
+                            idx = 0;
+                            elem = hash % table_size;
+                            if (symb_table[2 * elem] != 0)
+                              {
+                                second = hash % (table_size - 2) + 1;
+
+                                do
+                                  {
+                                    /* First compare the hashing value.  */
+                                    if (symb_table[2 * elem] == hash
+                                        && (c1
+                                            == extra[symb_table[2 * elem + 1]])
+                                        && memcmp (str,
+                                                   &extra[symb_table[2 * elem
+                                                                     + 1]
+                                                          + 1], c1) == 0)
+                                      {
+                                        /* Yep, this is the entry.  */
+                                        idx = symb_table[2 * elem + 1];
+                                        idx += 1 + extra[idx];
+                                        break;
+                                      }
+
+                                    /* Next entry.  */
+                                    elem += second;
+                                  }
+                                while (symb_table[2 * elem] != 0);
+                              }
+
+                            if (symb_table[2 * elem] != 0)
+                              {
+                                /* Compare the byte sequence but only if
+                                   this is not part of a range.  */
+# ifdef WIDE_CHAR_VERSION
+                                int32_t *wextra;
+
+                                idx += 1 + extra[idx];
+                                /* Adjust for the alignment.  */
+                                idx = (idx + 3) & ~3;
+
+                                wextra = (int32_t *) &extra[idx + 4];
+# endif
+
+                                if (! is_range)
+                                  {
+# ifdef WIDE_CHAR_VERSION
+                                    for (c1 = 0;
+                                         (int32_t) c1 < wextra[idx];
+                                         ++c1)
+                                      if (n[c1] != wextra[1 + c1])
+                                        break;
+
+                                    if ((int32_t) c1 == wextra[idx])
+                                      goto matched;
+# else
+                                    for (c1 = 0; c1 < extra[idx]; ++c1)
+                                      if (n[c1] != extra[1 + c1])
+                                        break;
+
+                                    if (c1 == extra[idx])
+                                      goto matched;
+# endif
+                                  }
+
+                                /* Get the collation sequence value.  */
+                                is_seqval = true;
+# ifdef WIDE_CHAR_VERSION
+                                cold = wextra[1 + wextra[idx]];
+# else
+                                /* Adjust for the alignment.  */
+                                idx += 1 + extra[idx];
+                                idx = (idx + 3) & ~4;
+                                cold = *((int32_t *) &extra[idx]);
+# endif
+
+                                c = *p++;
+                              }
+                            else if (c1 == 1)
+                              {
+                                /* No valid character.  Match it as a
+                                   single byte.  */
+                                if (!is_range && *n == str[0])
+                                  goto matched;
+
+                                cold = str[0];
+                                c = *p++;
+                              }
+                            else
+                              return FNM_NOMATCH;
+                          }
+                      }
+                    else
+# undef str
+#endif
+                      {
+                        c = FOLD (c);
+                      normal_bracket:
+
+                        /* We have to handling the symbols differently in
+                           ranges since then the collation sequence is
+                           important.  */
+                        is_range = (*p == L_('-') && p[1] != L_('\0')
+                                    && p[1] != L_(']'));
+
+                        if (!is_range && c == fn)
+                          goto matched;
+
+#if _LIBC
+                        /* This is needed if we goto normal_bracket; from
+                           outside of is_seqval's scope.  */
+                        is_seqval = false;
+#endif
+
+                        cold = c;
+                        c = *p++;
+                      }
+
+                    if (c == L_('-') && *p != L_(']'))
+                      {
+#if _LIBC
+                        /* We have to find the collation sequence
+                           value for C.  Collation sequence is nothing
+                           we can regularly access.  The sequence
+                           value is defined by the order in which the
+                           definitions of the collation values for the
+                           various characters appear in the source
+                           file.  A strange concept, nowhere
+                           documented.  */
+                        uint32_t fcollseq;
+                        uint32_t lcollseq;
+                        UCHAR cend = *p++;
+
+# ifdef WIDE_CHAR_VERSION
+                        /* Search in the `names' array for the characters.  */
+                        fcollseq = __collseq_table_lookup (collseq, fn);
+                        if (fcollseq == ~((uint32_t) 0))
+                          /* XXX We don't know anything about the character
+                             we are supposed to match.  This means we are
+                             failing.  */
+                          goto range_not_matched;
+
+                        if (is_seqval)
+                          lcollseq = cold;
+                        else
+                          lcollseq = __collseq_table_lookup (collseq, cold);
+# else
+                        fcollseq = collseq[fn];
+                        lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
+# endif
+
+                        is_seqval = false;
+                        if (cend == L_('[') && *p == L_('.'))
+                          {
+                            uint32_t nrules =
+                              _NL_CURRENT_WORD (LC_COLLATE,
+                                                _NL_COLLATE_NRULES);
+                            const CHAR *startp = p;
+                            size_t c1 = 0;
+
+                            while (1)
+                              {
+                                c = *++p;
+                                if (c == L_('.') && p[1] == L_(']'))
+                                  {
+                                    p += 2;
+                                    break;
+                                  }
+                                if (c == '\0')
+                                  return FNM_NOMATCH;
+                                ++c1;
+                              }
+
+                            if (nrules == 0)
+                              {
+                                /* There are no names defined in the
+                                   collation data.  Therefore we only
+                                   accept the trivial names consisting
+                                   of the character itself.  */
+                                if (c1 != 1)
+                                  return FNM_NOMATCH;
+
+                                cend = startp[1];
+                              }
+                            else
+                              {
+                                int32_t table_size;
+                                const int32_t *symb_table;
+# ifdef WIDE_CHAR_VERSION
+                                char str[c1];
+                                size_t strcnt;
+# else
+#  define str (startp + 1)
+# endif
+                                const unsigned char *extra;
+                                int32_t idx;
+                                int32_t elem;
+                                int32_t second;
+                                int32_t hash;
+
+# ifdef WIDE_CHAR_VERSION
+                                /* We have to convert the name to a single-byte
+                                   string.  This is possible since the names
+                                   consist of ASCII characters and the internal
+                                   representation is UCS4.  */
+                                for (strcnt = 0; strcnt < c1; ++strcnt)
+                                  str[strcnt] = startp[1 + strcnt];
+# endif
+
+                                table_size =
+                                  _NL_CURRENT_WORD (LC_COLLATE,
+                                                    _NL_COLLATE_SYMB_HASH_SIZEMB);
+                                symb_table = (const int32_t *)
+                                  _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_SYMB_TABLEMB);
+                                extra = (const unsigned char *)
+                                  _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_SYMB_EXTRAMB);
+
+                                /* Locate the character in the hashing
+                                   table.  */
+                                hash = elem_hash (str, c1);
+
+                                idx = 0;
+                                elem = hash % table_size;
+                                if (symb_table[2 * elem] != 0)
+                                  {
+                                    second = hash % (table_size - 2) + 1;
+
+                                    do
+                                      {
+                                        /* First compare the hashing value.  */
+                                        if (symb_table[2 * elem] == hash
+                                            && (c1
+                                                == extra[symb_table[2 * elem + 1]])
+                                            && memcmp (str,
+                                                       &extra[symb_table[2 * elem + 1]
+                                                              + 1], c1) == 0)
+                                          {
+                                            /* Yep, this is the entry.  */
+                                            idx = symb_table[2 * elem + 1];
+                                            idx += 1 + extra[idx];
+                                            break;
+                                          }
+
+                                        /* Next entry.  */
+                                        elem += second;
+                                      }
+                                    while (symb_table[2 * elem] != 0);
+                                  }
+
+                                if (symb_table[2 * elem] != 0)
+                                  {
+                                    /* Compare the byte sequence but only if
+                                       this is not part of a range.  */
+# ifdef WIDE_CHAR_VERSION
+                                    int32_t *wextra;
+
+                                    idx += 1 + extra[idx];
+                                    /* Adjust for the alignment.  */
+                                    idx = (idx + 3) & ~4;
+
+                                    wextra = (int32_t *) &extra[idx + 4];
+# endif
+                                    /* Get the collation sequence value.  */
+                                    is_seqval = true;
+# ifdef WIDE_CHAR_VERSION
+                                    cend = wextra[1 + wextra[idx]];
+# else
+                                    /* Adjust for the alignment.  */
+                                    idx += 1 + extra[idx];
+                                    idx = (idx + 3) & ~4;
+                                    cend = *((int32_t *) &extra[idx]);
+# endif
+                                  }
+                                else if (symb_table[2 * elem] != 0 && c1 == 1)
+                                  {
+                                    cend = str[0];
+                                    c = *p++;
+                                  }
+                                else
+                                  return FNM_NOMATCH;
+                              }
+# undef str
+                          }
+                        else
+                          {
+                            if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+                              cend = *p++;
+                            if (cend == L_('\0'))
+                              return FNM_NOMATCH;
+                            cend = FOLD (cend);
+                          }
+
+                        /* XXX It is not entirely clear to me how to handle
+                           characters which are not mentioned in the
+                           collation specification.  */
+                        if (
+# ifdef WIDE_CHAR_VERSION
+                            lcollseq == 0xffffffff ||
+# endif
+                            lcollseq <= fcollseq)
+                          {
+                            /* We have to look at the upper bound.  */
+                            uint32_t hcollseq;
+
+                            if (is_seqval)
+                              hcollseq = cend;
+                            else
+                              {
+# ifdef WIDE_CHAR_VERSION
+                                hcollseq =
+                                  __collseq_table_lookup (collseq, cend);
+                                if (hcollseq == ~((uint32_t) 0))
+                                  {
+                                    /* Hum, no information about the upper
+                                       bound.  The matching succeeds if the
+                                       lower bound is matched exactly.  */
+                                    if (lcollseq != fcollseq)
+                                      goto range_not_matched;
+
+                                    goto matched;
+                                  }
+# else
+                                hcollseq = collseq[cend];
+# endif
+                              }
+
+                            if (lcollseq <= hcollseq && fcollseq <= hcollseq)
+                              goto matched;
+                          }
+# ifdef WIDE_CHAR_VERSION
+                      range_not_matched:
+# endif
+#else
+                        /* We use a boring value comparison of the character
+                           values.  This is better than comparing using
+                           `strcoll' since the latter would have surprising
+                           and sometimes fatal consequences.  */
+                        UCHAR cend = *p++;
+
+                        if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+                          cend = *p++;
+                        if (cend == L_('\0'))
+                          return FNM_NOMATCH;
+
+                        /* It is a range.  */
+                        if (cold <= fn && fn <= cend)
+                          goto matched;
+#endif
+
+                        c = *p++;
+                      }
+                  }
+
+                if (c == L_(']'))
+                  break;
+              }
+
+            if (!not)
+              return FNM_NOMATCH;
+            break;
+
+          matched:
+            /* Skip the rest of the [...] that already matched.  */
+            do
+              {
+              ignore_next:
+                c = *p++;
+
+                if (c == L_('\0'))
+                  /* [... (unterminated) loses.  */
+                  return FNM_NOMATCH;
+
+                if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+                  {
+                    if (*p == L_('\0'))
+                      return FNM_NOMATCH;
+                    /* XXX 1003.2d11 is unclear if this is right.  */
+                    ++p;
+                  }
+                else if (c == L_('[') && *p == L_(':'))
+                  {
+                    int c1 = 0;
+                    const CHAR *startp = p;
+
+                    while (1)
+                      {
+                        c = *++p;
+                        if (++c1 == CHAR_CLASS_MAX_LENGTH)
+                          return FNM_NOMATCH;
+
+                        if (*p == L_(':') && p[1] == L_(']'))
+                          break;
+
+                        if (c < L_('a') || c >= L_('z'))
+                          {
+                            p = startp;
+                            goto ignore_next;
+                          }
+                      }
+                    p += 2;
+                    c = *p++;
+                  }
+                else if (c == L_('[') && *p == L_('='))
+                  {
+                    c = *++p;
+                    if (c == L_('\0'))
+                      return FNM_NOMATCH;
+                    c = *++p;
+                    if (c != L_('=') || p[1] != L_(']'))
+                      return FNM_NOMATCH;
+                    p += 2;
+                    c = *p++;
+                  }
+                else if (c == L_('[') && *p == L_('.'))
+                  {
+                    ++p;
+                    while (1)
+                      {
+                        c = *++p;
+                        if (c == '\0')
+                          return FNM_NOMATCH;
+
+                        if (*p == L_('.') && p[1] == L_(']'))
+                          break;
+                      }
+                    p += 2;
+                    c = *p++;
+                  }
+              }
+            while (c != L_(']'));
+            if (not)
+              return FNM_NOMATCH;
+          }
+          break;
+
+        case L_('+'):
+        case L_('@'):
+        case L_('!'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period, flags);
+              if (res != -1)
+                return res;
+            }
+          goto normal_match;
+
+        case L_('/'):
+          if (NO_LEADING_PERIOD (flags))
+            {
+              if (n == string_end || c != (UCHAR) *n)
+                return FNM_NOMATCH;
+
+              new_no_leading_period = true;
+              break;
+            }
+          /* FALLTHROUGH */
+        default:
+        normal_match:
+          if (n == string_end || c != FOLD ((UCHAR) *n))
+            return FNM_NOMATCH;
+        }
+
+      no_leading_period = new_no_leading_period;
+      ++n;
+    }
+
+  if (n == string_end)
+    return 0;
+
+  if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/'))
+    /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
+    return 0;
+
+  return FNM_NOMATCH;
+}
+
+
+static const CHAR *
+internal_function
+END (const CHAR *pattern)
+{
+  const CHAR *p = pattern;
+
+  while (1)
+    if (*++p == L_('\0'))
+      /* This is an invalid pattern.  */
+      return pattern;
+    else if (*p == L_('['))
+      {
+        /* Handle brackets special.  */
+        if (posixly_correct == 0)
+          posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+        /* Skip the not sign.  We have to recognize it because of a possibly
+           following ']'.  */
+        if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+          ++p;
+        /* A leading ']' is recognized as such.  */
+        if (*p == L_(']'))
+          ++p;
+        /* Skip over all characters of the list.  */
+        while (*p != L_(']'))
+          if (*p++ == L_('\0'))
+            /* This is no valid pattern.  */
+            return pattern;
+      }
+    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+              || *p == L_('!')) && p[1] == L_('('))
+      p = END (p + 1);
+    else if (*p == L_(')'))
+      break;
+
+  return p + 1;
+}
+
+
+static int
+internal_function
+EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+     bool no_leading_period, int flags)
+{
+  const CHAR *startp;
+  size_t level;
+  struct patternlist
+  {
+    struct patternlist *next;
+    CHAR str[1];
+  } *list = NULL;
+  struct patternlist **lastp = &list;
+  size_t pattern_len = STRLEN (pattern);
+  const CHAR *p;
+  const CHAR *rs;
+  enum { ALLOCA_LIMIT = 8000 };
+
+  /* Parse the pattern.  Store the individual parts in the list.  */
+  level = 0;
+  for (startp = p = pattern + 1; ; ++p)
+    if (*p == L_('\0'))
+      /* This is an invalid pattern.  */
+      return -1;
+    else if (*p == L_('['))
+      {
+        /* Handle brackets special.  */
+        if (posixly_correct == 0)
+          posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+        /* Skip the not sign.  We have to recognize it because of a possibly
+           following ']'.  */
+        if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+          ++p;
+        /* A leading ']' is recognized as such.  */
+        if (*p == L_(']'))
+          ++p;
+        /* Skip over all characters of the list.  */
+        while (*p != L_(']'))
+          if (*p++ == L_('\0'))
+            /* This is no valid pattern.  */
+            return -1;
+      }
+    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
+              || *p == L_('!')) && p[1] == L_('('))
+      /* Remember the nesting level.  */
+      ++level;
+    else if (*p == L_(')'))
+      {
+        if (level-- == 0)
+          {
+            /* This means we found the end of the pattern.  */
+#define NEW_PATTERN \
+            struct patternlist *newp;                                         \
+            size_t plen;                                                      \
+            size_t plensize;                                                  \
+            size_t newpsize;                                                  \
+                                                                              \
+            plen = (opt == L_('?') || opt == L_('@')                          \
+                    ? pattern_len                                             \
+                    : p - startp + 1UL);                                      \
+            plensize = plen * sizeof (CHAR);                                  \
+            newpsize = offsetof (struct patternlist, str) + plensize;         \
+            if ((size_t) -1 / sizeof (CHAR) < plen                            \
+                || newpsize < offsetof (struct patternlist, str)              \
+                || ALLOCA_LIMIT <= newpsize)                                  \
+              return -1;                                                      \
+            newp = (struct patternlist *) alloca (newpsize);                  \
+            *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0');    \
+            newp->next = NULL;                                                \
+            *lastp = newp;                                                    \
+            lastp = &newp->next
+            NEW_PATTERN;
+            break;
+          }
+      }
+    else if (*p == L_('|'))
+      {
+        if (level == 0)
+          {
+            NEW_PATTERN;
+            startp = p + 1;
+          }
+      }
+  assert (list != NULL);
+  assert (p[-1] == L_(')'));
+#undef NEW_PATTERN
+
+  switch (opt)
+    {
+    case L_('*'):
+      if (FCT (p, string, string_end, no_leading_period, flags) == 0)
+        return 0;
+      /* FALLTHROUGH */
+
+    case L_('+'):
+      do
+        {
+          for (rs = string; rs <= string_end; ++rs)
+            /* First match the prefix with the current pattern with the
+               current pattern.  */
+            if (FCT (list->str, string, rs, no_leading_period,
+                     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0
+                /* This was successful.  Now match the rest with the rest
+                   of the pattern.  */
+                && (FCT (p, rs, string_end,
+                         rs == string
+                         ? no_leading_period
+                         : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                         flags & FNM_FILE_NAME
+                         ? flags : flags & ~FNM_PERIOD) == 0
+                    /* This didn't work.  Try the whole pattern.  */
+                    || (rs != string
+                        && FCT (pattern - 1, rs, string_end,
+                                rs == string
+                                ? no_leading_period
+                                : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                                flags & FNM_FILE_NAME
+                                ? flags : flags & ~FNM_PERIOD) == 0)))
+              /* It worked.  Signal success.  */
+              return 0;
+        }
+      while ((list = list->next) != NULL);
+
+      /* None of the patterns lead to a match.  */
+      return FNM_NOMATCH;
+
+    case L_('?'):
+      if (FCT (p, string, string_end, no_leading_period, flags) == 0)
+        return 0;
+      /* FALLTHROUGH */
+
+    case L_('@'):
+      do
+        /* I cannot believe it but `strcat' is actually acceptable
+           here.  Match the entire string with the prefix from the
+           pattern list and the rest of the pattern following the
+           pattern list.  */
+        if (FCT (STRCAT (list->str, p), string, string_end,
+                 no_leading_period,
+                 flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+          /* It worked.  Signal success.  */
+          return 0;
+      while ((list = list->next) != NULL);
+
+      /* None of the patterns lead to a match.  */
+      return FNM_NOMATCH;
+
+    case L_('!'):
+      for (rs = string; rs <= string_end; ++rs)
+        {
+          struct patternlist *runp;
+
+          for (runp = list; runp != NULL; runp = runp->next)
+            if (FCT (runp->str, string, rs,  no_leading_period,
+                     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+              break;
+
+          /* If none of the patterns matched see whether the rest does.  */
+          if (runp == NULL
+              && (FCT (p, rs, string_end,
+                       rs == string
+                       ? no_leading_period
+                       : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                       flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
+                  == 0))
+            /* This is successful.  */
+            return 0;
+        }
+
+      /* None of the patterns together with the rest of the pattern
+         lead to a match.  */
+      return FNM_NOMATCH;
+
+    default:
+      assert (! "Invalid extended matching operator");
+      break;
+    }
+
+  return -1;
+}
+
+
+#undef FOLD
+#undef CHAR
+#undef UCHAR
+#undef INT
+#undef FCT
+#undef EXT
+#undef END
+#undef MEMPCPY
+#undef MEMCHR
+#undef STRCOLL
+#undef STRLEN
+#undef STRCAT
+#undef L_
+#undef BTOWC
diff --git a/gnulib/lib/getdelim.c b/gnulib/lib/getdelim.c
new file mode 100644 (file)
index 0000000..e00e9b5
--- /dev/null
@@ -0,0 +1,137 @@
+/* getdelim.c --- Implementation of replacement getdelim function.
+   Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2011 Free Software
+   Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+/* Ported from glibc by Simon Josefsson. */
+
+#include <config.h>
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below.  */
+#define _GL_ARG_NONNULL(params)
+
+#include <stdio.h>
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+# define getc_maybe_unlocked(fp)        getc(fp)
+#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
+# undef flockfile
+# undef funlockfile
+# define flockfile(x) ((void) 0)
+# define funlockfile(x) ((void) 0)
+# define getc_maybe_unlocked(fp)        getc(fp)
+#else
+# define getc_maybe_unlocked(fp)        getc_unlocked(fp)
+#endif
+
+/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
+   NUL-terminate it).  *LINEPTR is a pointer returned from malloc (or
+   NULL), pointing to *N characters of space.  It is realloc'ed as
+   necessary.  Returns the number of characters read (not including
+   the null terminator), or -1 on error or EOF.  */
+
+ssize_t
+getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
+{
+  ssize_t result;
+  size_t cur_len = 0;
+
+  if (lineptr == NULL || n == NULL || fp == NULL)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  flockfile (fp);
+
+  if (*lineptr == NULL || *n == 0)
+    {
+      char *new_lineptr;
+      *n = 120;
+      new_lineptr = (char *) realloc (*lineptr, *n);
+      if (new_lineptr == NULL)
+        {
+          result = -1;
+          goto unlock_return;
+        }
+      *lineptr = new_lineptr;
+    }
+
+  for (;;)
+    {
+      int i;
+
+      i = getc_maybe_unlocked (fp);
+      if (i == EOF)
+        {
+          result = -1;
+          break;
+        }
+
+      /* Make enough space for len+1 (for final NUL) bytes.  */
+      if (cur_len + 1 >= *n)
+        {
+          size_t needed_max =
+            SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+          size_t needed = 2 * *n + 1;   /* Be generous. */
+          char *new_lineptr;
+
+          if (needed_max < needed)
+            needed = needed_max;
+          if (cur_len + 1 >= needed)
+            {
+              result = -1;
+              errno = EOVERFLOW;
+              goto unlock_return;
+            }
+
+          new_lineptr = (char *) realloc (*lineptr, needed);
+          if (new_lineptr == NULL)
+            {
+              result = -1;
+              goto unlock_return;
+            }
+
+          *lineptr = new_lineptr;
+          *n = needed;
+        }
+
+      (*lineptr)[cur_len] = i;
+      cur_len++;
+
+      if (i == delimiter)
+        break;
+    }
+  (*lineptr)[cur_len] = '\0';
+  result = cur_len ? cur_len : result;
+
+ unlock_return:
+  funlockfile (fp); /* doesn't set errno */
+
+  return result;
+}
diff --git a/gnulib/lib/getfilecon.c b/gnulib/lib/getfilecon.c
new file mode 100644 (file)
index 0000000..c793367
--- /dev/null
@@ -0,0 +1,87 @@
+/* wrap getfilecon, lgetfilecon, and fgetfilecon
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+#include <selinux/selinux.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <string.h>
+
+/* FIXME: remove this once there is an errno-gnu module
+   that guarantees the definition of ENODATA.  */
+#ifndef ENODATA
+# define ENODATA ENOTSUP
+#endif
+
+#undef getfilecon
+#undef lgetfilecon
+#undef fgetfilecon
+int getfilecon (char const *file, security_context_t *con);
+int lgetfilecon (char const *file, security_context_t *con);
+int fgetfilecon (int fd, security_context_t *con);
+
+/* getfilecon, lgetfilecon, and fgetfilecon can all misbehave, be it
+   via an old version of libselinux where these would return 0 and set the
+   result context to NULL, or via a modern kernel+lib operating on a file
+   from a disk whose attributes were set by a kernel from around 2006.
+   In that latter case, the functions return a length of 10 for the
+   "unlabeled" context.  Map both failures to a return value of -1, and
+   set errno to ENOTSUP in the first case, and ENODATA in the latter.  */
+
+static inline int
+map_to_failure (int ret, security_context_t *con)
+{
+  if (ret == 0)
+    {
+      errno = ENOTSUP;
+      return -1;
+    }
+
+  if (ret == 10 && strcmp (*con, "unlabeled") == 0)
+    {
+      freecon (*con);
+      errno = ENODATA;
+      return -1;
+    }
+
+  return ret;
+}
+
+int
+rpl_getfilecon (char const *file, security_context_t *con)
+{
+  int ret = getfilecon (file, con);
+  return map_to_failure (ret, con);
+}
+
+int
+rpl_lgetfilecon (char const *file, security_context_t *con)
+{
+  int ret = lgetfilecon (file, con);
+  return map_to_failure (ret, con);
+}
+
+int
+rpl_fgetfilecon (int fd, security_context_t *con)
+{
+  int ret = fgetfilecon (fd, con);
+  return map_to_failure (ret, con);
+}
diff --git a/gnulib/lib/getline.c b/gnulib/lib/getline.c
new file mode 100644 (file)
index 0000000..9f9afec
--- /dev/null
@@ -0,0 +1,29 @@
+/* getline.c --- Implementation of replacement getline function.
+   Copyright (C) 2005-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 Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+/* Written by Simon Josefsson. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+ssize_t
+getline (char **lineptr, size_t *n, FILE *stream)
+{
+  return getdelim (lineptr, n, '\n', stream);
+}
diff --git a/gnulib/lib/getopt.c b/gnulib/lib/getopt.c
new file mode 100644 (file)
index 0000000..9e79ad4
--- /dev/null
@@ -0,0 +1,1192 @@
+/* Getopt for GNU.
+   NOTE: getopt is part of the C library, so if you don't know what
+   "Keep this file name-space clean" means, talk to drepper@gnu.org
+   before changing it!
+   Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+\f
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include "getopt.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+   but it behaves differently for the user, since it allows the user
+   to intersperse the options with the other arguments.
+
+   As `getopt_long' works, it permutes the elements of ARGV so that,
+   when it is done, all the options precede everything else.  Thus
+   all application programs are extended to handle flexible argument order.
+
+   Using `getopt' or setting the environment variable POSIXLY_CORRECT
+   disables permutation.
+   Then the behavior is completely standard.
+
+   GNU application programs can use a third alternative mode in which
+   they can distinguish the relative order of options and other arguments.  */
+
+#include "getopt_int.h"
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+/* 1003.2 says this must be 1 before any call.  */
+int optind = 1;
+
+/* Callers store zero here to inhibit the error message
+   for unrecognized options.  */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+   This must be initialized on some systems to avoid linking in the
+   system's own getopt implementation.  */
+
+int optopt = '?';
+
+/* Keep a global copy of all internal members of getopt_data.  */
+
+static struct _getopt_data getopt_data;
+
+\f
+#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV
+extern char *getenv ();
+#endif
+\f
+#ifdef _LIBC
+/* Stored original parameters.
+   XXX This is no good solution.  We should rather copy the args so
+   that we can compare them later.  But we must not use malloc(3).  */
+extern int __libc_argc;
+extern char **__libc_argv;
+
+/* Bash 2.0 gives us an environment variable containing flags
+   indicating ARGV elements that should not be considered arguments.  */
+
+# ifdef USE_NONOPTION_FLAGS
+/* Defined in getopt_init.c  */
+extern char *__getopt_nonoption_flags;
+# endif
+
+# ifdef USE_NONOPTION_FLAGS
+#  define SWAP_FLAGS(ch1, ch2) \
+  if (d->__nonoption_flags_len > 0)                                           \
+    {                                                                         \
+      char __tmp = __getopt_nonoption_flags[ch1];                             \
+      __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];          \
+      __getopt_nonoption_flags[ch2] = __tmp;                                  \
+    }
+# else
+#  define SWAP_FLAGS(ch1, ch2)
+# endif
+#else   /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif  /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+   One subsequence is elements [first_nonopt,last_nonopt)
+   which contains all the non-options that have been skipped so far.
+   The other is elements [last_nonopt,optind), which contains all
+   the options processed since those non-options were skipped.
+
+   `first_nonopt' and `last_nonopt' are relocated so that they describe
+   the new indices of the non-options in ARGV after they are moved.  */
+
+static void
+exchange (char **argv, struct _getopt_data *d)
+{
+  int bottom = d->__first_nonopt;
+  int middle = d->__last_nonopt;
+  int top = d->optind;
+  char *tem;
+
+  /* Exchange the shorter segment with the far end of the longer segment.
+     That puts the shorter segment into the right place.
+     It leaves the longer segment in the right place overall,
+     but it consists of two parts that need to be swapped next.  */
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  /* First make sure the handling of the `__getopt_nonoption_flags'
+     string can work normally.  Our top argument must be in the range
+     of the string.  */
+  if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
+    {
+      /* We must extend the array.  The user plays games with us and
+         presents new arguments.  */
+      char *new_str = malloc (top + 1);
+      if (new_str == NULL)
+        d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
+      else
+        {
+          memset (__mempcpy (new_str, __getopt_nonoption_flags,
+                             d->__nonoption_flags_max_len),
+                  '\0', top + 1 - d->__nonoption_flags_max_len);
+          d->__nonoption_flags_max_len = top + 1;
+          __getopt_nonoption_flags = new_str;
+        }
+    }
+#endif
+
+  while (top > middle && middle > bottom)
+    {
+      if (top - middle > middle - bottom)
+        {
+          /* Bottom segment is the short one.  */
+          int len = middle - bottom;
+          register int i;
+
+          /* Swap it with the top part of the top segment.  */
+          for (i = 0; i < len; i++)
+            {
+              tem = argv[bottom + i];
+              argv[bottom + i] = argv[top - (middle - bottom) + i];
+              argv[top - (middle - bottom) + i] = tem;
+              SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+            }
+          /* Exclude the moved bottom segment from further swapping.  */
+          top -= len;
+        }
+      else
+        {
+          /* Top segment is the short one.  */
+          int len = top - middle;
+          register int i;
+
+          /* Swap it with the bottom part of the bottom segment.  */
+          for (i = 0; i < len; i++)
+            {
+              tem = argv[bottom + i];
+              argv[bottom + i] = argv[middle + i];
+              argv[middle + i] = tem;
+              SWAP_FLAGS (bottom + i, middle + i);
+            }
+          /* Exclude the moved top segment from further swapping.  */
+          bottom += len;
+        }
+    }
+
+  /* Update records for the slots the non-options now occupy.  */
+
+  d->__first_nonopt += (d->optind - d->__last_nonopt);
+  d->__last_nonopt = d->optind;
+}
+
+/* Initialize the internal data when the first call is made.  */
+
+static const char *
+_getopt_initialize (int argc _GL_UNUSED,
+                    char **argv _GL_UNUSED, const char *optstring,
+                    struct _getopt_data *d, int posixly_correct)
+{
+  /* Start processing options with ARGV-element 1 (since ARGV-element 0
+     is the program name); the sequence of previously skipped
+     non-option ARGV-elements is empty.  */
+
+  d->__first_nonopt = d->__last_nonopt = d->optind;
+
+  d->__nextchar = NULL;
+
+  d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
+
+  /* Determine how to handle the ordering of options and nonoptions.  */
+
+  if (optstring[0] == '-')
+    {
+      d->__ordering = RETURN_IN_ORDER;
+      ++optstring;
+    }
+  else if (optstring[0] == '+')
+    {
+      d->__ordering = REQUIRE_ORDER;
+      ++optstring;
+    }
+  else if (d->__posixly_correct)
+    d->__ordering = REQUIRE_ORDER;
+  else
+    d->__ordering = PERMUTE;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  if (!d->__posixly_correct
+      && argc == __libc_argc && argv == __libc_argv)
+    {
+      if (d->__nonoption_flags_max_len == 0)
+        {
+          if (__getopt_nonoption_flags == NULL
+              || __getopt_nonoption_flags[0] == '\0')
+            d->__nonoption_flags_max_len = -1;
+          else
+            {
+              const char *orig_str = __getopt_nonoption_flags;
+              int len = d->__nonoption_flags_max_len = strlen (orig_str);
+              if (d->__nonoption_flags_max_len < argc)
+                d->__nonoption_flags_max_len = argc;
+              __getopt_nonoption_flags =
+                (char *) malloc (d->__nonoption_flags_max_len);
+              if (__getopt_nonoption_flags == NULL)
+                d->__nonoption_flags_max_len = -1;
+              else
+                memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+                        '\0', d->__nonoption_flags_max_len - len);
+            }
+        }
+      d->__nonoption_flags_len = d->__nonoption_flags_max_len;
+    }
+  else
+    d->__nonoption_flags_len = 0;
+#endif
+
+  return optstring;
+}
+\f
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+   given in OPTSTRING.
+
+   If an element of ARGV starts with '-', and is not exactly "-" or "--",
+   then it is an option element.  The characters of this element
+   (aside from the initial '-') are option characters.  If `getopt'
+   is called repeatedly, it returns successively each of the option characters
+   from each of the option elements.
+
+   If `getopt' finds another option character, it returns that character,
+   updating `optind' and `nextchar' so that the next call to `getopt' can
+   resume the scan with the following option character or ARGV-element.
+
+   If there are no more option characters, `getopt' returns -1.
+   Then `optind' is the index in ARGV of the first ARGV-element
+   that is not an option.  (The ARGV-elements have been permuted
+   so that those that are not options now come last.)
+
+   OPTSTRING is a string containing the legitimate option characters.
+   If an option character is seen that is not listed in OPTSTRING,
+   return '?' after printing an error message.  If you set `opterr' to
+   zero, the error message is suppressed but we still return '?'.
+
+   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+   so the following text in the same ARGV-element, or the text of the following
+   ARGV-element, is returned in `optarg'.  Two colons mean an option that
+   wants an optional arg; if there is text in the current ARGV-element,
+   it is returned in `optarg', otherwise `optarg' is set to zero.
+
+   If OPTSTRING starts with `-' or `+', it requests different methods of
+   handling the non-option ARGV-elements.
+   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+   Long-named options begin with `--' instead of `-'.
+   Their names may be abbreviated as long as the abbreviation is unique
+   or is an exact match for some defined option.  If they have an
+   argument, it follows the option name in the same ARGV-element, separated
+   from the option name by a `=', or else the in next ARGV-element.
+   When `getopt' finds a long-named option, it returns 0 if that option's
+   `flag' field is nonzero, the value of the option's `val' field
+   if the `flag' field is zero.
+
+   The elements of ARGV aren't really const, because we permute them.
+   But we pretend they're const in the prototype to be compatible
+   with other systems.
+
+   LONGOPTS is a vector of `struct option' terminated by an
+   element containing a name which is zero.
+
+   LONGIND returns the index in LONGOPT of the long-named option found.
+   It is only valid when a long-named option has been found by the most
+   recent call.
+
+   If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+   long-named options.  */
+
+int
+_getopt_internal_r (int argc, char **argv, const char *optstring,
+                    const struct option *longopts, int *longind,
+                    int long_only, struct _getopt_data *d, int posixly_correct)
+{
+  int print_errors = d->opterr;
+
+  if (argc < 1)
+    return -1;
+
+  d->optarg = NULL;
+
+  if (d->optind == 0 || !d->__initialized)
+    {
+      if (d->optind == 0)
+        d->optind = 1;  /* Don't scan ARGV[0], the program name.  */
+      optstring = _getopt_initialize (argc, argv, optstring, d,
+                                      posixly_correct);
+      d->__initialized = 1;
+    }
+  else if (optstring[0] == '-' || optstring[0] == '+')
+    optstring++;
+  if (optstring[0] == ':')
+    print_errors = 0;
+
+  /* Test whether ARGV[optind] points to a non-option argument.
+     Either it does not have option syntax, or there is an environment flag
+     from the shell indicating it is not an option.  The later information
+     is only used when the used in the GNU libc.  */
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
+                      || (d->optind < d->__nonoption_flags_len                \
+                          && __getopt_nonoption_flags[d->optind] == '1'))
+#else
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
+#endif
+
+  if (d->__nextchar == NULL || *d->__nextchar == '\0')
+    {
+      /* Advance to the next ARGV-element.  */
+
+      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+         moved back by the user (who may also have changed the arguments).  */
+      if (d->__last_nonopt > d->optind)
+        d->__last_nonopt = d->optind;
+      if (d->__first_nonopt > d->optind)
+        d->__first_nonopt = d->optind;
+
+      if (d->__ordering == PERMUTE)
+        {
+          /* If we have just processed some options following some non-options,
+             exchange them so that the options come first.  */
+
+          if (d->__first_nonopt != d->__last_nonopt
+              && d->__last_nonopt != d->optind)
+            exchange ((char **) argv, d);
+          else if (d->__last_nonopt != d->optind)
+            d->__first_nonopt = d->optind;
+
+          /* Skip any additional non-options
+             and extend the range of non-options previously skipped.  */
+
+          while (d->optind < argc && NONOPTION_P)
+            d->optind++;
+          d->__last_nonopt = d->optind;
+        }
+
+      /* The special ARGV-element `--' means premature end of options.
+         Skip it like a null option,
+         then exchange with previous non-options as if it were an option,
+         then skip everything else like a non-option.  */
+
+      if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+        {
+          d->optind++;
+
+          if (d->__first_nonopt != d->__last_nonopt
+              && d->__last_nonopt != d->optind)
+            exchange ((char **) argv, d);
+          else if (d->__first_nonopt == d->__last_nonopt)
+            d->__first_nonopt = d->optind;
+          d->__last_nonopt = argc;
+
+          d->optind = argc;
+        }
+
+      /* If we have done all the ARGV-elements, stop the scan
+         and back over any non-options that we skipped and permuted.  */
+
+      if (d->optind == argc)
+        {
+          /* Set the next-arg-index to point at the non-options
+             that we previously skipped, so the caller will digest them.  */
+          if (d->__first_nonopt != d->__last_nonopt)
+            d->optind = d->__first_nonopt;
+          return -1;
+        }
+
+      /* If we have come to a non-option and did not permute it,
+         either stop the scan or describe it to the caller and pass it by.  */
+
+      if (NONOPTION_P)
+        {
+          if (d->__ordering == REQUIRE_ORDER)
+            return -1;
+          d->optarg = argv[d->optind++];
+          return 1;
+        }
+
+      /* We have found another option-ARGV-element.
+         Skip the initial punctuation.  */
+
+      d->__nextchar = (argv[d->optind] + 1
+                  + (longopts != NULL && argv[d->optind][1] == '-'));
+    }
+
+  /* Decode the current option-ARGV-element.  */
+
+  /* Check whether the ARGV-element is a long option.
+
+     If long_only and the ARGV-element has the form "-f", where f is
+     a valid short option, don't consider it an abbreviated form of
+     a long option that starts with f.  Otherwise there would be no
+     way to give the -f short option.
+
+     On the other hand, if there's a long option "fubar" and
+     the ARGV-element is "-fu", do consider that an abbreviation of
+     the long option, just like "--fu", and not "-f" with arg "u".
+
+     This distinction seems to be the most useful approach.  */
+
+  if (longopts != NULL
+      && (argv[d->optind][1] == '-'
+          || (long_only && (argv[d->optind][2]
+                            || !strchr (optstring, argv[d->optind][1])))))
+    {
+      char *nameend;
+      const struct option *p;
+      const struct option *pfound = NULL;
+      int exact = 0;
+      int ambig = 0;
+      int indfound = -1;
+      int option_index;
+
+      for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
+        /* Do nothing.  */ ;
+
+      /* Test all long options for either exact match
+         or abbreviated matches.  */
+      for (p = longopts, option_index = 0; p->name; p++, option_index++)
+        if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+          {
+            if ((unsigned int) (nameend - d->__nextchar)
+                == (unsigned int) strlen (p->name))
+              {
+                /* Exact match found.  */
+                pfound = p;
+                indfound = option_index;
+                exact = 1;
+                break;
+              }
+            else if (pfound == NULL)
+              {
+                /* First nonexact match found.  */
+                pfound = p;
+                indfound = option_index;
+              }
+            else if (long_only
+                     || pfound->has_arg != p->has_arg
+                     || pfound->flag != p->flag
+                     || pfound->val != p->val)
+              /* Second or later nonexact match found.  */
+              ambig = 1;
+          }
+
+      if (ambig && !exact)
+        {
+          if (print_errors)
+            {
+#if defined _LIBC && defined USE_IN_LIBIO
+              char *buf;
+
+              if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"),
+                              argv[0], argv[d->optind]) >= 0)
+                {
+                  _IO_flockfile (stderr);
+
+                  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                  __fxprintf (NULL, "%s", buf);
+
+                  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                  _IO_funlockfile (stderr);
+
+                  free (buf);
+                }
+#else
+              fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
+                       argv[0], argv[d->optind]);
+#endif
+            }
+          d->__nextchar += strlen (d->__nextchar);
+          d->optind++;
+          d->optopt = 0;
+          return '?';
+        }
+
+      if (pfound != NULL)
+        {
+          option_index = indfound;
+          d->optind++;
+          if (*nameend)
+            {
+              /* Don't test has_arg with >, because some C compilers don't
+                 allow it to be used on enums.  */
+              if (pfound->has_arg)
+                d->optarg = nameend + 1;
+              else
+                {
+                  if (print_errors)
+                    {
+#if defined _LIBC && defined USE_IN_LIBIO
+                      char *buf;
+                      int n;
+#endif
+
+                      if (argv[d->optind - 1][1] == '-')
+                        {
+                          /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+                          n = __asprintf (&buf, _("\
+%s: option '--%s' doesn't allow an argument\n"),
+                                          argv[0], pfound->name);
+#else
+                          fprintf (stderr, _("\
+%s: option '--%s' doesn't allow an argument\n"),
+                                   argv[0], pfound->name);
+#endif
+                        }
+                      else
+                        {
+                          /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+                          n = __asprintf (&buf, _("\
+%s: option '%c%s' doesn't allow an argument\n"),
+                                          argv[0], argv[d->optind - 1][0],
+                                          pfound->name);
+#else
+                          fprintf (stderr, _("\
+%s: option '%c%s' doesn't allow an argument\n"),
+                                   argv[0], argv[d->optind - 1][0],
+                                   pfound->name);
+#endif
+                        }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+                      if (n >= 0)
+                        {
+                          _IO_flockfile (stderr);
+
+                          int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                          ((_IO_FILE *) stderr)->_flags2
+                            |= _IO_FLAGS2_NOTCANCEL;
+
+                          __fxprintf (NULL, "%s", buf);
+
+                          ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                          _IO_funlockfile (stderr);
+
+                          free (buf);
+                        }
+#endif
+                    }
+
+                  d->__nextchar += strlen (d->__nextchar);
+
+                  d->optopt = pfound->val;
+                  return '?';
+                }
+            }
+          else if (pfound->has_arg == 1)
+            {
+              if (d->optind < argc)
+                d->optarg = argv[d->optind++];
+              else
+                {
+                  if (print_errors)
+                    {
+#if defined _LIBC && defined USE_IN_LIBIO
+                      char *buf;
+
+                      if (__asprintf (&buf, _("\
+%s: option '--%s' requires an argument\n"),
+                                      argv[0], pfound->name) >= 0)
+                        {
+                          _IO_flockfile (stderr);
+
+                          int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                          ((_IO_FILE *) stderr)->_flags2
+                            |= _IO_FLAGS2_NOTCANCEL;
+
+                          __fxprintf (NULL, "%s", buf);
+
+                          ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                          _IO_funlockfile (stderr);
+
+                          free (buf);
+                        }
+#else
+                      fprintf (stderr,
+                               _("%s: option '--%s' requires an argument\n"),
+                               argv[0], pfound->name);
+#endif
+                    }
+                  d->__nextchar += strlen (d->__nextchar);
+                  d->optopt = pfound->val;
+                  return optstring[0] == ':' ? ':' : '?';
+                }
+            }
+          d->__nextchar += strlen (d->__nextchar);
+          if (longind != NULL)
+            *longind = option_index;
+          if (pfound->flag)
+            {
+              *(pfound->flag) = pfound->val;
+              return 0;
+            }
+          return pfound->val;
+        }
+
+      /* Can't find it as a long option.  If this is not getopt_long_only,
+         or the option starts with '--' or is not a valid short
+         option, then it's an error.
+         Otherwise interpret it as a short option.  */
+      if (!long_only || argv[d->optind][1] == '-'
+          || strchr (optstring, *d->__nextchar) == NULL)
+        {
+          if (print_errors)
+            {
+#if defined _LIBC && defined USE_IN_LIBIO
+              char *buf;
+              int n;
+#endif
+
+              if (argv[d->optind][1] == '-')
+                {
+                  /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+                  n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
+                                  argv[0], d->__nextchar);
+#else
+                  fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
+                           argv[0], d->__nextchar);
+#endif
+                }
+              else
+                {
+                  /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+                  n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
+                                  argv[0], argv[d->optind][0], d->__nextchar);
+#else
+                  fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
+                           argv[0], argv[d->optind][0], d->__nextchar);
+#endif
+                }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+              if (n >= 0)
+                {
+                  _IO_flockfile (stderr);
+
+                  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                  __fxprintf (NULL, "%s", buf);
+
+                  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                  _IO_funlockfile (stderr);
+
+                  free (buf);
+                }
+#endif
+            }
+          d->__nextchar = (char *) "";
+          d->optind++;
+          d->optopt = 0;
+          return '?';
+        }
+    }
+
+  /* Look at and handle the next short option-character.  */
+
+  {
+    char c = *d->__nextchar++;
+    const char *temp = strchr (optstring, c);
+
+    /* Increment `optind' when we start to process its last character.  */
+    if (*d->__nextchar == '\0')
+      ++d->optind;
+
+    if (temp == NULL || c == ':' || c == ';')
+      {
+        if (print_errors)
+          {
+#if defined _LIBC && defined USE_IN_LIBIO
+              char *buf;
+              int n;
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+              n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
+                              argv[0], c);
+#else
+              fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+            if (n >= 0)
+              {
+                _IO_flockfile (stderr);
+
+                int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                __fxprintf (NULL, "%s", buf);
+
+                ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                _IO_funlockfile (stderr);
+
+                free (buf);
+              }
+#endif
+          }
+        d->optopt = c;
+        return '?';
+      }
+    /* Convenience. Treat POSIX -W foo same as long option --foo */
+    if (temp[0] == 'W' && temp[1] == ';')
+      {
+        char *nameend;
+        const struct option *p;
+        const struct option *pfound = NULL;
+        int exact = 0;
+        int ambig = 0;
+        int indfound = 0;
+        int option_index;
+
+        /* This is an option that requires an argument.  */
+        if (*d->__nextchar != '\0')
+          {
+            d->optarg = d->__nextchar;
+            /* If we end this ARGV-element by taking the rest as an arg,
+               we must advance to the next element now.  */
+            d->optind++;
+          }
+        else if (d->optind == argc)
+          {
+            if (print_errors)
+              {
+#if defined _LIBC && defined USE_IN_LIBIO
+                char *buf;
+
+                if (__asprintf (&buf,
+                                _("%s: option requires an argument -- '%c'\n"),
+                                argv[0], c) >= 0)
+                  {
+                    _IO_flockfile (stderr);
+
+                    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                    __fxprintf (NULL, "%s", buf);
+
+                    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                    _IO_funlockfile (stderr);
+
+                    free (buf);
+                  }
+#else
+                fprintf (stderr,
+                         _("%s: option requires an argument -- '%c'\n"),
+                         argv[0], c);
+#endif
+              }
+            d->optopt = c;
+            if (optstring[0] == ':')
+              c = ':';
+            else
+              c = '?';
+            return c;
+          }
+        else
+          /* We already incremented `d->optind' once;
+             increment it again when taking next ARGV-elt as argument.  */
+          d->optarg = argv[d->optind++];
+
+        /* optarg is now the argument, see if it's in the
+           table of longopts.  */
+
+        for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
+             nameend++)
+          /* Do nothing.  */ ;
+
+        /* Test all long options for either exact match
+           or abbreviated matches.  */
+        for (p = longopts, option_index = 0; p->name; p++, option_index++)
+          if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+            {
+              if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
+                {
+                  /* Exact match found.  */
+                  pfound = p;
+                  indfound = option_index;
+                  exact = 1;
+                  break;
+                }
+              else if (pfound == NULL)
+                {
+                  /* First nonexact match found.  */
+                  pfound = p;
+                  indfound = option_index;
+                }
+              else if (long_only
+                       || pfound->has_arg != p->has_arg
+                       || pfound->flag != p->flag
+                       || pfound->val != p->val)
+                /* Second or later nonexact match found.  */
+                ambig = 1;
+            }
+        if (ambig && !exact)
+          {
+            if (print_errors)
+              {
+#if defined _LIBC && defined USE_IN_LIBIO
+                char *buf;
+
+                if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
+                                argv[0], d->optarg) >= 0)
+                  {
+                    _IO_flockfile (stderr);
+
+                    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                    __fxprintf (NULL, "%s", buf);
+
+                    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                    _IO_funlockfile (stderr);
+
+                    free (buf);
+                  }
+#else
+                fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
+                         argv[0], d->optarg);
+#endif
+              }
+            d->__nextchar += strlen (d->__nextchar);
+            d->optind++;
+            return '?';
+          }
+        if (pfound != NULL)
+          {
+            option_index = indfound;
+            if (*nameend)
+              {
+                /* Don't test has_arg with >, because some C compilers don't
+                   allow it to be used on enums.  */
+                if (pfound->has_arg)
+                  d->optarg = nameend + 1;
+                else
+                  {
+                    if (print_errors)
+                      {
+#if defined _LIBC && defined USE_IN_LIBIO
+                        char *buf;
+
+                        if (__asprintf (&buf, _("\
+%s: option '-W %s' doesn't allow an argument\n"),
+                                        argv[0], pfound->name) >= 0)
+                          {
+                            _IO_flockfile (stderr);
+
+                            int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                            ((_IO_FILE *) stderr)->_flags2
+                              |= _IO_FLAGS2_NOTCANCEL;
+
+                            __fxprintf (NULL, "%s", buf);
+
+                            ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                            _IO_funlockfile (stderr);
+
+                            free (buf);
+                          }
+#else
+                        fprintf (stderr, _("\
+%s: option '-W %s' doesn't allow an argument\n"),
+                                 argv[0], pfound->name);
+#endif
+                      }
+
+                    d->__nextchar += strlen (d->__nextchar);
+                    return '?';
+                  }
+              }
+            else if (pfound->has_arg == 1)
+              {
+                if (d->optind < argc)
+                  d->optarg = argv[d->optind++];
+                else
+                  {
+                    if (print_errors)
+                      {
+#if defined _LIBC && defined USE_IN_LIBIO
+                        char *buf;
+
+                        if (__asprintf (&buf, _("\
+%s: option '-W %s' requires an argument\n"),
+                                        argv[0], pfound->name) >= 0)
+                          {
+                            _IO_flockfile (stderr);
+
+                            int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                            ((_IO_FILE *) stderr)->_flags2
+                              |= _IO_FLAGS2_NOTCANCEL;
+
+                            __fxprintf (NULL, "%s", buf);
+
+                            ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                            _IO_funlockfile (stderr);
+
+                            free (buf);
+                          }
+#else
+                        fprintf (stderr, _("\
+%s: option '-W %s' requires an argument\n"),
+                                 argv[0], pfound->name);
+#endif
+                      }
+                    d->__nextchar += strlen (d->__nextchar);
+                    return optstring[0] == ':' ? ':' : '?';
+                  }
+              }
+            else
+              d->optarg = NULL;
+            d->__nextchar += strlen (d->__nextchar);
+            if (longind != NULL)
+              *longind = option_index;
+            if (pfound->flag)
+              {
+                *(pfound->flag) = pfound->val;
+                return 0;
+              }
+            return pfound->val;
+          }
+          d->__nextchar = NULL;
+          return 'W';   /* Let the application handle it.   */
+      }
+    if (temp[1] == ':')
+      {
+        if (temp[2] == ':')
+          {
+            /* This is an option that accepts an argument optionally.  */
+            if (*d->__nextchar != '\0')
+              {
+                d->optarg = d->__nextchar;
+                d->optind++;
+              }
+            else
+              d->optarg = NULL;
+            d->__nextchar = NULL;
+          }
+        else
+          {
+            /* This is an option that requires an argument.  */
+            if (*d->__nextchar != '\0')
+              {
+                d->optarg = d->__nextchar;
+                /* If we end this ARGV-element by taking the rest as an arg,
+                   we must advance to the next element now.  */
+                d->optind++;
+              }
+            else if (d->optind == argc)
+              {
+                if (print_errors)
+                  {
+#if defined _LIBC && defined USE_IN_LIBIO
+                    char *buf;
+
+                    if (__asprintf (&buf, _("\
+%s: option requires an argument -- '%c'\n"),
+                                    argv[0], c) >= 0)
+                      {
+                        _IO_flockfile (stderr);
+
+                        int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+                        ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+                        __fxprintf (NULL, "%s", buf);
+
+                        ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+                        _IO_funlockfile (stderr);
+
+                        free (buf);
+                      }
+#else
+                    fprintf (stderr,
+                             _("%s: option requires an argument -- '%c'\n"),
+                             argv[0], c);
+#endif
+                  }
+                d->optopt = c;
+                if (optstring[0] == ':')
+                  c = ':';
+                else
+                  c = '?';
+              }
+            else
+              /* We already incremented `optind' once;
+                 increment it again when taking next ARGV-elt as argument.  */
+              d->optarg = argv[d->optind++];
+            d->__nextchar = NULL;
+          }
+      }
+    return c;
+  }
+}
+
+int
+_getopt_internal (int argc, char **argv, const char *optstring,
+                  const struct option *longopts, int *longind, int long_only,
+                  int posixly_correct)
+{
+  int result;
+
+  getopt_data.optind = optind;
+  getopt_data.opterr = opterr;
+
+  result = _getopt_internal_r (argc, argv, optstring, longopts,
+                               longind, long_only, &getopt_data,
+                               posixly_correct);
+
+  optind = getopt_data.optind;
+  optarg = getopt_data.optarg;
+  optopt = getopt_data.optopt;
+
+  return result;
+}
+
+/* glibc gets a LSB-compliant getopt.
+   Standalone applications get a POSIX-compliant getopt.  */
+#if _LIBC
+enum { POSIXLY_CORRECT = 0 };
+#else
+enum { POSIXLY_CORRECT = 1 };
+#endif
+
+int
+getopt (int argc, char *const *argv, const char *optstring)
+{
+  return _getopt_internal (argc, (char **) argv, optstring,
+                           (const struct option *) 0,
+                           (int *) 0,
+                           0, POSIXLY_CORRECT);
+}
+
+#ifdef _LIBC
+int
+__posix_getopt (int argc, char *const *argv, const char *optstring)
+{
+  return _getopt_internal (argc, argv, optstring,
+                           (const struct option *) 0,
+                           (int *) 0,
+                           0, 1);
+}
+#endif
+
+\f
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+   the above definition of `getopt'.  */
+
+int
+main (int argc, char **argv)
+{
+  int c;
+  int digit_optind = 0;
+
+  while (1)
+    {
+      int this_option_optind = optind ? optind : 1;
+
+      c = getopt (argc, argv, "abc:d:0123456789");
+      if (c == -1)
+        break;
+
+      switch (c)
+        {
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+          if (digit_optind != 0 && digit_optind != this_option_optind)
+            printf ("digits occur in two different argv-elements.\n");
+          digit_optind = this_option_optind;
+          printf ("option %c\n", c);
+          break;
+
+        case 'a':
+          printf ("option a\n");
+          break;
+
+        case 'b':
+          printf ("option b\n");
+          break;
+
+        case 'c':
+          printf ("option c with value '%s'\n", optarg);
+          break;
+
+        case '?':
+          break;
+
+        default:
+          printf ("?? getopt returned character code 0%o ??\n", c);
+        }
+    }
+
+  if (optind < argc)
+    {
+      printf ("non-option ARGV-elements: ");
+      while (optind < argc)
+        printf ("%s ", argv[optind++]);
+      printf ("\n");
+    }
+
+  exit (0);
+}
+
+#endif /* TEST */
diff --git a/gnulib/lib/getopt.in.h b/gnulib/lib/getopt.in.h
new file mode 100644 (file)
index 0000000..479493c
--- /dev/null
@@ -0,0 +1,253 @@
+/* Declarations for getopt.
+   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GL_GETOPT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  We must
+   also inform the replacement unistd.h to not recursively use
+   <getopt.h>; our definitions will be present soon enough.  */
+#if @HAVE_GETOPT_H@
+# define _GL_SYSTEM_GETOPT
+# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
+# undef _GL_SYSTEM_GETOPT
+#endif
+
+#ifndef _GL_GETOPT_H
+
+#ifndef __need_getopt
+# define _GL_GETOPT_H 1
+#endif
+
+/* Standalone applications should #define __GETOPT_PREFIX to an
+   identifier that prefixes the external functions and variables
+   defined in this header.  When this happens, include the
+   headers that might declare getopt so that they will not cause
+   confusion if included after this file (if the system had <getopt.h>,
+   we have already included it).  Then systematically rename
+   identifiers so that they do not collide with the system functions
+   and variables.  Renaming avoids problems with some compilers and
+   linkers.  */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# if !@HAVE_GETOPT_H@
+#  include <stdlib.h>
+#  include <stdio.h>
+#  include <unistd.h>
+# endif
+# undef __need_getopt
+# undef getopt
+# undef getopt_long
+# undef getopt_long_only
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# undef option
+# define __GETOPT_CONCAT(x, y) x ## y
+# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
+# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
+# define getopt __GETOPT_ID (getopt)
+# define getopt_long __GETOPT_ID (getopt_long)
+# define getopt_long_only __GETOPT_ID (getopt_long_only)
+# define optarg __GETOPT_ID (optarg)
+# define opterr __GETOPT_ID (opterr)
+# define optind __GETOPT_ID (optind)
+# define optopt __GETOPT_ID (optopt)
+# define option __GETOPT_ID (option)
+# define _getopt_internal __GETOPT_ID (getopt_internal)
+#endif
+
+/* Standalone applications get correct prototypes for getopt_long and
+   getopt_long_only; they declare "char **argv".  libc uses prototypes
+   with "char *const *argv" that are incorrect because getopt_long and
+   getopt_long_only can permute argv; this is required for backward
+   compatibility (e.g., for LSB 2.0.1).
+
+   This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
+   but it caused redefinition warnings if both unistd.h and getopt.h were
+   included, since unistd.h includes getopt.h having previously defined
+   __need_getopt.
+
+   The only place where __getopt_argv_const is used is in definitions
+   of getopt_long and getopt_long_only below, but these are visible
+   only if __need_getopt is not defined, so it is quite safe to rewrite
+   the conditional as follows:
+*/
+#if !defined __need_getopt
+# if defined __GETOPT_PREFIX
+#  define __getopt_argv_const /* empty */
+# else
+#  define __getopt_argv_const const
+# endif
+#endif
+
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+   standalone, or this is the first header included in the source file.
+   If we are being used with glibc, we need to include <features.h>, but
+   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
+   not defined, include <ctype.h>, which will pull in <features.h> for us
+   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
+   doesn't flood the namespace with stuff the way some other headers do.)  */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
+
+#ifndef __THROW
+# ifndef __GNUC_PREREQ
+#  define __GNUC_PREREQ(maj, min) (0)
+# endif
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+#  define __THROW       throw ()
+# else
+#  define __THROW
+# endif
+#endif
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+   for unrecognized options.  */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized.  */
+
+extern int optopt;
+
+#ifndef __need_getopt
+/* Describe the long-named options requested by the application.
+   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+   of `struct option' terminated by an element containing a name which is
+   zero.
+
+   The field `has_arg' is:
+   no_argument          (or 0) if the option does not take an argument,
+   required_argument    (or 1) if the option requires an argument,
+   optional_argument    (or 2) if the option takes an optional argument.
+
+   If the field `flag' is not NULL, it points to a variable that is set
+   to the value given in the field `val' when the option is found, but
+   left unchanged if the option is not found.
+
+   To have a long-named option do something other than set an `int' to
+   a compiled-in constant, such as set a value from `optarg', set the
+   option's `flag' field to zero and its `val' field to a nonzero
+   value (the equivalent single-letter option character, if there is
+   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;
+  /* has_arg can't be an enum because some compilers complain about
+     type mismatches in all the code that assumes it is an int.  */
+  int has_arg;
+  int *flag;
+  int val;
+};
+#  define GNULIB_defined_struct_option 1
+# endif
+
+/* Names for the values of the `has_arg' field of `struct option'.  */
+
+# define no_argument            0
+# define required_argument      1
+# define optional_argument      2
+#endif  /* need getopt */
+
+
+/* Get definitions and prototypes for functions to process the
+   arguments in ARGV (ARGC of them, minus the program name) for
+   options given in OPTS.
+
+   Return the option character from OPTS just read.  Return -1 when
+   there are no more options.  For unrecognized options, or options
+   missing arguments, `optopt' is set to the option letter, and '?' is
+   returned.
+
+   The OPTS string is a list of characters which are recognized option
+   letters, optionally followed by colons, specifying that that letter
+   takes an argument, to be placed in `optarg'.
+
+   If a letter in OPTS is followed by two colons, its argument is
+   optional.  This behavior is specific to the GNU `getopt'.
+
+   The argument `--' causes premature termination of argument
+   scanning, explicitly telling `getopt' that there are no more
+   options.
+
+   If OPTS begins with `-', then non-option arguments are treated as
+   arguments to the option '\1'.  This behavior is specific to the GNU
+   `getopt'.  If OPTS begins with `+', or POSIXLY_CORRECT is set in
+   the environment, then do not permute arguments.  */
+
+extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+       __THROW _GL_ARG_NONNULL ((2, 3));
+
+#ifndef __need_getopt
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
+                        const char *__shortopts,
+                        const struct option *__longopts, int *__longind)
+       __THROW _GL_ARG_NONNULL ((2, 3));
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind)
+       __THROW _GL_ARG_NONNULL ((2, 3));
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Make sure we later can get all the definitions and declarations.  */
+#undef __need_getopt
+
+#endif /* getopt.h */
+#endif /* getopt.h */
diff --git a/gnulib/lib/getopt1.c b/gnulib/lib/getopt1.c
new file mode 100644 (file)
index 0000000..5cceeb4
--- /dev/null
@@ -0,0 +1,170 @@
+/* getopt_long and getopt_long_only entry points for GNU getopt.
+   Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+\f
+#ifdef _LIBC
+# include <getopt.h>
+#else
+# include <config.h>
+# include "getopt.h"
+#endif
+#include "getopt_int.h"
+
+#include <stdio.h>
+
+/* This needs to come after some library #include
+   to get __GNU_LIBRARY__ defined.  */
+#ifdef __GNU_LIBRARY__
+#include <stdlib.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+int
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+             const struct option *long_options, int *opt_index)
+{
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+                           opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+                const struct option *long_options, int *opt_index,
+                struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+                             0, d, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+   If an option that starts with '-' (not '--') doesn't match a long option,
+   but does match a short option, it is parsed as a short option
+   instead.  */
+
+int
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+                  const char *options,
+                  const struct option *long_options, int *opt_index)
+{
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+                           opt_index, 1, 0);
+}
+
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+                     const struct option *long_options, int *opt_index,
+                     struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+                             1, d, 0);
+}
+
+\f
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  int c;
+  int digit_optind = 0;
+
+  while (1)
+    {
+      int this_option_optind = optind ? optind : 1;
+      int option_index = 0;
+      static const struct option long_options[] =
+      {
+        {"add", 1, 0, 0},
+        {"append", 0, 0, 0},
+        {"delete", 1, 0, 0},
+        {"verbose", 0, 0, 0},
+        {"create", 0, 0, 0},
+        {"file", 1, 0, 0},
+        {0, 0, 0, 0}
+      };
+
+      c = getopt_long (argc, argv, "abc:d:0123456789",
+                       long_options, &option_index);
+      if (c == -1)
+        break;
+
+      switch (c)
+        {
+        case 0:
+          printf ("option %s", long_options[option_index].name);
+          if (optarg)
+            printf (" with arg %s", optarg);
+          printf ("\n");
+          break;
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+          if (digit_optind != 0 && digit_optind != this_option_optind)
+            printf ("digits occur in two different argv-elements.\n");
+          digit_optind = this_option_optind;
+          printf ("option %c\n", c);
+          break;
+
+        case 'a':
+          printf ("option a\n");
+          break;
+
+        case 'b':
+          printf ("option b\n");
+          break;
+
+        case 'c':
+          printf ("option c with value `%s'\n", optarg);
+          break;
+
+        case 'd':
+          printf ("option d with value `%s'\n", optarg);
+          break;
+
+        case '?':
+          break;
+
+        default:
+          printf ("?? getopt returned character code 0%o ??\n", c);
+        }
+    }
+
+  if (optind < argc)
+    {
+      printf ("non-option ARGV-elements: ");
+      while (optind < argc)
+        printf ("%s ", argv[optind++]);
+      printf ("\n");
+    }
+
+  exit (0);
+}
+
+#endif /* TEST */
diff --git a/gnulib/lib/getopt_int.h b/gnulib/lib/getopt_int.h
new file mode 100644 (file)
index 0000000..17be98e
--- /dev/null
@@ -0,0 +1,135 @@
+/* Internal declarations for getopt.
+   Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H   1
+
+#include <getopt.h>
+
+extern int _getopt_internal (int ___argc, char **___argv,
+                             const char *__shortopts,
+                             const struct option *__longopts, int *__longind,
+                             int __long_only, int __posixly_correct);
+
+\f
+/* Reentrant versions which can handle parsing multiple argument
+   vectors at the same time.  */
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+   If the caller did not specify anything,
+   the default is REQUIRE_ORDER if the environment variable
+   POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+   REQUIRE_ORDER means don't recognize them as options;
+   stop option processing when the first non-option is seen.
+   This is what Unix does.
+   This mode of operation is selected by either setting the environment
+   variable POSIXLY_CORRECT, or using `+' as the first character
+   of the list of option characters, or by calling getopt.
+
+   PERMUTE is the default.  We permute the contents of ARGV as we
+   scan, so that eventually all the non-options are at the end.
+   This allows options to be given in any order, even with programs
+   that were not written to expect this.
+
+   RETURN_IN_ORDER is an option available to programs that were
+   written to expect options and other ARGV-elements in any order
+   and that care about the ordering of the two.  We describe each
+   non-option ARGV-element as if it were the argument of an option
+   with character code 1.  Using `-' as the first character of the
+   list of option characters selects this mode of operation.
+
+   The special argument `--' forces an end of option-scanning regardless
+   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+
+enum __ord
+  {
+    REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+  };
+
+/* Data type for reentrant functions.  */
+struct _getopt_data
+{
+  /* These have exactly the same meaning as the corresponding global
+     variables, except that they are used for the reentrant
+     versions of getopt.  */
+  int optind;
+  int opterr;
+  int optopt;
+  char *optarg;
+
+  /* Internal members.  */
+
+  /* True if the internal members have been initialized.  */
+  int __initialized;
+
+  /* The next char to be scanned in the option-element
+     in which the last option character we returned was found.
+     This allows us to pick up the scan where we left off.
+
+     If this is zero, or a null string, it means resume the scan
+     by advancing to the next ARGV-element.  */
+  char *__nextchar;
+
+  /* See __ord above.  */
+  enum __ord __ordering;
+
+  /* If the POSIXLY_CORRECT environment variable is set
+     or getopt was called.  */
+  int __posixly_correct;
+
+
+  /* Handle permutation of arguments.  */
+
+  /* Describe the part of ARGV that contains non-options that have
+     been skipped.  `first_nonopt' is the index in ARGV of the first
+     of them; `last_nonopt' is the index after the last of them.  */
+
+  int __first_nonopt;
+  int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  int __nonoption_flags_max_len;
+  int __nonoption_flags_len;
+#endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+   default values and to clear the initialization flag.  */
+#define _GETOPT_DATA_INITIALIZER        { 1, 1 }
+
+extern int _getopt_internal_r (int ___argc, char **___argv,
+                               const char *__shortopts,
+                               const struct option *__longopts, int *__longind,
+                               int __long_only, struct _getopt_data *__data,
+                               int __posixly_correct);
+
+extern int _getopt_long_r (int ___argc, char **___argv,
+                           const char *__shortopts,
+                           const struct option *__longopts, int *__longind,
+                           struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char **___argv,
+                                const char *__shortopts,
+                                const struct option *__longopts,
+                                int *__longind,
+                                struct _getopt_data *__data);
+
+#endif /* getopt_int.h */
diff --git a/gnulib/lib/gettext.h b/gnulib/lib/gettext.h
new file mode 100644 (file)
index 0000000..c6b7925
--- /dev/null
@@ -0,0 +1,286 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+   Copyright (C) 1995-1998, 2000-2002, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option.  */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions.  */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+   the gettext() and ngettext() macros.  This is an alternative to calling
+   textdomain(), and is useful for libraries.  */
+# ifdef DEFAULT_TEXT_DOMAIN
+#  undef gettext
+#  define gettext(Msgid) \
+     dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+#  undef ngettext
+#  define ngettext(Msgid1, Msgid2, N) \
+     dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+   chokes if dcgettext is defined as a macro.  So include it now, to make
+   later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
+   as well because people using "gettext.h" will not include <libintl.h>,
+   and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+   is OK.  */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
+   it now, to make later inclusions of <libintl.h> a NOP.  */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
+#  include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+   The casts to 'const char *' serve the purpose of producing warnings
+   for invalid uses of the value returned from these functions.
+   On pre-ANSI systems without 'const', the config.h file is supposed to
+   contain "#define const".  */
+# undef gettext
+# define gettext(Msgid) ((const char *) (Msgid))
+# undef dgettext
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# undef dcgettext
+# define dcgettext(Domainname, Msgid, Category) \
+    ((void) (Category), dgettext (Domainname, Msgid))
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+    ((N) == 1 \
+     ? ((void) (Msgid2), (const char *) (Msgid1)) \
+     : ((void) (Msgid1), (const char *) (Msgid2)))
+# undef dngettext
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+    ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# undef dcngettext
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+    ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
+# undef textdomain
+# define textdomain(Domainname) ((const char *) (Domainname))
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) \
+    ((void) (Domainname), (const char *) (Dirname))
+# undef bind_textdomain_codeset
+# define bind_textdomain_codeset(Domainname, Codeset) \
+    ((void) (Domainname), (const char *) (Codeset))
+
+#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.
+   The argument, String, should be a literal string.  Concatenated strings
+   and other string expressions won't work.
+   The macro's expansion is not parenthesized, so that it is suitable as
+   initializer for static 'char[]' or 'const char[]' variables.  */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file.  */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+   MSGID.  MSGCTXT and MSGID must be string literals.  MSGCTXT should be
+   short and rarely need to change.
+   The letter 'p' stands for 'particular' or 'special'.  */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+   pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+   pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+  pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+   npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+   npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+  npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+              const char *msg_ctxt_id, const char *msgid,
+              int category)
+{
+  const char *translation = dcgettext (domain, msg_ctxt_id, category);
+  if (translation == msg_ctxt_id)
+    return msgid;
+  else
+    return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+               const char *msg_ctxt_id, const char *msgid,
+               const char *msgid_plural, unsigned long int n,
+               int category)
+{
+  const char *translation =
+    dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+  if (translation == msg_ctxt_id || translation == msgid_plural)
+    return (n == 1 ? msgid : msgid_plural);
+  else
+    return translation;
+}
+
+/* The same thing extended for non-constant arguments.  Here MSGCTXT and MSGID
+   can be arbitrary expressions.  But for string literals these macros are
+   less efficient than those above.  */
+
+#include <string.h>
+
+#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+  (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+   /* || __STDC_VERSION__ >= 199901L */ )
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+  dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+                 const char *msgctxt, const char *msgid,
+                 int category)
+{
+  size_t msgctxt_len = strlen (msgctxt) + 1;
+  size_t msgid_len = strlen (msgid) + 1;
+  const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+  char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+  char buf[1024];
+  char *msg_ctxt_id =
+    (msgctxt_len + msgid_len <= sizeof (buf)
+     ? buf
+     : (char *) malloc (msgctxt_len + msgid_len));
+  if (msg_ctxt_id != NULL)
+#endif
+    {
+      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+      msg_ctxt_id[msgctxt_len - 1] = '\004';
+      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+      translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+      if (msg_ctxt_id != buf)
+        free (msg_ctxt_id);
+#endif
+      if (translation != msg_ctxt_id)
+        return translation;
+    }
+  return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+  dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+                  const char *msgctxt, const char *msgid,
+                  const char *msgid_plural, unsigned long int n,
+                  int category)
+{
+  size_t msgctxt_len = strlen (msgctxt) + 1;
+  size_t msgid_len = strlen (msgid) + 1;
+  const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+  char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+  char buf[1024];
+  char *msg_ctxt_id =
+    (msgctxt_len + msgid_len <= sizeof (buf)
+     ? buf
+     : (char *) malloc (msgctxt_len + msgid_len));
+  if (msg_ctxt_id != NULL)
+#endif
+    {
+      memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+      msg_ctxt_id[msgctxt_len - 1] = '\004';
+      memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+      translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+      if (msg_ctxt_id != buf)
+        free (msg_ctxt_id);
+#endif
+      if (!(translation == msg_ctxt_id || translation == msgid_plural))
+        return translation;
+    }
+  return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
diff --git a/gnulib/lib/isblank.c b/gnulib/lib/isblank.c
new file mode 100644 (file)
index 0000000..b7e1289
--- /dev/null
@@ -0,0 +1,33 @@
+/* Test whether a character is a blank.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <ctype.h>
+
+int
+isblank (int c)
+{
+  /* On all known platforms, in all predefined locales, isblank(c) is likely
+     equivalent with  (c == ' ' || c == '\t').  Look at the glibc definition
+     (in glibc/localedata/locales/i18n): The "blank" characters are '\t', ' ',
+     U+1680, U+180E, U+2000..U+2006, U+2008..U+200A, U+205F, U+3000, and none
+     except the first two is present in a common 8-bit encoding.  Therefore
+     the substitute for other platforms is not more complicated than this.  */
+  return (c == ' ' || c == '\t');
+}
diff --git a/gnulib/lib/langinfo.in.h b/gnulib/lib/langinfo.in.h
new file mode 100644 (file)
index 0000000..0f5d5dc
--- /dev/null
@@ -0,0 +1,177 @@
+/* Substitute for and wrapper around <langinfo.h>.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/*
+ * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
+ * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
+ */
+
+#ifndef _GL_LANGINFO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_LANGINFO_H@
+# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
+#endif
+
+#ifndef _GL_LANGINFO_H
+#define _GL_LANGINFO_H
+
+
+#if !@HAVE_LANGINFO_H@
+
+/* A platform that lacks <langinfo.h>.  */
+
+/* Assume that it also lacks <nl_types.h> and the nl_item type.  */
+# 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
+/* nl_langinfo items of the LC_NUMERIC category */
+# define RADIXCHAR   10001
+# define THOUSEP     10002
+/* nl_langinfo items of the LC_TIME category */
+# define D_T_FMT     10003
+# define D_FMT       10004
+# define T_FMT       10005
+# define T_FMT_AMPM  10006
+# define AM_STR      10007
+# define PM_STR      10008
+# define DAY_1       10009
+# define DAY_2       (DAY_1 + 1)
+# define DAY_3       (DAY_1 + 2)
+# define DAY_4       (DAY_1 + 3)
+# define DAY_5       (DAY_1 + 4)
+# define DAY_6       (DAY_1 + 5)
+# define DAY_7       (DAY_1 + 6)
+# define ABDAY_1     10016
+# define ABDAY_2     (ABDAY_1 + 1)
+# define ABDAY_3     (ABDAY_1 + 2)
+# define ABDAY_4     (ABDAY_1 + 3)
+# define ABDAY_5     (ABDAY_1 + 4)
+# define ABDAY_6     (ABDAY_1 + 5)
+# define ABDAY_7     (ABDAY_1 + 6)
+# define MON_1       10023
+# define MON_2       (MON_1 + 1)
+# define MON_3       (MON_1 + 2)
+# define MON_4       (MON_1 + 3)
+# define MON_5       (MON_1 + 4)
+# define MON_6       (MON_1 + 5)
+# define MON_7       (MON_1 + 6)
+# define MON_8       (MON_1 + 7)
+# define MON_9       (MON_1 + 8)
+# define MON_10      (MON_1 + 9)
+# define MON_11      (MON_1 + 10)
+# define MON_12      (MON_1 + 11)
+# define ABMON_1     10035
+# define ABMON_2     (ABMON_1 + 1)
+# define ABMON_3     (ABMON_1 + 2)
+# define ABMON_4     (ABMON_1 + 3)
+# define ABMON_5     (ABMON_1 + 4)
+# define ABMON_6     (ABMON_1 + 5)
+# define ABMON_7     (ABMON_1 + 6)
+# define ABMON_8     (ABMON_1 + 7)
+# define ABMON_9     (ABMON_1 + 8)
+# define ABMON_10    (ABMON_1 + 9)
+# define ABMON_11    (ABMON_1 + 10)
+# define ABMON_12    (ABMON_1 + 11)
+# define ERA         10047
+# define ERA_D_FMT   10048
+# define ERA_D_T_FMT 10049
+# define ERA_T_FMT   10050
+# define ALT_DIGITS  10051
+/* nl_langinfo items of the LC_MONETARY category */
+# define CRNCYSTR    10052
+/* nl_langinfo items of the LC_MESSAGES category */
+# define YESEXPR     10053
+# define NOEXPR      10054
+
+#else
+
+/* A platform that has <langinfo.h>.  */
+
+# if !@HAVE_LANGINFO_CODESET@
+#  define CODESET     10000
+#  define GNULIB_defined_CODESET 1
+# endif
+
+# if !@HAVE_LANGINFO_T_FMT_AMPM@
+#  define T_FMT_AMPM  10006
+#  define GNULIB_defined_T_FMT_AMPM 1
+# endif
+
+# if !@HAVE_LANGINFO_ERA@
+#  define ERA         10047
+#  define ERA_D_FMT   10048
+#  define ERA_D_T_FMT 10049
+#  define ERA_T_FMT   10050
+#  define ALT_DIGITS  10051
+#  define GNULIB_defined_ERA 1
+# endif
+
+# if !@HAVE_LANGINFO_YESEXPR@
+#  define YESEXPR     10053
+#  define NOEXPR      10054
+#  define GNULIB_defined_YESEXPR 1
+# endif
+
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Declare overridden functions.  */
+
+
+/* Return a piece of locale dependent information.
+   Note: The difference between nl_langinfo (CODESET) and locale_charset ()
+   is that the latter normalizes the encoding names to GNU conventions.  */
+
+#if @GNULIB_NL_LANGINFO@
+# if @REPLACE_NL_LANGINFO@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef nl_langinfo
+#   define nl_langinfo rpl_nl_langinfo
+#  endif
+_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item));
+_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
+# else
+#  if !@HAVE_NL_LANGINFO@
+_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
+#  endif
+_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
+# endif
+_GL_CXXALIASWARN (nl_langinfo);
+#elif defined GNULIB_POSIXCHECK
+# undef nl_langinfo
+# if HAVE_RAW_DECL_NL_LANGINFO
+_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
+                 "use gnulib module nl_langinfo for portability");
+# endif
+#endif
+
+
+#endif /* _GL_LANGINFO_H */
+#endif /* _GL_LANGINFO_H */
diff --git a/gnulib/lib/localcharset.c b/gnulib/lib/localcharset.c
new file mode 100644 (file)
index 0000000..3a49593
--- /dev/null
@@ -0,0 +1,547 @@
+/* Determine a canonical name for the current locale's character encoding.
+
+   Copyright (C) 2000-2006, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "localcharset.h"
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
+# define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */
+#endif
+
+#if defined _WIN32 || defined __WIN32__
+# define WIN32_NATIVE
+#endif
+
+#if defined __EMX__
+/* Assume EMX program runs on OS/2, even if compiled under DOS.  */
+# ifndef OS2
+#  define OS2
+# endif
+#endif
+
+#if !defined WIN32_NATIVE
+# include <unistd.h>
+# if HAVE_LANGINFO_CODESET
+#  include <langinfo.h>
+# else
+#  if 0 /* see comment below */
+#   include <locale.h>
+#  endif
+# endif
+# ifdef __CYGWIN__
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+# endif
+#elif defined WIN32_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+#if defined OS2
+# define INCL_DOS
+# include <os2.h>
+#endif
+
+#if ENABLE_RELOCATABLE
+# include "relocatable.h"
+#else
+# define relocate(pathname) (pathname)
+#endif
+
+/* Get LIBDIR.  */
+#ifndef LIBDIR
+# include "configmake.h"
+#endif
+
+/* Define O_NOFOLLOW to 0 on platforms where it does not exist.  */
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+  /* Win32, Cygwin, OS/2, DOS */
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#endif
+
+#ifndef DIRECTORY_SEPARATOR
+# define DIRECTORY_SEPARATOR '/'
+#endif
+
+#ifndef ISSLASH
+# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
+#endif
+
+#if HAVE_DECL_GETC_UNLOCKED
+# undef getc
+# define getc getc_unlocked
+#endif
+
+/* The following static variable is declared 'volatile' to avoid a
+   possible multithread problem in the function get_charset_aliases. If we
+   are running in a threaded environment, and if two threads initialize
+   'charset_aliases' simultaneously, both will produce the same value,
+   and everything will be ok if the two assignments to 'charset_aliases'
+   are atomic. But I don't know what will happen if the two assignments mix.  */
+#if __STDC__ != 1
+# define volatile /* empty */
+#endif
+/* Pointer to the contents of the charset.alias file, if it has already been
+   read, else NULL.  Its format is:
+   ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0'  */
+static const char * volatile charset_aliases;
+
+/* Return a pointer to the contents of the charset.alias file.  */
+static const char *
+get_charset_aliases (void)
+{
+  const char *cp;
+
+  cp = charset_aliases;
+  if (cp == NULL)
+    {
+#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
+      const char *dir;
+      const char *base = "charset.alias";
+      char *file_name;
+
+      /* Make it possible to override the charset.alias location.  This is
+         necessary for running the testsuite before "make install".  */
+      dir = getenv ("CHARSETALIASDIR");
+      if (dir == NULL || dir[0] == '\0')
+        dir = relocate (LIBDIR);
+
+      /* Concatenate dir and base into freshly allocated file_name.  */
+      {
+        size_t dir_len = strlen (dir);
+        size_t base_len = strlen (base);
+        int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
+        file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
+        if (file_name != NULL)
+          {
+            memcpy (file_name, dir, dir_len);
+            if (add_slash)
+              file_name[dir_len] = DIRECTORY_SEPARATOR;
+            memcpy (file_name + dir_len + add_slash, base, base_len + 1);
+          }
+      }
+
+      if (file_name == NULL)
+        /* Out of memory.  Treat the file as empty.  */
+        cp = "";
+      else
+        {
+          int fd;
+
+          /* Open the file.  Reject symbolic links on platforms that support
+             O_NOFOLLOW.  This is a security feature.  Without it, an attacker
+             could retrieve parts of the contents (namely, the tail of the
+             first line that starts with "* ") of an arbitrary file by placing
+             a symbolic link to that file under the name "charset.alias" in
+             some writable directory and defining the environment variable
+             CHARSETALIASDIR to point to that directory.  */
+          fd = open (file_name,
+                     O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
+          if (fd < 0)
+            /* File not found.  Treat it as empty.  */
+            cp = "";
+          else
+            {
+              FILE *fp;
+
+              fp = fdopen (fd, "r");
+              if (fp == NULL)
+                {
+                  /* Out of memory.  Treat the file as empty.  */
+                  close (fd);
+                  cp = "";
+                }
+              else
+                {
+                  /* Parse the file's contents.  */
+                  char *res_ptr = NULL;
+                  size_t res_size = 0;
+
+                  for (;;)
+                    {
+                      int c;
+                      char buf1[50+1];
+                      char buf2[50+1];
+                      size_t l1, l2;
+                      char *old_res_ptr;
+
+                      c = getc (fp);
+                      if (c == EOF)
+                        break;
+                      if (c == '\n' || c == ' ' || c == '\t')
+                        continue;
+                      if (c == '#')
+                        {
+                          /* Skip comment, to end of line.  */
+                          do
+                            c = getc (fp);
+                          while (!(c == EOF || c == '\n'));
+                          if (c == EOF)
+                            break;
+                          continue;
+                        }
+                      ungetc (c, fp);
+                      if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
+                        break;
+                      l1 = strlen (buf1);
+                      l2 = strlen (buf2);
+                      old_res_ptr = res_ptr;
+                      if (res_size == 0)
+                        {
+                          res_size = l1 + 1 + l2 + 1;
+                          res_ptr = (char *) malloc (res_size + 1);
+                        }
+                      else
+                        {
+                          res_size += l1 + 1 + l2 + 1;
+                          res_ptr = (char *) realloc (res_ptr, res_size + 1);
+                        }
+                      if (res_ptr == NULL)
+                        {
+                          /* Out of memory. */
+                          res_size = 0;
+                          free (old_res_ptr);
+                          break;
+                        }
+                      strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
+                      strcpy (res_ptr + res_size - (l2 + 1), buf2);
+                    }
+                  fclose (fp);
+                  if (res_size == 0)
+                    cp = "";
+                  else
+                    {
+                      *(res_ptr + res_size) = '\0';
+                      cp = res_ptr;
+                    }
+                }
+            }
+
+          free (file_name);
+        }
+
+#else
+
+# if defined DARWIN7
+      /* To avoid the trouble of installing a file that is shared by many
+         GNU packages -- many packaging systems have problems with this --,
+         simply inline the aliases here.  */
+      cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
+           "ISO8859-2" "\0" "ISO-8859-2" "\0"
+           "ISO8859-4" "\0" "ISO-8859-4" "\0"
+           "ISO8859-5" "\0" "ISO-8859-5" "\0"
+           "ISO8859-7" "\0" "ISO-8859-7" "\0"
+           "ISO8859-9" "\0" "ISO-8859-9" "\0"
+           "ISO8859-13" "\0" "ISO-8859-13" "\0"
+           "ISO8859-15" "\0" "ISO-8859-15" "\0"
+           "KOI8-R" "\0" "KOI8-R" "\0"
+           "KOI8-U" "\0" "KOI8-U" "\0"
+           "CP866" "\0" "CP866" "\0"
+           "CP949" "\0" "CP949" "\0"
+           "CP1131" "\0" "CP1131" "\0"
+           "CP1251" "\0" "CP1251" "\0"
+           "eucCN" "\0" "GB2312" "\0"
+           "GB2312" "\0" "GB2312" "\0"
+           "eucJP" "\0" "EUC-JP" "\0"
+           "eucKR" "\0" "EUC-KR" "\0"
+           "Big5" "\0" "BIG5" "\0"
+           "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
+           "GBK" "\0" "GBK" "\0"
+           "GB18030" "\0" "GB18030" "\0"
+           "SJIS" "\0" "SHIFT_JIS" "\0"
+           "ARMSCII-8" "\0" "ARMSCII-8" "\0"
+           "PT154" "\0" "PT154" "\0"
+         /*"ISCII-DEV" "\0" "?" "\0"*/
+           "*" "\0" "UTF-8" "\0";
+# endif
+
+# if defined VMS
+      /* To avoid the troubles of an extra file charset.alias_vms in the
+         sources of many GNU packages, simply inline the aliases here.  */
+      /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
+         "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
+         section 10.7 "Handling Different Character Sets".  */
+      cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
+           "ISO8859-2" "\0" "ISO-8859-2" "\0"
+           "ISO8859-5" "\0" "ISO-8859-5" "\0"
+           "ISO8859-7" "\0" "ISO-8859-7" "\0"
+           "ISO8859-8" "\0" "ISO-8859-8" "\0"
+           "ISO8859-9" "\0" "ISO-8859-9" "\0"
+           /* Japanese */
+           "eucJP" "\0" "EUC-JP" "\0"
+           "SJIS" "\0" "SHIFT_JIS" "\0"
+           "DECKANJI" "\0" "DEC-KANJI" "\0"
+           "SDECKANJI" "\0" "EUC-JP" "\0"
+           /* Chinese */
+           "eucTW" "\0" "EUC-TW" "\0"
+           "DECHANYU" "\0" "DEC-HANYU" "\0"
+           "DECHANZI" "\0" "GB2312" "\0"
+           /* Korean */
+           "DECKOREAN" "\0" "EUC-KR" "\0";
+# endif
+
+# if defined WIN32_NATIVE || defined __CYGWIN__
+      /* To avoid the troubles of installing a separate file in the same
+         directory as the DLL and of retrieving the DLL's directory at
+         runtime, simply inline the aliases here.  */
+
+      cp = "CP936" "\0" "GBK" "\0"
+           "CP1361" "\0" "JOHAB" "\0"
+           "CP20127" "\0" "ASCII" "\0"
+           "CP20866" "\0" "KOI8-R" "\0"
+           "CP20936" "\0" "GB2312" "\0"
+           "CP21866" "\0" "KOI8-RU" "\0"
+           "CP28591" "\0" "ISO-8859-1" "\0"
+           "CP28592" "\0" "ISO-8859-2" "\0"
+           "CP28593" "\0" "ISO-8859-3" "\0"
+           "CP28594" "\0" "ISO-8859-4" "\0"
+           "CP28595" "\0" "ISO-8859-5" "\0"
+           "CP28596" "\0" "ISO-8859-6" "\0"
+           "CP28597" "\0" "ISO-8859-7" "\0"
+           "CP28598" "\0" "ISO-8859-8" "\0"
+           "CP28599" "\0" "ISO-8859-9" "\0"
+           "CP28605" "\0" "ISO-8859-15" "\0"
+           "CP38598" "\0" "ISO-8859-8" "\0"
+           "CP51932" "\0" "EUC-JP" "\0"
+           "CP51936" "\0" "GB2312" "\0"
+           "CP51949" "\0" "EUC-KR" "\0"
+           "CP51950" "\0" "EUC-TW" "\0"
+           "CP54936" "\0" "GB18030" "\0"
+           "CP65001" "\0" "UTF-8" "\0";
+# endif
+#endif
+
+      charset_aliases = cp;
+    }
+
+  return cp;
+}
+
+/* Determine the current locale's character encoding, and canonicalize it
+   into one of the canonical names listed in config.charset.
+   The result must not be freed; it is statically allocated.
+   If the canonical name cannot be determined, the result is a non-canonical
+   name.  */
+
+#ifdef STATIC
+STATIC
+#endif
+const char *
+locale_charset (void)
+{
+  const char *codeset;
+  const char *aliases;
+
+#if !(defined WIN32_NATIVE || defined OS2)
+
+# if HAVE_LANGINFO_CODESET
+
+  /* Most systems support nl_langinfo (CODESET) nowadays.  */
+  codeset = nl_langinfo (CODESET);
+
+#  ifdef __CYGWIN__
+  /* Cygwin < 1.7 does not have locales.  nl_langinfo (CODESET) always
+     returns "US-ASCII".  Return the suffix of the locale name from the
+     environment variables (if present) or the codepage as a number.  */
+  if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
+    {
+      const char *locale;
+      static char buf[2 + 10 + 1];
+
+      locale = getenv ("LC_ALL");
+      if (locale == NULL || locale[0] == '\0')
+        {
+          locale = getenv ("LC_CTYPE");
+          if (locale == NULL || locale[0] == '\0')
+            locale = getenv ("LANG");
+        }
+      if (locale != NULL && locale[0] != '\0')
+        {
+          /* If the locale name contains an encoding after the dot, return
+             it.  */
+          const char *dot = strchr (locale, '.');
+
+          if (dot != NULL)
+            {
+              const char *modifier;
+
+              dot++;
+              /* Look for the possible @... trailer and remove it, if any.  */
+              modifier = strchr (dot, '@');
+              if (modifier == NULL)
+                return dot;
+              if (modifier - dot < sizeof (buf))
+                {
+                  memcpy (buf, dot, modifier - dot);
+                  buf [modifier - dot] = '\0';
+                  return buf;
+                }
+            }
+        }
+
+      /* Woe32 has a function returning the locale's codepage as a number:
+         GetACP().  This encoding is used by Cygwin, unless the user has set
+         the environment variable CYGWIN=codepage:oem (which very few people
+         do).
+         Output directed to console windows needs to be converted (to
+         GetOEMCP() if the console is using a raster font, or to
+         GetConsoleOutputCP() if it is using a TrueType font).  Cygwin does
+         this conversion transparently (see winsup/cygwin/fhandler_console.cc),
+         converting to GetConsoleOutputCP().  This leads to correct results,
+         except when SetConsoleOutputCP has been called and a raster font is
+         in use.  */
+      sprintf (buf, "CP%u", GetACP ());
+      codeset = buf;
+    }
+#  endif
+
+# else
+
+  /* On old systems which lack it, use setlocale or getenv.  */
+  const char *locale = NULL;
+
+  /* But most old systems don't have a complete set of locales.  Some
+     (like SunOS 4 or DJGPP) have only the C locale.  Therefore we don't
+     use setlocale here; it would return "C" when it doesn't support the
+     locale name the user has set.  */
+#  if 0
+  locale = setlocale (LC_CTYPE, NULL);
+#  endif
+  if (locale == NULL || locale[0] == '\0')
+    {
+      locale = getenv ("LC_ALL");
+      if (locale == NULL || locale[0] == '\0')
+        {
+          locale = getenv ("LC_CTYPE");
+          if (locale == NULL || locale[0] == '\0')
+            locale = getenv ("LANG");
+        }
+    }
+
+  /* On some old systems, one used to set locale = "iso8859_1". On others,
+     you set it to "language_COUNTRY.charset". In any case, we resolve it
+     through the charset.alias file.  */
+  codeset = locale;
+
+# endif
+
+#elif defined WIN32_NATIVE
+
+  static char buf[2 + 10 + 1];
+
+  /* Woe32 has a function returning the locale's codepage as a number:
+     GetACP().
+     When the output goes to a console window, it needs to be provided in
+     GetOEMCP() encoding if the console is using a raster font, or in
+     GetConsoleOutputCP() encoding if it is using a TrueType font.
+     But in GUI programs and for output sent to files and pipes, GetACP()
+     encoding is the best bet.  */
+  sprintf (buf, "CP%u", GetACP ());
+  codeset = buf;
+
+#elif defined OS2
+
+  const char *locale;
+  static char buf[2 + 10 + 1];
+  ULONG cp[3];
+  ULONG cplen;
+
+  /* Allow user to override the codeset, as set in the operating system,
+     with standard language environment variables.  */
+  locale = getenv ("LC_ALL");
+  if (locale == NULL || locale[0] == '\0')
+    {
+      locale = getenv ("LC_CTYPE");
+      if (locale == NULL || locale[0] == '\0')
+        locale = getenv ("LANG");
+    }
+  if (locale != NULL && locale[0] != '\0')
+    {
+      /* If the locale name contains an encoding after the dot, return it.  */
+      const char *dot = strchr (locale, '.');
+
+      if (dot != NULL)
+        {
+          const char *modifier;
+
+          dot++;
+          /* Look for the possible @... trailer and remove it, if any.  */
+          modifier = strchr (dot, '@');
+          if (modifier == NULL)
+            return dot;
+          if (modifier - dot < sizeof (buf))
+            {
+              memcpy (buf, dot, modifier - dot);
+              buf [modifier - dot] = '\0';
+              return buf;
+            }
+        }
+
+      /* Resolve through the charset.alias file.  */
+      codeset = locale;
+    }
+  else
+    {
+      /* OS/2 has a function returning the locale's codepage as a number.  */
+      if (DosQueryCp (sizeof (cp), cp, &cplen))
+        codeset = "";
+      else
+        {
+          sprintf (buf, "CP%u", cp[0]);
+          codeset = buf;
+        }
+    }
+
+#endif
+
+  if (codeset == NULL)
+    /* The canonical name cannot be determined.  */
+    codeset = "";
+
+  /* Resolve alias. */
+  for (aliases = get_charset_aliases ();
+       *aliases != '\0';
+       aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
+    if (strcmp (codeset, aliases) == 0
+        || (aliases[0] == '*' && aliases[1] == '\0'))
+      {
+        codeset = aliases + strlen (aliases) + 1;
+        break;
+      }
+
+  /* Don't return an empty string.  GNU libc and GNU libiconv interpret
+     the empty string as denoting "the locale's character encoding",
+     thus GNU libiconv would call this function a second time.  */
+  if (codeset[0] == '\0')
+    codeset = "ASCII";
+
+  return codeset;
+}
diff --git a/gnulib/lib/localcharset.h b/gnulib/lib/localcharset.h
new file mode 100644 (file)
index 0000000..a38a1f6
--- /dev/null
@@ -0,0 +1,41 @@
+/* Determine a canonical name for the current locale's character encoding.
+   Copyright (C) 2000-2003, 2009-2011 Free Software Foundation, Inc.
+   This file is part of the GNU CHARSET Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _LOCALCHARSET_H
+#define _LOCALCHARSET_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Determine the current locale's character encoding, and canonicalize it
+   into one of the canonical names listed in config.charset.
+   The result must not be freed; it is statically allocated.
+   If the canonical name cannot be determined, the result is a non-canonical
+   name.  */
+extern const char * locale_charset (void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _LOCALCHARSET_H */
diff --git a/gnulib/lib/locale.in.h b/gnulib/lib/locale.in.h
new file mode 100644 (file)
index 0000000..266b093
--- /dev/null
@@ -0,0 +1,96 @@
+/* A POSIX <locale.h>.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GL_LOCALE_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
+
+#ifndef _GL_LOCALE_H
+#define _GL_LOCALE_H
+
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
+/* MacOS X 10.5 defines the locale_t type in <xlocale.h>.  */
+#if @HAVE_XLOCALE_H@
+# include <xlocale.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
+   On systems that don't define it, use the same value as GNU libintl.  */
+#if !defined LC_MESSAGES
+# 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)
+#   undef duplocale
+#   define duplocale rpl_duplocale
+#  endif
+_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
+# else
+#  if @HAVE_DUPLOCALE@
+_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
+#  endif
+# endif
+# if @HAVE_DUPLOCALE@
+_GL_CXXALIASWARN (duplocale);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef duplocale
+# if HAVE_RAW_DECL_DUPLOCALE
+_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
+                 "use gnulib module duplocale for portability");
+# endif
+#endif
+
+#endif /* _GL_LOCALE_H */
+#endif /* _GL_LOCALE_H */
diff --git a/gnulib/lib/lstat.c b/gnulib/lib/lstat.c
new file mode 100644 (file)
index 0000000..bfb2b02
--- /dev/null
@@ -0,0 +1,91 @@
+/* Work around a bug of lstat on some systems
+
+   Copyright (C) 1997-2006, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+#if !HAVE_LSTAT
+/* On systems that lack symlinks, our replacement <sys/stat.h> already
+   defined lstat as stat, so there is nothing further to do other than
+   avoid an empty file.  */
+typedef int dummy;
+#else /* HAVE_LSTAT */
+
+/* Get the original definition of lstat.  It might be defined as a macro.  */
+# define __need_system_sys_stat_h
+# include <sys/types.h>
+# include <sys/stat.h>
+# undef __need_system_sys_stat_h
+
+static inline int
+orig_lstat (const char *filename, struct stat *buf)
+{
+  return lstat (filename, buf);
+}
+
+/* Specification.  */
+# include <sys/stat.h>
+
+# include <string.h>
+# include <errno.h>
+
+/* lstat works differently on Linux and Solaris systems.  POSIX (see
+   `pathname resolution' in the glossary) requires that programs like
+   `ls' take into consideration the fact that FILE has a trailing slash
+   when FILE is a symbolic link.  On Linux and Solaris 10 systems, the
+   lstat function already has the desired semantics (in treating
+   `lstat ("symlink/", sbuf)' just like `lstat ("symlink/.", sbuf)',
+   but on Solaris 9 and earlier it does not.
+
+   If FILE has a trailing slash and specifies a symbolic link,
+   then use stat() to get more info on the referent of FILE.
+   If the referent is a non-directory, then set errno to ENOTDIR
+   and return -1.  Otherwise, return stat's result.  */
+
+int
+rpl_lstat (const char *file, struct stat *sbuf)
+{
+  size_t len;
+  int lstat_result = orig_lstat (file, sbuf);
+
+  if (lstat_result != 0)
+    return lstat_result;
+
+  /* This replacement file can blindly check against '/' rather than
+     using the ISSLASH macro, because all platforms with '\\' either
+     lack symlinks (mingw) or have working lstat (cygwin) and thus do
+     not compile this file.  0 len should have already been filtered
+     out above, with a failure return of ENOENT.  */
+  len = strlen (file);
+  if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode))
+    return 0;
+
+  /* At this point, a trailing slash is only permitted on
+     symlink-to-dir; but it should have found information on the
+     directory, not the symlink.  Call stat() to get info about the
+     link's referent.  Our replacement stat guarantees valid results,
+     even if the symlink is not pointing to a directory.  */
+  if (!S_ISLNK (sbuf->st_mode))
+    {
+      errno = ENOTDIR;
+      return -1;
+    }
+  return stat (file, sbuf);
+}
+
+#endif /* HAVE_LSTAT */
diff --git a/gnulib/lib/malloc.c b/gnulib/lib/malloc.c
new file mode 100644 (file)
index 0000000..bc84c41
--- /dev/null
@@ -0,0 +1,60 @@
+/* malloc() function that is glibc compatible.
+
+   Copyright (C) 1997-1998, 2006-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#include <config.h>
+/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h.  */
+#ifdef malloc
+# define NEED_MALLOC_GNU 1
+# undef malloc
+/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU.  */
+#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
+# define NEED_MALLOC_GNU 1
+#endif
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Call the system's malloc below.  */
+#undef malloc
+
+/* Allocate an N-byte block of memory from the heap.
+   If N is zero, allocate a 1-byte block.  */
+
+void *
+rpl_malloc (size_t n)
+{
+  void *result;
+
+#if NEED_MALLOC_GNU
+  if (n == 0)
+    n = 1;
+#endif
+
+  result = malloc (n);
+
+#if !HAVE_MALLOC_POSIX
+  if (result == NULL)
+    errno = ENOMEM;
+#endif
+
+  return result;
+}
diff --git a/gnulib/lib/malloca.c b/gnulib/lib/malloca.c
new file mode 100644 (file)
index 0000000..32d3a30
--- /dev/null
@@ -0,0 +1,141 @@
+/* Safe automatic memory allocation.
+   Copyright (C) 2003, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "malloca.h"
+
+#include "verify.h"
+
+/* Use the system functions, not the gnulib overrides in this file.  */
+#undef malloc
+
+/* The speed critical point in this file is freea() applied to an alloca()
+   result: it must be fast, to match the speed of alloca().  The speed of
+   mmalloca() and freea() in the other case are not critical, because they
+   are only invoked for big memory sizes.  */
+
+#if HAVE_ALLOCA
+
+/* Store the mmalloca() results in a hash table.  This is needed to reliably
+   distinguish a mmalloca() result and an alloca() result.
+
+   Although it is possible that the same pointer is returned by alloca() and
+   by mmalloca() at different times in the same application, it does not lead
+   to a bug in freea(), because:
+     - Before a pointer returned by alloca() can point into malloc()ed memory,
+       the function must return, and once this has happened the programmer must
+       not call freea() on it anyway.
+     - Before a pointer returned by mmalloca() can point into the stack, it
+       must be freed.  The only function that can free it is freea(), and
+       when freea() frees it, it also removes it from the hash table.  */
+
+#define MAGIC_NUMBER 0x1415fb4a
+#define MAGIC_SIZE sizeof (int)
+/* This is how the header info would look like without any alignment
+   considerations.  */
+struct preliminary_header { void *next; char room[MAGIC_SIZE]; };
+/* But the header's size must be a multiple of sa_alignment_max.  */
+#define HEADER_SIZE \
+  (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
+struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; };
+verify (HEADER_SIZE == sizeof (struct header));
+/* We make the hash table quite big, so that during lookups the probability
+   of empty hash buckets is quite high.  There is no need to make the hash
+   table resizable, because when the hash table gets filled so much that the
+   lookup becomes slow, it means that the application has memory leaks.  */
+#define HASH_TABLE_SIZE 257
+static void * mmalloca_results[HASH_TABLE_SIZE];
+
+#endif
+
+void *
+mmalloca (size_t n)
+{
+#if HAVE_ALLOCA
+  /* Allocate one more word, that serves as an indicator for malloc()ed
+     memory, so that freea() of an alloca() result is fast.  */
+  size_t nplus = n + HEADER_SIZE;
+
+  if (nplus >= n)
+    {
+      char *p = (char *) malloc (nplus);
+
+      if (p != NULL)
+        {
+          size_t slot;
+
+          p += HEADER_SIZE;
+
+          /* Put a magic number into the indicator word.  */
+          ((int *) p)[-1] = MAGIC_NUMBER;
+
+          /* Enter p into the hash table.  */
+          slot = (unsigned long) p % HASH_TABLE_SIZE;
+          ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
+          mmalloca_results[slot] = p;
+
+          return p;
+        }
+    }
+  /* Out of memory.  */
+  return NULL;
+#else
+# if !MALLOC_0_IS_NONNULL
+  if (n == 0)
+    n = 1;
+# endif
+  return malloc (n);
+#endif
+}
+
+#if HAVE_ALLOCA
+void
+freea (void *p)
+{
+  /* mmalloca() may have returned NULL.  */
+  if (p != NULL)
+    {
+      /* Attempt to quickly distinguish the mmalloca() result - which has
+         a magic indicator word - and the alloca() result - which has an
+         uninitialized indicator word.  It is for this test that sa_increment
+         additional bytes are allocated in the alloca() case.  */
+      if (((int *) p)[-1] == MAGIC_NUMBER)
+        {
+          /* Looks like a mmalloca() result.  To see whether it really is one,
+             perform a lookup in the hash table.  */
+          size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
+          void **chain = &mmalloca_results[slot];
+          for (; *chain != NULL;)
+            {
+              if (*chain == p)
+                {
+                  /* Found it.  Remove it from the hash table and free it.  */
+                  char *p_begin = (char *) p - HEADER_SIZE;
+                  *chain = ((struct header *) p_begin)->next;
+                  free (p_begin);
+                  return;
+                }
+              chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
+            }
+        }
+      /* At this point, we know it was not a mmalloca() result.  */
+    }
+}
+#endif
diff --git a/gnulib/lib/malloca.h b/gnulib/lib/malloca.h
new file mode 100644 (file)
index 0000000..086e903
--- /dev/null
@@ -0,0 +1,134 @@
+/* Safe automatic memory allocation.
+   Copyright (C) 2003-2007, 2009-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _MALLOCA_H
+#define _MALLOCA_H
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
+   alloca(N); otherwise it returns NULL.  It either returns N bytes of
+   memory allocated on the stack, that lasts until the function returns,
+   or NULL.
+   Use of safe_alloca should be avoided:
+     - inside arguments of function calls - undefined behaviour,
+     - in inline functions - the allocation may actually last until the
+       calling function returns.
+*/
+#if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+   and a page size can be as small as 4096 bytes.  So we cannot safely
+   allocate anything larger than 4096 bytes.  Also care for the possibility
+   of a few compiler-allocated temporary stack slots.
+   This must be a macro, not an inline function.  */
+# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
+#else
+# define safe_alloca(N) ((void) (N), NULL)
+#endif
+
+/* malloca(N) is a safe variant of alloca(N).  It allocates N bytes of
+   memory allocated on the stack, that must be freed using freea() before
+   the function returns.  Upon failure, it returns NULL.  */
+#if HAVE_ALLOCA
+# define malloca(N) \
+  ((N) < 4032 - sa_increment                                        \
+   ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
+   : mmalloca (N))
+#else
+# define malloca(N) \
+  mmalloca (N)
+#endif
+extern void * mmalloca (size_t n);
+
+/* Free a block of memory allocated through malloca().  */
+#if HAVE_ALLOCA
+extern void freea (void *p);
+#else
+# define freea free
+#endif
+
+/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
+   It allocates an array of N objects, each with S bytes of memory,
+   on the stack.  S must be positive and N must be nonnegative.
+   The array must be freed using freea() before the function returns.  */
+#if 1
+/* Cf. the definition of xalloc_oversized.  */
+# define nmalloca(n, s) \
+    ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
+     ? NULL \
+     : malloca ((n) * (s)))
+#else
+extern void * nmalloca (size_t n, size_t s);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* ------------------- Auxiliary, non-public definitions ------------------- */
+
+/* Determine the alignment of a type at compile time.  */
+#if defined __GNUC__
+# define sa_alignof __alignof__
+#elif defined __cplusplus
+  template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
+# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2)
+#elif defined __hpux
+  /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
+     values.  */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#elif defined _AIX
+  /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
+     values.  */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#else
+# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+enum
+{
+/* The desired alignment of memory allocations is the maximum alignment
+   among all elementary types.  */
+  sa_alignment_long = sa_alignof (long),
+  sa_alignment_double = sa_alignof (double),
+#if HAVE_LONG_LONG_INT
+  sa_alignment_longlong = sa_alignof (long long),
+#endif
+  sa_alignment_longdouble = sa_alignof (long double),
+  sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
+#if HAVE_LONG_LONG_INT
+                      | (sa_alignment_longlong - 1)
+#endif
+                      | (sa_alignment_longdouble - 1)
+                     ) + 1,
+/* The increment that guarantees room for a magic word must be >= sizeof (int)
+   and a multiple of sa_alignment_max.  */
+  sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
+};
+
+#endif /* _MALLOCA_H */
diff --git a/gnulib/lib/malloca.valgrind b/gnulib/lib/malloca.valgrind
new file mode 100644 (file)
index 0000000..52f0a50
--- /dev/null
@@ -0,0 +1,7 @@
+# Suppress a valgrind message about use of uninitialized memory in freea().
+# This use is OK because it provides only a speedup.
+{
+    freea
+    Memcheck:Cond
+    fun:freea
+}
diff --git a/gnulib/lib/mbrtowc.c b/gnulib/lib/mbrtowc.c
new file mode 100644 (file)
index 0000000..b087cf3
--- /dev/null
@@ -0,0 +1,396 @@
+/* Convert multibyte character to wide character.
+   Copyright (C) 1999-2002, 2005-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#if GNULIB_defined_mbstate_t
+/* Implement mbrtowc() on top of mbtowc().  */
+
+# include <errno.h>
+# include <stdlib.h>
+
+# include "localcharset.h"
+# include "streq.h"
+# include "verify.h"
+
+
+verify (sizeof (mbstate_t) >= 4);
+
+static char internal_state[4];
+
+size_t
+mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+  char *pstate = (char *)ps;
+
+  if (s == NULL)
+    {
+      pwc = NULL;
+      s = "";
+      n = 1;
+    }
+
+  if (n == 0)
+    return (size_t)(-2);
+
+  /* Here n > 0.  */
+
+  if (pstate == NULL)
+    pstate = internal_state;
+
+  {
+    size_t nstate = pstate[0];
+    char buf[4];
+    const char *p;
+    size_t m;
+
+    switch (nstate)
+      {
+      case 0:
+        p = s;
+        m = n;
+        break;
+      case 3:
+        buf[2] = pstate[3];
+        /*FALLTHROUGH*/
+      case 2:
+        buf[1] = pstate[2];
+        /*FALLTHROUGH*/
+      case 1:
+        buf[0] = pstate[1];
+        p = buf;
+        m = nstate;
+        buf[m++] = s[0];
+        if (n >= 2 && m < 4)
+          {
+            buf[m++] = s[1];
+            if (n >= 3 && m < 4)
+              buf[m++] = s[2];
+          }
+        break;
+      default:
+        errno = EINVAL;
+        return (size_t)(-1);
+      }
+
+    /* Here m > 0.  */
+
+# if __GLIBC__ || defined __UCLIBC__
+    /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
+    mbtowc (NULL, NULL, 0);
+# endif
+    {
+      int res = mbtowc (pwc, p, m);
+
+      if (res >= 0)
+        {
+          if (pwc != NULL && ((*pwc == 0) != (res == 0)))
+            abort ();
+          if (nstate >= (res > 0 ? res : 1))
+            abort ();
+          res -= nstate;
+          pstate[0] = 0;
+          return res;
+        }
+
+      /* mbtowc does not distinguish between invalid and incomplete multibyte
+         sequences.  But mbrtowc needs to make this distinction.
+         There are two possible approaches:
+           - Use iconv() and its return value.
+           - Use built-in knowledge about the possible encodings.
+         Given the low quality of implementation of iconv() on the systems that
+         lack mbrtowc(), we use the second approach.
+         The possible encodings are:
+           - 8-bit encodings,
+           - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
+           - UTF-8.
+         Use specialized code for each.  */
+      if (m >= 4 || m >= MB_CUR_MAX)
+        goto invalid;
+      /* Here MB_CUR_MAX > 1 and 0 < m < 4.  */
+      {
+        const char *encoding = locale_charset ();
+
+        if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+          {
+            /* Cf. unistr/u8-mblen.c.  */
+            unsigned char c = (unsigned char) p[0];
+
+            if (c >= 0xc2)
+              {
+                if (c < 0xe0)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                  }
+                else if (c < 0xf0)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                    if (m == 2)
+                      {
+                        unsigned char c2 = (unsigned char) p[1];
+
+                        if ((c2 ^ 0x80) < 0x40
+                            && (c >= 0xe1 || c2 >= 0xa0)
+                            && (c != 0xed || c2 < 0xa0))
+                          goto incomplete;
+                      }
+                  }
+                else if (c <= 0xf4)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                    else /* m == 2 || m == 3 */
+                      {
+                        unsigned char c2 = (unsigned char) p[1];
+
+                        if ((c2 ^ 0x80) < 0x40
+                            && (c >= 0xf1 || c2 >= 0x90)
+                            && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
+                          {
+                            if (m == 2)
+                              goto incomplete;
+                            else /* m == 3 */
+                              {
+                                unsigned char c3 = (unsigned char) p[2];
+
+                                if ((c3 ^ 0x80) < 0x40)
+                                  goto incomplete;
+                              }
+                          }
+                      }
+                  }
+              }
+            goto invalid;
+          }
+
+        /* As a reference for this code, you can use the GNU libiconv
+           implementation.  Look for uses of the RET_TOOFEW macro.  */
+
+        if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
+                  goto incomplete;
+              }
+            if (m == 2)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c == 0x8f)
+                  {
+                    unsigned char c2 = (unsigned char) p[1];
+
+                    if (c2 >= 0xa1 && c2 < 0xff)
+                      goto incomplete;
+                  }
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+            || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+            || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c >= 0xa1 && c < 0xff)
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
+                  goto incomplete;
+              }
+            else /* m == 2 || m == 3 */
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c == 0x8e)
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
+                  goto incomplete;
+              }
+            else /* m == 2 || m == 3 */
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c >= 0x90 && c <= 0xe3)
+                  {
+                    unsigned char c2 = (unsigned char) p[1];
+
+                    if (c2 >= 0x30 && c2 <= 0x39)
+                      {
+                        if (m == 2)
+                          goto incomplete;
+                        else /* m == 3 */
+                          {
+                            unsigned char c3 = (unsigned char) p[2];
+
+                            if (c3 >= 0x81 && c3 <= 0xfe)
+                              goto incomplete;
+                          }
+                      }
+                  }
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
+                    || (c >= 0xf0 && c <= 0xf9))
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+
+        /* An unknown multibyte encoding.  */
+        goto incomplete;
+      }
+
+     incomplete:
+      {
+        size_t k = nstate;
+        /* Here 0 <= k < m < 4.  */
+        pstate[++k] = s[0];
+        if (k < m)
+          {
+            pstate[++k] = s[1];
+            if (k < m)
+              pstate[++k] = s[2];
+          }
+        if (k != m)
+          abort ();
+      }
+      pstate[0] = m;
+      return (size_t)(-2);
+
+     invalid:
+      errno = EILSEQ;
+      /* The conversion state is undefined, says POSIX.  */
+      return (size_t)(-1);
+    }
+  }
+}
+
+#else
+/* Override the system's mbrtowc() function.  */
+
+# undef mbrtowc
+
+size_t
+rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
+  if (s == NULL)
+    {
+      pwc = NULL;
+      s = "";
+      n = 1;
+    }
+# endif
+
+# if MBRTOWC_RETVAL_BUG
+  {
+    static mbstate_t internal_state;
+
+    /* Override mbrtowc's internal state.  We can not call mbsinit() on the
+       hidden internal state, but we can call it on our variable.  */
+    if (ps == NULL)
+      ps = &internal_state;
+
+    if (!mbsinit (ps))
+      {
+        /* Parse the rest of the multibyte character byte for byte.  */
+        size_t count = 0;
+        for (; n > 0; s++, n--)
+          {
+            wchar_t wc;
+            size_t ret = mbrtowc (&wc, s, 1, ps);
+
+            if (ret == (size_t)(-1))
+              return (size_t)(-1);
+            count++;
+            if (ret != (size_t)(-2))
+              {
+                /* The multibyte character has been completed.  */
+                if (pwc != NULL)
+                  *pwc = wc;
+                return (wc == 0 ? 0 : count);
+              }
+          }
+        return (size_t)(-2);
+      }
+  }
+# endif
+
+# if MBRTOWC_NUL_RETVAL_BUG
+  {
+    wchar_t wc;
+    size_t ret = mbrtowc (&wc, s, n, ps);
+
+    if (ret != (size_t)(-1) && ret != (size_t)(-2))
+      {
+        if (pwc != NULL)
+          *pwc = wc;
+        if (wc == 0)
+          ret = 0;
+      }
+    return ret;
+  }
+# else
+  {
+#   if MBRTOWC_NULL_ARG1_BUG
+    wchar_t dummy;
+
+    if (pwc == NULL)
+      pwc = &dummy;
+#   endif
+
+    return mbrtowc (pwc, s, n, ps);
+  }
+# endif
+}
+
+#endif
diff --git a/gnulib/lib/mbsinit.c b/gnulib/lib/mbsinit.c
new file mode 100644 (file)
index 0000000..f48af0e
--- /dev/null
@@ -0,0 +1,61 @@
+/* Test for initial conversion state.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#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
+     - sizeof (mbstate_t) >= 4,
+     - only stateless encodings are supported (such as UTF-8 and EUC-JP, but
+       not ISO-2022 variants),
+     - for each encoding, the number of bytes for a wide character is <= 4.
+       (This maximum is attained for UTF-8, GB18030, EUC-TW.)
+   We define the meaning of mbstate_t as follows:
+     - In mb -> wc direction, mbstate_t's first byte contains the number of
+       buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
+     - In wc -> mb direction, mbstate_t contains no information. In other
+       words, it is always in the initial state.  */
+
+verify (sizeof (mbstate_t) >= 4);
+
+int
+mbsinit (const mbstate_t *ps)
+{
+  const char *pstate = (const char *)ps;
+
+  return pstate == NULL || pstate[0] == 0;
+}
+
+#endif
diff --git a/gnulib/lib/mbsrtowcs-impl.h b/gnulib/lib/mbsrtowcs-impl.h
new file mode 100644 (file)
index 0000000..8c3224d
--- /dev/null
@@ -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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+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);
+  }
+}
diff --git a/gnulib/lib/mbsrtowcs-state.c b/gnulib/lib/mbsrtowcs-state.c
new file mode 100644 (file)
index 0000000..a75f31e
--- /dev/null
@@ -0,0 +1,37 @@
+/* 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+/* Internal state used by the functions mbsrtowcs() and mbsnrtowcs().  */
+mbstate_t _gl_mbsrtowcs_state
+/* The state must initially be in the "initial state"; so, zero-initialize it.
+   On most systems, putting it into BSS is sufficient.  Not so on MacOS X 10.3,
+   see <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>.
+   When it needs an initializer, use 0 or {0} as initializer? 0 only works
+   when mbstate_t is a scalar type (such as when gnulib defines it, or on
+   AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct
+   or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)).  */
+#if defined __ELF__
+  /* On ELF systems, variables in BSS behave well.  */
+#else
+  /* Use braces, to be on the safe side.  */
+  = { 0 }
+#endif
+  ;
diff --git a/gnulib/lib/mbsrtowcs.c b/gnulib/lib/mbsrtowcs.c
new file mode 100644 (file)
index 0000000..eeba1c2
--- /dev/null
@@ -0,0 +1,32 @@
+/* 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "strnlen1.h"
+
+
+extern mbstate_t _gl_mbsrtowcs_state;
+
+#include "mbsrtowcs-impl.h"
diff --git a/gnulib/lib/mbtowc-impl.h b/gnulib/lib/mbtowc-impl.h
new file mode 100644 (file)
index 0000000..d81db18
--- /dev/null
@@ -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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* 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);
+    }
+}
diff --git a/gnulib/lib/mbtowc.c b/gnulib/lib/mbtowc.c
new file mode 100644 (file)
index 0000000..ab6c3eb
--- /dev/null
@@ -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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <errno.h>
+#include <string.h>
+#include <wchar.h>
+
+#include "mbtowc-impl.h"
diff --git a/gnulib/lib/memchr.c b/gnulib/lib/memchr.c
new file mode 100644 (file)
index 0000000..05cf97f
--- /dev/null
@@ -0,0 +1,172 @@
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2011
+   Free Software Foundation, Inc.
+
+   Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
+   with help from Dan Sahlin (dan@sics.se) and
+   commentary by Jim Blandy (jimb@ai.mit.edu);
+   adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+   and implemented by Roland McGrath (roland@ai.mit.edu).
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 2.1 of the License, or any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#include <stddef.h>
+
+#if defined _LIBC
+# include <memcopy.h>
+#else
+# define reg_char char
+#endif
+
+#include <limits.h>
+
+#if HAVE_BP_SYM_H || defined _LIBC
+# include <bp-sym.h>
+#else
+# define BP_SYM(sym) sym
+#endif
+
+#undef __memchr
+#ifdef _LIBC
+# undef memchr
+#endif
+
+#ifndef weak_alias
+# define __memchr memchr
+#endif
+
+/* Search no more than N bytes of S for C.  */
+void *
+__memchr (void const *s, int c_in, size_t n)
+{
+  /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
+     long instead of a 64-bit uintmax_t tends to give better
+     performance.  On 64-bit hardware, unsigned long is generally 64
+     bits already.  Change this typedef to experiment with
+     performance.  */
+  typedef unsigned long int longword;
+
+  const unsigned char *char_ptr;
+  const longword *longword_ptr;
+  longword repeated_one;
+  longword repeated_c;
+  unsigned reg_char c;
+
+  c = (unsigned char) c_in;
+
+  /* Handle the first few bytes by reading one byte at a time.
+     Do this until CHAR_PTR is aligned on a longword boundary.  */
+  for (char_ptr = (const unsigned char *) s;
+       n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+       --n, ++char_ptr)
+    if (*char_ptr == c)
+      return (void *) char_ptr;
+
+  longword_ptr = (const longword *) char_ptr;
+
+  /* All these elucidatory comments refer to 4-byte longwords,
+     but the theory applies equally well to any size longwords.  */
+
+  /* Compute auxiliary longword values:
+     repeated_one is a value which has a 1 in every byte.
+     repeated_c has c in every byte.  */
+  repeated_one = 0x01010101;
+  repeated_c = c | (c << 8);
+  repeated_c |= repeated_c << 16;
+  if (0xffffffffU < (longword) -1)
+    {
+      repeated_one |= repeated_one << 31 << 1;
+      repeated_c |= repeated_c << 31 << 1;
+      if (8 < sizeof (longword))
+        {
+          size_t i;
+
+          for (i = 64; i < sizeof (longword) * 8; i *= 2)
+            {
+              repeated_one |= repeated_one << i;
+              repeated_c |= repeated_c << i;
+            }
+        }
+    }
+
+  /* Instead of the traditional loop which tests each byte, we will test a
+     longword at a time.  The tricky part is testing if *any of the four*
+     bytes in the longword in question are equal to c.  We first use an xor
+     with repeated_c.  This reduces the task to testing whether *any of the
+     four* bytes in longword1 is zero.
+
+     We compute tmp =
+       ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
+     That is, we perform the following operations:
+       1. Subtract repeated_one.
+       2. & ~longword1.
+       3. & a mask consisting of 0x80 in every byte.
+     Consider what happens in each byte:
+       - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
+         and step 3 transforms it into 0x80.  A carry can also be propagated
+         to more significant bytes.
+       - If a byte of longword1 is nonzero, let its lowest 1 bit be at
+         position k (0 <= k <= 7); so the lowest k bits are 0.  After step 1,
+         the byte ends in a single bit of value 0 and k bits of value 1.
+         After step 2, the result is just k bits of value 1: 2^k - 1.  After
+         step 3, the result is 0.  And no carry is produced.
+     So, if longword1 has only non-zero bytes, tmp is zero.
+     Whereas if longword1 has a zero byte, call j the position of the least
+     significant zero byte.  Then the result has a zero at positions 0, ...,
+     j-1 and a 0x80 at position j.  We cannot predict the result at the more
+     significant bytes (positions j+1..3), but it does not matter since we
+     already have a non-zero bit at position 8*j+7.
+
+     So, the test whether any byte in longword1 is zero is equivalent to
+     testing whether tmp is nonzero.  */
+
+  while (n >= sizeof (longword))
+    {
+      longword longword1 = *longword_ptr ^ repeated_c;
+
+      if ((((longword1 - repeated_one) & ~longword1)
+           & (repeated_one << 7)) != 0)
+        break;
+      longword_ptr++;
+      n -= sizeof (longword);
+    }
+
+  char_ptr = (const unsigned char *) longword_ptr;
+
+  /* At this point, we know that either n < sizeof (longword), or one of the
+     sizeof (longword) bytes starting at char_ptr is == c.  On little-endian
+     machines, we could determine the first such byte without any further
+     memory accesses, just by looking at the tmp result from the last loop
+     iteration.  But this does not work on big-endian machines.  Choose code
+     that works in both cases.  */
+
+  for (; n > 0; --n, ++char_ptr)
+    {
+      if (*char_ptr == c)
+        return (void *) char_ptr;
+    }
+
+  return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memchr, BP_SYM (memchr))
+#endif
diff --git a/gnulib/lib/memchr.valgrind b/gnulib/lib/memchr.valgrind
new file mode 100644 (file)
index 0000000..60f247e
--- /dev/null
@@ -0,0 +1,14 @@
+# Suppress a valgrind message about use of uninitialized memory in memchr().
+# POSIX states that when the character is found, memchr must not read extra
+# bytes in an overestimated length (for example, where memchr is used to
+# implement strnlen).  However, we use a safe word read to provide a speedup.
+{
+    memchr-value4
+    Memcheck:Value4
+    fun:rpl_memchr
+}
+{
+    memchr-value8
+    Memcheck:Value8
+    fun:rpl_memchr
+}
diff --git a/gnulib/lib/mempcpy.c b/gnulib/lib/mempcpy.c
new file mode 100644 (file)
index 0000000..d8e7ffb
--- /dev/null
@@ -0,0 +1,29 @@
+/* Copy memory area and return pointer after last written byte.
+   Copyright (C) 2003, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <string.h>
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+   last written byte.  */
+void *
+mempcpy (void *dest, const void *src, size_t n)
+{
+  return (char *) memcpy (dest, src, n) + n;
+}
diff --git a/gnulib/lib/nl_langinfo.c b/gnulib/lib/nl_langinfo.c
new file mode 100644 (file)
index 0000000..bb2cf90
--- /dev/null
@@ -0,0 +1,270 @@
+/* nl_langinfo() replacement: query locale dependent information.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <langinfo.h>
+
+#if REPLACE_NL_LANGINFO
+
+/* Override nl_langinfo with support for added nl_item values.  */
+
+# include <locale.h>
+# include <string.h>
+
+# undef nl_langinfo
+
+char *
+rpl_nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+# if GNULIB_defined_CODESET
+    case CODESET:
+      {
+        const char *locale;
+        static char buf[2 + 10 + 1];
+
+        locale = setlocale (LC_CTYPE, NULL);
+        if (locale != NULL && locale[0] != '\0')
+          {
+            /* If the locale name contains an encoding after the dot, return
+               it.  */
+            const char *dot = strchr (locale, '.');
+
+            if (dot != NULL)
+              {
+                const char *modifier;
+
+                dot++;
+                /* Look for the possible @... trailer and remove it, if any.  */
+                modifier = strchr (dot, '@');
+                if (modifier == NULL)
+                  return dot;
+                if (modifier - dot < sizeof (buf))
+                  {
+                    memcpy (buf, dot, modifier - dot);
+                    buf [modifier - dot] = '\0';
+                    return buf;
+                  }
+              }
+          }
+        return "";
+      }
+# endif
+# if GNULIB_defined_T_FMT_AMPM
+    case T_FMT_AMPM:
+      return "%I:%M:%S %p";
+# endif
+# if GNULIB_defined_ERA
+    case ERA:
+      /* The format is not standardized.  In glibc it is a sequence of strings
+         of the form "direction:offset:start_date:end_date:era_name:era_format"
+         with an empty string at the end.  */
+      return "";
+    case ERA_D_FMT:
+      /* The %Ex conversion in strftime behaves like %x if the locale does not
+         have an alternative time format.  */
+      item = D_FMT;
+      break;
+    case ERA_D_T_FMT:
+      /* The %Ec conversion in strftime behaves like %c if the locale does not
+         have an alternative time format.  */
+      item = D_T_FMT;
+      break;
+    case ERA_T_FMT:
+      /* The %EX conversion in strftime behaves like %X if the locale does not
+         have an alternative time format.  */
+      item = T_FMT;
+      break;
+    case ALT_DIGITS:
+      /* The format is not standardized.  In glibc it is a sequence of 10
+         strings, appended in memory.  */
+      return "\0\0\0\0\0\0\0\0\0\0";
+# endif
+# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
+    case YESEXPR:
+      return "^[yY]";
+    case NOEXPR:
+      return "^[nN]";
+# endif
+    default:
+      break;
+    }
+  return nl_langinfo (item);
+}
+
+#else
+
+/* Provide nl_langinfo from scratch.  */
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Native Windows platforms.  */
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+#  include <stdio.h>
+
+# else
+
+/* An old Unix platform without locales, such as Linux libc5 or BeOS.  */
+
+# endif
+
+# include <locale.h>
+
+char *
+nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+    /* nl_langinfo items of the LC_CTYPE category */
+    case CODESET:
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+      {
+        static char buf[2 + 10 + 1];
+
+        /* Woe32 has a function returning the locale's codepage as a number.  */
+        sprintf (buf, "CP%u", GetACP ());
+        return buf;
+      }
+# elif defined __BEOS__
+      return "UTF-8";
+# else
+      return "ISO-8859-1";
+# endif
+    /* nl_langinfo items of the LC_NUMERIC category */
+    case RADIXCHAR:
+      return localeconv () ->decimal_point;
+    case THOUSEP:
+      return localeconv () ->thousands_sep;
+    /* nl_langinfo items of the LC_TIME category.
+       TODO: Really use the locale.  */
+    case D_T_FMT:
+    case ERA_D_T_FMT:
+      return "%a %b %e %H:%M:%S %Y";
+    case D_FMT:
+    case ERA_D_FMT:
+      return "%m/%d/%y";
+    case T_FMT:
+    case ERA_T_FMT:
+      return "%H:%M:%S";
+    case T_FMT_AMPM:
+      return "%I:%M:%S %p";
+    case AM_STR:
+      return "AM";
+    case PM_STR:
+      return "PM";
+    case DAY_1:
+      return "Sunday";
+    case DAY_2:
+      return "Monday";
+    case DAY_3:
+      return "Tuesday";
+    case DAY_4:
+      return "Wednesday";
+    case DAY_5:
+      return "Thursday";
+    case DAY_6:
+      return "Friday";
+    case DAY_7:
+      return "Saturday";
+    case ABDAY_1:
+      return "Sun";
+    case ABDAY_2:
+      return "Mon";
+    case ABDAY_3:
+      return "Tue";
+    case ABDAY_4:
+      return "Wed";
+    case ABDAY_5:
+      return "Thu";
+    case ABDAY_6:
+      return "Fri";
+    case ABDAY_7:
+      return "Sat";
+    case MON_1:
+      return "January";
+    case MON_2:
+      return "February";
+    case MON_3:
+      return "March";
+    case MON_4:
+      return "April";
+    case MON_5:
+      return "May";
+    case MON_6:
+      return "June";
+    case MON_7:
+      return "July";
+    case MON_8:
+      return "August";
+    case MON_9:
+      return "September";
+    case MON_10:
+      return "October";
+    case MON_11:
+      return "November";
+    case MON_12:
+      return "December";
+    case ABMON_1:
+      return "Jan";
+    case ABMON_2:
+      return "Feb";
+    case ABMON_3:
+      return "Mar";
+    case ABMON_4:
+      return "Apr";
+    case ABMON_5:
+      return "May";
+    case ABMON_6:
+      return "Jun";
+    case ABMON_7:
+      return "Jul";
+    case ABMON_8:
+      return "Aug";
+    case ABMON_9:
+      return "Sep";
+    case ABMON_10:
+      return "Oct";
+    case ABMON_11:
+      return "Nov";
+    case ABMON_12:
+      return "Dec";
+    case ERA:
+      return "";
+    case ALT_DIGITS:
+      return "\0\0\0\0\0\0\0\0\0\0";
+    /* nl_langinfo items of the LC_MONETARY category
+       TODO: Really use the locale. */
+    case CRNCYSTR:
+      return "-";
+    /* nl_langinfo items of the LC_MESSAGES category
+       TODO: Really use the locale. */
+    case YESEXPR:
+      return "^[yY]";
+    case NOEXPR:
+      return "^[nN]";
+    default:
+      return "";
+    }
+}
+
+#endif
diff --git a/gnulib/lib/pathmax.h b/gnulib/lib/pathmax.h
new file mode 100644 (file)
index 0000000..4d8fc3b
--- /dev/null
@@ -0,0 +1,48 @@
+/* Define PATH_MAX somehow.  Requires sys/types.h.
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _PATHMAX_H
+# define _PATHMAX_H
+
+# include <unistd.h>
+
+# include <limits.h>
+
+# ifndef _POSIX_PATH_MAX
+#  define _POSIX_PATH_MAX 256
+# endif
+
+# if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF
+#  define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
+                    : pathconf ("/", _PC_PATH_MAX))
+# endif
+
+/* Don't include sys/param.h if it already has been.  */
+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
+#  include <sys/param.h>
+# endif
+
+# if !defined PATH_MAX && defined MAXPATHLEN
+#  define PATH_MAX MAXPATHLEN
+# endif
+
+# ifndef PATH_MAX
+#  define PATH_MAX _POSIX_PATH_MAX
+# endif
+
+#endif /* _PATHMAX_H */
diff --git a/gnulib/lib/printf-args.c b/gnulib/lib/printf-args.c
new file mode 100644 (file)
index 0000000..f913a96
--- /dev/null
@@ -0,0 +1,188 @@
+/* Decomposed printf argument list.
+   Copyright (C) 1999, 2002-2003, 2005-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This file can be parametrized with the following macros:
+     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
+     PRINTF_FETCHARGS   Name of the function to be defined.
+     STATIC             Set to 'static' to declare the function static.  */
+
+#ifndef PRINTF_FETCHARGS
+# include <config.h>
+#endif
+
+/* Specification.  */
+#ifndef PRINTF_FETCHARGS
+# include "printf-args.h"
+#endif
+
+#ifdef STATIC
+STATIC
+#endif
+int
+PRINTF_FETCHARGS (va_list args, arguments *a)
+{
+  size_t i;
+  argument *ap;
+
+  for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
+    switch (ap->type)
+      {
+      case TYPE_SCHAR:
+        ap->a.a_schar = va_arg (args, /*signed char*/ int);
+        break;
+      case TYPE_UCHAR:
+        ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
+        break;
+      case TYPE_SHORT:
+        ap->a.a_short = va_arg (args, /*short*/ int);
+        break;
+      case TYPE_USHORT:
+        ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
+        break;
+      case TYPE_INT:
+        ap->a.a_int = va_arg (args, int);
+        break;
+      case TYPE_UINT:
+        ap->a.a_uint = va_arg (args, unsigned int);
+        break;
+      case TYPE_LONGINT:
+        ap->a.a_longint = va_arg (args, long int);
+        break;
+      case TYPE_ULONGINT:
+        ap->a.a_ulongint = va_arg (args, unsigned long int);
+        break;
+#if HAVE_LONG_LONG_INT
+      case TYPE_LONGLONGINT:
+        ap->a.a_longlongint = va_arg (args, long long int);
+        break;
+      case TYPE_ULONGLONGINT:
+        ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
+        break;
+#endif
+      case TYPE_DOUBLE:
+        ap->a.a_double = va_arg (args, double);
+        break;
+      case TYPE_LONGDOUBLE:
+        ap->a.a_longdouble = va_arg (args, long double);
+        break;
+      case TYPE_CHAR:
+        ap->a.a_char = va_arg (args, int);
+        break;
+#if HAVE_WINT_T
+      case TYPE_WIDE_CHAR:
+        /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
+           default argument promotions", this is not the case in mingw32,
+           where wint_t is 'unsigned short'.  */
+        ap->a.a_wide_char =
+          (sizeof (wint_t) < sizeof (int)
+           ? (wint_t) va_arg (args, int)
+           : va_arg (args, wint_t));
+        break;
+#endif
+      case TYPE_STRING:
+        ap->a.a_string = va_arg (args, const char *);
+        /* A null pointer is an invalid argument for "%s", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_string == NULL)
+          ap->a.a_string = "(NULL)";
+        break;
+#if HAVE_WCHAR_T
+      case TYPE_WIDE_STRING:
+        ap->a.a_wide_string = va_arg (args, const wchar_t *);
+        /* A null pointer is an invalid argument for "%ls", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_wide_string == NULL)
+          {
+            static const wchar_t wide_null_string[] =
+              {
+                (wchar_t)'(',
+                (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+                (wchar_t)')',
+                (wchar_t)0
+              };
+            ap->a.a_wide_string = wide_null_string;
+          }
+        break;
+#endif
+      case TYPE_POINTER:
+        ap->a.a_pointer = va_arg (args, void *);
+        break;
+      case TYPE_COUNT_SCHAR_POINTER:
+        ap->a.a_count_schar_pointer = va_arg (args, signed char *);
+        break;
+      case TYPE_COUNT_SHORT_POINTER:
+        ap->a.a_count_short_pointer = va_arg (args, short *);
+        break;
+      case TYPE_COUNT_INT_POINTER:
+        ap->a.a_count_int_pointer = va_arg (args, int *);
+        break;
+      case TYPE_COUNT_LONGINT_POINTER:
+        ap->a.a_count_longint_pointer = va_arg (args, long int *);
+        break;
+#if HAVE_LONG_LONG_INT
+      case TYPE_COUNT_LONGLONGINT_POINTER:
+        ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
+        break;
+#endif
+#if ENABLE_UNISTDIO
+      /* The unistdio extensions.  */
+      case TYPE_U8_STRING:
+        ap->a.a_u8_string = va_arg (args, const uint8_t *);
+        /* A null pointer is an invalid argument for "%U", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u8_string == NULL)
+          {
+            static const uint8_t u8_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u8_string = u8_null_string;
+          }
+        break;
+      case TYPE_U16_STRING:
+        ap->a.a_u16_string = va_arg (args, const uint16_t *);
+        /* A null pointer is an invalid argument for "%lU", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u16_string == NULL)
+          {
+            static const uint16_t u16_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u16_string = u16_null_string;
+          }
+        break;
+      case TYPE_U32_STRING:
+        ap->a.a_u32_string = va_arg (args, const uint32_t *);
+        /* A null pointer is an invalid argument for "%llU", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u32_string == NULL)
+          {
+            static const uint32_t u32_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u32_string = u32_null_string;
+          }
+        break;
+#endif
+      default:
+        /* Unknown type.  */
+        return -1;
+      }
+  return 0;
+}
diff --git a/gnulib/lib/printf-args.h b/gnulib/lib/printf-args.h
new file mode 100644 (file)
index 0000000..3b8d9af
--- /dev/null
@@ -0,0 +1,159 @@
+/* Decomposed printf argument list.
+   Copyright (C) 1999, 2002-2003, 2006-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _PRINTF_ARGS_H
+#define _PRINTF_ARGS_H
+
+/* This file can be parametrized with the following macros:
+     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
+     PRINTF_FETCHARGS   Name of the function to be declared.
+     STATIC             Set to 'static' to declare the function static.  */
+
+/* Default parameters.  */
+#ifndef PRINTF_FETCHARGS
+# define PRINTF_FETCHARGS printf_fetchargs
+#endif
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* Get wchar_t.  */
+#if HAVE_WCHAR_T
+# include <stddef.h>
+#endif
+
+/* Get wint_t.  */
+#if HAVE_WINT_T
+# include <wchar.h>
+#endif
+
+/* Get va_list.  */
+#include <stdarg.h>
+
+
+/* Argument types */
+typedef enum
+{
+  TYPE_NONE,
+  TYPE_SCHAR,
+  TYPE_UCHAR,
+  TYPE_SHORT,
+  TYPE_USHORT,
+  TYPE_INT,
+  TYPE_UINT,
+  TYPE_LONGINT,
+  TYPE_ULONGINT,
+#if HAVE_LONG_LONG_INT
+  TYPE_LONGLONGINT,
+  TYPE_ULONGLONGINT,
+#endif
+  TYPE_DOUBLE,
+  TYPE_LONGDOUBLE,
+  TYPE_CHAR,
+#if HAVE_WINT_T
+  TYPE_WIDE_CHAR,
+#endif
+  TYPE_STRING,
+#if HAVE_WCHAR_T
+  TYPE_WIDE_STRING,
+#endif
+  TYPE_POINTER,
+  TYPE_COUNT_SCHAR_POINTER,
+  TYPE_COUNT_SHORT_POINTER,
+  TYPE_COUNT_INT_POINTER,
+  TYPE_COUNT_LONGINT_POINTER
+#if HAVE_LONG_LONG_INT
+, TYPE_COUNT_LONGLONGINT_POINTER
+#endif
+#if ENABLE_UNISTDIO
+  /* The unistdio extensions.  */
+, TYPE_U8_STRING
+, TYPE_U16_STRING
+, TYPE_U32_STRING
+#endif
+} arg_type;
+
+/* Polymorphic argument */
+typedef struct
+{
+  arg_type type;
+  union
+  {
+    signed char                 a_schar;
+    unsigned char               a_uchar;
+    short                       a_short;
+    unsigned short              a_ushort;
+    int                         a_int;
+    unsigned int                a_uint;
+    long int                    a_longint;
+    unsigned long int           a_ulongint;
+#if HAVE_LONG_LONG_INT
+    long long int               a_longlongint;
+    unsigned long long int      a_ulonglongint;
+#endif
+    float                       a_float;
+    double                      a_double;
+    long double                 a_longdouble;
+    int                         a_char;
+#if HAVE_WINT_T
+    wint_t                      a_wide_char;
+#endif
+    const char*                 a_string;
+#if HAVE_WCHAR_T
+    const wchar_t*              a_wide_string;
+#endif
+    void*                       a_pointer;
+    signed char *               a_count_schar_pointer;
+    short *                     a_count_short_pointer;
+    int *                       a_count_int_pointer;
+    long int *                  a_count_longint_pointer;
+#if HAVE_LONG_LONG_INT
+    long long int *             a_count_longlongint_pointer;
+#endif
+#if ENABLE_UNISTDIO
+    /* The unistdio extensions.  */
+    const uint8_t *             a_u8_string;
+    const uint16_t *            a_u16_string;
+    const uint32_t *            a_u32_string;
+#endif
+  }
+  a;
+}
+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;
+
+
+/* Fetch the arguments, putting them into a. */
+#ifdef STATIC
+STATIC
+#else
+extern
+#endif
+int PRINTF_FETCHARGS (va_list args, arguments *a);
+
+#endif /* _PRINTF_ARGS_H */
diff --git a/gnulib/lib/printf-parse.c b/gnulib/lib/printf-parse.c
new file mode 100644 (file)
index 0000000..a147412
--- /dev/null
@@ -0,0 +1,639 @@
+/* Formatted output to strings.
+   Copyright (C) 1999-2000, 2002-2003, 2006-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This file can be parametrized with the following macros:
+     CHAR_T             The element type of the format string.
+     CHAR_T_ONLY_ASCII  Set to 1 to enable verification that all characters
+                        in the format string are ASCII.
+     DIRECTIVE          Structure denoting a format directive.
+                        Depends on CHAR_T.
+     DIRECTIVES         Structure denoting the set of format directives of a
+                        format string.  Depends on CHAR_T.
+     PRINTF_PARSE       Function that parses a format string.
+                        Depends on CHAR_T.
+     STATIC             Set to 'static' to declare the function static.
+     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.  */
+
+#ifndef PRINTF_PARSE
+# include <config.h>
+#endif
+
+/* Specification.  */
+#ifndef PRINTF_PARSE
+# include "printf-parse.h"
+#endif
+
+/* Default parameters.  */
+#ifndef PRINTF_PARSE
+# define PRINTF_PARSE printf_parse
+# define CHAR_T char
+# define DIRECTIVE char_directive
+# define DIRECTIVES char_directives
+#endif
+
+/* Get size_t, NULL.  */
+#include <stddef.h>
+
+/* Get intmax_t.  */
+#if defined IN_LIBINTL || defined IN_LIBASPRINTF
+# if HAVE_STDINT_H_WITH_UINTMAX
+#  include <stdint.h>
+# endif
+# if HAVE_INTTYPES_H_WITH_UINTMAX
+#  include <inttypes.h>
+# endif
+#else
+# include <stdint.h>
+#endif
+
+/* malloc(), realloc(), free().  */
+#include <stdlib.h>
+
+/* memcpy().  */
+#include <string.h>
+
+/* errno.  */
+#include <errno.h>
+
+/* Checked size_t computations.  */
+#include "xsize.h"
+
+#if CHAR_T_ONLY_ASCII
+/* c_isascii().  */
+# include "c-ctype.h"
+#endif
+
+#ifdef STATIC
+STATIC
+#endif
+int
+PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
+{
+  const CHAR_T *cp = format;    /* pointer into format */
+  size_t arg_posn = 0;          /* number of regular arguments consumed */
+  size_t d_allocated;           /* allocated elements of d->dir */
+  size_t a_allocated;           /* allocated elements of a->arg */
+  size_t max_width_length = 0;
+  size_t max_precision_length = 0;
+
+  d->count = 0;
+  d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
+  d->dir = d->direct_alloc_dir;
+
+  a->count = 0;
+  a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
+  a->arg = a->direct_alloc_arg;
+
+#define REGISTER_ARG(_index_,_type_) \
+  {                                                                     \
+    size_t n = (_index_);                                               \
+    if (n >= a_allocated)                                               \
+      {                                                                 \
+        size_t memory_size;                                             \
+        argument *memory;                                               \
+                                                                        \
+        a_allocated = xtimes (a_allocated, 2);                          \
+        if (a_allocated <= n)                                           \
+          a_allocated = xsum (n, 1);                                    \
+        memory_size = xtimes (a_allocated, sizeof (argument));          \
+        if (size_overflow_p (memory_size))                              \
+          /* Overflow, would lead to out of memory.  */                 \
+          goto out_of_memory;                                           \
+        memory = (argument *) (a->arg != 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)                                               \
+      a->arg[a->count++].type = TYPE_NONE;                              \
+    if (a->arg[n].type == TYPE_NONE)                                    \
+      a->arg[n].type = (_type_);                                        \
+    else if (a->arg[n].type != (_type_))                                \
+      /* Ambiguous type for positional argument.  */                    \
+      goto error;                                                       \
+  }
+
+  while (*cp != '\0')
+    {
+      CHAR_T c = *cp++;
+      if (c == '%')
+        {
+          size_t arg_index = ARG_NONE;
+          DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
+
+          /* Initialize the next directive.  */
+          dp->dir_start = cp - 1;
+          dp->flags = 0;
+          dp->width_start = NULL;
+          dp->width_end = NULL;
+          dp->width_arg_index = ARG_NONE;
+          dp->precision_start = NULL;
+          dp->precision_end = NULL;
+          dp->precision_arg_index = ARG_NONE;
+          dp->arg_index = ARG_NONE;
+
+          /* Test for positional argument.  */
+          if (*cp >= '0' && *cp <= '9')
+            {
+              const CHAR_T *np;
+
+              for (np = cp; *np >= '0' && *np <= '9'; np++)
+                ;
+              if (*np == '$')
+                {
+                  size_t n = 0;
+
+                  for (np = cp; *np >= '0' && *np <= '9'; np++)
+                    n = xsum (xtimes (n, 10), *np - '0');
+                  if (n == 0)
+                    /* Positional argument 0.  */
+                    goto error;
+                  if (size_overflow_p (n))
+                    /* n too large, would lead to out of memory later.  */
+                    goto error;
+                  arg_index = n - 1;
+                  cp = np + 1;
+                }
+            }
+
+          /* Read the flags.  */
+          for (;;)
+            {
+              if (*cp == '\'')
+                {
+                  dp->flags |= FLAG_GROUP;
+                  cp++;
+                }
+              else if (*cp == '-')
+                {
+                  dp->flags |= FLAG_LEFT;
+                  cp++;
+                }
+              else if (*cp == '+')
+                {
+                  dp->flags |= FLAG_SHOWSIGN;
+                  cp++;
+                }
+              else if (*cp == ' ')
+                {
+                  dp->flags |= FLAG_SPACE;
+                  cp++;
+                }
+              else if (*cp == '#')
+                {
+                  dp->flags |= FLAG_ALT;
+                  cp++;
+                }
+              else if (*cp == '0')
+                {
+                  dp->flags |= FLAG_ZERO;
+                  cp++;
+                }
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+              else if (*cp == 'I')
+                {
+                  dp->flags |= FLAG_LOCALIZED;
+                  cp++;
+                }
+#endif
+              else
+                break;
+            }
+
+          /* Parse the field width.  */
+          if (*cp == '*')
+            {
+              dp->width_start = cp;
+              cp++;
+              dp->width_end = cp;
+              if (max_width_length < 1)
+                max_width_length = 1;
+
+              /* Test for positional argument.  */
+              if (*cp >= '0' && *cp <= '9')
+                {
+                  const CHAR_T *np;
+
+                  for (np = cp; *np >= '0' && *np <= '9'; np++)
+                    ;
+                  if (*np == '$')
+                    {
+                      size_t n = 0;
+
+                      for (np = cp; *np >= '0' && *np <= '9'; np++)
+                        n = xsum (xtimes (n, 10), *np - '0');
+                      if (n == 0)
+                        /* Positional argument 0.  */
+                        goto error;
+                      if (size_overflow_p (n))
+                        /* n too large, would lead to out of memory later.  */
+                        goto error;
+                      dp->width_arg_index = n - 1;
+                      cp = np + 1;
+                    }
+                }
+              if (dp->width_arg_index == ARG_NONE)
+                {
+                  dp->width_arg_index = arg_posn++;
+                  if (dp->width_arg_index == ARG_NONE)
+                    /* arg_posn wrapped around.  */
+                    goto error;
+                }
+              REGISTER_ARG (dp->width_arg_index, TYPE_INT);
+            }
+          else if (*cp >= '0' && *cp <= '9')
+            {
+              size_t width_length;
+
+              dp->width_start = cp;
+              for (; *cp >= '0' && *cp <= '9'; cp++)
+                ;
+              dp->width_end = cp;
+              width_length = dp->width_end - dp->width_start;
+              if (max_width_length < width_length)
+                max_width_length = width_length;
+            }
+
+          /* Parse the precision.  */
+          if (*cp == '.')
+            {
+              cp++;
+              if (*cp == '*')
+                {
+                  dp->precision_start = cp - 1;
+                  cp++;
+                  dp->precision_end = cp;
+                  if (max_precision_length < 2)
+                    max_precision_length = 2;
+
+                  /* Test for positional argument.  */
+                  if (*cp >= '0' && *cp <= '9')
+                    {
+                      const CHAR_T *np;
+
+                      for (np = cp; *np >= '0' && *np <= '9'; np++)
+                        ;
+                      if (*np == '$')
+                        {
+                          size_t n = 0;
+
+                          for (np = cp; *np >= '0' && *np <= '9'; np++)
+                            n = xsum (xtimes (n, 10), *np - '0');
+                          if (n == 0)
+                            /* Positional argument 0.  */
+                            goto error;
+                          if (size_overflow_p (n))
+                            /* n too large, would lead to out of memory
+                               later.  */
+                            goto error;
+                          dp->precision_arg_index = n - 1;
+                          cp = np + 1;
+                        }
+                    }
+                  if (dp->precision_arg_index == ARG_NONE)
+                    {
+                      dp->precision_arg_index = arg_posn++;
+                      if (dp->precision_arg_index == ARG_NONE)
+                        /* arg_posn wrapped around.  */
+                        goto error;
+                    }
+                  REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
+                }
+              else
+                {
+                  size_t precision_length;
+
+                  dp->precision_start = cp - 1;
+                  for (; *cp >= '0' && *cp <= '9'; cp++)
+                    ;
+                  dp->precision_end = cp;
+                  precision_length = dp->precision_end - dp->precision_start;
+                  if (max_precision_length < precision_length)
+                    max_precision_length = precision_length;
+                }
+            }
+
+          {
+            arg_type type;
+
+            /* Parse argument type/size specifiers.  */
+            {
+              int flags = 0;
+
+              for (;;)
+                {
+                  if (*cp == 'h')
+                    {
+                      flags |= (1 << (flags & 1));
+                      cp++;
+                    }
+                  else if (*cp == 'L')
+                    {
+                      flags |= 4;
+                      cp++;
+                    }
+                  else if (*cp == 'l')
+                    {
+                      flags += 8;
+                      cp++;
+                    }
+                  else if (*cp == 'j')
+                    {
+                      if (sizeof (intmax_t) > sizeof (long))
+                        {
+                          /* intmax_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (intmax_t) > sizeof (int))
+                        {
+                          /* intmax_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+                  else if (*cp == 'z' || *cp == 'Z')
+                    {
+                      /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
+                         because the warning facility in gcc-2.95.2 understands
+                         only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784).  */
+                      if (sizeof (size_t) > sizeof (long))
+                        {
+                          /* size_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (size_t) > sizeof (int))
+                        {
+                          /* size_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+                  else if (*cp == 't')
+                    {
+                      if (sizeof (ptrdiff_t) > sizeof (long))
+                        {
+                          /* ptrdiff_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (ptrdiff_t) > sizeof (int))
+                        {
+                          /* ptrdiff_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+#if defined __APPLE__ && defined __MACH__
+                  /* On MacOS X 10.3, PRIdMAX is defined as "qd".
+                     We cannot change it to "lld" because PRIdMAX must also
+                     be understood by the system's printf routines.  */
+                  else if (*cp == 'q')
+                    {
+                      if (64 / 8 > sizeof (long))
+                        {
+                          /* int64_t = long long */
+                          flags += 16;
+                        }
+                      else
+                        {
+                          /* int64_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                  /* On native Win32, PRIdMAX is defined as "I64d".
+                     We cannot change it to "lld" because PRIdMAX must also
+                     be understood by the system's printf routines.  */
+                  else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
+                    {
+                      if (64 / 8 > sizeof (long))
+                        {
+                          /* __int64 = long long */
+                          flags += 16;
+                        }
+                      else
+                        {
+                          /* __int64 = long */
+                          flags += 8;
+                        }
+                      cp += 3;
+                    }
+#endif
+                  else
+                    break;
+                }
+
+              /* Read the conversion character.  */
+              c = *cp++;
+              switch (c)
+                {
+                case 'd': case 'i':
+#if HAVE_LONG_LONG_INT
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_LONGLONGINT;
+                  else
+#endif
+                  /* If 'long long' exists and is the same as 'long', we parse
+                     "lld" into TYPE_LONGINT.  */
+                  if (flags >= 8)
+                    type = TYPE_LONGINT;
+                  else if (flags & 2)
+                    type = TYPE_SCHAR;
+                  else if (flags & 1)
+                    type = TYPE_SHORT;
+                  else
+                    type = TYPE_INT;
+                  break;
+                case 'o': case 'u': case 'x': case 'X':
+#if HAVE_LONG_LONG_INT
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_ULONGLONGINT;
+                  else
+#endif
+                  /* If 'unsigned long long' exists and is the same as
+                     'unsigned long', we parse "llu" into TYPE_ULONGINT.  */
+                  if (flags >= 8)
+                    type = TYPE_ULONGINT;
+                  else if (flags & 2)
+                    type = TYPE_UCHAR;
+                  else if (flags & 1)
+                    type = TYPE_USHORT;
+                  else
+                    type = TYPE_UINT;
+                  break;
+                case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+                case 'a': case 'A':
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_LONGDOUBLE;
+                  else
+                    type = TYPE_DOUBLE;
+                  break;
+                case 'c':
+                  if (flags >= 8)
+#if HAVE_WINT_T
+                    type = TYPE_WIDE_CHAR;
+#else
+                    goto error;
+#endif
+                  else
+                    type = TYPE_CHAR;
+                  break;
+#if HAVE_WINT_T
+                case 'C':
+                  type = TYPE_WIDE_CHAR;
+                  c = 'c';
+                  break;
+#endif
+                case 's':
+                  if (flags >= 8)
+#if HAVE_WCHAR_T
+                    type = TYPE_WIDE_STRING;
+#else
+                    goto error;
+#endif
+                  else
+                    type = TYPE_STRING;
+                  break;
+#if HAVE_WCHAR_T
+                case 'S':
+                  type = TYPE_WIDE_STRING;
+                  c = 's';
+                  break;
+#endif
+                case 'p':
+                  type = TYPE_POINTER;
+                  break;
+                case 'n':
+#if HAVE_LONG_LONG_INT
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_COUNT_LONGLONGINT_POINTER;
+                  else
+#endif
+                  /* If 'long long' exists and is the same as 'long', we parse
+                     "lln" into TYPE_COUNT_LONGINT_POINTER.  */
+                  if (flags >= 8)
+                    type = TYPE_COUNT_LONGINT_POINTER;
+                  else if (flags & 2)
+                    type = TYPE_COUNT_SCHAR_POINTER;
+                  else if (flags & 1)
+                    type = TYPE_COUNT_SHORT_POINTER;
+                  else
+                    type = TYPE_COUNT_INT_POINTER;
+                  break;
+#if ENABLE_UNISTDIO
+                /* The unistdio extensions.  */
+                case 'U':
+                  if (flags >= 16)
+                    type = TYPE_U32_STRING;
+                  else if (flags >= 8)
+                    type = TYPE_U16_STRING;
+                  else
+                    type = TYPE_U8_STRING;
+                  break;
+#endif
+                case '%':
+                  type = TYPE_NONE;
+                  break;
+                default:
+                  /* Unknown conversion character.  */
+                  goto error;
+                }
+            }
+
+            if (type != TYPE_NONE)
+              {
+                dp->arg_index = arg_index;
+                if (dp->arg_index == ARG_NONE)
+                  {
+                    dp->arg_index = arg_posn++;
+                    if (dp->arg_index == ARG_NONE)
+                      /* arg_posn wrapped around.  */
+                      goto error;
+                  }
+                REGISTER_ARG (dp->arg_index, type);
+              }
+            dp->conversion = c;
+            dp->dir_end = cp;
+          }
+
+          d->count++;
+          if (d->count >= d_allocated)
+            {
+              size_t memory_size;
+              DIRECTIVE *memory;
+
+              d_allocated = xtimes (d_allocated, 2);
+              memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
+              if (size_overflow_p (memory_size))
+                /* Overflow, would lead to out of memory.  */
+                goto out_of_memory;
+              memory = (DIRECTIVE *) (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;
+            }
+        }
+#if CHAR_T_ONLY_ASCII
+      else if (!c_isascii (c))
+        {
+          /* Non-ASCII character.  Not supported.  */
+          goto error;
+        }
+#endif
+    }
+  d->dir[d->count].dir_start = cp;
+
+  d->max_width_length = max_width_length;
+  d->max_precision_length = max_precision_length;
+  return 0;
+
+error:
+  if (a->arg != a->direct_alloc_arg)
+    free (a->arg);
+  if (d->dir != d->direct_alloc_dir)
+    free (d->dir);
+  errno = EINVAL;
+  return -1;
+
+out_of_memory:
+  if (a->arg != a->direct_alloc_arg)
+    free (a->arg);
+  if (d->dir != d->direct_alloc_dir)
+    free (d->dir);
+  errno = ENOMEM;
+  return -1;
+}
+
+#undef PRINTF_PARSE
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef CHAR_T_ONLY_ASCII
+#undef CHAR_T
diff --git a/gnulib/lib/printf-parse.h b/gnulib/lib/printf-parse.h
new file mode 100644 (file)
index 0000000..b8583e3
--- /dev/null
@@ -0,0 +1,194 @@
+/* Parse printf format string.
+   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
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _PRINTF_PARSE_H
+#define _PRINTF_PARSE_H
+
+/* This file can be parametrized with the following macros:
+     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
+     STATIC             Set to 'static' to declare the function static.  */
+
+#if HAVE_FEATURES_H
+# include <features.h> /* for __GLIBC__, __UCLIBC__ */
+#endif
+
+#include "printf-args.h"
+
+
+/* Flags */
+#define FLAG_GROUP       1      /* ' flag */
+#define FLAG_LEFT        2      /* - flag */
+#define FLAG_SHOWSIGN    4      /* + flag */
+#define FLAG_SPACE       8      /* space flag */
+#define FLAG_ALT        16      /* # flag */
+#define FLAG_ZERO       32
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+# define FLAG_LOCALIZED 64      /* I flag, uses localized digits */
+#endif
+
+/* arg_index value indicating that no argument is consumed.  */
+#define ARG_NONE        (~(size_t)0)
+
+/* 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
+{
+  const char* dir_start;
+  const char* dir_end;
+  int flags;
+  const char* width_start;
+  const char* width_end;
+  size_t width_arg_index;
+  const char* precision_start;
+  const char* precision_end;
+  size_t precision_arg_index;
+  char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  size_t arg_index;
+}
+char_directive;
+
+/* A parsed format string.  */
+typedef struct
+{
+  size_t count;
+  char_directive *dir;
+  size_t max_width_length;
+  size_t max_precision_length;
+  char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+char_directives;
+
+#if ENABLE_UNISTDIO
+
+/* A parsed directive.  */
+typedef struct
+{
+  const uint8_t* dir_start;
+  const uint8_t* dir_end;
+  int flags;
+  const uint8_t* width_start;
+  const uint8_t* width_end;
+  size_t width_arg_index;
+  const uint8_t* precision_start;
+  const uint8_t* precision_end;
+  size_t precision_arg_index;
+  uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  size_t arg_index;
+}
+u8_directive;
+
+/* A parsed format string.  */
+typedef struct
+{
+  size_t count;
+  u8_directive *dir;
+  size_t max_width_length;
+  size_t max_precision_length;
+  u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u8_directives;
+
+/* A parsed directive.  */
+typedef struct
+{
+  const uint16_t* dir_start;
+  const uint16_t* dir_end;
+  int flags;
+  const uint16_t* width_start;
+  const uint16_t* width_end;
+  size_t width_arg_index;
+  const uint16_t* precision_start;
+  const uint16_t* precision_end;
+  size_t precision_arg_index;
+  uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  size_t arg_index;
+}
+u16_directive;
+
+/* A parsed format string.  */
+typedef struct
+{
+  size_t count;
+  u16_directive *dir;
+  size_t max_width_length;
+  size_t max_precision_length;
+  u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u16_directives;
+
+/* A parsed directive.  */
+typedef struct
+{
+  const uint32_t* dir_start;
+  const uint32_t* dir_end;
+  int flags;
+  const uint32_t* width_start;
+  const uint32_t* width_end;
+  size_t width_arg_index;
+  const uint32_t* precision_start;
+  const uint32_t* precision_end;
+  size_t precision_arg_index;
+  uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
+  size_t arg_index;
+}
+u32_directive;
+
+/* A parsed format string.  */
+typedef struct
+{
+  size_t count;
+  u32_directive *dir;
+  size_t max_width_length;
+  size_t max_precision_length;
+  u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
+}
+u32_directives;
+
+#endif
+
+
+/* Parses the format string.  Fills in the number N of directives, and fills
+   in directives[0], ..., directives[N-1], and sets directives[N].dir_start
+   to the end of the format string.  Also fills in the arg_type fields of the
+   arguments and the needed count of arguments.  */
+#if ENABLE_UNISTDIO
+extern int
+       ulc_printf_parse (const char *format, char_directives *d, arguments *a);
+extern int
+       u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
+extern int
+       u16_printf_parse (const uint16_t *format, u16_directives *d,
+                         arguments *a);
+extern int
+       u32_printf_parse (const uint32_t *format, u32_directives *d,
+                         arguments *a);
+#else
+# ifdef STATIC
+STATIC
+# else
+extern
+# endif
+int printf_parse (const char *format, char_directives *d, arguments *a);
+#endif
+
+#endif /* _PRINTF_PARSE_H */
diff --git a/gnulib/lib/readlink.c b/gnulib/lib/readlink.c
new file mode 100644 (file)
index 0000000..8470f06
--- /dev/null
@@ -0,0 +1,74 @@
+/* Stub for readlink().
+   Copyright (C) 2003-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#if !HAVE_READLINK
+
+/* readlink() substitute for systems that don't have a readlink() function,
+   such as DJGPP 2.03 and mingw32.  */
+
+ssize_t
+readlink (const char *name, char *buf _GL_UNUSED,
+          size_t bufsize _GL_UNUSED)
+{
+  struct stat statbuf;
+
+  /* In general we should use lstat() here, not stat().  But on platforms
+     without symbolic links, lstat() - if it exists - would be equivalent to
+     stat(), therefore we can use stat().  This saves us a configure check.  */
+  if (stat (name, &statbuf) >= 0)
+    errno = EINVAL;
+  return -1;
+}
+
+#else /* HAVE_READLINK */
+
+# undef readlink
+
+/* readlink() wrapper that uses correct types, for systems like cygwin
+   1.5.x where readlink returns int, and which rejects trailing slash,
+   for Solaris 9.  */
+
+ssize_t
+rpl_readlink (const char *name, char *buf, size_t bufsize)
+{
+# if READLINK_TRAILING_SLASH_BUG
+  size_t len = strlen (name);
+  if (len && name[len - 1] == '/')
+    {
+      /* Even if name without the slash is a symlink to a directory,
+         both lstat() and stat() must resolve the trailing slash to
+         the directory rather than the symlink.  We can therefore
+         safely use stat() to distinguish between EINVAL and
+         ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat().  */
+      struct stat st;
+      if (stat (name, &st) == 0)
+        errno = EINVAL;
+      return -1;
+    }
+# endif /* READLINK_TRAILING_SLASH_BUG */
+  return readlink (name, buf, bufsize);
+}
+
+#endif /* HAVE_READLINK */
diff --git a/gnulib/lib/realloc.c b/gnulib/lib/realloc.c
new file mode 100644 (file)
index 0000000..e0a7a16
--- /dev/null
@@ -0,0 +1,91 @@
+/* realloc() function that is glibc compatible.
+
+   Copyright (C) 1997, 2003-2004, 2006-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* written by Jim Meyering and Bruno Haible */
+
+#include <config.h>
+
+/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h.  */
+#ifdef realloc
+# define NEED_REALLOC_GNU 1
+/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU.  */
+#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU
+# define NEED_REALLOC_GNU 1
+#endif
+
+/* Infer the properties of the system's malloc function.
+   The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU.  */
+#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU
+# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1
+#endif
+
+/* Below we want to call the system's malloc and realloc.
+   Undefine the symbols here so that including <stdlib.h> provides a
+   declaration of malloc(), not of rpl_malloc(), and likewise for realloc.  */
+#undef malloc
+#undef realloc
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <errno.h>
+
+/* Below we want to call the system's malloc and realloc.
+   Undefine the symbols, if they were defined by gnulib's <stdlib.h>
+   replacement.  */
+#undef malloc
+#undef realloc
+
+/* Change the size of an allocated block of memory P to N bytes,
+   with error checking.  If N is zero, change it to 1.  If P is NULL,
+   use malloc.  */
+
+void *
+rpl_realloc (void *p, size_t n)
+{
+  void *result;
+
+#if NEED_REALLOC_GNU
+  if (n == 0)
+    {
+      n = 1;
+
+      /* In theory realloc might fail, so don't rely on it to free.  */
+      free (p);
+      p = NULL;
+    }
+#endif
+
+  if (p == NULL)
+    {
+#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
+      if (n == 0)
+        n = 1;
+#endif
+      result = malloc (n);
+    }
+  else
+    result = realloc (p, n);
+
+#if !HAVE_REALLOC_POSIX
+  if (result == NULL)
+    errno = ENOMEM;
+#endif
+
+  return result;
+}
diff --git a/gnulib/lib/ref-add.sin b/gnulib/lib/ref-add.sin
new file mode 100644 (file)
index 0000000..12835d0
--- /dev/null
@@ -0,0 +1,30 @@
+# Add this package to a list of references stored in a text file.
+#
+#   Copyright (C) 2000, 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 Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1, or (at your option)
+#   any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU Lesser General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License along
+#   with this program; if not, write to the Free Software Foundation,
+#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Written by Bruno Haible <haible@clisp.cons.org>.
+#
+/^# Packages using this file: / {
+  s/# Packages using this file://
+  ta
+  :a
+  s/ @PACKAGE@ / @PACKAGE@ /
+  tb
+  s/ $/ @PACKAGE@ /
+  :b
+  s/^/# Packages using this file:/
+}
diff --git a/gnulib/lib/ref-del.sin b/gnulib/lib/ref-del.sin
new file mode 100644 (file)
index 0000000..360e4d6
--- /dev/null
@@ -0,0 +1,25 @@
+# Remove this package from a list of references stored in a text file.
+#
+#   Copyright (C) 2000, 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 Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1, or (at your option)
+#   any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU Lesser General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License along
+#   with this program; if not, write to the Free Software Foundation,
+#   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Written by Bruno Haible <haible@clisp.cons.org>.
+#
+/^# Packages using this file: / {
+  s/# Packages using this file://
+  s/ @PACKAGE@ / /
+  s/^/# Packages using this file:/
+}
diff --git a/gnulib/lib/regcomp.c b/gnulib/lib/regcomp.c
new file mode 100644 (file)
index 0000000..b6dfe4a
--- /dev/null
@@ -0,0 +1,3876 @@
+/* Extended regular expression matching and search library.
+   Copyright (C) 2002-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
+                                         size_t length, reg_syntax_t syntax);
+static void re_compile_fastmap_iter (regex_t *bufp,
+                                    const re_dfastate_t *init_state,
+                                    char *fastmap);
+static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
+#ifdef RE_ENABLE_I18N
+static void free_charset (re_charset_t *cset);
+#endif /* RE_ENABLE_I18N */
+static void free_workarea_compile (regex_t *preg);
+static reg_errcode_t create_initial_state (re_dfa_t *dfa);
+#ifdef RE_ENABLE_I18N
+static void optimize_utf8 (re_dfa_t *dfa);
+#endif
+static reg_errcode_t analyze (regex_t *preg);
+static reg_errcode_t preorder (bin_tree_t *root,
+                              reg_errcode_t (fn (void *, bin_tree_t *)),
+                              void *extra);
+static reg_errcode_t postorder (bin_tree_t *root,
+                               reg_errcode_t (fn (void *, bin_tree_t *)),
+                               void *extra);
+static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node);
+static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node);
+static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
+                                bin_tree_t *node);
+static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
+static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
+static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
+static Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint);
+static Idx search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
+                                  unsigned int constraint);
+static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
+static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
+                                        Idx node, bool root);
+static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
+static Idx fetch_number (re_string_t *input, re_token_t *token,
+                        reg_syntax_t syntax);
+static int peek_token (re_token_t *token, re_string_t *input,
+                       reg_syntax_t syntax) internal_function;
+static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
+                         reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
+                                 re_token_t *token, reg_syntax_t syntax,
+                                 Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg,
+                                re_token_t *token, reg_syntax_t syntax,
+                                Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg,
+                                    re_token_t *token, reg_syntax_t syntax,
+                                    Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg,
+                                 re_token_t *token, reg_syntax_t syntax,
+                                 Idx nest, reg_errcode_t *err);
+static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp,
+                                re_dfa_t *dfa, re_token_t *token,
+                                reg_syntax_t syntax, reg_errcode_t *err);
+static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa,
+                                     re_token_t *token, reg_syntax_t syntax,
+                                     reg_errcode_t *err);
+static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
+                                           re_string_t *regexp,
+                                           re_token_t *token, int token_len,
+                                           re_dfa_t *dfa,
+                                           reg_syntax_t syntax,
+                                           bool accept_hyphen);
+static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
+                                         re_string_t *regexp,
+                                         re_token_t *token);
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+                                       re_charset_t *mbcset,
+                                       Idx *equiv_class_alloc,
+                                       const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+                                     bitset_t sbcset,
+                                     re_charset_t *mbcset,
+                                     Idx *char_class_alloc,
+                                     const unsigned char *class_name,
+                                     reg_syntax_t syntax);
+#else  /* not RE_ENABLE_I18N */
+static reg_errcode_t build_equiv_class (bitset_t sbcset,
+                                       const unsigned char *name);
+static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+                                     bitset_t sbcset,
+                                     const unsigned char *class_name,
+                                     reg_syntax_t syntax);
+#endif /* not RE_ENABLE_I18N */
+static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
+                                      RE_TRANSLATE_TYPE trans,
+                                      const unsigned char *class_name,
+                                      const unsigned char *extra,
+                                      bool non_match, reg_errcode_t *err);
+static bin_tree_t *create_tree (re_dfa_t *dfa,
+                               bin_tree_t *left, bin_tree_t *right,
+                               re_token_type_t type);
+static bin_tree_t *create_token_tree (re_dfa_t *dfa,
+                                     bin_tree_t *left, bin_tree_t *right,
+                                     const re_token_t *token);
+static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa);
+static void free_token (re_token_t *node);
+static reg_errcode_t free_tree (void *extra, bin_tree_t *node);
+static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
+\f
+/* This table gives an error message for each of the error codes listed
+   in regex.h.  Obviously the order here has to be same as there.
+   POSIX doesn't require that we do anything for REG_NOERROR,
+   but why not be nice?  */
+
+static const char __re_error_msgid[] =
+  {
+#define REG_NOERROR_IDX        0
+    gettext_noop ("Success")   /* REG_NOERROR */
+    "\0"
+#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
+    gettext_noop ("No match")  /* REG_NOMATCH */
+    "\0"
+#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
+    gettext_noop ("Invalid regular expression") /* REG_BADPAT */
+    "\0"
+#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
+    gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
+    "\0"
+#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
+    gettext_noop ("Invalid character class name") /* REG_ECTYPE */
+    "\0"
+#define REG_EESCAPE_IDX        (REG_ECTYPE_IDX + sizeof "Invalid character class name")
+    gettext_noop ("Trailing backslash") /* REG_EESCAPE */
+    "\0"
+#define REG_ESUBREG_IDX        (REG_EESCAPE_IDX + sizeof "Trailing backslash")
+    gettext_noop ("Invalid back reference") /* REG_ESUBREG */
+    "\0"
+#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
+    gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
+    "\0"
+#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
+    gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
+    "\0"
+#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
+    gettext_noop ("Unmatched \\{") /* REG_EBRACE */
+    "\0"
+#define REG_BADBR_IDX  (REG_EBRACE_IDX + sizeof "Unmatched \\{")
+    gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
+    "\0"
+#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
+    gettext_noop ("Invalid range end") /* REG_ERANGE */
+    "\0"
+#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
+    gettext_noop ("Memory exhausted") /* REG_ESPACE */
+    "\0"
+#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
+    gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
+    "\0"
+#define REG_EEND_IDX   (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
+    gettext_noop ("Premature end of regular expression") /* REG_EEND */
+    "\0"
+#define REG_ESIZE_IDX  (REG_EEND_IDX + sizeof "Premature end of regular expression")
+    gettext_noop ("Regular expression too big") /* REG_ESIZE */
+    "\0"
+#define REG_ERPAREN_IDX        (REG_ESIZE_IDX + sizeof "Regular expression too big")
+    gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
+  };
+
+static const size_t __re_error_msgid_idx[] =
+  {
+    REG_NOERROR_IDX,
+    REG_NOMATCH_IDX,
+    REG_BADPAT_IDX,
+    REG_ECOLLATE_IDX,
+    REG_ECTYPE_IDX,
+    REG_EESCAPE_IDX,
+    REG_ESUBREG_IDX,
+    REG_EBRACK_IDX,
+    REG_EPAREN_IDX,
+    REG_EBRACE_IDX,
+    REG_BADBR_IDX,
+    REG_ERANGE_IDX,
+    REG_ESPACE_IDX,
+    REG_BADRPT_IDX,
+    REG_EEND_IDX,
+    REG_ESIZE_IDX,
+    REG_ERPAREN_IDX
+  };
+\f
+/* Entry points for GNU code.  */
+
+/* re_compile_pattern is the GNU regular expression compiler: it
+   compiles PATTERN (of length LENGTH) and puts the result in BUFP.
+   Returns 0 if the pattern was valid, otherwise an error string.
+
+   Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+   are set in BUFP on entry.  */
+
+#ifdef _LIBC
+const char *
+re_compile_pattern (pattern, length, bufp)
+    const char *pattern;
+    size_t length;
+    struct re_pattern_buffer *bufp;
+#else /* size_t might promote */
+const char *
+re_compile_pattern (const char *pattern, size_t length,
+                   struct re_pattern_buffer *bufp)
+#endif
+{
+  reg_errcode_t ret;
+
+  /* And GNU code determines whether or not to get register information
+     by passing null for the REGS argument to re_match, etc., not by
+     setting no_sub, unless RE_NO_SUB is set.  */
+  bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
+
+  /* Match anchors at newline.  */
+  bufp->newline_anchor = 1;
+
+  ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
+
+  if (!ret)
+    return NULL;
+  return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+#ifdef _LIBC
+weak_alias (__re_compile_pattern, re_compile_pattern)
+#endif
+
+/* Set by `re_set_syntax' to the current regexp syntax to recognize.  Can
+   also be assigned to arbitrarily: each pattern buffer stores its own
+   syntax, so it can be changed between regex compilations.  */
+/* This has no initializer because initialized variables in Emacs
+   become read-only after dumping.  */
+reg_syntax_t re_syntax_options;
+
+
+/* Specify the precise syntax of regexps for compilation.  This provides
+   for compatibility for various utilities which historically have
+   different, incompatible syntaxes.
+
+   The argument SYNTAX is a bit mask comprised of the various bits
+   defined in regex.h.  We return the old syntax.  */
+
+reg_syntax_t
+re_set_syntax (syntax)
+    reg_syntax_t syntax;
+{
+  reg_syntax_t ret = re_syntax_options;
+
+  re_syntax_options = syntax;
+  return ret;
+}
+#ifdef _LIBC
+weak_alias (__re_set_syntax, re_set_syntax)
+#endif
+
+int
+re_compile_fastmap (bufp)
+    struct re_pattern_buffer *bufp;
+{
+  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+  char *fastmap = bufp->fastmap;
+
+  memset (fastmap, '\0', sizeof (char) * SBC_MAX);
+  re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
+  if (dfa->init_state != dfa->init_state_word)
+    re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
+  if (dfa->init_state != dfa->init_state_nl)
+    re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
+  if (dfa->init_state != dfa->init_state_begbuf)
+    re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
+  bufp->fastmap_accurate = 1;
+  return 0;
+}
+#ifdef _LIBC
+weak_alias (__re_compile_fastmap, re_compile_fastmap)
+#endif
+
+static inline void
+__attribute ((always_inline))
+re_set_fastmap (char *fastmap, bool icase, int ch)
+{
+  fastmap[ch] = 1;
+  if (icase)
+    fastmap[tolower (ch)] = 1;
+}
+
+/* Helper function for re_compile_fastmap.
+   Compile fastmap for the initial_state INIT_STATE.  */
+
+static void
+re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
+                        char *fastmap)
+{
+  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+  Idx node_cnt;
+  bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
+  for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
+    {
+      Idx node = init_state->nodes.elems[node_cnt];
+      re_token_type_t type = dfa->nodes[node].type;
+
+      if (type == CHARACTER)
+       {
+         re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
+#ifdef RE_ENABLE_I18N
+         if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+           {
+             unsigned char buf[MB_LEN_MAX];
+             unsigned char *p;
+             wchar_t wc;
+             mbstate_t state;
+
+             p = buf;
+             *p++ = dfa->nodes[node].opr.c;
+             while (++node < dfa->nodes_len
+                    && dfa->nodes[node].type == CHARACTER
+                    && dfa->nodes[node].mb_partial)
+               *p++ = dfa->nodes[node].opr.c;
+             memset (&state, '\0', sizeof (state));
+             if (__mbrtowc (&wc, (const char *) buf, p - buf,
+                            &state) == p - buf
+                 && (__wcrtomb ((char *) buf, towlower (wc), &state)
+                     != (size_t) -1))
+               re_set_fastmap (fastmap, false, buf[0]);
+           }
+#endif
+       }
+      else if (type == SIMPLE_BRACKET)
+       {
+         int i, ch;
+         for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+           {
+             int j;
+             bitset_word_t w = dfa->nodes[node].opr.sbcset[i];
+             for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+               if (w & ((bitset_word_t) 1 << j))
+                 re_set_fastmap (fastmap, icase, ch);
+           }
+       }
+#ifdef RE_ENABLE_I18N
+      else if (type == COMPLEX_BRACKET)
+       {
+         re_charset_t *cset = dfa->nodes[node].opr.mbcset;
+         Idx i;
+
+# ifdef _LIBC
+         /* See if we have to try all bytes which start multiple collation
+            elements.
+            e.g. In da_DK, we want to catch 'a' since "aa" is a valid
+                 collation element, and don't catch 'b' since 'b' is
+                 the only collation element which starts from 'b' (and
+                 it is caught by SIMPLE_BRACKET).  */
+             if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
+                 && (cset->ncoll_syms || cset->nranges))
+               {
+                 const int32_t *table = (const int32_t *)
+                   _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+                 for (i = 0; i < SBC_MAX; ++i)
+                   if (table[i] < 0)
+                     re_set_fastmap (fastmap, icase, i);
+               }
+# endif /* _LIBC */
+
+         /* See if we have to start the match at all multibyte characters,
+            i.e. where we would not find an invalid sequence.  This only
+            applies to multibyte character sets; for single byte character
+            sets, the SIMPLE_BRACKET again suffices.  */
+         if (dfa->mb_cur_max > 1
+             && (cset->nchar_classes || cset->non_match || cset->nranges
+# ifdef _LIBC
+                 || cset->nequiv_classes
+# endif /* _LIBC */
+                ))
+           {
+             unsigned char c = 0;
+             do
+               {
+                 mbstate_t mbs;
+                 memset (&mbs, 0, sizeof (mbs));
+                 if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
+                   re_set_fastmap (fastmap, false, (int) c);
+               }
+             while (++c != 0);
+           }
+
+         else
+           {
+             /* ... Else catch all bytes which can start the mbchars.  */
+             for (i = 0; i < cset->nmbchars; ++i)
+               {
+                 char buf[256];
+                 mbstate_t state;
+                 memset (&state, '\0', sizeof (state));
+                 if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
+                   re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+                 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+                   {
+                     if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
+                         != (size_t) -1)
+                       re_set_fastmap (fastmap, false, *(unsigned char *) buf);
+                   }
+               }
+           }
+       }
+#endif /* RE_ENABLE_I18N */
+      else if (type == OP_PERIOD
+#ifdef RE_ENABLE_I18N
+              || type == OP_UTF8_PERIOD
+#endif /* RE_ENABLE_I18N */
+              || type == END_OF_RE)
+       {
+         memset (fastmap, '\1', sizeof (char) * SBC_MAX);
+         if (type == END_OF_RE)
+           bufp->can_be_null = 1;
+         return;
+       }
+    }
+}
+\f
+/* Entry point for POSIX code.  */
+/* regcomp takes a regular expression as a string and compiles it.
+
+   PREG is a regex_t *.  We do not expect any fields to be initialized,
+   since POSIX says we shouldn't.  Thus, we set
+
+     `buffer' to the compiled pattern;
+     `used' to the length of the compiled pattern;
+     `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+       REG_EXTENDED bit in CFLAGS is set; otherwise, to
+       RE_SYNTAX_POSIX_BASIC;
+     `newline_anchor' to REG_NEWLINE being set in CFLAGS;
+     `fastmap' to an allocated space for the fastmap;
+     `fastmap_accurate' to zero;
+     `re_nsub' to the number of subexpressions in PATTERN.
+
+   PATTERN is the address of the pattern string.
+
+   CFLAGS is a series of bits which affect compilation.
+
+     If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
+     use POSIX basic syntax.
+
+     If REG_NEWLINE is set, then . and [^...] don't match newline.
+     Also, regexec will try a match beginning after every newline.
+
+     If REG_ICASE is set, then we considers upper- and lowercase
+     versions of letters to be equivalent when matching.
+
+     If REG_NOSUB is set, then when PREG is passed to regexec, that
+     routine will report only success or failure, and nothing about the
+     registers.
+
+   It returns 0 if it succeeds, nonzero if it doesn't.  (See regex.h for
+   the return codes and their meanings.)  */
+
+int
+regcomp (preg, pattern, cflags)
+    regex_t *_Restrict_ preg;
+    const char *_Restrict_ pattern;
+    int cflags;
+{
+  reg_errcode_t ret;
+  reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
+                        : RE_SYNTAX_POSIX_BASIC);
+
+  preg->buffer = NULL;
+  preg->allocated = 0;
+  preg->used = 0;
+
+  /* Try to allocate space for the fastmap.  */
+  preg->fastmap = re_malloc (char, SBC_MAX);
+  if (BE (preg->fastmap == NULL, 0))
+    return REG_ESPACE;
+
+  syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
+
+  /* If REG_NEWLINE is set, newlines are treated differently.  */
+  if (cflags & REG_NEWLINE)
+    { /* REG_NEWLINE implies neither . nor [^...] match newline.  */
+      syntax &= ~RE_DOT_NEWLINE;
+      syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+      /* It also changes the matching behavior.  */
+      preg->newline_anchor = 1;
+    }
+  else
+    preg->newline_anchor = 0;
+  preg->no_sub = !!(cflags & REG_NOSUB);
+  preg->translate = NULL;
+
+  ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
+
+  /* POSIX doesn't distinguish between an unmatched open-group and an
+     unmatched close-group: both are REG_EPAREN.  */
+  if (ret == REG_ERPAREN)
+    ret = REG_EPAREN;
+
+  /* We have already checked preg->fastmap != NULL.  */
+  if (BE (ret == REG_NOERROR, 1))
+    /* Compute the fastmap now, since regexec cannot modify the pattern
+       buffer.  This function never fails in this implementation.  */
+    (void) re_compile_fastmap (preg);
+  else
+    {
+      /* Some error occurred while compiling the expression.  */
+      re_free (preg->fastmap);
+      preg->fastmap = NULL;
+    }
+
+  return (int) ret;
+}
+#ifdef _LIBC
+weak_alias (__regcomp, regcomp)
+#endif
+
+/* Returns a message corresponding to an error code, ERRCODE, returned
+   from either regcomp or regexec.   We don't use PREG here.  */
+
+#ifdef _LIBC
+size_t
+regerror (errcode, preg, errbuf, errbuf_size)
+    int errcode;
+    const regex_t *_Restrict_ preg;
+    char *_Restrict_ errbuf;
+    size_t errbuf_size;
+#else /* size_t might promote */
+size_t
+regerror (int errcode, const regex_t *_Restrict_ preg,
+         char *_Restrict_ errbuf, size_t errbuf_size)
+#endif
+{
+  const char *msg;
+  size_t msg_size;
+
+  if (BE (errcode < 0
+         || errcode >= (int) (sizeof (__re_error_msgid_idx)
+                              / sizeof (__re_error_msgid_idx[0])), 0))
+    /* Only error codes returned by the rest of the code should be passed
+       to this routine.  If we are given anything else, or if other regex
+       code generates an invalid error code, then the program has a bug.
+       Dump core so we can fix it.  */
+    abort ();
+
+  msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
+
+  msg_size = strlen (msg) + 1; /* Includes the null.  */
+
+  if (BE (errbuf_size != 0, 1))
+    {
+      size_t cpy_size = msg_size;
+      if (BE (msg_size > errbuf_size, 0))
+       {
+         cpy_size = errbuf_size - 1;
+         errbuf[cpy_size] = '\0';
+       }
+      memcpy (errbuf, msg, cpy_size);
+    }
+
+  return msg_size;
+}
+#ifdef _LIBC
+weak_alias (__regerror, regerror)
+#endif
+
+
+#ifdef RE_ENABLE_I18N
+/* This static array is used for the map to single-byte characters when
+   UTF-8 is used.  Otherwise we would allocate memory just to initialize
+   it the same all the time.  UTF-8 is the preferred encoding so this is
+   a worthwhile optimization.  */
+static const bitset_t utf8_sb_map =
+{
+  /* Set the first 128 bits.  */
+# if 4 * BITSET_WORD_BITS < ASCII_CHARS
+#  error "bitset_word_t is narrower than 32 bits"
+# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
+  BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
+# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
+  BITSET_WORD_MAX, BITSET_WORD_MAX,
+# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
+  BITSET_WORD_MAX,
+# endif
+  (BITSET_WORD_MAX
+   >> (SBC_MAX % BITSET_WORD_BITS == 0
+       ? 0
+       : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
+};
+#endif
+
+
+static void
+free_dfa_content (re_dfa_t *dfa)
+{
+  Idx i, j;
+
+  if (dfa->nodes)
+    for (i = 0; i < dfa->nodes_len; ++i)
+      free_token (dfa->nodes + i);
+  re_free (dfa->nexts);
+  for (i = 0; i < dfa->nodes_len; ++i)
+    {
+      if (dfa->eclosures != NULL)
+       re_node_set_free (dfa->eclosures + i);
+      if (dfa->inveclosures != NULL)
+       re_node_set_free (dfa->inveclosures + i);
+      if (dfa->edests != NULL)
+       re_node_set_free (dfa->edests + i);
+    }
+  re_free (dfa->edests);
+  re_free (dfa->eclosures);
+  re_free (dfa->inveclosures);
+  re_free (dfa->nodes);
+
+  if (dfa->state_table)
+    for (i = 0; i <= dfa->state_hash_mask; ++i)
+      {
+       struct re_state_table_entry *entry = dfa->state_table + i;
+       for (j = 0; j < entry->num; ++j)
+         {
+           re_dfastate_t *state = entry->array[j];
+           free_state (state);
+         }
+       re_free (entry->array);
+      }
+  re_free (dfa->state_table);
+#ifdef RE_ENABLE_I18N
+  if (dfa->sb_char != utf8_sb_map)
+    re_free (dfa->sb_char);
+#endif
+  re_free (dfa->subexp_map);
+#ifdef DEBUG
+  re_free (dfa->re_str);
+#endif
+
+  re_free (dfa);
+}
+
+
+/* Free dynamically allocated space used by PREG.  */
+
+void
+regfree (preg)
+    regex_t *preg;
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  if (BE (dfa != NULL, 1))
+    free_dfa_content (dfa);
+  preg->buffer = NULL;
+  preg->allocated = 0;
+
+  re_free (preg->fastmap);
+  preg->fastmap = NULL;
+
+  re_free (preg->translate);
+  preg->translate = NULL;
+}
+#ifdef _LIBC
+weak_alias (__regfree, regfree)
+#endif
+\f
+/* Entry points compatible with 4.2 BSD regex library.  We don't define
+   them unless specifically requested.  */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+
+/* BSD has one and only one pattern buffer.  */
+static struct re_pattern_buffer re_comp_buf;
+
+char *
+# ifdef _LIBC
+/* Make these definitions weak in libc, so POSIX programs can redefine
+   these names if they don't use our functions, and still use
+   regcomp/regexec above without link errors.  */
+weak_function
+# endif
+re_comp (s)
+     const char *s;
+{
+  reg_errcode_t ret;
+  char *fastmap;
+
+  if (!s)
+    {
+      if (!re_comp_buf.buffer)
+       return gettext ("No previous regular expression");
+      return 0;
+    }
+
+  if (re_comp_buf.buffer)
+    {
+      fastmap = re_comp_buf.fastmap;
+      re_comp_buf.fastmap = NULL;
+      __regfree (&re_comp_buf);
+      memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
+      re_comp_buf.fastmap = fastmap;
+    }
+
+  if (re_comp_buf.fastmap == NULL)
+    {
+      re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
+      if (re_comp_buf.fastmap == NULL)
+       return (char *) gettext (__re_error_msgid
+                                + __re_error_msgid_idx[(int) REG_ESPACE]);
+    }
+
+  /* Since `re_exec' always passes NULL for the `regs' argument, we
+     don't need to initialize the pattern buffer fields which affect it.  */
+
+  /* Match anchors at newlines.  */
+  re_comp_buf.newline_anchor = 1;
+
+  ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
+
+  if (!ret)
+    return NULL;
+
+  /* Yes, we're discarding `const' here if !HAVE_LIBINTL.  */
+  return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
+}
+
+#ifdef _LIBC
+libc_freeres_fn (free_mem)
+{
+  __regfree (&re_comp_buf);
+}
+#endif
+
+#endif /* _REGEX_RE_COMP */
+\f
+/* Internal entry point.
+   Compile the regular expression PATTERN, whose length is LENGTH.
+   SYNTAX indicate regular expression's syntax.  */
+
+static reg_errcode_t
+re_compile_internal (regex_t *preg, const char * pattern, size_t length,
+                    reg_syntax_t syntax)
+{
+  reg_errcode_t err = REG_NOERROR;
+  re_dfa_t *dfa;
+  re_string_t regexp;
+
+  /* Initialize the pattern buffer.  */
+  preg->fastmap_accurate = 0;
+  preg->syntax = syntax;
+  preg->not_bol = preg->not_eol = 0;
+  preg->used = 0;
+  preg->re_nsub = 0;
+  preg->can_be_null = 0;
+  preg->regs_allocated = REGS_UNALLOCATED;
+
+  /* Initialize the dfa.  */
+  dfa = (re_dfa_t *) preg->buffer;
+  if (BE (preg->allocated < sizeof (re_dfa_t), 0))
+    {
+      /* If zero allocated, but buffer is non-null, try to realloc
+        enough space.  This loses if buffer's address is bogus, but
+        that is the user's responsibility.  If ->buffer is NULL this
+        is a simple allocation.  */
+      dfa = re_realloc (preg->buffer, re_dfa_t, 1);
+      if (dfa == NULL)
+       return REG_ESPACE;
+      preg->allocated = sizeof (re_dfa_t);
+      preg->buffer = (unsigned char *) dfa;
+    }
+  preg->used = sizeof (re_dfa_t);
+
+  err = init_dfa (dfa, length);
+  if (BE (err != REG_NOERROR, 0))
+    {
+      free_dfa_content (dfa);
+      preg->buffer = NULL;
+      preg->allocated = 0;
+      return err;
+    }
+#ifdef DEBUG
+  /* Note: length+1 will not overflow since it is checked in init_dfa.  */
+  dfa->re_str = re_malloc (char, length + 1);
+  strncpy (dfa->re_str, pattern, length + 1);
+#endif
+
+  __libc_lock_init (dfa->lock);
+
+  err = re_string_construct (&regexp, pattern, length, preg->translate,
+                            (syntax & RE_ICASE) != 0, dfa);
+  if (BE (err != REG_NOERROR, 0))
+    {
+    re_compile_internal_free_return:
+      free_workarea_compile (preg);
+      re_string_destruct (&regexp);
+      free_dfa_content (dfa);
+      preg->buffer = NULL;
+      preg->allocated = 0;
+      return err;
+    }
+
+  /* Parse the regular expression, and build a structure tree.  */
+  preg->re_nsub = 0;
+  dfa->str_tree = parse (&regexp, preg, syntax, &err);
+  if (BE (dfa->str_tree == NULL, 0))
+    goto re_compile_internal_free_return;
+
+  /* Analyze the tree and create the nfa.  */
+  err = analyze (preg);
+  if (BE (err != REG_NOERROR, 0))
+    goto re_compile_internal_free_return;
+
+#ifdef RE_ENABLE_I18N
+  /* If possible, do searching in single byte encoding to speed things up.  */
+  if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
+    optimize_utf8 (dfa);
+#endif
+
+  /* Then create the initial state of the dfa.  */
+  err = create_initial_state (dfa);
+
+  /* Release work areas.  */
+  free_workarea_compile (preg);
+  re_string_destruct (&regexp);
+
+  if (BE (err != REG_NOERROR, 0))
+    {
+      free_dfa_content (dfa);
+      preg->buffer = NULL;
+      preg->allocated = 0;
+    }
+
+  return err;
+}
+
+/* Initialize DFA.  We use the length of the regular expression PAT_LEN
+   as the initial length of some arrays.  */
+
+static reg_errcode_t
+init_dfa (re_dfa_t *dfa, size_t pat_len)
+{
+  __re_size_t table_size;
+#ifndef _LIBC
+  char *codeset_name;
+#endif
+#ifdef RE_ENABLE_I18N
+  size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
+#else
+  size_t max_i18n_object_size = 0;
+#endif
+  size_t max_object_size =
+    MAX (sizeof (struct re_state_table_entry),
+        MAX (sizeof (re_token_t),
+             MAX (sizeof (re_node_set),
+                  MAX (sizeof (regmatch_t),
+                       max_i18n_object_size))));
+
+  memset (dfa, '\0', sizeof (re_dfa_t));
+
+  /* Force allocation of str_tree_storage the first time.  */
+  dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+
+  /* Avoid overflows.  The extra "/ 2" is for the table_size doubling
+     calculation below, and for similar doubling calculations
+     elsewhere.  And it's <= rather than <, because some of the
+     doubling calculations add 1 afterwards.  */
+  if (BE (SIZE_MAX / max_object_size / 2 <= pat_len, 0))
+    return REG_ESPACE;
+
+  dfa->nodes_alloc = pat_len + 1;
+  dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc);
+
+  /*  table_size = 2 ^ ceil(log pat_len) */
+  for (table_size = 1; ; table_size <<= 1)
+    if (table_size > pat_len)
+      break;
+
+  dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+  dfa->state_hash_mask = table_size - 1;
+
+  dfa->mb_cur_max = MB_CUR_MAX;
+#ifdef _LIBC
+  if (dfa->mb_cur_max == 6
+      && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
+    dfa->is_utf8 = 1;
+  dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
+                      != 0);
+#else
+  codeset_name = nl_langinfo (CODESET);
+  if (strcasecmp (codeset_name, "UTF-8") == 0
+      || strcasecmp (codeset_name, "UTF8") == 0)
+    dfa->is_utf8 = 1;
+
+  /* We check exhaustively in the loop below if this charset is a
+     superset of ASCII.  */
+  dfa->map_notascii = 0;
+#endif
+
+#ifdef RE_ENABLE_I18N
+  if (dfa->mb_cur_max > 1)
+    {
+      if (dfa->is_utf8)
+       dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map;
+      else
+       {
+         int i, j, ch;
+
+         dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+         if (BE (dfa->sb_char == NULL, 0))
+           return REG_ESPACE;
+
+         /* Set the bits corresponding to single byte chars.  */
+         for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+           for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+             {
+               wint_t wch = __btowc (ch);
+               if (wch != WEOF)
+                 dfa->sb_char[i] |= (bitset_word_t) 1 << j;
+# ifndef _LIBC
+               if (isascii (ch) && wch != ch)
+                 dfa->map_notascii = 1;
+# endif
+             }
+       }
+    }
+#endif
+
+  if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0))
+    return REG_ESPACE;
+  return REG_NOERROR;
+}
+
+/* Initialize WORD_CHAR table, which indicate which character is
+   "word".  In this case "word" means that it is the word construction
+   character used by some operators like "\<", "\>", etc.  */
+
+static void
+internal_function
+init_word_char (re_dfa_t *dfa)
+{
+  int i, j, ch;
+  dfa->word_ops_used = 1;
+  for (i = 0, ch = 0; i < BITSET_WORDS; ++i)
+    for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
+      if (isalnum (ch) || ch == '_')
+       dfa->word_char[i] |= (bitset_word_t) 1 << j;
+}
+
+/* Free the work area which are only used while compiling.  */
+
+static void
+free_workarea_compile (regex_t *preg)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_storage_t *storage, *next;
+  for (storage = dfa->str_tree_storage; storage; storage = next)
+    {
+      next = storage->next;
+      re_free (storage);
+    }
+  dfa->str_tree_storage = NULL;
+  dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE;
+  dfa->str_tree = NULL;
+  re_free (dfa->org_indices);
+  dfa->org_indices = NULL;
+}
+
+/* Create initial states for all contexts.  */
+
+static reg_errcode_t
+create_initial_state (re_dfa_t *dfa)
+{
+  Idx first, i;
+  reg_errcode_t err;
+  re_node_set init_nodes;
+
+  /* Initial states have the epsilon closure of the node which is
+     the first node of the regular expression.  */
+  first = dfa->str_tree->first->node_idx;
+  dfa->init_node = first;
+  err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+
+  /* The back-references which are in initial states can epsilon transit,
+     since in this case all of the subexpressions can be null.
+     Then we add epsilon closures of the nodes which are the next nodes of
+     the back-references.  */
+  if (dfa->nbackref > 0)
+    for (i = 0; i < init_nodes.nelem; ++i)
+      {
+       Idx node_idx = init_nodes.elems[i];
+       re_token_type_t type = dfa->nodes[node_idx].type;
+
+       Idx clexp_idx;
+       if (type != OP_BACK_REF)
+         continue;
+       for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx)
+         {
+           re_token_t *clexp_node;
+           clexp_node = dfa->nodes + init_nodes.elems[clexp_idx];
+           if (clexp_node->type == OP_CLOSE_SUBEXP
+               && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx)
+             break;
+         }
+       if (clexp_idx == init_nodes.nelem)
+         continue;
+
+       if (type == OP_BACK_REF)
+         {
+           Idx dest_idx = dfa->edests[node_idx].elems[0];
+           if (!re_node_set_contains (&init_nodes, dest_idx))
+             {
+               reg_errcode_t merge_err
+                  = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
+               if (merge_err != REG_NOERROR)
+                 return merge_err;
+               i = 0;
+             }
+         }
+      }
+
+  /* It must be the first time to invoke acquire_state.  */
+  dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
+  /* We don't check ERR here, since the initial state must not be NULL.  */
+  if (BE (dfa->init_state == NULL, 0))
+    return err;
+  if (dfa->init_state->has_constraint)
+    {
+      dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
+                                                      CONTEXT_WORD);
+      dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes,
+                                                    CONTEXT_NEWLINE);
+      dfa->init_state_begbuf = re_acquire_state_context (&err, dfa,
+                                                        &init_nodes,
+                                                        CONTEXT_NEWLINE
+                                                        | CONTEXT_BEGBUF);
+      if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL
+             || dfa->init_state_begbuf == NULL, 0))
+       return err;
+    }
+  else
+    dfa->init_state_word = dfa->init_state_nl
+      = dfa->init_state_begbuf = dfa->init_state;
+
+  re_node_set_free (&init_nodes);
+  return REG_NOERROR;
+}
+\f
+#ifdef RE_ENABLE_I18N
+/* If it is possible to do searching in single byte encoding instead of UTF-8
+   to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
+   DFA nodes where needed.  */
+
+static void
+optimize_utf8 (re_dfa_t *dfa)
+{
+  Idx node;
+  int i;
+  bool mb_chars = false;
+  bool has_period = false;
+
+  for (node = 0; node < dfa->nodes_len; ++node)
+    switch (dfa->nodes[node].type)
+      {
+      case CHARACTER:
+       if (dfa->nodes[node].opr.c >= ASCII_CHARS)
+         mb_chars = true;
+       break;
+      case ANCHOR:
+       switch (dfa->nodes[node].opr.ctx_type)
+         {
+         case LINE_FIRST:
+         case LINE_LAST:
+         case BUF_FIRST:
+         case BUF_LAST:
+           break;
+         default:
+           /* Word anchors etc. cannot be handled.  It's okay to test
+              opr.ctx_type since constraints (for all DFA nodes) are
+              created by ORing one or more opr.ctx_type values.  */
+           return;
+         }
+       break;
+      case OP_PERIOD:
+       has_period = true;
+       break;
+      case OP_BACK_REF:
+      case OP_ALT:
+      case END_OF_RE:
+      case OP_DUP_ASTERISK:
+      case OP_OPEN_SUBEXP:
+      case OP_CLOSE_SUBEXP:
+       break;
+      case COMPLEX_BRACKET:
+       return;
+      case SIMPLE_BRACKET:
+       /* Just double check.  */
+       {
+         int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0
+                       ? 0
+                       : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS);
+         for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i)
+           {
+             if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0)
+               return;
+             rshift = 0;
+           }
+       }
+       break;
+      default:
+       abort ();
+      }
+
+  if (mb_chars || has_period)
+    for (node = 0; node < dfa->nodes_len; ++node)
+      {
+       if (dfa->nodes[node].type == CHARACTER
+           && dfa->nodes[node].opr.c >= ASCII_CHARS)
+         dfa->nodes[node].mb_partial = 0;
+       else if (dfa->nodes[node].type == OP_PERIOD)
+         dfa->nodes[node].type = OP_UTF8_PERIOD;
+      }
+
+  /* The search can be in single byte locale.  */
+  dfa->mb_cur_max = 1;
+  dfa->is_utf8 = 0;
+  dfa->has_mb_node = dfa->nbackref > 0 || has_period;
+}
+#endif
+\f
+/* Analyze the structure tree, and calculate "first", "next", "edest",
+   "eclosure", and "inveclosure".  */
+
+static reg_errcode_t
+analyze (regex_t *preg)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  reg_errcode_t ret;
+
+  /* Allocate arrays.  */
+  dfa->nexts = re_malloc (Idx, dfa->nodes_alloc);
+  dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
+  dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
+  dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
+  if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL
+         || dfa->eclosures == NULL, 0))
+    return REG_ESPACE;
+
+  dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
+  if (dfa->subexp_map != NULL)
+    {
+      Idx i;
+      for (i = 0; i < preg->re_nsub; i++)
+       dfa->subexp_map[i] = i;
+      preorder (dfa->str_tree, optimize_subexps, dfa);
+      for (i = 0; i < preg->re_nsub; i++)
+       if (dfa->subexp_map[i] != i)
+         break;
+      if (i == preg->re_nsub)
+       {
+         free (dfa->subexp_map);
+         dfa->subexp_map = NULL;
+       }
+    }
+
+  ret = postorder (dfa->str_tree, lower_subexps, preg);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+  ret = postorder (dfa->str_tree, calc_first, dfa);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+  preorder (dfa->str_tree, calc_next, dfa);
+  ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+  ret = calc_eclosure (dfa);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+
+  /* We only need this during the prune_impossible_nodes pass in regexec.c;
+     skip it if p_i_n will not run, as calc_inveclosure can be quadratic.  */
+  if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
+      || dfa->nbackref)
+    {
+      dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
+      if (BE (dfa->inveclosures == NULL, 0))
+       return REG_ESPACE;
+      ret = calc_inveclosure (dfa);
+    }
+
+  return ret;
+}
+
+/* Our parse trees are very unbalanced, so we cannot use a stack to
+   implement parse tree visits.  Instead, we use parent pointers and
+   some hairy code in these two functions.  */
+static reg_errcode_t
+postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+          void *extra)
+{
+  bin_tree_t *node, *prev;
+
+  for (node = root; ; )
+    {
+      /* Descend down the tree, preferably to the left (or to the right
+        if that's the only child).  */
+      while (node->left || node->right)
+       if (node->left)
+         node = node->left;
+       else
+         node = node->right;
+
+      do
+       {
+         reg_errcode_t err = fn (extra, node);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+         if (node->parent == NULL)
+           return REG_NOERROR;
+         prev = node;
+         node = node->parent;
+       }
+      /* Go up while we have a node that is reached from the right.  */
+      while (node->right == prev || node->right == NULL);
+      node = node->right;
+    }
+}
+
+static reg_errcode_t
+preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+         void *extra)
+{
+  bin_tree_t *node;
+
+  for (node = root; ; )
+    {
+      reg_errcode_t err = fn (extra, node);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+
+      /* Go to the left node, or up and to the right.  */
+      if (node->left)
+       node = node->left;
+      else
+       {
+         bin_tree_t *prev = NULL;
+         while (node->right == prev || node->right == NULL)
+           {
+             prev = node;
+             node = node->parent;
+             if (!node)
+               return REG_NOERROR;
+           }
+         node = node->right;
+       }
+    }
+}
+
+/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell
+   re_search_internal to map the inner one's opr.idx to this one's.  Adjust
+   backreferences as well.  Requires a preorder visit.  */
+static reg_errcode_t
+optimize_subexps (void *extra, bin_tree_t *node)
+{
+  re_dfa_t *dfa = (re_dfa_t *) extra;
+
+  if (node->token.type == OP_BACK_REF && dfa->subexp_map)
+    {
+      int idx = node->token.opr.idx;
+      node->token.opr.idx = dfa->subexp_map[idx];
+      dfa->used_bkref_map |= 1 << node->token.opr.idx;
+    }
+
+  else if (node->token.type == SUBEXP
+          && node->left && node->left->token.type == SUBEXP)
+    {
+      Idx other_idx = node->left->token.opr.idx;
+
+      node->left = node->left->left;
+      if (node->left)
+       node->left->parent = node;
+
+      dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
+      if (other_idx < BITSET_WORD_BITS)
+       dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx);
+    }
+
+  return REG_NOERROR;
+}
+
+/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation
+   of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP.  */
+static reg_errcode_t
+lower_subexps (void *extra, bin_tree_t *node)
+{
+  regex_t *preg = (regex_t *) extra;
+  reg_errcode_t err = REG_NOERROR;
+
+  if (node->left && node->left->token.type == SUBEXP)
+    {
+      node->left = lower_subexp (&err, preg, node->left);
+      if (node->left)
+       node->left->parent = node;
+    }
+  if (node->right && node->right->token.type == SUBEXP)
+    {
+      node->right = lower_subexp (&err, preg, node->right);
+      if (node->right)
+       node->right->parent = node;
+    }
+
+  return err;
+}
+
+static bin_tree_t *
+lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_t *body = node->left;
+  bin_tree_t *op, *cls, *tree1, *tree;
+
+  if (preg->no_sub
+      /* We do not optimize empty subexpressions, because otherwise we may
+        have bad CONCAT nodes with NULL children.  This is obviously not
+        very common, so we do not lose much.  An example that triggers
+        this case is the sed "script" /\(\)/x.  */
+      && node->left != NULL
+      && (node->token.opr.idx >= BITSET_WORD_BITS
+         || !(dfa->used_bkref_map
+              & ((bitset_word_t) 1 << node->token.opr.idx))))
+    return node->left;
+
+  /* Convert the SUBEXP node to the concatenation of an
+     OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP.  */
+  op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP);
+  cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
+  tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
+  tree = create_tree (dfa, op, tree1, CONCAT);
+  if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0))
+    {
+      *err = REG_ESPACE;
+      return NULL;
+    }
+
+  op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx;
+  op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp;
+  return tree;
+}
+
+/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton
+   nodes.  Requires a postorder visit.  */
+static reg_errcode_t
+calc_first (void *extra, bin_tree_t *node)
+{
+  re_dfa_t *dfa = (re_dfa_t *) extra;
+  if (node->token.type == CONCAT)
+    {
+      node->first = node->left->first;
+      node->node_idx = node->left->node_idx;
+    }
+  else
+    {
+      node->first = node;
+      node->node_idx = re_dfa_add_node (dfa, node->token);
+      if (BE (node->node_idx == REG_MISSING, 0))
+       return REG_ESPACE;
+      if (node->token.type == ANCHOR)
+       dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
+    }
+  return REG_NOERROR;
+}
+
+/* Pass 2: compute NEXT on the tree.  Preorder visit.  */
+static reg_errcode_t
+calc_next (void *extra, bin_tree_t *node)
+{
+  switch (node->token.type)
+    {
+    case OP_DUP_ASTERISK:
+      node->left->next = node;
+      break;
+    case CONCAT:
+      node->left->next = node->right->first;
+      node->right->next = node->next;
+      break;
+    default:
+      if (node->left)
+       node->left->next = node->next;
+      if (node->right)
+       node->right->next = node->next;
+      break;
+    }
+  return REG_NOERROR;
+}
+
+/* Pass 3: link all DFA nodes to their NEXT node (any order will do).  */
+static reg_errcode_t
+link_nfa_nodes (void *extra, bin_tree_t *node)
+{
+  re_dfa_t *dfa = (re_dfa_t *) extra;
+  Idx idx = node->node_idx;
+  reg_errcode_t err = REG_NOERROR;
+
+  switch (node->token.type)
+    {
+    case CONCAT:
+      break;
+
+    case END_OF_RE:
+      assert (node->next == NULL);
+      break;
+
+    case OP_DUP_ASTERISK:
+    case OP_ALT:
+      {
+       Idx left, right;
+       dfa->has_plural_match = 1;
+       if (node->left != NULL)
+         left = node->left->first->node_idx;
+       else
+         left = node->next->node_idx;
+       if (node->right != NULL)
+         right = node->right->first->node_idx;
+       else
+         right = node->next->node_idx;
+       assert (REG_VALID_INDEX (left));
+       assert (REG_VALID_INDEX (right));
+       err = re_node_set_init_2 (dfa->edests + idx, left, right);
+      }
+      break;
+
+    case ANCHOR:
+    case OP_OPEN_SUBEXP:
+    case OP_CLOSE_SUBEXP:
+      err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx);
+      break;
+
+    case OP_BACK_REF:
+      dfa->nexts[idx] = node->next->node_idx;
+      if (node->token.type == OP_BACK_REF)
+       err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
+      break;
+
+    default:
+      assert (!IS_EPSILON_NODE (node->token.type));
+      dfa->nexts[idx] = node->next->node_idx;
+      break;
+    }
+
+  return err;
+}
+
+/* Duplicate the epsilon closure of the node ROOT_NODE.
+   Note that duplicated nodes have constraint INIT_CONSTRAINT in addition
+   to their own constraint.  */
+
+static reg_errcode_t
+internal_function
+duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
+                       Idx root_node, unsigned int init_constraint)
+{
+  Idx org_node, clone_node;
+  bool ok;
+  unsigned int constraint = init_constraint;
+  for (org_node = top_org_node, clone_node = top_clone_node;;)
+    {
+      Idx org_dest, clone_dest;
+      if (dfa->nodes[org_node].type == OP_BACK_REF)
+       {
+         /* If the back reference epsilon-transit, its destination must
+            also have the constraint.  Then duplicate the epsilon closure
+            of the destination of the back reference, and store it in
+            edests of the back reference.  */
+         org_dest = dfa->nexts[org_node];
+         re_node_set_empty (dfa->edests + clone_node);
+         clone_dest = duplicate_node (dfa, org_dest, constraint);
+         if (BE (clone_dest == REG_MISSING, 0))
+           return REG_ESPACE;
+         dfa->nexts[clone_node] = dfa->nexts[org_node];
+         ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+         if (BE (! ok, 0))
+           return REG_ESPACE;
+       }
+      else if (dfa->edests[org_node].nelem == 0)
+       {
+         /* In case of the node can't epsilon-transit, don't duplicate the
+            destination and store the original destination as the
+            destination of the node.  */
+         dfa->nexts[clone_node] = dfa->nexts[org_node];
+         break;
+       }
+      else if (dfa->edests[org_node].nelem == 1)
+       {
+         /* In case of the node can epsilon-transit, and it has only one
+            destination.  */
+         org_dest = dfa->edests[org_node].elems[0];
+         re_node_set_empty (dfa->edests + clone_node);
+         /* If the node is root_node itself, it means the epsilon closure
+            has a loop.  Then tie it to the destination of the root_node.  */
+         if (org_node == root_node && clone_node != org_node)
+           {
+             ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
+             if (BE (! ok, 0))
+               return REG_ESPACE;
+             break;
+           }
+         /* In case the node has another constraint, append it.  */
+         constraint |= dfa->nodes[org_node].constraint;
+         clone_dest = duplicate_node (dfa, org_dest, constraint);
+         if (BE (clone_dest == REG_MISSING, 0))
+           return REG_ESPACE;
+         ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+         if (BE (! ok, 0))
+           return REG_ESPACE;
+       }
+      else /* dfa->edests[org_node].nelem == 2 */
+       {
+         /* In case of the node can epsilon-transit, and it has two
+            destinations. In the bin_tree_t and DFA, that's '|' and '*'.   */
+         org_dest = dfa->edests[org_node].elems[0];
+         re_node_set_empty (dfa->edests + clone_node);
+         /* Search for a duplicated node which satisfies the constraint.  */
+         clone_dest = search_duplicated_node (dfa, org_dest, constraint);
+         if (clone_dest == REG_MISSING)
+           {
+             /* There is no such duplicated node, create a new one.  */
+             reg_errcode_t err;
+             clone_dest = duplicate_node (dfa, org_dest, constraint);
+             if (BE (clone_dest == REG_MISSING, 0))
+               return REG_ESPACE;
+             ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+             if (BE (! ok, 0))
+               return REG_ESPACE;
+             err = duplicate_node_closure (dfa, org_dest, clone_dest,
+                                           root_node, constraint);
+             if (BE (err != REG_NOERROR, 0))
+               return err;
+           }
+         else
+           {
+             /* There is a duplicated node which satisfies the constraint,
+                use it to avoid infinite loop.  */
+             ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+             if (BE (! ok, 0))
+               return REG_ESPACE;
+           }
+
+         org_dest = dfa->edests[org_node].elems[1];
+         clone_dest = duplicate_node (dfa, org_dest, constraint);
+         if (BE (clone_dest == REG_MISSING, 0))
+           return REG_ESPACE;
+         ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
+         if (BE (! ok, 0))
+           return REG_ESPACE;
+       }
+      org_node = org_dest;
+      clone_node = clone_dest;
+    }
+  return REG_NOERROR;
+}
+
+/* Search for a node which is duplicated from the node ORG_NODE, and
+   satisfies the constraint CONSTRAINT.  */
+
+static Idx
+search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
+                       unsigned int constraint)
+{
+  Idx idx;
+  for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
+    {
+      if (org_node == dfa->org_indices[idx]
+         && constraint == dfa->nodes[idx].constraint)
+       return idx; /* Found.  */
+    }
+  return REG_MISSING; /* Not found.  */
+}
+
+/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
+   Return the index of the new node, or REG_MISSING if insufficient storage is
+   available.  */
+
+static Idx
+duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
+{
+  Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
+  if (BE (dup_idx != REG_MISSING, 1))
+    {
+      dfa->nodes[dup_idx].constraint = constraint;
+      dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
+      dfa->nodes[dup_idx].duplicated = 1;
+
+      /* Store the index of the original node.  */
+      dfa->org_indices[dup_idx] = org_idx;
+    }
+  return dup_idx;
+}
+
+static reg_errcode_t
+calc_inveclosure (re_dfa_t *dfa)
+{
+  Idx src, idx;
+  bool ok;
+  for (idx = 0; idx < dfa->nodes_len; ++idx)
+    re_node_set_init_empty (dfa->inveclosures + idx);
+
+  for (src = 0; src < dfa->nodes_len; ++src)
+    {
+      Idx *elems = dfa->eclosures[src].elems;
+      for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
+       {
+         ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
+         if (BE (! ok, 0))
+           return REG_ESPACE;
+       }
+    }
+
+  return REG_NOERROR;
+}
+
+/* Calculate "eclosure" for all the node in DFA.  */
+
+static reg_errcode_t
+calc_eclosure (re_dfa_t *dfa)
+{
+  Idx node_idx;
+  bool incomplete;
+#ifdef DEBUG
+  assert (dfa->nodes_len > 0);
+#endif
+  incomplete = false;
+  /* For each nodes, calculate epsilon closure.  */
+  for (node_idx = 0; ; ++node_idx)
+    {
+      reg_errcode_t err;
+      re_node_set eclosure_elem;
+      if (node_idx == dfa->nodes_len)
+       {
+         if (!incomplete)
+           break;
+         incomplete = false;
+         node_idx = 0;
+       }
+
+#ifdef DEBUG
+      assert (dfa->eclosures[node_idx].nelem != REG_MISSING);
+#endif
+
+      /* If we have already calculated, skip it.  */
+      if (dfa->eclosures[node_idx].nelem != 0)
+       continue;
+      /* Calculate epsilon closure of `node_idx'.  */
+      err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+
+      if (dfa->eclosures[node_idx].nelem == 0)
+       {
+         incomplete = true;
+         re_node_set_free (&eclosure_elem);
+       }
+    }
+  return REG_NOERROR;
+}
+
+/* Calculate epsilon closure of NODE.  */
+
+static reg_errcode_t
+calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
+{
+  reg_errcode_t err;
+  Idx i;
+  re_node_set eclosure;
+  bool ok;
+  bool incomplete = false;
+  err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+
+  /* This indicates that we are calculating this node now.
+     We reference this value to avoid infinite loop.  */
+  dfa->eclosures[node].nelem = REG_MISSING;
+
+  /* If the current node has constraints, duplicate all nodes
+     since they must inherit the constraints.  */
+  if (dfa->nodes[node].constraint
+      && dfa->edests[node].nelem
+      && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
+    {
+      err = duplicate_node_closure (dfa, node, node, node,
+                                   dfa->nodes[node].constraint);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+    }
+
+  /* Expand each epsilon destination nodes.  */
+  if (IS_EPSILON_NODE(dfa->nodes[node].type))
+    for (i = 0; i < dfa->edests[node].nelem; ++i)
+      {
+       re_node_set eclosure_elem;
+       Idx edest = dfa->edests[node].elems[i];
+       /* If calculating the epsilon closure of `edest' is in progress,
+          return intermediate result.  */
+       if (dfa->eclosures[edest].nelem == REG_MISSING)
+         {
+           incomplete = true;
+           continue;
+         }
+       /* If we haven't calculated the epsilon closure of `edest' yet,
+          calculate now. Otherwise use calculated epsilon closure.  */
+       if (dfa->eclosures[edest].nelem == 0)
+         {
+           err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
+           if (BE (err != REG_NOERROR, 0))
+             return err;
+         }
+       else
+         eclosure_elem = dfa->eclosures[edest];
+       /* Merge the epsilon closure of `edest'.  */
+       err = re_node_set_merge (&eclosure, &eclosure_elem);
+       if (BE (err != REG_NOERROR, 0))
+         return err;
+       /* If the epsilon closure of `edest' is incomplete,
+          the epsilon closure of this node is also incomplete.  */
+       if (dfa->eclosures[edest].nelem == 0)
+         {
+           incomplete = true;
+           re_node_set_free (&eclosure_elem);
+         }
+      }
+
+  /* An epsilon closure includes itself.  */
+  ok = re_node_set_insert (&eclosure, node);
+  if (BE (! ok, 0))
+    return REG_ESPACE;
+  if (incomplete && !root)
+    dfa->eclosures[node].nelem = 0;
+  else
+    dfa->eclosures[node] = eclosure;
+  *new_set = eclosure;
+  return REG_NOERROR;
+}
+\f
+/* Functions for token which are used in the parser.  */
+
+/* Fetch a token from INPUT.
+   We must not use this function inside bracket expressions.  */
+
+static void
+internal_function
+fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
+{
+  re_string_skip_bytes (input, peek_token (result, input, syntax));
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+   We must not use this function inside bracket expressions.  */
+
+static int
+internal_function
+peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+  unsigned char c;
+
+  if (re_string_eoi (input))
+    {
+      token->type = END_OF_RE;
+      return 0;
+    }
+
+  c = re_string_peek_byte (input, 0);
+  token->opr.c = c;
+
+  token->word_char = 0;
+#ifdef RE_ENABLE_I18N
+  token->mb_partial = 0;
+  if (input->mb_cur_max > 1 &&
+      !re_string_first_byte (input, re_string_cur_idx (input)))
+    {
+      token->type = CHARACTER;
+      token->mb_partial = 1;
+      return 1;
+    }
+#endif
+  if (c == '\\')
+    {
+      unsigned char c2;
+      if (re_string_cur_idx (input) + 1 >= re_string_length (input))
+       {
+         token->type = BACK_SLASH;
+         return 1;
+       }
+
+      c2 = re_string_peek_byte_case (input, 1);
+      token->opr.c = c2;
+      token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+      if (input->mb_cur_max > 1)
+       {
+         wint_t wc = re_string_wchar_at (input,
+                                         re_string_cur_idx (input) + 1);
+         token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+       }
+      else
+#endif
+       token->word_char = IS_WORD_CHAR (c2) != 0;
+
+      switch (c2)
+       {
+       case '|':
+         if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
+           token->type = OP_ALT;
+         break;
+       case '1': case '2': case '3': case '4': case '5':
+       case '6': case '7': case '8': case '9':
+         if (!(syntax & RE_NO_BK_REFS))
+           {
+             token->type = OP_BACK_REF;
+             token->opr.idx = c2 - '1';
+           }
+         break;
+       case '<':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = WORD_FIRST;
+           }
+         break;
+       case '>':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = WORD_LAST;
+           }
+         break;
+       case 'b':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = WORD_DELIM;
+           }
+         break;
+       case 'B':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = NOT_WORD_DELIM;
+           }
+         break;
+       case 'w':
+         if (!(syntax & RE_NO_GNU_OPS))
+           token->type = OP_WORD;
+         break;
+       case 'W':
+         if (!(syntax & RE_NO_GNU_OPS))
+           token->type = OP_NOTWORD;
+         break;
+       case 's':
+         if (!(syntax & RE_NO_GNU_OPS))
+           token->type = OP_SPACE;
+         break;
+       case 'S':
+         if (!(syntax & RE_NO_GNU_OPS))
+           token->type = OP_NOTSPACE;
+         break;
+       case '`':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = BUF_FIRST;
+           }
+         break;
+       case '\'':
+         if (!(syntax & RE_NO_GNU_OPS))
+           {
+             token->type = ANCHOR;
+             token->opr.ctx_type = BUF_LAST;
+           }
+         break;
+       case '(':
+         if (!(syntax & RE_NO_BK_PARENS))
+           token->type = OP_OPEN_SUBEXP;
+         break;
+       case ')':
+         if (!(syntax & RE_NO_BK_PARENS))
+           token->type = OP_CLOSE_SUBEXP;
+         break;
+       case '+':
+         if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+           token->type = OP_DUP_PLUS;
+         break;
+       case '?':
+         if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+           token->type = OP_DUP_QUESTION;
+         break;
+       case '{':
+         if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+           token->type = OP_OPEN_DUP_NUM;
+         break;
+       case '}':
+         if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+           token->type = OP_CLOSE_DUP_NUM;
+         break;
+       default:
+         break;
+       }
+      return 2;
+    }
+
+  token->type = CHARACTER;
+#ifdef RE_ENABLE_I18N
+  if (input->mb_cur_max > 1)
+    {
+      wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
+      token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
+    }
+  else
+#endif
+    token->word_char = IS_WORD_CHAR (token->opr.c);
+
+  switch (c)
+    {
+    case '\n':
+      if (syntax & RE_NEWLINE_ALT)
+       token->type = OP_ALT;
+      break;
+    case '|':
+      if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
+       token->type = OP_ALT;
+      break;
+    case '*':
+      token->type = OP_DUP_ASTERISK;
+      break;
+    case '+':
+      if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+       token->type = OP_DUP_PLUS;
+      break;
+    case '?':
+      if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+       token->type = OP_DUP_QUESTION;
+      break;
+    case '{':
+      if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+       token->type = OP_OPEN_DUP_NUM;
+      break;
+    case '}':
+      if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+       token->type = OP_CLOSE_DUP_NUM;
+      break;
+    case '(':
+      if (syntax & RE_NO_BK_PARENS)
+       token->type = OP_OPEN_SUBEXP;
+      break;
+    case ')':
+      if (syntax & RE_NO_BK_PARENS)
+       token->type = OP_CLOSE_SUBEXP;
+      break;
+    case '[':
+      token->type = OP_OPEN_BRACKET;
+      break;
+    case '.':
+      token->type = OP_PERIOD;
+      break;
+    case '^':
+      if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
+         re_string_cur_idx (input) != 0)
+       {
+         char prev = re_string_peek_byte (input, -1);
+         if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
+           break;
+       }
+      token->type = ANCHOR;
+      token->opr.ctx_type = LINE_FIRST;
+      break;
+    case '$':
+      if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
+         re_string_cur_idx (input) + 1 != re_string_length (input))
+       {
+         re_token_t next;
+         re_string_skip_bytes (input, 1);
+         peek_token (&next, input, syntax);
+         re_string_skip_bytes (input, -1);
+         if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP)
+           break;
+       }
+      token->type = ANCHOR;
+      token->opr.ctx_type = LINE_LAST;
+      break;
+    default:
+      break;
+    }
+  return 1;
+}
+
+/* Peek a token from INPUT, and return the length of the token.
+   We must not use this function out of bracket expressions.  */
+
+static int
+internal_function
+peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
+{
+  unsigned char c;
+  if (re_string_eoi (input))
+    {
+      token->type = END_OF_RE;
+      return 0;
+    }
+  c = re_string_peek_byte (input, 0);
+  token->opr.c = c;
+
+#ifdef RE_ENABLE_I18N
+  if (input->mb_cur_max > 1 &&
+      !re_string_first_byte (input, re_string_cur_idx (input)))
+    {
+      token->type = CHARACTER;
+      return 1;
+    }
+#endif /* RE_ENABLE_I18N */
+
+  if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+      && re_string_cur_idx (input) + 1 < re_string_length (input))
+    {
+      /* In this case, '\' escape a character.  */
+      unsigned char c2;
+      re_string_skip_bytes (input, 1);
+      c2 = re_string_peek_byte (input, 0);
+      token->opr.c = c2;
+      token->type = CHARACTER;
+      return 1;
+    }
+  if (c == '[') /* '[' is a special char in a bracket exps.  */
+    {
+      unsigned char c2;
+      int token_len;
+      if (re_string_cur_idx (input) + 1 < re_string_length (input))
+       c2 = re_string_peek_byte (input, 1);
+      else
+       c2 = 0;
+      token->opr.c = c2;
+      token_len = 2;
+      switch (c2)
+       {
+       case '.':
+         token->type = OP_OPEN_COLL_ELEM;
+         break;
+       case '=':
+         token->type = OP_OPEN_EQUIV_CLASS;
+         break;
+       case ':':
+         if (syntax & RE_CHAR_CLASSES)
+           {
+             token->type = OP_OPEN_CHAR_CLASS;
+             break;
+           }
+         /* else fall through.  */
+       default:
+         token->type = CHARACTER;
+         token->opr.c = c;
+         token_len = 1;
+         break;
+       }
+      return token_len;
+    }
+  switch (c)
+    {
+    case '-':
+      token->type = OP_CHARSET_RANGE;
+      break;
+    case ']':
+      token->type = OP_CLOSE_BRACKET;
+      break;
+    case '^':
+      token->type = OP_NON_MATCH_LIST;
+      break;
+    default:
+      token->type = CHARACTER;
+    }
+  return 1;
+}
+\f
+/* Functions for parser.  */
+
+/* Entry point of the parser.
+   Parse the regular expression REGEXP and return the structure tree.
+   If an error is occured, ERR is set by error code, and return NULL.
+   This function build the following tree, from regular expression <reg_exp>:
+          CAT
+          / \
+         /   \
+   <reg_exp>  EOR
+
+   CAT means concatenation.
+   EOR means end of regular expression.  */
+
+static bin_tree_t *
+parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
+       reg_errcode_t *err)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_t *tree, *eor, *root;
+  re_token_t current_token;
+  dfa->syntax = syntax;
+  fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+  tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
+  if (BE (*err != REG_NOERROR && tree == NULL, 0))
+    return NULL;
+  eor = create_tree (dfa, NULL, NULL, END_OF_RE);
+  if (tree != NULL)
+    root = create_tree (dfa, tree, eor, CONCAT);
+  else
+    root = eor;
+  if (BE (eor == NULL || root == NULL, 0))
+    {
+      *err = REG_ESPACE;
+      return NULL;
+    }
+  return root;
+}
+
+/* This function build the following tree, from regular expression
+   <branch1>|<branch2>:
+          ALT
+          / \
+         /   \
+   <branch1> <branch2>
+
+   ALT means alternative, which represents the operator `|'.  */
+
+static bin_tree_t *
+parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+              reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_t *tree, *branch = NULL;
+  tree = parse_branch (regexp, preg, token, syntax, nest, err);
+  if (BE (*err != REG_NOERROR && tree == NULL, 0))
+    return NULL;
+
+  while (token->type == OP_ALT)
+    {
+      fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+      if (token->type != OP_ALT && token->type != END_OF_RE
+         && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+       {
+         branch = parse_branch (regexp, preg, token, syntax, nest, err);
+         if (BE (*err != REG_NOERROR && branch == NULL, 0))
+           return NULL;
+       }
+      else
+       branch = NULL;
+      tree = create_tree (dfa, tree, branch, OP_ALT);
+      if (BE (tree == NULL, 0))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+    }
+  return tree;
+}
+
+/* This function build the following tree, from regular expression
+   <exp1><exp2>:
+       CAT
+       / \
+       /   \
+   <exp1> <exp2>
+
+   CAT means concatenation.  */
+
+static bin_tree_t *
+parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
+             reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+  bin_tree_t *tree, *expr;
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  tree = parse_expression (regexp, preg, token, syntax, nest, err);
+  if (BE (*err != REG_NOERROR && tree == NULL, 0))
+    return NULL;
+
+  while (token->type != OP_ALT && token->type != END_OF_RE
+        && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
+    {
+      expr = parse_expression (regexp, preg, token, syntax, nest, err);
+      if (BE (*err != REG_NOERROR && expr == NULL, 0))
+       {
+         return NULL;
+       }
+      if (tree != NULL && expr != NULL)
+       {
+         tree = create_tree (dfa, tree, expr, CONCAT);
+         if (tree == NULL)
+           {
+             *err = REG_ESPACE;
+             return NULL;
+           }
+       }
+      else if (tree == NULL)
+       tree = expr;
+      /* Otherwise expr == NULL, we don't need to create new tree.  */
+    }
+  return tree;
+}
+
+/* This function build the following tree, from regular expression a*:
+        *
+        |
+        a
+*/
+
+static bin_tree_t *
+parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
+                 reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_t *tree;
+  switch (token->type)
+    {
+    case CHARACTER:
+      tree = create_token_tree (dfa, NULL, NULL, token);
+      if (BE (tree == NULL, 0))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+#ifdef RE_ENABLE_I18N
+      if (dfa->mb_cur_max > 1)
+       {
+         while (!re_string_eoi (regexp)
+                && !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
+           {
+             bin_tree_t *mbc_remain;
+             fetch_token (token, regexp, syntax);
+             mbc_remain = create_token_tree (dfa, NULL, NULL, token);
+             tree = create_tree (dfa, tree, mbc_remain, CONCAT);
+             if (BE (mbc_remain == NULL || tree == NULL, 0))
+               {
+                 *err = REG_ESPACE;
+                 return NULL;
+               }
+           }
+       }
+#endif
+      break;
+    case OP_OPEN_SUBEXP:
+      tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
+      if (BE (*err != REG_NOERROR && tree == NULL, 0))
+       return NULL;
+      break;
+    case OP_OPEN_BRACKET:
+      tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
+      if (BE (*err != REG_NOERROR && tree == NULL, 0))
+       return NULL;
+      break;
+    case OP_BACK_REF:
+      if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1))
+       {
+         *err = REG_ESUBREG;
+         return NULL;
+       }
+      dfa->used_bkref_map |= 1 << token->opr.idx;
+      tree = create_token_tree (dfa, NULL, NULL, token);
+      if (BE (tree == NULL, 0))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+      ++dfa->nbackref;
+      dfa->has_mb_node = 1;
+      break;
+    case OP_OPEN_DUP_NUM:
+      if (syntax & RE_CONTEXT_INVALID_DUP)
+       {
+         *err = REG_BADRPT;
+         return NULL;
+       }
+      /* FALLTHROUGH */
+    case OP_DUP_ASTERISK:
+    case OP_DUP_PLUS:
+    case OP_DUP_QUESTION:
+      if (syntax & RE_CONTEXT_INVALID_OPS)
+       {
+         *err = REG_BADRPT;
+         return NULL;
+       }
+      else if (syntax & RE_CONTEXT_INDEP_OPS)
+       {
+         fetch_token (token, regexp, syntax);
+         return parse_expression (regexp, preg, token, syntax, nest, err);
+       }
+      /* else fall through  */
+    case OP_CLOSE_SUBEXP:
+      if ((token->type == OP_CLOSE_SUBEXP) &&
+         !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+       {
+         *err = REG_ERPAREN;
+         return NULL;
+       }
+      /* else fall through  */
+    case OP_CLOSE_DUP_NUM:
+      /* We treat it as a normal character.  */
+
+      /* Then we can these characters as normal characters.  */
+      token->type = CHARACTER;
+      /* mb_partial and word_char bits should be initialized already
+        by peek_token.  */
+      tree = create_token_tree (dfa, NULL, NULL, token);
+      if (BE (tree == NULL, 0))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+      break;
+    case ANCHOR:
+      if ((token->opr.ctx_type
+          & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
+         && dfa->word_ops_used == 0)
+       init_word_char (dfa);
+      if (token->opr.ctx_type == WORD_DELIM
+         || token->opr.ctx_type == NOT_WORD_DELIM)
+       {
+         bin_tree_t *tree_first, *tree_last;
+         if (token->opr.ctx_type == WORD_DELIM)
+           {
+             token->opr.ctx_type = WORD_FIRST;
+             tree_first = create_token_tree (dfa, NULL, NULL, token);
+             token->opr.ctx_type = WORD_LAST;
+           }
+         else
+           {
+             token->opr.ctx_type = INSIDE_WORD;
+             tree_first = create_token_tree (dfa, NULL, NULL, token);
+             token->opr.ctx_type = INSIDE_NOTWORD;
+           }
+         tree_last = create_token_tree (dfa, NULL, NULL, token);
+         tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
+         if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
+           {
+             *err = REG_ESPACE;
+             return NULL;
+           }
+       }
+      else
+       {
+         tree = create_token_tree (dfa, NULL, NULL, token);
+         if (BE (tree == NULL, 0))
+           {
+             *err = REG_ESPACE;
+             return NULL;
+           }
+       }
+      /* We must return here, since ANCHORs can't be followed
+        by repetition operators.
+        eg. RE"^*" is invalid or "<ANCHOR(^)><CHAR(*)>",
+            it must not be "<ANCHOR(^)><REPEAT(*)>".  */
+      fetch_token (token, regexp, syntax);
+      return tree;
+    case OP_PERIOD:
+      tree = create_token_tree (dfa, NULL, NULL, token);
+      if (BE (tree == NULL, 0))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+      if (dfa->mb_cur_max > 1)
+       dfa->has_mb_node = 1;
+      break;
+    case OP_WORD:
+    case OP_NOTWORD:
+      tree = build_charclass_op (dfa, regexp->trans,
+                                (const unsigned char *) "alnum",
+                                (const unsigned char *) "_",
+                                token->type == OP_NOTWORD, err);
+      if (BE (*err != REG_NOERROR && tree == NULL, 0))
+       return NULL;
+      break;
+    case OP_SPACE:
+    case OP_NOTSPACE:
+      tree = build_charclass_op (dfa, regexp->trans,
+                                (const unsigned char *) "space",
+                                (const unsigned char *) "",
+                                token->type == OP_NOTSPACE, err);
+      if (BE (*err != REG_NOERROR && tree == NULL, 0))
+       return NULL;
+      break;
+    case OP_ALT:
+    case END_OF_RE:
+      return NULL;
+    case BACK_SLASH:
+      *err = REG_EESCAPE;
+      return NULL;
+    default:
+      /* Must not happen?  */
+#ifdef DEBUG
+      assert (0);
+#endif
+      return NULL;
+    }
+  fetch_token (token, regexp, syntax);
+
+  while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
+        || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
+    {
+      tree = parse_dup_op (tree, regexp, dfa, token, syntax, err);
+      if (BE (*err != REG_NOERROR && tree == NULL, 0))
+       return NULL;
+      /* In BRE consecutive duplications are not allowed.  */
+      if ((syntax & RE_CONTEXT_INVALID_DUP)
+         && (token->type == OP_DUP_ASTERISK
+             || token->type == OP_OPEN_DUP_NUM))
+       {
+         *err = REG_BADRPT;
+         return NULL;
+       }
+    }
+
+  return tree;
+}
+
+/* This function build the following tree, from regular expression
+   (<reg_exp>):
+        SUBEXP
+           |
+       <reg_exp>
+*/
+
+static bin_tree_t *
+parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
+              reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
+{
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+  bin_tree_t *tree;
+  size_t cur_nsub;
+  cur_nsub = preg->re_nsub++;
+
+  fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+
+  /* The subexpression may be a null string.  */
+  if (token->type == OP_CLOSE_SUBEXP)
+    tree = NULL;
+  else
+    {
+      tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
+      if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0))
+       *err = REG_EPAREN;
+      if (BE (*err != REG_NOERROR, 0))
+       return NULL;
+    }
+
+  if (cur_nsub <= '9' - '1')
+    dfa->completed_bkref_map |= 1 << cur_nsub;
+
+  tree = create_tree (dfa, tree, NULL, SUBEXP);
+  if (BE (tree == NULL, 0))
+    {
+      *err = REG_ESPACE;
+      return NULL;
+    }
+  tree->token.opr.idx = cur_nsub;
+  return tree;
+}
+
+/* This function parse repetition operators like "*", "+", "{1,3}" etc.  */
+
+static bin_tree_t *
+parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
+             re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
+{
+  bin_tree_t *tree = NULL, *old_tree = NULL;
+  Idx i, start, end, start_idx = re_string_cur_idx (regexp);
+  re_token_t start_token = *token;
+
+  if (token->type == OP_OPEN_DUP_NUM)
+    {
+      end = 0;
+      start = fetch_number (regexp, token, syntax);
+      if (start == REG_MISSING)
+       {
+         if (token->type == CHARACTER && token->opr.c == ',')
+           start = 0; /* We treat "{,m}" as "{0,m}".  */
+         else
+           {
+             *err = REG_BADBR; /* <re>{} is invalid.  */
+             return NULL;
+           }
+       }
+      if (BE (start != REG_ERROR, 1))
+       {
+         /* We treat "{n}" as "{n,n}".  */
+         end = ((token->type == OP_CLOSE_DUP_NUM) ? start
+                : ((token->type == CHARACTER && token->opr.c == ',')
+                   ? fetch_number (regexp, token, syntax) : REG_ERROR));
+       }
+      if (BE (start == REG_ERROR || end == REG_ERROR, 0))
+       {
+         /* Invalid sequence.  */
+         if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
+           {
+             if (token->type == END_OF_RE)
+               *err = REG_EBRACE;
+             else
+               *err = REG_BADBR;
+
+             return NULL;
+           }
+
+         /* If the syntax bit is set, rollback.  */
+         re_string_set_index (regexp, start_idx);
+         *token = start_token;
+         token->type = CHARACTER;
+         /* mb_partial and word_char bits should be already initialized by
+            peek_token.  */
+         return elem;
+       }
+
+      if (BE ((end != REG_MISSING && start > end)
+             || token->type != OP_CLOSE_DUP_NUM, 0))
+       {
+         /* First number greater than second.  */
+         *err = REG_BADBR;
+         return NULL;
+       }
+    }
+  else
+    {
+      start = (token->type == OP_DUP_PLUS) ? 1 : 0;
+      end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING;
+    }
+
+  fetch_token (token, regexp, syntax);
+
+  if (BE (elem == NULL, 0))
+    return NULL;
+  if (BE (start == 0 && end == 0, 0))
+    {
+      postorder (elem, free_tree, NULL);
+      return NULL;
+    }
+
+  /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}".  */
+  if (BE (start > 0, 0))
+    {
+      tree = elem;
+      for (i = 2; i <= start; ++i)
+       {
+         elem = duplicate_tree (elem, dfa);
+         tree = create_tree (dfa, tree, elem, CONCAT);
+         if (BE (elem == NULL || tree == NULL, 0))
+           goto parse_dup_op_espace;
+       }
+
+      if (start == end)
+       return tree;
+
+      /* Duplicate ELEM before it is marked optional.  */
+      elem = duplicate_tree (elem, dfa);
+      old_tree = tree;
+    }
+  else
+    old_tree = NULL;
+
+  if (elem->token.type == SUBEXP)
+    postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx);
+
+  tree = create_tree (dfa, elem, NULL,
+                     (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT));
+  if (BE (tree == NULL, 0))
+    goto parse_dup_op_espace;
+
+/* From gnulib's "intprops.h":
+   True if the arithmetic type T is signed.  */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+  /* This loop is actually executed only when end != REG_MISSING,
+     to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?...  We have
+     already created the start+1-th copy.  */
+  if (TYPE_SIGNED (Idx) || end != REG_MISSING)
+    for (i = start + 2; i <= end; ++i)
+      {
+       elem = duplicate_tree (elem, dfa);
+       tree = create_tree (dfa, tree, elem, CONCAT);
+       if (BE (elem == NULL || tree == NULL, 0))
+         goto parse_dup_op_espace;
+
+       tree = create_tree (dfa, tree, NULL, OP_ALT);
+       if (BE (tree == NULL, 0))
+         goto parse_dup_op_espace;
+      }
+
+  if (old_tree)
+    tree = create_tree (dfa, old_tree, tree, CONCAT);
+
+  return tree;
+
+ parse_dup_op_espace:
+  *err = REG_ESPACE;
+  return NULL;
+}
+
+/* Size of the names for collating symbol/equivalence_class/character_class.
+   I'm not sure, but maybe enough.  */
+#define BRACKET_NAME_BUF_SIZE 32
+
+#ifndef _LIBC
+  /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
+     Build the range expression which starts from START_ELEM, and ends
+     at END_ELEM.  The result are written to MBCSET and SBCSET.
+     RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+     mbcset->range_ends, is a pointer argument sinse we may
+     update it.  */
+
+static reg_errcode_t
+internal_function
+# ifdef RE_ENABLE_I18N
+build_range_exp (const reg_syntax_t syntax,
+                 bitset_t sbcset,
+                 re_charset_t *mbcset,
+                 Idx *range_alloc,
+                 const bracket_elem_t *start_elem,
+                 const bracket_elem_t *end_elem)
+# else /* not RE_ENABLE_I18N */
+build_range_exp (const reg_syntax_t syntax,
+                 bitset_t sbcset,
+                 const bracket_elem_t *start_elem,
+                 const bracket_elem_t *end_elem)
+# endif /* not RE_ENABLE_I18N */
+{
+  unsigned int start_ch, end_ch;
+  /* Equivalence Classes and Character Classes can't be a range start/end.  */
+  if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
+         || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
+         0))
+    return REG_ERANGE;
+
+  /* We can handle no multi character collating elements without libc
+     support.  */
+  if (BE ((start_elem->type == COLL_SYM
+          && strlen ((char *) start_elem->opr.name) > 1)
+         || (end_elem->type == COLL_SYM
+             && strlen ((char *) end_elem->opr.name) > 1), 0))
+    return REG_ECOLLATE;
+
+# ifdef RE_ENABLE_I18N
+  {
+    wchar_t wc;
+    wint_t start_wc;
+    wint_t end_wc;
+    wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+
+    start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
+               : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+                  : 0));
+    end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
+             : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+                : 0));
+    start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
+               ? __btowc (start_ch) : start_elem->opr.wch);
+    end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
+             ? __btowc (end_ch) : end_elem->opr.wch);
+    if (start_wc == WEOF || end_wc == WEOF)
+      return REG_ECOLLATE;
+    cmp_buf[0] = start_wc;
+    cmp_buf[4] = end_wc;
+
+    if (BE ((syntax & RE_NO_EMPTY_RANGES)
+            && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0))
+      return REG_ERANGE;
+
+    /* Got valid collation sequence values, add them as a new entry.
+       However, for !_LIBC we have no collation elements: if the
+       character set is single byte, the single byte character set
+       that we build below suffices.  parse_bracket_exp passes
+       no MBCSET if dfa->mb_cur_max == 1.  */
+    if (mbcset)
+      {
+       /* Check the space of the arrays.  */
+       if (BE (*range_alloc == mbcset->nranges, 0))
+         {
+           /* There is not enough space, need realloc.  */
+           wchar_t *new_array_start, *new_array_end;
+           Idx new_nranges;
+
+           /* +1 in case of mbcset->nranges is 0.  */
+           new_nranges = 2 * mbcset->nranges + 1;
+           /* Use realloc since mbcset->range_starts and mbcset->range_ends
+              are NULL if *range_alloc == 0.  */
+           new_array_start = re_realloc (mbcset->range_starts, wchar_t,
+                                         new_nranges);
+           new_array_end = re_realloc (mbcset->range_ends, wchar_t,
+                                       new_nranges);
+
+           if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+             return REG_ESPACE;
+
+           mbcset->range_starts = new_array_start;
+           mbcset->range_ends = new_array_end;
+           *range_alloc = new_nranges;
+         }
+
+       mbcset->range_starts[mbcset->nranges] = start_wc;
+       mbcset->range_ends[mbcset->nranges++] = end_wc;
+      }
+
+    /* Build the table for single byte characters.  */
+    for (wc = 0; wc < SBC_MAX; ++wc)
+      {
+       cmp_buf[2] = wc;
+       if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+           && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+         bitset_set (sbcset, wc);
+      }
+  }
+# else /* not RE_ENABLE_I18N */
+  {
+    unsigned int ch;
+    start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
+               : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
+                  : 0));
+    end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
+             : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
+                : 0));
+    if (start_ch > end_ch)
+      return REG_ERANGE;
+    /* Build the table for single byte characters.  */
+    for (ch = 0; ch < SBC_MAX; ++ch)
+      if (start_ch <= ch  && ch <= end_ch)
+       bitset_set (sbcset, ch);
+  }
+# endif /* not RE_ENABLE_I18N */
+  return REG_NOERROR;
+}
+#endif /* not _LIBC */
+
+#ifndef _LIBC
+/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
+   Build the collating element which is represented by NAME.
+   The result are written to MBCSET and SBCSET.
+   COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+   pointer argument since we may update it.  */
+
+static reg_errcode_t
+internal_function
+build_collating_symbol (bitset_t sbcset,
+# ifdef RE_ENABLE_I18N
+                       re_charset_t *mbcset, Idx *coll_sym_alloc,
+# endif
+                       const unsigned char *name)
+{
+  size_t name_len = strlen ((const char *) name);
+  if (BE (name_len != 1, 0))
+    return REG_ECOLLATE;
+  else
+    {
+      bitset_set (sbcset, name[0]);
+      return REG_NOERROR;
+    }
+}
+#endif /* not _LIBC */
+
+/* This function parse bracket expression like "[abc]", "[a-c]",
+   "[[.a-a.]]" etc.  */
+
+static bin_tree_t *
+parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
+                  reg_syntax_t syntax, reg_errcode_t *err)
+{
+#ifdef _LIBC
+  const unsigned char *collseqmb;
+  const char *collseqwc;
+  uint32_t nrules;
+  int32_t table_size;
+  const int32_t *symb_table;
+  const unsigned char *extra;
+
+  /* Local function for parse_bracket_exp used in _LIBC environement.
+     Seek the collating symbol entry correspondings to NAME.
+     Return the index of the symbol in the SYMB_TABLE.  */
+
+  auto inline int32_t
+  __attribute ((always_inline))
+  seek_collating_symbol_entry (name, name_len)
+        const unsigned char *name;
+        size_t name_len;
+    {
+      int32_t hash = elem_hash ((const char *) name, name_len);
+      int32_t elem = hash % table_size;
+      if (symb_table[2 * elem] != 0)
+       {
+         int32_t second = hash % (table_size - 2) + 1;
+
+         do
+           {
+             /* First compare the hashing value.  */
+             if (symb_table[2 * elem] == hash
+                 /* Compare the length of the name.  */
+                 && name_len == extra[symb_table[2 * elem + 1]]
+                 /* Compare the name.  */
+                 && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
+                            name_len) == 0)
+               {
+                 /* Yep, this is the entry.  */
+                 break;
+               }
+
+             /* Next entry.  */
+             elem += second;
+           }
+         while (symb_table[2 * elem] != 0);
+       }
+      return elem;
+    }
+
+  /* Local function for parse_bracket_exp used in _LIBC environment.
+     Look up the collation sequence value of BR_ELEM.
+     Return the value if succeeded, UINT_MAX otherwise.  */
+
+  auto inline unsigned int
+  __attribute ((always_inline))
+  lookup_collation_sequence_value (br_elem)
+        bracket_elem_t *br_elem;
+    {
+      if (br_elem->type == SB_CHAR)
+       {
+         /*
+         if (MB_CUR_MAX == 1)
+         */
+         if (nrules == 0)
+           return collseqmb[br_elem->opr.ch];
+         else
+           {
+             wint_t wc = __btowc (br_elem->opr.ch);
+             return __collseq_table_lookup (collseqwc, wc);
+           }
+       }
+      else if (br_elem->type == MB_CHAR)
+       {
+         if (nrules != 0)
+           return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
+       }
+      else if (br_elem->type == COLL_SYM)
+       {
+         size_t sym_name_len = strlen ((char *) br_elem->opr.name);
+         if (nrules != 0)
+           {
+             int32_t elem, idx;
+             elem = seek_collating_symbol_entry (br_elem->opr.name,
+                                                 sym_name_len);
+             if (symb_table[2 * elem] != 0)
+               {
+                 /* We found the entry.  */
+                 idx = symb_table[2 * elem + 1];
+                 /* Skip the name of collating element name.  */
+                 idx += 1 + extra[idx];
+                 /* Skip the byte sequence of the collating element.  */
+                 idx += 1 + extra[idx];
+                 /* Adjust for the alignment.  */
+                 idx = (idx + 3) & ~3;
+                 /* Skip the multibyte collation sequence value.  */
+                 idx += sizeof (unsigned int);
+                 /* Skip the wide char sequence of the collating element.  */
+                 idx += sizeof (unsigned int) *
+                   (1 + *(unsigned int *) (extra + idx));
+                 /* Return the collation sequence value.  */
+                 return *(unsigned int *) (extra + idx);
+               }
+             else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
+               {
+                 /* No valid character.  Match it as a single byte
+                    character.  */
+                 return collseqmb[br_elem->opr.name[0]];
+               }
+           }
+         else if (sym_name_len == 1)
+           return collseqmb[br_elem->opr.name[0]];
+       }
+      return UINT_MAX;
+    }
+
+  /* Local function for parse_bracket_exp used in _LIBC environement.
+     Build the range expression which starts from START_ELEM, and ends
+     at END_ELEM.  The result are written to MBCSET and SBCSET.
+     RANGE_ALLOC is the allocated size of mbcset->range_starts, and
+     mbcset->range_ends, is a pointer argument sinse we may
+     update it.  */
+
+  auto inline reg_errcode_t
+  __attribute ((always_inline))
+  build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
+        re_charset_t *mbcset;
+        Idx *range_alloc;
+        bitset_t sbcset;
+        bracket_elem_t *start_elem, *end_elem;
+    {
+      unsigned int ch;
+      uint32_t start_collseq;
+      uint32_t end_collseq;
+
+      /* Equivalence Classes and Character Classes can't be a range
+        start/end.  */
+      if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
+             || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
+             0))
+       return REG_ERANGE;
+
+      start_collseq = lookup_collation_sequence_value (start_elem);
+      end_collseq = lookup_collation_sequence_value (end_elem);
+      /* Check start/end collation sequence values.  */
+      if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
+       return REG_ECOLLATE;
+      if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
+       return REG_ERANGE;
+
+      /* Got valid collation sequence values, add them as a new entry.
+        However, if we have no collation elements, and the character set
+        is single byte, the single byte character set that we
+        build below suffices. */
+      if (nrules > 0 || dfa->mb_cur_max > 1)
+       {
+         /* Check the space of the arrays.  */
+         if (BE (*range_alloc == mbcset->nranges, 0))
+           {
+             /* There is not enough space, need realloc.  */
+             uint32_t *new_array_start;
+             uint32_t *new_array_end;
+             Idx new_nranges;
+
+             /* +1 in case of mbcset->nranges is 0.  */
+             new_nranges = 2 * mbcset->nranges + 1;
+             new_array_start = re_realloc (mbcset->range_starts, uint32_t,
+                                           new_nranges);
+             new_array_end = re_realloc (mbcset->range_ends, uint32_t,
+                                         new_nranges);
+
+             if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+               return REG_ESPACE;
+
+             mbcset->range_starts = new_array_start;
+             mbcset->range_ends = new_array_end;
+             *range_alloc = new_nranges;
+           }
+
+         mbcset->range_starts[mbcset->nranges] = start_collseq;
+         mbcset->range_ends[mbcset->nranges++] = end_collseq;
+       }
+
+      /* Build the table for single byte characters.  */
+      for (ch = 0; ch < SBC_MAX; ch++)
+       {
+         uint32_t ch_collseq;
+         /*
+         if (MB_CUR_MAX == 1)
+         */
+         if (nrules == 0)
+           ch_collseq = collseqmb[ch];
+         else
+           ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
+         if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
+           bitset_set (sbcset, ch);
+       }
+      return REG_NOERROR;
+    }
+
+  /* Local function for parse_bracket_exp used in _LIBC environement.
+     Build the collating element which is represented by NAME.
+     The result are written to MBCSET and SBCSET.
+     COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
+     pointer argument sinse we may update it.  */
+
+  auto inline reg_errcode_t
+  __attribute ((always_inline))
+  build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
+        re_charset_t *mbcset;
+        Idx *coll_sym_alloc;
+        bitset_t sbcset;
+        const unsigned char *name;
+    {
+      int32_t elem, idx;
+      size_t name_len = strlen ((const char *) name);
+      if (nrules != 0)
+       {
+         elem = seek_collating_symbol_entry (name, name_len);
+         if (symb_table[2 * elem] != 0)
+           {
+             /* We found the entry.  */
+             idx = symb_table[2 * elem + 1];
+             /* Skip the name of collating element name.  */
+             idx += 1 + extra[idx];
+           }
+         else if (symb_table[2 * elem] == 0 && name_len == 1)
+           {
+             /* No valid character, treat it as a normal
+                character.  */
+             bitset_set (sbcset, name[0]);
+             return REG_NOERROR;
+           }
+         else
+           return REG_ECOLLATE;
+
+         /* Got valid collation sequence, add it as a new entry.  */
+         /* Check the space of the arrays.  */
+         if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
+           {
+             /* Not enough, realloc it.  */
+             /* +1 in case of mbcset->ncoll_syms is 0.  */
+             Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
+             /* Use realloc since mbcset->coll_syms is NULL
+                if *alloc == 0.  */
+             int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
+                                                  new_coll_sym_alloc);
+             if (BE (new_coll_syms == NULL, 0))
+               return REG_ESPACE;
+             mbcset->coll_syms = new_coll_syms;
+             *coll_sym_alloc = new_coll_sym_alloc;
+           }
+         mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
+         return REG_NOERROR;
+       }
+      else
+       {
+         if (BE (name_len != 1, 0))
+           return REG_ECOLLATE;
+         else
+           {
+             bitset_set (sbcset, name[0]);
+             return REG_NOERROR;
+           }
+       }
+    }
+#endif
+
+  re_token_t br_token;
+  re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+  re_charset_t *mbcset;
+  Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
+  Idx equiv_class_alloc = 0, char_class_alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+  bool non_match = false;
+  bin_tree_t *work_tree;
+  int token_len;
+  bool first_round = true;
+#ifdef _LIBC
+  collseqmb = (const unsigned char *)
+    _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+  nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+  if (nrules)
+    {
+      /*
+      if (MB_CUR_MAX > 1)
+      */
+      collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+      table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
+      symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+                                                 _NL_COLLATE_SYMB_TABLEMB);
+      extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+                                                  _NL_COLLATE_SYMB_EXTRAMB);
+    }
+#endif
+  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+#ifdef RE_ENABLE_I18N
+  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+#endif /* RE_ENABLE_I18N */
+#ifdef RE_ENABLE_I18N
+  if (BE (sbcset == NULL || mbcset == NULL, 0))
+#else
+  if (BE (sbcset == NULL, 0))
+#endif /* RE_ENABLE_I18N */
+    {
+      *err = REG_ESPACE;
+      return NULL;
+    }
+
+  token_len = peek_token_bracket (token, regexp, syntax);
+  if (BE (token->type == END_OF_RE, 0))
+    {
+      *err = REG_BADPAT;
+      goto parse_bracket_exp_free_return;
+    }
+  if (token->type == OP_NON_MATCH_LIST)
+    {
+#ifdef RE_ENABLE_I18N
+      mbcset->non_match = 1;
+#endif /* not RE_ENABLE_I18N */
+      non_match = true;
+      if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+       bitset_set (sbcset, '\n');
+      re_string_skip_bytes (regexp, token_len); /* Skip a token.  */
+      token_len = peek_token_bracket (token, regexp, syntax);
+      if (BE (token->type == END_OF_RE, 0))
+       {
+         *err = REG_BADPAT;
+         goto parse_bracket_exp_free_return;
+       }
+    }
+
+  /* We treat the first ']' as a normal character.  */
+  if (token->type == OP_CLOSE_BRACKET)
+    token->type = CHARACTER;
+
+  while (1)
+    {
+      bracket_elem_t start_elem, end_elem;
+      unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE];
+      unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE];
+      reg_errcode_t ret;
+      int token_len2 = 0;
+      bool is_range_exp = false;
+      re_token_t token2;
+
+      start_elem.opr.name = start_name_buf;
+      ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
+                                  syntax, first_round);
+      if (BE (ret != REG_NOERROR, 0))
+       {
+         *err = ret;
+         goto parse_bracket_exp_free_return;
+       }
+      first_round = false;
+
+      /* Get information about the next token.  We need it in any case.  */
+      token_len = peek_token_bracket (token, regexp, syntax);
+
+      /* Do not check for ranges if we know they are not allowed.  */
+      if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
+       {
+         if (BE (token->type == END_OF_RE, 0))
+           {
+             *err = REG_EBRACK;
+             goto parse_bracket_exp_free_return;
+           }
+         if (token->type == OP_CHARSET_RANGE)
+           {
+             re_string_skip_bytes (regexp, token_len); /* Skip '-'.  */
+             token_len2 = peek_token_bracket (&token2, regexp, syntax);
+             if (BE (token2.type == END_OF_RE, 0))
+               {
+                 *err = REG_EBRACK;
+                 goto parse_bracket_exp_free_return;
+               }
+             if (token2.type == OP_CLOSE_BRACKET)
+               {
+                 /* We treat the last '-' as a normal character.  */
+                 re_string_skip_bytes (regexp, -token_len);
+                 token->type = CHARACTER;
+               }
+             else
+               is_range_exp = true;
+           }
+       }
+
+      if (is_range_exp == true)
+       {
+         end_elem.opr.name = end_name_buf;
+         ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
+                                      dfa, syntax, true);
+         if (BE (ret != REG_NOERROR, 0))
+           {
+             *err = ret;
+             goto parse_bracket_exp_free_return;
+           }
+
+         token_len = peek_token_bracket (token, regexp, syntax);
+
+#ifdef _LIBC
+         *err = build_range_exp (sbcset, mbcset, &range_alloc,
+                                 &start_elem, &end_elem);
+#else
+# ifdef RE_ENABLE_I18N
+         *err = build_range_exp (syntax, sbcset,
+                                 dfa->mb_cur_max > 1 ? mbcset : NULL,
+                                 &range_alloc, &start_elem, &end_elem);
+# else
+         *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
+# endif
+#endif /* RE_ENABLE_I18N */
+         if (BE (*err != REG_NOERROR, 0))
+           goto parse_bracket_exp_free_return;
+       }
+      else
+       {
+         switch (start_elem.type)
+           {
+           case SB_CHAR:
+             bitset_set (sbcset, start_elem.opr.ch);
+             break;
+#ifdef RE_ENABLE_I18N
+           case MB_CHAR:
+             /* Check whether the array has enough space.  */
+             if (BE (mbchar_alloc == mbcset->nmbchars, 0))
+               {
+                 wchar_t *new_mbchars;
+                 /* Not enough, realloc it.  */
+                 /* +1 in case of mbcset->nmbchars is 0.  */
+                 mbchar_alloc = 2 * mbcset->nmbchars + 1;
+                 /* Use realloc since array is NULL if *alloc == 0.  */
+                 new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
+                                           mbchar_alloc);
+                 if (BE (new_mbchars == NULL, 0))
+                   goto parse_bracket_exp_espace;
+                 mbcset->mbchars = new_mbchars;
+               }
+             mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
+             break;
+#endif /* RE_ENABLE_I18N */
+           case EQUIV_CLASS:
+             *err = build_equiv_class (sbcset,
+#ifdef RE_ENABLE_I18N
+                                       mbcset, &equiv_class_alloc,
+#endif /* RE_ENABLE_I18N */
+                                       start_elem.opr.name);
+             if (BE (*err != REG_NOERROR, 0))
+               goto parse_bracket_exp_free_return;
+             break;
+           case COLL_SYM:
+             *err = build_collating_symbol (sbcset,
+#ifdef RE_ENABLE_I18N
+                                            mbcset, &coll_sym_alloc,
+#endif /* RE_ENABLE_I18N */
+                                            start_elem.opr.name);
+             if (BE (*err != REG_NOERROR, 0))
+               goto parse_bracket_exp_free_return;
+             break;
+           case CHAR_CLASS:
+             *err = build_charclass (regexp->trans, sbcset,
+#ifdef RE_ENABLE_I18N
+                                     mbcset, &char_class_alloc,
+#endif /* RE_ENABLE_I18N */
+                                     start_elem.opr.name, syntax);
+             if (BE (*err != REG_NOERROR, 0))
+              goto parse_bracket_exp_free_return;
+             break;
+           default:
+             assert (0);
+             break;
+           }
+       }
+      if (BE (token->type == END_OF_RE, 0))
+       {
+         *err = REG_EBRACK;
+         goto parse_bracket_exp_free_return;
+       }
+      if (token->type == OP_CLOSE_BRACKET)
+       break;
+    }
+
+  re_string_skip_bytes (regexp, token_len); /* Skip a token.  */
+
+  /* If it is non-matching list.  */
+  if (non_match)
+    bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+  /* Ensure only single byte characters are set.  */
+  if (dfa->mb_cur_max > 1)
+    bitset_mask (sbcset, dfa->sb_char);
+
+  if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes
+      || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes
+                                                    || mbcset->non_match)))
+    {
+      bin_tree_t *mbc_tree;
+      int sbc_idx;
+      /* Build a tree for complex bracket.  */
+      dfa->has_mb_node = 1;
+      br_token.type = COMPLEX_BRACKET;
+      br_token.opr.mbcset = mbcset;
+      mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+      if (BE (mbc_tree == NULL, 0))
+       goto parse_bracket_exp_espace;
+      for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
+       if (sbcset[sbc_idx])
+         break;
+      /* If there are no bits set in sbcset, there is no point
+        of having both SIMPLE_BRACKET and COMPLEX_BRACKET.  */
+      if (sbc_idx < BITSET_WORDS)
+       {
+         /* Build a tree for simple bracket.  */
+         br_token.type = SIMPLE_BRACKET;
+         br_token.opr.sbcset = sbcset;
+         work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+         if (BE (work_tree == NULL, 0))
+           goto parse_bracket_exp_espace;
+
+         /* Then join them by ALT node.  */
+         work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
+         if (BE (work_tree == NULL, 0))
+           goto parse_bracket_exp_espace;
+       }
+      else
+       {
+         re_free (sbcset);
+         work_tree = mbc_tree;
+       }
+    }
+  else
+#endif /* not RE_ENABLE_I18N */
+    {
+#ifdef RE_ENABLE_I18N
+      free_charset (mbcset);
+#endif
+      /* Build a tree for simple bracket.  */
+      br_token.type = SIMPLE_BRACKET;
+      br_token.opr.sbcset = sbcset;
+      work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+      if (BE (work_tree == NULL, 0))
+       goto parse_bracket_exp_espace;
+    }
+  return work_tree;
+
+ parse_bracket_exp_espace:
+  *err = REG_ESPACE;
+ parse_bracket_exp_free_return:
+  re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+  free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+  return NULL;
+}
+
+/* Parse an element in the bracket expression.  */
+
+static reg_errcode_t
+parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
+                      re_token_t *token, int token_len, re_dfa_t *dfa,
+                      reg_syntax_t syntax, bool accept_hyphen)
+{
+#ifdef RE_ENABLE_I18N
+  int cur_char_size;
+  cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
+  if (cur_char_size > 1)
+    {
+      elem->type = MB_CHAR;
+      elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
+      re_string_skip_bytes (regexp, cur_char_size);
+      return REG_NOERROR;
+    }
+#endif /* RE_ENABLE_I18N */
+  re_string_skip_bytes (regexp, token_len); /* Skip a token.  */
+  if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
+      || token->type == OP_OPEN_EQUIV_CLASS)
+    return parse_bracket_symbol (elem, regexp, token);
+  if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen)
+    {
+      /* A '-' must only appear as anything but a range indicator before
+        the closing bracket.  Everything else is an error.  */
+      re_token_t token2;
+      (void) peek_token_bracket (&token2, regexp, syntax);
+      if (token2.type != OP_CLOSE_BRACKET)
+       /* The actual error value is not standardized since this whole
+          case is undefined.  But ERANGE makes good sense.  */
+       return REG_ERANGE;
+    }
+  elem->type = SB_CHAR;
+  elem->opr.ch = token->opr.c;
+  return REG_NOERROR;
+}
+
+/* Parse a bracket symbol in the bracket expression.  Bracket symbols are
+   such as [:<character_class>:], [.<collating_element>.], and
+   [=<equivalent_class>=].  */
+
+static reg_errcode_t
+parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
+                     re_token_t *token)
+{
+  unsigned char ch, delim = token->opr.c;
+  int i = 0;
+  if (re_string_eoi(regexp))
+    return REG_EBRACK;
+  for (;; ++i)
+    {
+      if (i >= BRACKET_NAME_BUF_SIZE)
+       return REG_EBRACK;
+      if (token->type == OP_OPEN_CHAR_CLASS)
+       ch = re_string_fetch_byte_case (regexp);
+      else
+       ch = re_string_fetch_byte (regexp);
+      if (re_string_eoi(regexp))
+       return REG_EBRACK;
+      if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
+       break;
+      elem->opr.name[i] = ch;
+    }
+  re_string_skip_bytes (regexp, 1);
+  elem->opr.name[i] = '\0';
+  switch (token->type)
+    {
+    case OP_OPEN_COLL_ELEM:
+      elem->type = COLL_SYM;
+      break;
+    case OP_OPEN_EQUIV_CLASS:
+      elem->type = EQUIV_CLASS;
+      break;
+    case OP_OPEN_CHAR_CLASS:
+      elem->type = CHAR_CLASS;
+      break;
+    default:
+      break;
+    }
+  return REG_NOERROR;
+}
+
+  /* Helper function for parse_bracket_exp.
+     Build the equivalence class which is represented by NAME.
+     The result are written to MBCSET and SBCSET.
+     EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
+     is a pointer argument sinse we may update it.  */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
+                  Idx *equiv_class_alloc, const unsigned char *name)
+#else /* not RE_ENABLE_I18N */
+build_equiv_class (bitset_t sbcset, const unsigned char *name)
+#endif /* not RE_ENABLE_I18N */
+{
+#ifdef _LIBC
+  uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+  if (nrules != 0)
+    {
+      const int32_t *table, *indirect;
+      const unsigned char *weights, *extra, *cp;
+      unsigned char char_buf[2];
+      int32_t idx1, idx2;
+      unsigned int ch;
+      size_t len;
+      /* This #include defines a local function!  */
+# include <locale/weight.h>
+      /* Calculate the index for equivalence class.  */
+      cp = name;
+      table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+      weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+                                              _NL_COLLATE_WEIGHTMB);
+      extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+                                                  _NL_COLLATE_EXTRAMB);
+      indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_INDIRECTMB);
+      idx1 = findidx (&cp);
+      if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0))
+       /* This isn't a valid character.  */
+       return REG_ECOLLATE;
+
+      /* Build single byte matcing table for this equivalence class.  */
+      char_buf[1] = (unsigned char) '\0';
+      len = weights[idx1 & 0xffffff];
+      for (ch = 0; ch < SBC_MAX; ++ch)
+       {
+         char_buf[0] = ch;
+         cp = char_buf;
+         idx2 = findidx (&cp);
+/*
+         idx2 = table[ch];
+*/
+         if (idx2 == 0)
+           /* This isn't a valid character.  */
+           continue;
+         /* Compare only if the length matches and the collation rule
+            index is the same.  */
+         if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24))
+           {
+             int cnt = 0;
+
+             while (cnt <= len &&
+                    weights[(idx1 & 0xffffff) + 1 + cnt]
+                    == weights[(idx2 & 0xffffff) + 1 + cnt])
+               ++cnt;
+
+             if (cnt > len)
+               bitset_set (sbcset, ch);
+           }
+       }
+      /* Check whether the array has enough space.  */
+      if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0))
+       {
+         /* Not enough, realloc it.  */
+         /* +1 in case of mbcset->nequiv_classes is 0.  */
+         Idx new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1;
+         /* Use realloc since the array is NULL if *alloc == 0.  */
+         int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
+                                                  int32_t,
+                                                  new_equiv_class_alloc);
+         if (BE (new_equiv_classes == NULL, 0))
+           return REG_ESPACE;
+         mbcset->equiv_classes = new_equiv_classes;
+         *equiv_class_alloc = new_equiv_class_alloc;
+       }
+      mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
+    }
+  else
+#endif /* _LIBC */
+    {
+      if (BE (strlen ((const char *) name) != 1, 0))
+       return REG_ECOLLATE;
+      bitset_set (sbcset, *name);
+    }
+  return REG_NOERROR;
+}
+
+  /* Helper function for parse_bracket_exp.
+     Build the character class which is represented by NAME.
+     The result are written to MBCSET and SBCSET.
+     CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
+     is a pointer argument sinse we may update it.  */
+
+static reg_errcode_t
+#ifdef RE_ENABLE_I18N
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+                re_charset_t *mbcset, Idx *char_class_alloc,
+                const unsigned char *class_name, reg_syntax_t syntax)
+#else /* not RE_ENABLE_I18N */
+build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+                const unsigned char *class_name, reg_syntax_t syntax)
+#endif /* not RE_ENABLE_I18N */
+{
+  int i;
+  const char *name = (const char *) class_name;
+
+  /* In case of REG_ICASE "upper" and "lower" match the both of
+     upper and lower cases.  */
+  if ((syntax & RE_ICASE)
+      && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
+    name = "alpha";
+
+#ifdef RE_ENABLE_I18N
+  /* Check the space of the arrays.  */
+  if (BE (*char_class_alloc == mbcset->nchar_classes, 0))
+    {
+      /* Not enough, realloc it.  */
+      /* +1 in case of mbcset->nchar_classes is 0.  */
+      Idx new_char_class_alloc = 2 * mbcset->nchar_classes + 1;
+      /* Use realloc since array is NULL if *alloc == 0.  */
+      wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
+                                              new_char_class_alloc);
+      if (BE (new_char_classes == NULL, 0))
+       return REG_ESPACE;
+      mbcset->char_classes = new_char_classes;
+      *char_class_alloc = new_char_class_alloc;
+    }
+  mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
+#endif /* RE_ENABLE_I18N */
+
+#define BUILD_CHARCLASS_LOOP(ctype_func)       \
+  do {                                         \
+    if (BE (trans != NULL, 0))                 \
+      {                                                \
+       for (i = 0; i < SBC_MAX; ++i)           \
+         if (ctype_func (i))                   \
+           bitset_set (sbcset, trans[i]);      \
+      }                                                \
+    else                                       \
+      {                                                \
+       for (i = 0; i < SBC_MAX; ++i)           \
+         if (ctype_func (i))                   \
+           bitset_set (sbcset, i);             \
+      }                                                \
+  } while (0)
+
+  if (strcmp (name, "alnum") == 0)
+    BUILD_CHARCLASS_LOOP (isalnum);
+  else if (strcmp (name, "cntrl") == 0)
+    BUILD_CHARCLASS_LOOP (iscntrl);
+  else if (strcmp (name, "lower") == 0)
+    BUILD_CHARCLASS_LOOP (islower);
+  else if (strcmp (name, "space") == 0)
+    BUILD_CHARCLASS_LOOP (isspace);
+  else if (strcmp (name, "alpha") == 0)
+    BUILD_CHARCLASS_LOOP (isalpha);
+  else if (strcmp (name, "digit") == 0)
+    BUILD_CHARCLASS_LOOP (isdigit);
+  else if (strcmp (name, "print") == 0)
+    BUILD_CHARCLASS_LOOP (isprint);
+  else if (strcmp (name, "upper") == 0)
+    BUILD_CHARCLASS_LOOP (isupper);
+  else if (strcmp (name, "blank") == 0)
+    BUILD_CHARCLASS_LOOP (isblank);
+  else if (strcmp (name, "graph") == 0)
+    BUILD_CHARCLASS_LOOP (isgraph);
+  else if (strcmp (name, "punct") == 0)
+    BUILD_CHARCLASS_LOOP (ispunct);
+  else if (strcmp (name, "xdigit") == 0)
+    BUILD_CHARCLASS_LOOP (isxdigit);
+  else
+    return REG_ECTYPE;
+
+  return REG_NOERROR;
+}
+
+static bin_tree_t *
+build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+                   const unsigned char *class_name,
+                   const unsigned char *extra, bool non_match,
+                   reg_errcode_t *err)
+{
+  re_bitset_ptr_t sbcset;
+#ifdef RE_ENABLE_I18N
+  re_charset_t *mbcset;
+  Idx alloc = 0;
+#endif /* not RE_ENABLE_I18N */
+  reg_errcode_t ret;
+  re_token_t br_token;
+  bin_tree_t *tree;
+
+  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+#ifdef RE_ENABLE_I18N
+  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+#endif /* RE_ENABLE_I18N */
+
+#ifdef RE_ENABLE_I18N
+  if (BE (sbcset == NULL || mbcset == NULL, 0))
+#else /* not RE_ENABLE_I18N */
+  if (BE (sbcset == NULL, 0))
+#endif /* not RE_ENABLE_I18N */
+    {
+      *err = REG_ESPACE;
+      return NULL;
+    }
+
+  if (non_match)
+    {
+#ifdef RE_ENABLE_I18N
+      mbcset->non_match = 1;
+#endif /* not RE_ENABLE_I18N */
+    }
+
+  /* We don't care the syntax in this case.  */
+  ret = build_charclass (trans, sbcset,
+#ifdef RE_ENABLE_I18N
+                        mbcset, &alloc,
+#endif /* RE_ENABLE_I18N */
+                        class_name, 0);
+
+  if (BE (ret != REG_NOERROR, 0))
+    {
+      re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+      free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+      *err = ret;
+      return NULL;
+    }
+  /* \w match '_' also.  */
+  for (; *extra; extra++)
+    bitset_set (sbcset, *extra);
+
+  /* If it is non-matching list.  */
+  if (non_match)
+    bitset_not (sbcset);
+
+#ifdef RE_ENABLE_I18N
+  /* Ensure only single byte characters are set.  */
+  if (dfa->mb_cur_max > 1)
+    bitset_mask (sbcset, dfa->sb_char);
+#endif
+
+  /* Build a tree for simple bracket.  */
+  br_token.type = SIMPLE_BRACKET;
+  br_token.opr.sbcset = sbcset;
+  tree = create_token_tree (dfa, NULL, NULL, &br_token);
+  if (BE (tree == NULL, 0))
+    goto build_word_op_espace;
+
+#ifdef RE_ENABLE_I18N
+  if (dfa->mb_cur_max > 1)
+    {
+      bin_tree_t *mbc_tree;
+      /* Build a tree for complex bracket.  */
+      br_token.type = COMPLEX_BRACKET;
+      br_token.opr.mbcset = mbcset;
+      dfa->has_mb_node = 1;
+      mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+      if (BE (mbc_tree == NULL, 0))
+       goto build_word_op_espace;
+      /* Then join them by ALT node.  */
+      tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
+      if (BE (mbc_tree != NULL, 1))
+       return tree;
+    }
+  else
+    {
+      free_charset (mbcset);
+      return tree;
+    }
+#else /* not RE_ENABLE_I18N */
+  return tree;
+#endif /* not RE_ENABLE_I18N */
+
+ build_word_op_espace:
+  re_free (sbcset);
+#ifdef RE_ENABLE_I18N
+  free_charset (mbcset);
+#endif /* RE_ENABLE_I18N */
+  *err = REG_ESPACE;
+  return NULL;
+}
+
+/* This is intended for the expressions like "a{1,3}".
+   Fetch a number from `input', and return the number.
+   Return REG_MISSING if the number field is empty like "{,1}".
+   Return REG_ERROR if an error occurred.  */
+
+static Idx
+fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
+{
+  Idx num = REG_MISSING;
+  unsigned char c;
+  while (1)
+    {
+      fetch_token (token, input, syntax);
+      c = token->opr.c;
+      if (BE (token->type == END_OF_RE, 0))
+       return REG_ERROR;
+      if (token->type == OP_CLOSE_DUP_NUM || c == ',')
+       break;
+      num = ((token->type != CHARACTER || c < '0' || '9' < c
+             || num == REG_ERROR)
+            ? REG_ERROR
+            : ((num == REG_MISSING) ? c - '0' : num * 10 + c - '0'));
+      num = (num > RE_DUP_MAX) ? REG_ERROR : num;
+    }
+  return num;
+}
+\f
+#ifdef RE_ENABLE_I18N
+static void
+free_charset (re_charset_t *cset)
+{
+  re_free (cset->mbchars);
+# ifdef _LIBC
+  re_free (cset->coll_syms);
+  re_free (cset->equiv_classes);
+  re_free (cset->range_starts);
+  re_free (cset->range_ends);
+# endif
+  re_free (cset->char_classes);
+  re_free (cset);
+}
+#endif /* RE_ENABLE_I18N */
+\f
+/* Functions for binary tree operation.  */
+
+/* Create a tree node.  */
+
+static bin_tree_t *
+create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+            re_token_type_t type)
+{
+  re_token_t t;
+  t.type = type;
+  return create_token_tree (dfa, left, right, &t);
+}
+
+static bin_tree_t *
+create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+                  const re_token_t *token)
+{
+  bin_tree_t *tree;
+  if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0))
+    {
+      bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
+
+      if (storage == NULL)
+       return NULL;
+      storage->next = dfa->str_tree_storage;
+      dfa->str_tree_storage = storage;
+      dfa->str_tree_storage_idx = 0;
+    }
+  tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++];
+
+  tree->parent = NULL;
+  tree->left = left;
+  tree->right = right;
+  tree->token = *token;
+  tree->token.duplicated = 0;
+  tree->token.opt_subexp = 0;
+  tree->first = NULL;
+  tree->next = NULL;
+  tree->node_idx = REG_MISSING;
+
+  if (left != NULL)
+    left->parent = tree;
+  if (right != NULL)
+    right->parent = tree;
+  return tree;
+}
+
+/* Mark the tree SRC as an optional subexpression.
+   To be called from preorder or postorder.  */
+
+static reg_errcode_t
+mark_opt_subexp (void *extra, bin_tree_t *node)
+{
+  Idx idx = (Idx) (long) extra;
+  if (node->token.type == SUBEXP && node->token.opr.idx == idx)
+    node->token.opt_subexp = 1;
+
+  return REG_NOERROR;
+}
+
+/* Free the allocated memory inside NODE. */
+
+static void
+free_token (re_token_t *node)
+{
+#ifdef RE_ENABLE_I18N
+  if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
+    free_charset (node->opr.mbcset);
+  else
+#endif /* RE_ENABLE_I18N */
+    if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
+      re_free (node->opr.sbcset);
+}
+
+/* Worker function for tree walking.  Free the allocated memory inside NODE
+   and its children. */
+
+static reg_errcode_t
+free_tree (void *extra, bin_tree_t *node)
+{
+  free_token (&node->token);
+  return REG_NOERROR;
+}
+
+
+/* Duplicate the node SRC, and return new node.  This is a preorder
+   visit similar to the one implemented by the generic visitor, but
+   we need more infrastructure to maintain two parallel trees --- so,
+   it's easier to duplicate.  */
+
+static bin_tree_t *
+duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
+{
+  const bin_tree_t *node;
+  bin_tree_t *dup_root;
+  bin_tree_t **p_new = &dup_root, *dup_node = root->parent;
+
+  for (node = root; ; )
+    {
+      /* Create a new tree and link it back to the current parent.  */
+      *p_new = create_token_tree (dfa, NULL, NULL, &node->token);
+      if (*p_new == NULL)
+       return NULL;
+      (*p_new)->parent = dup_node;
+      (*p_new)->token.duplicated = 1;
+      dup_node = *p_new;
+
+      /* Go to the left node, or up and to the right.  */
+      if (node->left)
+       {
+         node = node->left;
+         p_new = &dup_node->left;
+       }
+      else
+       {
+         const bin_tree_t *prev = NULL;
+         while (node->right == prev || node->right == NULL)
+           {
+             prev = node;
+             node = node->parent;
+             dup_node = dup_node->parent;
+             if (!node)
+               return dup_root;
+           }
+         node = node->right;
+         p_new = &dup_node->right;
+       }
+    }
+}
diff --git a/gnulib/lib/regex.c b/gnulib/lib/regex.c
new file mode 100644 (file)
index 0000000..b1e34ac
--- /dev/null
@@ -0,0 +1,71 @@
+/* Extended regular expression matching and search library.
+   Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <config.h>
+
+/* Make sure noone compiles this code with a C++ compiler.  */
+#if defined __cplusplus && defined _LIBC
+# error "This is C code, use a C compiler"
+#endif
+
+#ifdef _LIBC
+/* We have to keep the namespace clean.  */
+# define regfree(preg) __regfree (preg)
+# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
+# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
+# define regerror(errcode, preg, errbuf, errbuf_size) \
+       __regerror(errcode, preg, errbuf, errbuf_size)
+# define re_set_registers(bu, re, nu, st, en) \
+       __re_set_registers (bu, re, nu, st, en)
+# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
+       __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+# define re_match(bufp, string, size, pos, regs) \
+       __re_match (bufp, string, size, pos, regs)
+# define re_search(bufp, string, size, startpos, range, regs) \
+       __re_search (bufp, string, size, startpos, range, regs)
+# define re_compile_pattern(pattern, length, bufp) \
+       __re_compile_pattern (pattern, length, bufp)
+# define re_set_syntax(syntax) __re_set_syntax (syntax)
+# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
+       __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
+# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
+
+# include "../locale/localeinfo.h"
+#endif
+
+/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
+   GNU regex allows.  Include it before <regex.h>, which correctly
+   #undefs RE_DUP_MAX and sets it to the right value.  */
+#include <limits.h>
+
+#include <regex.h>
+#include "regex_internal.h"
+
+#include "regex_internal.c"
+#include "regcomp.c"
+#include "regexec.c"
+
+/* Binary backward compatibility.  */
+#if _LIBC
+# include <shlib-compat.h>
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
+link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
+int re_max_failures = 2000;
+# endif
+#endif
diff --git a/gnulib/lib/regex.h b/gnulib/lib/regex.h
new file mode 100644 (file)
index 0000000..0089a47
--- /dev/null
@@ -0,0 +1,675 @@
+/* Definitions for data structures and routines for the regular
+   expression library.
+   Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2006, 2009-2011
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _REGEX_H
+#define _REGEX_H 1
+
+#include <sys/types.h>
+
+/* Allow the use in C++ code.  */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define __USE_GNU_REGEX to declare GNU extensions that violate the
+   POSIX name space rules.  */
+#undef __USE_GNU_REGEX
+#if (defined _GNU_SOURCE                                       \
+     || (!defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE    \
+        && !defined _XOPEN_SOURCE))
+# define __USE_GNU_REGEX 1
+#endif
+
+#ifdef _REGEX_LARGE_OFFSETS
+
+/* Use types and values that are wide enough to represent signed and
+   unsigned byte offsets in memory.  This currently works only when
+   the regex code is used outside of the GNU C library; it is not yet
+   supported within glibc itself, and glibc users should not define
+   _REGEX_LARGE_OFFSETS.  */
+
+/* The type of the offset of a byte within a string.
+   For historical reasons POSIX 1003.1-2004 requires that regoff_t be
+   at least as wide as off_t.  However, many common POSIX platforms set
+   regoff_t to the more-sensible ssize_t and the Open Group has
+   signalled its intention to change the requirement to be that
+   regoff_t be at least as wide as ptrdiff_t and ssize_t; see XBD ERN
+   60 (2005-08-25).  We don't know of any hosts where ssize_t or
+   ptrdiff_t is wider than ssize_t, so ssize_t is safe.  */
+typedef ssize_t regoff_t;
+
+/* The type of nonnegative object indexes.  Traditionally, GNU regex
+   uses 'int' for these.  Code that uses __re_idx_t should work
+   regardless of whether the type is signed.  */
+typedef size_t __re_idx_t;
+
+/* The type of object sizes.  */
+typedef size_t __re_size_t;
+
+/* The type of object sizes, in places where the traditional code
+   uses unsigned long int.  */
+typedef size_t __re_long_size_t;
+
+#else
+
+/* Use types that are binary-compatible with the traditional GNU regex
+   implementation, which mishandles strings longer than INT_MAX.  */
+
+typedef int regoff_t;
+typedef int __re_idx_t;
+typedef unsigned int __re_size_t;
+typedef unsigned long int __re_long_size_t;
+
+#endif
+
+/* The following two types have to be signed and unsigned integer type
+   wide enough to hold a value of a pointer.  For most ANSI compilers
+   ptrdiff_t and size_t should be likely OK.  Still size of these two
+   types is 2 for Microsoft C.  Ugh... */
+typedef long int s_reg_t;
+typedef unsigned long int active_reg_t;
+
+/* The following bits are used to determine the regexp syntax we
+   recognize.  The set/not-set meanings are chosen so that Emacs syntax
+   remains the value 0.  The bits are given in alphabetical order, and
+   the definitions shifted by one from the previous bit; thus, when we
+   add or remove a bit, only one other definition need change.  */
+typedef unsigned long int reg_syntax_t;
+
+#ifdef __USE_GNU_REGEX
+
+/* If this bit is not set, then \ inside a bracket expression is literal.
+   If set, then such a \ quotes the following character.  */
+# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+     literals.
+   If set, then \+ and \? are operators and + and ? are literals.  */
+# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+
+/* If this bit is set, then character classes are supported.  They are:
+     [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
+     [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+   If not set, then character classes are not supported.  */
+# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+     expressions, of course).
+   If this bit is not set, then it depends:
+       ^  is an anchor if it is at the beginning of a regular
+          expression or after an open-group or an alternation operator;
+       $  is an anchor if it is at the end of a regular expression, or
+          before a close-group or an alternation operator.
+
+   This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+   POSIX draft 11.2 says that * etc. in leading positions is undefined.
+   We already implemented a previous draft which made those constructs
+   invalid, though, so we haven't changed the code back.  */
+# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+
+/* If this bit is set, then special characters are always special
+     regardless of where they are in the pattern.
+   If this bit is not set, then special characters are special only in
+     some contexts; otherwise they are ordinary.  Specifically,
+     * + ? and intervals are only special when not after the beginning,
+     open-group, or alternation operator.  */
+# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+     immediately after an alternation or begin-group operator.  */
+# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+
+/* If this bit is set, then . matches newline.
+   If not set, then it doesn't.  */
+# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+
+/* If this bit is set, then . doesn't match NUL.
+   If not set, then it does.  */
+# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+   If not set, they do.  */
+# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+
+/* If this bit is set, either \{...\} or {...} defines an
+     interval, depending on RE_NO_BK_BRACES.
+   If not set, \{, \}, {, and } are literals.  */
+# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
+/* If this bit is set, +, ? and | aren't recognized as operators.
+   If not set, they are.  */
+# define RE_LIMITED_OPS (RE_INTERVALS << 1)
+
+/* If this bit is set, newline is an alternation operator.
+   If not set, newline is literal.  */
+# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+
+/* If this bit is set, then `{...}' defines an interval, and \{ and \}
+     are literals.
+  If not set, then `\{...\}' defines an interval.  */
+# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+   If not set, \(...\) defines a group, and ( and ) are literals.  */
+# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+
+/* If this bit is set, then \<digit> matches <digit>.
+   If not set, then \<digit> is a back-reference.  */
+# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+   If not set, then \| is an alternation operator, and | is literal.  */
+# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+
+/* If this bit is set, then an ending range point collating higher
+     than the starting range point, as in [z-a], is invalid.
+   If not set, then when ending range point collates higher than the
+     starting range point, the range is ignored.  */
+# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+
+/* If this bit is set, then an unmatched ) is ordinary.
+   If not set, then an unmatched ) is invalid.  */
+# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+
+/* If this bit is set, succeed as soon as we match the whole pattern,
+   without further backtracking.  */
+# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+
+/* If this bit is set, do not process the GNU regex operators.
+   If not set, then the GNU regex operators are recognized. */
+# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+
+/* If this bit is set, turn on internal regex debugging.
+   If not set, and debugging was on, turn it off.
+   This only works if regex.c is compiled -DDEBUG.
+   We define this bit always, so that all that's needed to turn on
+   debugging is to recompile regex.c; the calling code can always have
+   this bit set, and it won't affect anything in the normal case. */
+# define RE_DEBUG (RE_NO_GNU_OPS << 1)
+
+/* If this bit is set, a syntactically invalid interval is treated as
+   a string of ordinary characters.  For example, the ERE 'a{1' is
+   treated as 'a\{1'.  */
+# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+
+/* If this bit is set, then ignore case when matching.
+   If not set, then case is significant.  */
+# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
+
+/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
+   for ^, because it is difficult to scan the regex backwards to find
+   whether ^ should be special.  */
+# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
+
+/* If this bit is set, then \{ cannot be first in a regex or
+   immediately after an alternation, open-group or \} operator.  */
+# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
+
+/* If this bit is set, then no_sub will be set to 1 during
+   re_compile_pattern.  */
+# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+
+#endif /* defined __USE_GNU_REGEX */
+
+/* This global variable defines the particular regexp syntax to use (for
+   some interfaces).  When a regexp is compiled, the syntax used is
+   stored in the pattern buffer, so changing this does not affect
+   already-compiled regexps.  */
+extern reg_syntax_t re_syntax_options;
+\f
+#ifdef __USE_GNU_REGEX
+/* Define combinations of the above bits for the standard possibilities.
+   (The [[[ comments delimit what gets put into the Texinfo file, so
+   don't delete them!)  */
+/* [[[begin syntaxes]]] */
+# define RE_SYNTAX_EMACS 0
+
+# define RE_SYNTAX_AWK                                                 \
+  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL                    \
+   | RE_NO_BK_PARENS              | RE_NO_BK_REFS                      \
+   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES                 \
+   | RE_DOT_NEWLINE              | RE_CONTEXT_INDEP_ANCHORS            \
+   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
+
+# define RE_SYNTAX_GNU_AWK                                             \
+  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG)        \
+   & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS           \
+       | RE_CONTEXT_INVALID_OPS ))
+
+# define RE_SYNTAX_POSIX_AWK                                           \
+  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS             \
+   | RE_INTERVALS          | RE_NO_GNU_OPS)
+
+# define RE_SYNTAX_GREP                                                        \
+  (RE_BK_PLUS_QM              | RE_CHAR_CLASSES                                \
+   | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS                           \
+   | RE_NEWLINE_ALT)
+
+# define RE_SYNTAX_EGREP                                               \
+  (RE_CHAR_CLASSES        | RE_CONTEXT_INDEP_ANCHORS                   \
+   | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE                   \
+   | RE_NEWLINE_ALT       | RE_NO_BK_PARENS                            \
+   | RE_NO_BK_VBAR)
+
+# define RE_SYNTAX_POSIX_EGREP                                         \
+  (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES                    \
+   | RE_INVALID_INTERVAL_ORD)
+
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff.  */
+# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
+
+# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
+
+/* Syntax bits common to both basic and extended POSIX regex syntax.  */
+# define _RE_SYNTAX_POSIX_COMMON                                       \
+  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL             \
+   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)
+
+# define RE_SYNTAX_POSIX_BASIC                                         \
+  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
+
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+   RE_LIMITED_OPS, i.e., \? \+ \| are not recognized.  Actually, this
+   isn't minimal, since other operators, such as \`, aren't disabled.  */
+# define RE_SYNTAX_POSIX_MINIMAL_BASIC                                 \
+  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
+
+# define RE_SYNTAX_POSIX_EXTENDED                                      \
+  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS                 \
+   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES                          \
+   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR                            \
+   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
+   removed and RE_NO_BK_REFS is added.  */
+# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED                              \
+  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS                 \
+   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES                          \
+   | RE_NO_BK_PARENS        | RE_NO_BK_REFS                            \
+   | RE_NO_BK_VBAR         | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+
+#endif /* defined __USE_GNU_REGEX */
+\f
+#ifdef __USE_GNU_REGEX
+
+/* Maximum number of duplicates an interval can allow.  POSIX-conforming
+   systems might define this in <limits.h>, but we want our
+   value, so remove any previous define.  */
+# ifdef RE_DUP_MAX
+#  undef RE_DUP_MAX
+# endif
+
+/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored
+   the counter as a 2-byte signed integer.  This is no longer true, so
+   RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to
+   ((SIZE_MAX - 2) / 10 - 1) if _REGEX_LARGE_OFFSETS is defined.
+   However, there would be a huge performance problem if someone
+   actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains
+   its historical value.  */
+# define RE_DUP_MAX (0x7fff)
+
+#endif /* defined __USE_GNU_REGEX */
+
+
+/* POSIX `cflags' bits (i.e., information for `regcomp').  */
+
+/* If this bit is set, then use extended regular expression syntax.
+   If not set, then use basic regular expression syntax.  */
+#define REG_EXTENDED 1
+
+/* If this bit is set, then ignore case when matching.
+   If not set, then case is significant.  */
+#define REG_ICASE (1 << 1)
+
+/* If this bit is set, then anchors do not match at newline
+     characters in the string.
+   If not set, then anchors do match at newlines.  */
+#define REG_NEWLINE (1 << 2)
+
+/* If this bit is set, then report only success or fail in regexec.
+   If not set, then returns differ between not matching and errors.  */
+#define REG_NOSUB (1 << 3)
+
+
+/* POSIX `eflags' bits (i.e., information for regexec).  */
+
+/* If this bit is set, then the beginning-of-line operator doesn't match
+     the beginning of the string (presumably because it's not the
+     beginning of a line).
+   If not set, then the beginning-of-line operator does match the
+     beginning of the string.  */
+#define REG_NOTBOL 1
+
+/* Like REG_NOTBOL, except for the end-of-line.  */
+#define REG_NOTEOL (1 << 1)
+
+/* Use PMATCH[0] to delimit the start and end of the search in the
+   buffer.  */
+#define REG_STARTEND (1 << 2)
+
+
+/* If any error codes are removed, changed, or added, update the
+   `__re_error_msgid' table in regcomp.c.  */
+
+typedef enum
+{
+  _REG_ENOSYS = -1,    /* This will never happen for this implementation.  */
+  _REG_NOERROR = 0,    /* Success.  */
+  _REG_NOMATCH,                /* Didn't find a match (for regexec).  */
+
+  /* POSIX regcomp return error codes.  (In the order listed in the
+     standard.)  */
+  _REG_BADPAT,         /* Invalid pattern.  */
+  _REG_ECOLLATE,       /* Invalid collating element.  */
+  _REG_ECTYPE,         /* Invalid character class name.  */
+  _REG_EESCAPE,                /* Trailing backslash.  */
+  _REG_ESUBREG,                /* Invalid back reference.  */
+  _REG_EBRACK,         /* Unmatched left bracket.  */
+  _REG_EPAREN,         /* Parenthesis imbalance.  */
+  _REG_EBRACE,         /* Unmatched \{.  */
+  _REG_BADBR,          /* Invalid contents of \{\}.  */
+  _REG_ERANGE,         /* Invalid range end.  */
+  _REG_ESPACE,         /* Ran out of memory.  */
+  _REG_BADRPT,         /* No preceding re for repetition op.  */
+
+  /* Error codes we've added.  */
+  _REG_EEND,           /* Premature end.  */
+  _REG_ESIZE,          /* Compiled pattern bigger than 2^16 bytes.  */
+  _REG_ERPAREN         /* Unmatched ) or \); not returned from regcomp.  */
+} reg_errcode_t;
+
+#ifdef _XOPEN_SOURCE
+# define REG_ENOSYS    _REG_ENOSYS
+#endif
+#define REG_NOERROR    _REG_NOERROR
+#define REG_NOMATCH    _REG_NOMATCH
+#define REG_BADPAT     _REG_BADPAT
+#define REG_ECOLLATE   _REG_ECOLLATE
+#define REG_ECTYPE     _REG_ECTYPE
+#define REG_EESCAPE    _REG_EESCAPE
+#define REG_ESUBREG    _REG_ESUBREG
+#define REG_EBRACK     _REG_EBRACK
+#define REG_EPAREN     _REG_EPAREN
+#define REG_EBRACE     _REG_EBRACE
+#define REG_BADBR      _REG_BADBR
+#define REG_ERANGE     _REG_ERANGE
+#define REG_ESPACE     _REG_ESPACE
+#define REG_BADRPT     _REG_BADRPT
+#define REG_EEND       _REG_EEND
+#define REG_ESIZE      _REG_ESIZE
+#define REG_ERPAREN    _REG_ERPAREN
+\f
+/* struct re_pattern_buffer normally uses member names like `buffer'
+   that POSIX does not allow.  In POSIX mode these members have names
+   with leading `re_' (e.g., `re_buffer').  */
+#ifdef __USE_GNU_REGEX
+# define _REG_RE_NAME(id) id
+# define _REG_RM_NAME(id) id
+#else
+# define _REG_RE_NAME(id) re_##id
+# define _REG_RM_NAME(id) rm_##id
+#endif
+
+/* The user can specify the type of the re_translate member by
+   defining the macro RE_TRANSLATE_TYPE, which defaults to unsigned
+   char *.  This pollutes the POSIX name space, so in POSIX mode just
+   use unsigned char *.  */
+#ifdef __USE_GNU_REGEX
+# ifndef RE_TRANSLATE_TYPE
+#  define RE_TRANSLATE_TYPE unsigned char *
+# endif
+# define REG_TRANSLATE_TYPE RE_TRANSLATE_TYPE
+#else
+# define REG_TRANSLATE_TYPE unsigned char *
+#endif
+
+/* This data structure represents a compiled pattern.  Before calling
+   the pattern compiler, the fields `buffer', `allocated', `fastmap',
+   `translate', and `no_sub' can be set.  After the pattern has been
+   compiled, the `re_nsub' field is available.  All other fields are
+   private to the regex routines.  */
+
+struct re_pattern_buffer
+{
+  /* Space that holds the compiled pattern.  It is declared as
+     `unsigned char *' because its elements are sometimes used as
+     array indexes.  */
+  unsigned char *_REG_RE_NAME (buffer);
+
+  /* Number of bytes to which `buffer' points.  */
+  __re_long_size_t _REG_RE_NAME (allocated);
+
+  /* Number of bytes actually used in `buffer'.  */
+  __re_long_size_t _REG_RE_NAME (used);
+
+  /* Syntax setting with which the pattern was compiled.  */
+  reg_syntax_t _REG_RE_NAME (syntax);
+
+  /* Pointer to a fastmap, if any, otherwise zero.  re_search uses the
+     fastmap, if there is one, to skip over impossible starting points
+     for matches.  */
+  char *_REG_RE_NAME (fastmap);
+
+  /* Either a translate table to apply to all characters before
+     comparing them, or zero for no translation.  The translation is
+     applied to a pattern when it is compiled and to a string when it
+     is matched.  */
+  REG_TRANSLATE_TYPE _REG_RE_NAME (translate);
+
+  /* Number of subexpressions found by the compiler.  */
+  size_t re_nsub;
+
+  /* Zero if this pattern cannot match the empty string, one else.
+     Well, in truth it's used only in `re_search_2', to see whether or
+     not we should use the fastmap, so we don't set this absolutely
+     perfectly; see `re_compile_fastmap' (the `duplicate' case).  */
+  unsigned int _REG_RE_NAME (can_be_null) : 1;
+
+  /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+     for `max (RE_NREGS, re_nsub + 1)' groups.
+     If REGS_REALLOCATE, reallocate space if necessary.
+     If REGS_FIXED, use what's there.  */
+#ifdef __USE_GNU_REGEX
+# define REGS_UNALLOCATED 0
+# define REGS_REALLOCATE 1
+# define REGS_FIXED 2
+#endif
+  unsigned int _REG_RE_NAME (regs_allocated) : 2;
+
+  /* Set to zero when `re_compile_pattern' compiles a pattern; set to
+     one by `re_compile_fastmap' if it updates the fastmap.  */
+  unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
+
+  /* If set, `re_match_2' does not return information about
+     subexpressions.  */
+  unsigned int _REG_RE_NAME (no_sub) : 1;
+
+  /* If set, a beginning-of-line anchor doesn't match at the beginning
+     of the string.  */
+  unsigned int _REG_RE_NAME (not_bol) : 1;
+
+  /* Similarly for an end-of-line anchor.  */
+  unsigned int _REG_RE_NAME (not_eol) : 1;
+
+  /* If true, an anchor at a newline matches.  */
+  unsigned int _REG_RE_NAME (newline_anchor) : 1;
+
+/* [[[end pattern_buffer]]] */
+};
+
+typedef struct re_pattern_buffer regex_t;
+\f
+/* This is the structure we store register match data in.  See
+   regex.texinfo for a full description of what registers match.  */
+struct re_registers
+{
+  __re_size_t _REG_RM_NAME (num_regs);
+  regoff_t *_REG_RM_NAME (start);
+  regoff_t *_REG_RM_NAME (end);
+};
+
+
+/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+   `re_match_2' returns information about at least this many registers
+   the first time a `regs' structure is passed.  */
+#if !defined RE_NREGS && defined __USE_GNU_REGEX
+# define RE_NREGS 30
+#endif
+
+
+/* POSIX specification for registers.  Aside from the different names than
+   `re_registers', POSIX uses an array of structures, instead of a
+   structure of arrays.  */
+typedef struct
+{
+  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
+  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
+} regmatch_t;
+\f
+/* Declarations for routines.  */
+
+/* Sets the current default syntax to SYNTAX, and return the old syntax.
+   You can also simply assign to the `re_syntax_options' variable.  */
+extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
+
+/* Compile the regular expression PATTERN, with length LENGTH
+   and syntax given by the global `re_syntax_options', into the buffer
+   BUFFER.  Return NULL if successful, and an error string if not.  */
+extern const char *re_compile_pattern (const char *__pattern, size_t __length,
+                                      struct re_pattern_buffer *__buffer);
+
+
+/* Compile a fastmap for the compiled pattern in BUFFER; used to
+   accelerate searches.  Return 0 if successful and -2 if was an
+   internal error.  */
+extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
+
+
+/* Search in the string STRING (with length LENGTH) for the pattern
+   compiled into BUFFER.  Start searching at position START, for RANGE
+   characters.  Return the starting position of the match, -1 for no
+   match, or -2 for an internal error.  Also return register
+   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
+extern regoff_t re_search (struct re_pattern_buffer *__buffer,
+                          const char *__string, __re_idx_t __length,
+                          __re_idx_t __start, regoff_t __range,
+                          struct re_registers *__regs);
+
+
+/* Like `re_search', but search in the concatenation of STRING1 and
+   STRING2.  Also, stop searching at index START + STOP.  */
+extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
+                            const char *__string1, __re_idx_t __length1,
+                            const char *__string2, __re_idx_t __length2,
+                            __re_idx_t __start, regoff_t __range,
+                            struct re_registers *__regs,
+                            __re_idx_t __stop);
+
+
+/* Like `re_search', but return how many characters in STRING the regexp
+   in BUFFER matched, starting at position START.  */
+extern regoff_t re_match (struct re_pattern_buffer *__buffer,
+                         const char *__string, __re_idx_t __length,
+                         __re_idx_t __start, struct re_registers *__regs);
+
+
+/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
+extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
+                           const char *__string1, __re_idx_t __length1,
+                           const char *__string2, __re_idx_t __length2,
+                           __re_idx_t __start, struct re_registers *__regs,
+                           __re_idx_t __stop);
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+   ENDS.  Subsequent matches using BUFFER and REGS will use this memory
+   for recording register information.  STARTS and ENDS must be
+   allocated with malloc, and must each be at least `NUM_REGS * sizeof
+   (regoff_t)' bytes long.
+
+   If NUM_REGS == 0, then subsequent matches should allocate their own
+   register data.
+
+   Unless this function is called, the first search or match using
+   BUFFER will allocate its own register data, without freeing the old
+   data.  */
+extern void re_set_registers (struct re_pattern_buffer *__buffer,
+                             struct re_registers *__regs,
+                             __re_size_t __num_regs,
+                             regoff_t *__starts, regoff_t *__ends);
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+# ifndef _CRAY
+/* 4.2 bsd compatibility.  */
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
+# endif
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+   "restrict", and "configure" may have defined "restrict".
+   Other compilers use __restrict, __restrict__, and _Restrict, and
+   'configure' might #define 'restrict' to those words, so pick a
+   different name.  */
+#ifndef _Restrict_
+# if 199901L <= __STDC_VERSION__
+#  define _Restrict_ restrict
+# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+#  define _Restrict_ __restrict
+# else
+#  define _Restrict_
+# endif
+#endif
+/* gcc 3.1 and up support the [restrict] syntax.  Don't trust
+   sys/cdefs.h's definition of __restrict_arr, though, as it
+   mishandles gcc -ansi -pedantic.  */
+#ifndef _Restrict_arr_
+# if ((199901L <= __STDC_VERSION__                                     \
+       || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))    \
+          && !__STRICT_ANSI__))                                        \
+      && !defined __GNUG__)
+#  define _Restrict_arr_ _Restrict_
+# else
+#  define _Restrict_arr_
+# endif
+#endif
+
+/* POSIX compatibility.  */
+extern int regcomp (regex_t *_Restrict_ __preg,
+                   const char *_Restrict_ __pattern,
+                   int __cflags);
+
+extern int regexec (const regex_t *_Restrict_ __preg,
+                   const char *_Restrict_ __string, size_t __nmatch,
+                   regmatch_t __pmatch[_Restrict_arr_],
+                   int __eflags);
+
+extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
+                       char *_Restrict_ __errbuf, size_t __errbuf_size);
+
+extern void regfree (regex_t *__preg);
+
+
+#ifdef __cplusplus
+}
+#endif /* C++ */
+
+#endif /* regex.h */
diff --git a/gnulib/lib/regex_internal.c b/gnulib/lib/regex_internal.c
new file mode 100644 (file)
index 0000000..8147779
--- /dev/null
@@ -0,0 +1,1741 @@
+/* Extended regular expression matching and search library.
+   Copyright (C) 2002-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+static void re_string_construct_common (const char *str, Idx len,
+                                       re_string_t *pstr,
+                                       RE_TRANSLATE_TYPE trans, bool icase,
+                                       const re_dfa_t *dfa) internal_function;
+static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
+                                         const re_node_set *nodes,
+                                         re_hashval_t hash) internal_function;
+static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
+                                         const re_node_set *nodes,
+                                         unsigned int context,
+                                         re_hashval_t hash) internal_function;
+\f
+/* Functions for string operation.  */
+
+/* This function allocate the buffers.  It is necessary to call
+   re_string_reconstruct before using the object.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
+                   RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
+{
+  reg_errcode_t ret;
+  Idx init_buf_len;
+
+  /* Ensure at least one character fits into the buffers.  */
+  if (init_len < dfa->mb_cur_max)
+    init_len = dfa->mb_cur_max;
+  init_buf_len = (len + 1 < init_len) ? len + 1: init_len;
+  re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+  ret = re_string_realloc_buffers (pstr, init_buf_len);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+
+  pstr->word_char = dfa->word_char;
+  pstr->word_ops_used = dfa->word_ops_used;
+  pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+  pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
+  pstr->valid_raw_len = pstr->valid_len;
+  return REG_NOERROR;
+}
+
+/* This function allocate the buffers, and initialize them.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_string_construct (re_string_t *pstr, const char *str, Idx len,
+                    RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
+{
+  reg_errcode_t ret;
+  memset (pstr, '\0', sizeof (re_string_t));
+  re_string_construct_common (str, len, pstr, trans, icase, dfa);
+
+  if (len > 0)
+    {
+      ret = re_string_realloc_buffers (pstr, len + 1);
+      if (BE (ret != REG_NOERROR, 0))
+       return ret;
+    }
+  pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
+
+  if (icase)
+    {
+#ifdef RE_ENABLE_I18N
+      if (dfa->mb_cur_max > 1)
+       {
+         while (1)
+           {
+             ret = build_wcs_upper_buffer (pstr);
+             if (BE (ret != REG_NOERROR, 0))
+               return ret;
+             if (pstr->valid_raw_len >= len)
+               break;
+             if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
+               break;
+             ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+             if (BE (ret != REG_NOERROR, 0))
+               return ret;
+           }
+       }
+      else
+#endif /* RE_ENABLE_I18N  */
+       build_upper_buffer (pstr);
+    }
+  else
+    {
+#ifdef RE_ENABLE_I18N
+      if (dfa->mb_cur_max > 1)
+       build_wcs_buffer (pstr);
+      else
+#endif /* RE_ENABLE_I18N  */
+       {
+         if (trans != NULL)
+           re_string_translate_buffer (pstr);
+         else
+           {
+             pstr->valid_len = pstr->bufs_len;
+             pstr->valid_raw_len = pstr->bufs_len;
+           }
+       }
+    }
+
+  return REG_NOERROR;
+}
+
+/* Helper functions for re_string_allocate, and re_string_construct.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
+{
+#ifdef RE_ENABLE_I18N
+  if (pstr->mb_cur_max > 1)
+    {
+      wint_t *new_wcs;
+
+      /* Avoid overflow.  */
+      size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
+      if (BE (SIZE_MAX / max_object_size < new_buf_len, 0))
+       return REG_ESPACE;
+
+      new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
+      if (BE (new_wcs == NULL, 0))
+       return REG_ESPACE;
+      pstr->wcs = new_wcs;
+      if (pstr->offsets != NULL)
+       {
+         Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
+         if (BE (new_offsets == NULL, 0))
+           return REG_ESPACE;
+         pstr->offsets = new_offsets;
+       }
+    }
+#endif /* RE_ENABLE_I18N  */
+  if (pstr->mbs_allocated)
+    {
+      unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
+                                          new_buf_len);
+      if (BE (new_mbs == NULL, 0))
+       return REG_ESPACE;
+      pstr->mbs = new_mbs;
+    }
+  pstr->bufs_len = new_buf_len;
+  return REG_NOERROR;
+}
+
+
+static void
+internal_function
+re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
+                           RE_TRANSLATE_TYPE trans, bool icase,
+                           const re_dfa_t *dfa)
+{
+  pstr->raw_mbs = (const unsigned char *) str;
+  pstr->len = len;
+  pstr->raw_len = len;
+  pstr->trans = trans;
+  pstr->icase = icase;
+  pstr->mbs_allocated = (trans != NULL || icase);
+  pstr->mb_cur_max = dfa->mb_cur_max;
+  pstr->is_utf8 = dfa->is_utf8;
+  pstr->map_notascii = dfa->map_notascii;
+  pstr->stop = pstr->len;
+  pstr->raw_stop = pstr->stop;
+}
+
+#ifdef RE_ENABLE_I18N
+
+/* Build wide character buffer PSTR->WCS.
+   If the byte sequence of the string are:
+     <mb1>(0), <mb1>(1), <mb2>(0), <mb2>(1), <sb3>
+   Then wide character buffer will be:
+     <wc1>   , WEOF    , <wc2>   , WEOF    , <wc3>
+   We use WEOF for padding, they indicate that the position isn't
+   a first byte of a multibyte character.
+
+   Note that this function assumes PSTR->VALID_LEN elements are already
+   built and starts from PSTR->VALID_LEN.  */
+
+static void
+internal_function
+build_wcs_buffer (re_string_t *pstr)
+{
+#ifdef _LIBC
+  unsigned char buf[MB_LEN_MAX];
+  assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+  unsigned char buf[64];
+#endif
+  mbstate_t prev_st;
+  Idx byte_idx, end_idx, remain_len;
+  size_t mbclen;
+
+  /* Build the buffers from pstr->valid_len to either pstr->len or
+     pstr->bufs_len.  */
+  end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+  for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
+    {
+      wchar_t wc;
+      const char *p;
+
+      remain_len = end_idx - byte_idx;
+      prev_st = pstr->cur_state;
+      /* Apply the translation if we need.  */
+      if (BE (pstr->trans != NULL, 0))
+       {
+         int i, ch;
+
+         for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+           {
+             ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i];
+             buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch];
+           }
+         p = (const char *) buf;
+       }
+      else
+       p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
+      mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+      if (BE (mbclen == (size_t) -2, 0))
+       {
+         /* The buffer doesn't have enough space, finish to build.  */
+         pstr->cur_state = prev_st;
+         break;
+       }
+      else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
+       {
+         /* We treat these cases as a singlebyte character.  */
+         mbclen = 1;
+         wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+         if (BE (pstr->trans != NULL, 0))
+           wc = pstr->trans[wc];
+         pstr->cur_state = prev_st;
+       }
+
+      /* Write wide character and padding.  */
+      pstr->wcs[byte_idx++] = wc;
+      /* Write paddings.  */
+      for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+       pstr->wcs[byte_idx++] = WEOF;
+    }
+  pstr->valid_len = byte_idx;
+  pstr->valid_raw_len = byte_idx;
+}
+
+/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
+   but for REG_ICASE.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+build_wcs_upper_buffer (re_string_t *pstr)
+{
+  mbstate_t prev_st;
+  Idx src_idx, byte_idx, end_idx, remain_len;
+  size_t mbclen;
+#ifdef _LIBC
+  char buf[MB_LEN_MAX];
+  assert (MB_LEN_MAX >= pstr->mb_cur_max);
+#else
+  char buf[64];
+#endif
+
+  byte_idx = pstr->valid_len;
+  end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+  /* The following optimization assumes that ASCII characters can be
+     mapped to wide characters with a simple cast.  */
+  if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
+    {
+      while (byte_idx < end_idx)
+       {
+         wchar_t wc;
+
+         if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
+             && mbsinit (&pstr->cur_state))
+           {
+             /* In case of a singlebyte character.  */
+             pstr->mbs[byte_idx]
+               = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
+             /* The next step uses the assumption that wchar_t is encoded
+                ASCII-safe: all ASCII values can be converted like this.  */
+             pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
+             ++byte_idx;
+             continue;
+           }
+
+         remain_len = end_idx - byte_idx;
+         prev_st = pstr->cur_state;
+         mbclen = __mbrtowc (&wc,
+                             ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+                              + byte_idx), remain_len, &pstr->cur_state);
+         if (BE (mbclen < (size_t) -2, 1))
+           {
+             wchar_t wcu = wc;
+             if (iswlower (wc))
+               {
+                 size_t mbcdlen;
+
+                 wcu = towupper (wc);
+                 mbcdlen = wcrtomb (buf, wcu, &prev_st);
+                 if (BE (mbclen == mbcdlen, 1))
+                   memcpy (pstr->mbs + byte_idx, buf, mbclen);
+                 else
+                   {
+                     src_idx = byte_idx;
+                     goto offsets_needed;
+                   }
+               }
+             else
+               memcpy (pstr->mbs + byte_idx,
+                       pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
+             pstr->wcs[byte_idx++] = wcu;
+             /* Write paddings.  */
+             for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+               pstr->wcs[byte_idx++] = WEOF;
+           }
+         else if (mbclen == (size_t) -1 || mbclen == 0)
+           {
+             /* It is an invalid character or '\0'.  Just use the byte.  */
+             int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+             pstr->mbs[byte_idx] = ch;
+             /* And also cast it to wide char.  */
+             pstr->wcs[byte_idx++] = (wchar_t) ch;
+             if (BE (mbclen == (size_t) -1, 0))
+               pstr->cur_state = prev_st;
+           }
+         else
+           {
+             /* The buffer doesn't have enough space, finish to build.  */
+             pstr->cur_state = prev_st;
+             break;
+           }
+       }
+      pstr->valid_len = byte_idx;
+      pstr->valid_raw_len = byte_idx;
+      return REG_NOERROR;
+    }
+  else
+    for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
+      {
+       wchar_t wc;
+       const char *p;
+      offsets_needed:
+       remain_len = end_idx - byte_idx;
+       prev_st = pstr->cur_state;
+       if (BE (pstr->trans != NULL, 0))
+         {
+           int i, ch;
+
+           for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
+             {
+               ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i];
+               buf[i] = pstr->trans[ch];
+             }
+           p = (const char *) buf;
+         }
+       else
+         p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
+       mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+       if (BE (mbclen < (size_t) -2, 1))
+         {
+           wchar_t wcu = wc;
+           if (iswlower (wc))
+             {
+               size_t mbcdlen;
+
+               wcu = towupper (wc);
+               mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st);
+               if (BE (mbclen == mbcdlen, 1))
+                 memcpy (pstr->mbs + byte_idx, buf, mbclen);
+               else if (mbcdlen != (size_t) -1)
+                 {
+                   size_t i;
+
+                   if (byte_idx + mbcdlen > pstr->bufs_len)
+                     {
+                       pstr->cur_state = prev_st;
+                       break;
+                     }
+
+                   if (pstr->offsets == NULL)
+                     {
+                       pstr->offsets = re_malloc (Idx, pstr->bufs_len);
+
+                       if (pstr->offsets == NULL)
+                         return REG_ESPACE;
+                     }
+                   if (!pstr->offsets_needed)
+                     {
+                       for (i = 0; i < (size_t) byte_idx; ++i)
+                         pstr->offsets[i] = i;
+                       pstr->offsets_needed = 1;
+                     }
+
+                   memcpy (pstr->mbs + byte_idx, buf, mbcdlen);
+                   pstr->wcs[byte_idx] = wcu;
+                   pstr->offsets[byte_idx] = src_idx;
+                   for (i = 1; i < mbcdlen; ++i)
+                     {
+                       pstr->offsets[byte_idx + i]
+                         = src_idx + (i < mbclen ? i : mbclen - 1);
+                       pstr->wcs[byte_idx + i] = WEOF;
+                     }
+                   pstr->len += mbcdlen - mbclen;
+                   if (pstr->raw_stop > src_idx)
+                     pstr->stop += mbcdlen - mbclen;
+                   end_idx = (pstr->bufs_len > pstr->len)
+                             ? pstr->len : pstr->bufs_len;
+                   byte_idx += mbcdlen;
+                   src_idx += mbclen;
+                   continue;
+                 }
+               else
+                 memcpy (pstr->mbs + byte_idx, p, mbclen);
+             }
+           else
+             memcpy (pstr->mbs + byte_idx, p, mbclen);
+
+           if (BE (pstr->offsets_needed != 0, 0))
+             {
+               size_t i;
+               for (i = 0; i < mbclen; ++i)
+                 pstr->offsets[byte_idx + i] = src_idx + i;
+             }
+           src_idx += mbclen;
+
+           pstr->wcs[byte_idx++] = wcu;
+           /* Write paddings.  */
+           for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+             pstr->wcs[byte_idx++] = WEOF;
+         }
+       else if (mbclen == (size_t) -1 || mbclen == 0)
+         {
+           /* It is an invalid character or '\0'.  Just use the byte.  */
+           int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
+
+           if (BE (pstr->trans != NULL, 0))
+             ch = pstr->trans [ch];
+           pstr->mbs[byte_idx] = ch;
+
+           if (BE (pstr->offsets_needed != 0, 0))
+             pstr->offsets[byte_idx] = src_idx;
+           ++src_idx;
+
+           /* And also cast it to wide char.  */
+           pstr->wcs[byte_idx++] = (wchar_t) ch;
+           if (BE (mbclen == (size_t) -1, 0))
+             pstr->cur_state = prev_st;
+         }
+       else
+         {
+           /* The buffer doesn't have enough space, finish to build.  */
+           pstr->cur_state = prev_st;
+           break;
+         }
+      }
+  pstr->valid_len = byte_idx;
+  pstr->valid_raw_len = src_idx;
+  return REG_NOERROR;
+}
+
+/* Skip characters until the index becomes greater than NEW_RAW_IDX.
+   Return the index.  */
+
+static Idx
+internal_function
+re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
+{
+  mbstate_t prev_st;
+  Idx rawbuf_idx;
+  size_t mbclen;
+  wint_t wc = WEOF;
+
+  /* Skip the characters which are not necessary to check.  */
+  for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
+       rawbuf_idx < new_raw_idx;)
+    {
+      wchar_t wc2;
+      Idx remain_len;
+      remain_len = pstr->len - rawbuf_idx;
+      prev_st = pstr->cur_state;
+      mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
+                         remain_len, &pstr->cur_state);
+      if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
+       {
+         /* We treat these cases as a single byte character.  */
+         if (mbclen == 0 || remain_len == 0)
+           wc = L'\0';
+         else
+           wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx);
+         mbclen = 1;
+         pstr->cur_state = prev_st;
+       }
+      else
+       wc = wc2;
+      /* Then proceed the next character.  */
+      rawbuf_idx += mbclen;
+    }
+  *last_wc = wc;
+  return rawbuf_idx;
+}
+#endif /* RE_ENABLE_I18N  */
+
+/* Build the buffer PSTR->MBS, and apply the translation if we need.
+   This function is used in case of REG_ICASE.  */
+
+static void
+internal_function
+build_upper_buffer (re_string_t *pstr)
+{
+  Idx char_idx, end_idx;
+  end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+  for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
+    {
+      int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
+      if (BE (pstr->trans != NULL, 0))
+       ch = pstr->trans[ch];
+      if (islower (ch))
+       pstr->mbs[char_idx] = toupper (ch);
+      else
+       pstr->mbs[char_idx] = ch;
+    }
+  pstr->valid_len = char_idx;
+  pstr->valid_raw_len = char_idx;
+}
+
+/* Apply TRANS to the buffer in PSTR.  */
+
+static void
+internal_function
+re_string_translate_buffer (re_string_t *pstr)
+{
+  Idx buf_idx, end_idx;
+  end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
+
+  for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
+    {
+      int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx];
+      pstr->mbs[buf_idx] = pstr->trans[ch];
+    }
+
+  pstr->valid_len = buf_idx;
+  pstr->valid_raw_len = buf_idx;
+}
+
+/* This function re-construct the buffers.
+   Concretely, convert to wide character in case of pstr->mb_cur_max > 1,
+   convert to upper case in case of REG_ICASE, apply translation.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
+{
+  Idx offset;
+
+  if (BE (pstr->raw_mbs_idx <= idx, 0))
+    offset = idx - pstr->raw_mbs_idx;
+  else
+    {
+      /* Reset buffer.  */
+#ifdef RE_ENABLE_I18N
+      if (pstr->mb_cur_max > 1)
+       memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+#endif /* RE_ENABLE_I18N */
+      pstr->len = pstr->raw_len;
+      pstr->stop = pstr->raw_stop;
+      pstr->valid_len = 0;
+      pstr->raw_mbs_idx = 0;
+      pstr->valid_raw_len = 0;
+      pstr->offsets_needed = 0;
+      pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+                          : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
+      if (!pstr->mbs_allocated)
+       pstr->mbs = (unsigned char *) pstr->raw_mbs;
+      offset = idx;
+    }
+
+  if (BE (offset != 0, 1))
+    {
+      /* Should the already checked characters be kept?  */
+      if (BE (offset < pstr->valid_raw_len, 1))
+       {
+         /* Yes, move them to the front of the buffer.  */
+#ifdef RE_ENABLE_I18N
+         if (BE (pstr->offsets_needed, 0))
+           {
+             Idx low = 0, high = pstr->valid_len, mid;
+             do
+               {
+                 mid = (high + low) / 2;
+                 if (pstr->offsets[mid] > offset)
+                   high = mid;
+                 else if (pstr->offsets[mid] < offset)
+                   low = mid + 1;
+                 else
+                   break;
+               }
+             while (low < high);
+             if (pstr->offsets[mid] < offset)
+               ++mid;
+             pstr->tip_context = re_string_context_at (pstr, mid - 1,
+                                                       eflags);
+             /* This can be quite complicated, so handle specially
+                only the common and easy case where the character with
+                different length representation of lower and upper
+                case is present at or after offset.  */
+             if (pstr->valid_len > offset
+                 && mid == offset && pstr->offsets[mid] == offset)
+               {
+                 memmove (pstr->wcs, pstr->wcs + offset,
+                          (pstr->valid_len - offset) * sizeof (wint_t));
+                 memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset);
+                 pstr->valid_len -= offset;
+                 pstr->valid_raw_len -= offset;
+                 for (low = 0; low < pstr->valid_len; low++)
+                   pstr->offsets[low] = pstr->offsets[low + offset] - offset;
+               }
+             else
+               {
+                 /* Otherwise, just find out how long the partial multibyte
+                    character at offset is and fill it with WEOF/255.  */
+                 pstr->len = pstr->raw_len - idx + offset;
+                 pstr->stop = pstr->raw_stop - idx + offset;
+                 pstr->offsets_needed = 0;
+                 while (mid > 0 && pstr->offsets[mid - 1] == offset)
+                   --mid;
+                 while (mid < pstr->valid_len)
+                   if (pstr->wcs[mid] != WEOF)
+                     break;
+                   else
+                     ++mid;
+                 if (mid == pstr->valid_len)
+                   pstr->valid_len = 0;
+                 else
+                   {
+                     pstr->valid_len = pstr->offsets[mid] - offset;
+                     if (pstr->valid_len)
+                       {
+                         for (low = 0; low < pstr->valid_len; ++low)
+                           pstr->wcs[low] = WEOF;
+                         memset (pstr->mbs, 255, pstr->valid_len);
+                       }
+                   }
+                 pstr->valid_raw_len = pstr->valid_len;
+               }
+           }
+         else
+#endif
+           {
+             pstr->tip_context = re_string_context_at (pstr, offset - 1,
+                                                       eflags);
+#ifdef RE_ENABLE_I18N
+             if (pstr->mb_cur_max > 1)
+               memmove (pstr->wcs, pstr->wcs + offset,
+                        (pstr->valid_len - offset) * sizeof (wint_t));
+#endif /* RE_ENABLE_I18N */
+             if (BE (pstr->mbs_allocated, 0))
+               memmove (pstr->mbs, pstr->mbs + offset,
+                        pstr->valid_len - offset);
+             pstr->valid_len -= offset;
+             pstr->valid_raw_len -= offset;
+#if DEBUG
+             assert (pstr->valid_len > 0);
+#endif
+           }
+       }
+      else
+       {
+#ifdef RE_ENABLE_I18N
+         /* No, skip all characters until IDX.  */
+         Idx prev_valid_len = pstr->valid_len;
+
+         if (BE (pstr->offsets_needed, 0))
+           {
+             pstr->len = pstr->raw_len - idx + offset;
+             pstr->stop = pstr->raw_stop - idx + offset;
+             pstr->offsets_needed = 0;
+           }
+#endif
+         pstr->valid_len = 0;
+#ifdef RE_ENABLE_I18N
+         if (pstr->mb_cur_max > 1)
+           {
+             Idx wcs_idx;
+             wint_t wc = WEOF;
+
+             if (pstr->is_utf8)
+               {
+                 const unsigned char *raw, *p, *end;
+
+                 /* Special case UTF-8.  Multi-byte chars start with any
+                    byte other than 0x80 - 0xbf.  */
+                 raw = pstr->raw_mbs + pstr->raw_mbs_idx;
+                 end = raw + (offset - pstr->mb_cur_max);
+                 if (end < pstr->raw_mbs)
+                   end = pstr->raw_mbs;
+                 p = raw + offset - 1;
+#ifdef _LIBC
+                 /* We know the wchar_t encoding is UCS4, so for the simple
+                    case, ASCII characters, skip the conversion step.  */
+                 if (isascii (*p) && BE (pstr->trans == NULL, 1))
+                   {
+                     memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+                     /* pstr->valid_len = 0; */
+                     wc = (wchar_t) *p;
+                   }
+                 else
+#endif
+                   for (; p >= end; --p)
+                     if ((*p & 0xc0) != 0x80)
+                       {
+                         mbstate_t cur_state;
+                         wchar_t wc2;
+                         Idx mlen = raw + pstr->len - p;
+                         size_t mbclen;
+
+#if 0 /* dead code: buf is set but never used */
+                         unsigned char buf[6];
+                         if (BE (pstr->trans != NULL, 0))
+                           {
+                             int i = mlen < 6 ? mlen : 6;
+                             while (--i >= 0)
+                               buf[i] = pstr->trans[p[i]];
+                           }
+#endif
+                         /* XXX Don't use mbrtowc, we know which conversion
+                            to use (UTF-8 -> UCS4).  */
+                         memset (&cur_state, 0, sizeof (cur_state));
+                         mbclen = __mbrtowc (&wc2, (const char *) p, mlen,
+                                             &cur_state);
+                         if (raw + offset - p <= mbclen
+                             && mbclen < (size_t) -2)
+                           {
+                             memset (&pstr->cur_state, '\0',
+                                     sizeof (mbstate_t));
+                             pstr->valid_len = mbclen - (raw + offset - p);
+                             wc = wc2;
+                           }
+                         break;
+                       }
+               }
+
+             if (wc == WEOF)
+               pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;
+             if (wc == WEOF)
+               pstr->tip_context
+                 = re_string_context_at (pstr, prev_valid_len - 1, eflags);
+             else
+               pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
+                                     && IS_WIDE_WORD_CHAR (wc))
+                                    ? CONTEXT_WORD
+                                    : ((IS_WIDE_NEWLINE (wc)
+                                        && pstr->newline_anchor)
+                                       ? CONTEXT_NEWLINE : 0));
+             if (BE (pstr->valid_len, 0))
+               {
+                 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
+                   pstr->wcs[wcs_idx] = WEOF;
+                 if (pstr->mbs_allocated)
+                   memset (pstr->mbs, 255, pstr->valid_len);
+               }
+             pstr->valid_raw_len = pstr->valid_len;
+           }
+         else
+#endif /* RE_ENABLE_I18N */
+           {
+             int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
+             pstr->valid_raw_len = 0;
+             if (pstr->trans)
+               c = pstr->trans[c];
+             pstr->tip_context = (bitset_contain (pstr->word_char, c)
+                                  ? CONTEXT_WORD
+                                  : ((IS_NEWLINE (c) && pstr->newline_anchor)
+                                     ? CONTEXT_NEWLINE : 0));
+           }
+       }
+      if (!BE (pstr->mbs_allocated, 0))
+       pstr->mbs += offset;
+    }
+  pstr->raw_mbs_idx = idx;
+  pstr->len -= offset;
+  pstr->stop -= offset;
+
+  /* Then build the buffers.  */
+#ifdef RE_ENABLE_I18N
+  if (pstr->mb_cur_max > 1)
+    {
+      if (pstr->icase)
+       {
+         reg_errcode_t ret = build_wcs_upper_buffer (pstr);
+         if (BE (ret != REG_NOERROR, 0))
+           return ret;
+       }
+      else
+       build_wcs_buffer (pstr);
+    }
+  else
+#endif /* RE_ENABLE_I18N */
+    if (BE (pstr->mbs_allocated, 0))
+      {
+       if (pstr->icase)
+         build_upper_buffer (pstr);
+       else if (pstr->trans != NULL)
+         re_string_translate_buffer (pstr);
+      }
+    else
+      pstr->valid_len = pstr->len;
+
+  pstr->cur_idx = 0;
+  return REG_NOERROR;
+}
+
+static unsigned char
+internal_function __attribute ((pure))
+re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
+{
+  int ch;
+  Idx off;
+
+  /* Handle the common (easiest) cases first.  */
+  if (BE (!pstr->mbs_allocated, 1))
+    return re_string_peek_byte (pstr, idx);
+
+#ifdef RE_ENABLE_I18N
+  if (pstr->mb_cur_max > 1
+      && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
+    return re_string_peek_byte (pstr, idx);
+#endif
+
+  off = pstr->cur_idx + idx;
+#ifdef RE_ENABLE_I18N
+  if (pstr->offsets_needed)
+    off = pstr->offsets[off];
+#endif
+
+  ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+#ifdef RE_ENABLE_I18N
+  /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
+     this function returns CAPITAL LETTER I instead of first byte of
+     DOTLESS SMALL LETTER I.  The latter would confuse the parser,
+     since peek_byte_case doesn't advance cur_idx in any way.  */
+  if (pstr->offsets_needed && !isascii (ch))
+    return re_string_peek_byte (pstr, idx);
+#endif
+
+  return ch;
+}
+
+static unsigned char
+internal_function __attribute ((pure))
+re_string_fetch_byte_case (re_string_t *pstr)
+{
+  if (BE (!pstr->mbs_allocated, 1))
+    return re_string_fetch_byte (pstr);
+
+#ifdef RE_ENABLE_I18N
+  if (pstr->offsets_needed)
+    {
+      Idx off;
+      int ch;
+
+      /* For tr_TR.UTF-8 [[:islower:]] there is
+        [[: CAPITAL LETTER I WITH DOT lower:]] in mbs.  Skip
+        in that case the whole multi-byte character and return
+        the original letter.  On the other side, with
+        [[: DOTLESS SMALL LETTER I return [[:I, as doing
+        anything else would complicate things too much.  */
+
+      if (!re_string_first_byte (pstr, pstr->cur_idx))
+       return re_string_fetch_byte (pstr);
+
+      off = pstr->offsets[pstr->cur_idx];
+      ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
+
+      if (! isascii (ch))
+       return re_string_fetch_byte (pstr);
+
+      re_string_skip_bytes (pstr,
+                           re_string_char_size_at (pstr, pstr->cur_idx));
+      return ch;
+    }
+#endif
+
+  return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
+}
+
+static void
+internal_function
+re_string_destruct (re_string_t *pstr)
+{
+#ifdef RE_ENABLE_I18N
+  re_free (pstr->wcs);
+  re_free (pstr->offsets);
+#endif /* RE_ENABLE_I18N  */
+  if (pstr->mbs_allocated)
+    re_free (pstr->mbs);
+}
+
+/* Return the context at IDX in INPUT.  */
+
+static unsigned int
+internal_function
+re_string_context_at (const re_string_t *input, Idx idx, int eflags)
+{
+  int c;
+  if (BE (! REG_VALID_INDEX (idx), 0))
+    /* In this case, we use the value stored in input->tip_context,
+       since we can't know the character in input->mbs[-1] here.  */
+    return input->tip_context;
+  if (BE (idx == input->len, 0))
+    return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
+           : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
+#ifdef RE_ENABLE_I18N
+  if (input->mb_cur_max > 1)
+    {
+      wint_t wc;
+      Idx wc_idx = idx;
+      while(input->wcs[wc_idx] == WEOF)
+       {
+#ifdef DEBUG
+         /* It must not happen.  */
+         assert (REG_VALID_INDEX (wc_idx));
+#endif
+         --wc_idx;
+         if (! REG_VALID_INDEX (wc_idx))
+           return input->tip_context;
+       }
+      wc = input->wcs[wc_idx];
+      if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
+       return CONTEXT_WORD;
+      return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
+             ? CONTEXT_NEWLINE : 0);
+    }
+  else
+#endif
+    {
+      c = re_string_byte_at (input, idx);
+      if (bitset_contain (input->word_char, c))
+       return CONTEXT_WORD;
+      return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
+    }
+}
+\f
+/* Functions for set operation.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_alloc (re_node_set *set, Idx size)
+{
+  set->alloc = size;
+  set->nelem = 0;
+  set->elems = re_malloc (Idx, size);
+  if (BE (set->elems == NULL, 0))
+    return REG_ESPACE;
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_init_1 (re_node_set *set, Idx elem)
+{
+  set->alloc = 1;
+  set->nelem = 1;
+  set->elems = re_malloc (Idx, 1);
+  if (BE (set->elems == NULL, 0))
+    {
+      set->alloc = set->nelem = 0;
+      return REG_ESPACE;
+    }
+  set->elems[0] = elem;
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
+{
+  set->alloc = 2;
+  set->elems = re_malloc (Idx, 2);
+  if (BE (set->elems == NULL, 0))
+    return REG_ESPACE;
+  if (elem1 == elem2)
+    {
+      set->nelem = 1;
+      set->elems[0] = elem1;
+    }
+  else
+    {
+      set->nelem = 2;
+      if (elem1 < elem2)
+       {
+         set->elems[0] = elem1;
+         set->elems[1] = elem2;
+       }
+      else
+       {
+         set->elems[0] = elem2;
+         set->elems[1] = elem1;
+       }
+    }
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
+{
+  dest->nelem = src->nelem;
+  if (src->nelem > 0)
+    {
+      dest->alloc = dest->nelem;
+      dest->elems = re_malloc (Idx, dest->alloc);
+      if (BE (dest->elems == NULL, 0))
+       {
+         dest->alloc = dest->nelem = 0;
+         return REG_ESPACE;
+       }
+      memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
+    }
+  else
+    re_node_set_init_empty (dest);
+  return REG_NOERROR;
+}
+
+/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to
+   DEST. Return value indicate the error code or REG_NOERROR if succeeded.
+   Note: We assume dest->elems is NULL, when dest->alloc is 0.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
+                          const re_node_set *src2)
+{
+  Idx i1, i2, is, id, delta, sbase;
+  if (src1->nelem == 0 || src2->nelem == 0)
+    return REG_NOERROR;
+
+  /* We need dest->nelem + 2 * elems_in_intersection; this is a
+     conservative estimate.  */
+  if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
+    {
+      Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
+      Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
+      if (BE (new_elems == NULL, 0))
+       return REG_ESPACE;
+      dest->elems = new_elems;
+      dest->alloc = new_alloc;
+    }
+
+  /* Find the items in the intersection of SRC1 and SRC2, and copy
+     into the top of DEST those that are not already in DEST itself.  */
+  sbase = dest->nelem + src1->nelem + src2->nelem;
+  i1 = src1->nelem - 1;
+  i2 = src2->nelem - 1;
+  id = dest->nelem - 1;
+  for (;;)
+    {
+      if (src1->elems[i1] == src2->elems[i2])
+       {
+         /* Try to find the item in DEST.  Maybe we could binary search?  */
+         while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1])
+           --id;
+
+          if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1])
+            dest->elems[--sbase] = src1->elems[i1];
+
+         if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2))
+           break;
+       }
+
+      /* Lower the highest of the two items.  */
+      else if (src1->elems[i1] < src2->elems[i2])
+       {
+         if (! REG_VALID_INDEX (--i2))
+           break;
+       }
+      else
+       {
+         if (! REG_VALID_INDEX (--i1))
+           break;
+       }
+    }
+
+  id = dest->nelem - 1;
+  is = dest->nelem + src1->nelem + src2->nelem - 1;
+  delta = is - sbase + 1;
+
+  /* Now copy.  When DELTA becomes zero, the remaining
+     DEST elements are already in place; this is more or
+     less the same loop that is in re_node_set_merge.  */
+  dest->nelem += delta;
+  if (delta > 0 && REG_VALID_INDEX (id))
+    for (;;)
+      {
+       if (dest->elems[is] > dest->elems[id])
+         {
+           /* Copy from the top.  */
+           dest->elems[id + delta--] = dest->elems[is--];
+           if (delta == 0)
+             break;
+         }
+       else
+         {
+           /* Slide from the bottom.  */
+           dest->elems[id + delta] = dest->elems[id];
+           if (! REG_VALID_INDEX (--id))
+             break;
+         }
+      }
+
+  /* Copy remaining SRC elements.  */
+  memcpy (dest->elems, dest->elems + sbase, delta * sizeof (Idx));
+
+  return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets SRC1 and SRC2. And store it to
+   DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
+                       const re_node_set *src2)
+{
+  Idx i1, i2, id;
+  if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
+    {
+      dest->alloc = src1->nelem + src2->nelem;
+      dest->elems = re_malloc (Idx, dest->alloc);
+      if (BE (dest->elems == NULL, 0))
+       return REG_ESPACE;
+    }
+  else
+    {
+      if (src1 != NULL && src1->nelem > 0)
+       return re_node_set_init_copy (dest, src1);
+      else if (src2 != NULL && src2->nelem > 0)
+       return re_node_set_init_copy (dest, src2);
+      else
+       re_node_set_init_empty (dest);
+      return REG_NOERROR;
+    }
+  for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
+    {
+      if (src1->elems[i1] > src2->elems[i2])
+       {
+         dest->elems[id++] = src2->elems[i2++];
+         continue;
+       }
+      if (src1->elems[i1] == src2->elems[i2])
+       ++i2;
+      dest->elems[id++] = src1->elems[i1++];
+    }
+  if (i1 < src1->nelem)
+    {
+      memcpy (dest->elems + id, src1->elems + i1,
+            (src1->nelem - i1) * sizeof (Idx));
+      id += src1->nelem - i1;
+    }
+  else if (i2 < src2->nelem)
+    {
+      memcpy (dest->elems + id, src2->elems + i2,
+            (src2->nelem - i2) * sizeof (Idx));
+      id += src2->nelem - i2;
+    }
+  dest->nelem = id;
+  return REG_NOERROR;
+}
+
+/* Calculate the union set of the sets DEST and SRC. And store it to
+   DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_node_set_merge (re_node_set *dest, const re_node_set *src)
+{
+  Idx is, id, sbase, delta;
+  if (src == NULL || src->nelem == 0)
+    return REG_NOERROR;
+  if (dest->alloc < 2 * src->nelem + dest->nelem)
+    {
+      Idx new_alloc = 2 * (src->nelem + dest->alloc);
+      Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
+      if (BE (new_buffer == NULL, 0))
+       return REG_ESPACE;
+      dest->elems = new_buffer;
+      dest->alloc = new_alloc;
+    }
+
+  if (BE (dest->nelem == 0, 0))
+    {
+      dest->nelem = src->nelem;
+      memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
+      return REG_NOERROR;
+    }
+
+  /* Copy into the top of DEST the items of SRC that are not
+     found in DEST.  Maybe we could binary search in DEST?  */
+  for (sbase = dest->nelem + 2 * src->nelem,
+       is = src->nelem - 1, id = dest->nelem - 1;
+       REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
+    {
+      if (dest->elems[id] == src->elems[is])
+       is--, id--;
+      else if (dest->elems[id] < src->elems[is])
+       dest->elems[--sbase] = src->elems[is--];
+      else /* if (dest->elems[id] > src->elems[is]) */
+       --id;
+    }
+
+  if (REG_VALID_INDEX (is))
+    {
+      /* If DEST is exhausted, the remaining items of SRC must be unique.  */
+      sbase -= is + 1;
+      memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (Idx));
+    }
+
+  id = dest->nelem - 1;
+  is = dest->nelem + 2 * src->nelem - 1;
+  delta = is - sbase + 1;
+  if (delta == 0)
+    return REG_NOERROR;
+
+  /* Now copy.  When DELTA becomes zero, the remaining
+     DEST elements are already in place.  */
+  dest->nelem += delta;
+  for (;;)
+    {
+      if (dest->elems[is] > dest->elems[id])
+       {
+         /* Copy from the top.  */
+         dest->elems[id + delta--] = dest->elems[is--];
+         if (delta == 0)
+           break;
+       }
+      else
+       {
+         /* Slide from the bottom.  */
+         dest->elems[id + delta] = dest->elems[id];
+         if (! REG_VALID_INDEX (--id))
+           {
+             /* Copy remaining SRC elements.  */
+             memcpy (dest->elems, dest->elems + sbase,
+                     delta * sizeof (Idx));
+             break;
+           }
+       }
+    }
+
+  return REG_NOERROR;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+   SET should not already have ELEM.
+   Return true if successful.  */
+
+static bool
+internal_function __attribute_warn_unused_result__
+re_node_set_insert (re_node_set *set, Idx elem)
+{
+  Idx idx;
+  /* In case the set is empty.  */
+  if (set->alloc == 0)
+    return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1);
+
+  if (BE (set->nelem, 0) == 0)
+    {
+      /* We already guaranteed above that set->alloc != 0.  */
+      set->elems[0] = elem;
+      ++set->nelem;
+      return true;
+    }
+
+  /* Realloc if we need.  */
+  if (set->alloc == set->nelem)
+    {
+      Idx *new_elems;
+      set->alloc = set->alloc * 2;
+      new_elems = re_realloc (set->elems, Idx, set->alloc);
+      if (BE (new_elems == NULL, 0))
+       return false;
+      set->elems = new_elems;
+    }
+
+  /* Move the elements which follows the new element.  Test the
+     first element separately to skip a check in the inner loop.  */
+  if (elem < set->elems[0])
+    {
+      idx = 0;
+      for (idx = set->nelem; idx > 0; idx--)
+       set->elems[idx] = set->elems[idx - 1];
+    }
+  else
+    {
+      for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
+       set->elems[idx] = set->elems[idx - 1];
+    }
+
+  /* Insert the new element.  */
+  set->elems[idx] = elem;
+  ++set->nelem;
+  return true;
+}
+
+/* Insert the new element ELEM to the re_node_set* SET.
+   SET should not already have any element greater than or equal to ELEM.
+   Return true if successful.  */
+
+static bool
+internal_function __attribute_warn_unused_result__
+re_node_set_insert_last (re_node_set *set, Idx elem)
+{
+  /* Realloc if we need.  */
+  if (set->alloc == set->nelem)
+    {
+      Idx *new_elems;
+      set->alloc = (set->alloc + 1) * 2;
+      new_elems = re_realloc (set->elems, Idx, set->alloc);
+      if (BE (new_elems == NULL, 0))
+       return false;
+      set->elems = new_elems;
+    }
+
+  /* Insert the new element.  */
+  set->elems[set->nelem++] = elem;
+  return true;
+}
+
+/* Compare two node sets SET1 and SET2.
+   Return true if SET1 and SET2 are equivalent.  */
+
+static bool
+internal_function __attribute ((pure))
+re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
+{
+  Idx i;
+  if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
+    return false;
+  for (i = set1->nelem ; REG_VALID_INDEX (--i) ; )
+    if (set1->elems[i] != set2->elems[i])
+      return false;
+  return true;
+}
+
+/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise.  */
+
+static Idx
+internal_function __attribute ((pure))
+re_node_set_contains (const re_node_set *set, Idx elem)
+{
+  __re_size_t idx, right, mid;
+  if (! REG_VALID_NONZERO_INDEX (set->nelem))
+    return 0;
+
+  /* Binary search the element.  */
+  idx = 0;
+  right = set->nelem - 1;
+  while (idx < right)
+    {
+      mid = (idx + right) / 2;
+      if (set->elems[mid] < elem)
+       idx = mid + 1;
+      else
+       right = mid;
+    }
+  return set->elems[idx] == elem ? idx + 1 : 0;
+}
+
+static void
+internal_function
+re_node_set_remove_at (re_node_set *set, Idx idx)
+{
+  if (idx < 0 || idx >= set->nelem)
+    return;
+  --set->nelem;
+  for (; idx < set->nelem; idx++)
+    set->elems[idx] = set->elems[idx + 1];
+}
+\f
+
+/* Add the token TOKEN to dfa->nodes, and return the index of the token.
+   Or return REG_MISSING if an error occurred.  */
+
+static Idx
+internal_function
+re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
+{
+  if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
+    {
+      size_t new_nodes_alloc = dfa->nodes_alloc * 2;
+      Idx *new_nexts, *new_indices;
+      re_node_set *new_edests, *new_eclosures;
+      re_token_t *new_nodes;
+      size_t max_object_size =
+       MAX (sizeof (re_token_t),
+            MAX (sizeof (re_node_set),
+                 sizeof (Idx)));
+
+      /* Avoid overflows.  */
+      if (BE (SIZE_MAX / 2 / max_object_size < dfa->nodes_alloc, 0))
+       return REG_MISSING;
+
+      new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
+      if (BE (new_nodes == NULL, 0))
+       return REG_MISSING;
+      dfa->nodes = new_nodes;
+      new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
+      new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
+      new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
+      new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
+      if (BE (new_nexts == NULL || new_indices == NULL
+             || new_edests == NULL || new_eclosures == NULL, 0))
+       return REG_MISSING;
+      dfa->nexts = new_nexts;
+      dfa->org_indices = new_indices;
+      dfa->edests = new_edests;
+      dfa->eclosures = new_eclosures;
+      dfa->nodes_alloc = new_nodes_alloc;
+    }
+  dfa->nodes[dfa->nodes_len] = token;
+  dfa->nodes[dfa->nodes_len].constraint = 0;
+#ifdef RE_ENABLE_I18N
+  {
+  int type = token.type;
+  dfa->nodes[dfa->nodes_len].accept_mb =
+    (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
+  }
+#endif
+  dfa->nexts[dfa->nodes_len] = REG_MISSING;
+  re_node_set_init_empty (dfa->edests + dfa->nodes_len);
+  re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
+  return dfa->nodes_len++;
+}
+
+static inline re_hashval_t
+internal_function
+calc_state_hash (const re_node_set *nodes, unsigned int context)
+{
+  re_hashval_t hash = nodes->nelem + context;
+  Idx i;
+  for (i = 0 ; i < nodes->nelem ; i++)
+    hash += nodes->elems[i];
+  return hash;
+}
+
+/* Search for the state whose node_set is equivalent to NODES.
+   Return the pointer to the state, if we found it in the DFA.
+   Otherwise create the new one and return it.  In case of an error
+   return NULL and set the error code in ERR.
+   Note: - We assume NULL as the invalid state, then it is possible that
+          return value is NULL and ERR is REG_NOERROR.
+        - We never return non-NULL value in case of any errors, it is for
+          optimization.  */
+
+static re_dfastate_t *
+internal_function __attribute_warn_unused_result__
+re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
+                 const re_node_set *nodes)
+{
+  re_hashval_t hash;
+  re_dfastate_t *new_state;
+  struct re_state_table_entry *spot;
+  Idx i;
+#ifdef lint
+  /* Suppress bogus uninitialized-variable warnings.  */
+  *err = REG_NOERROR;
+#endif
+  if (BE (nodes->nelem == 0, 0))
+    {
+      *err = REG_NOERROR;
+      return NULL;
+    }
+  hash = calc_state_hash (nodes, 0);
+  spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+  for (i = 0 ; i < spot->num ; i++)
+    {
+      re_dfastate_t *state = spot->array[i];
+      if (hash != state->hash)
+       continue;
+      if (re_node_set_compare (&state->nodes, nodes))
+       return state;
+    }
+
+  /* There are no appropriate state in the dfa, create the new one.  */
+  new_state = create_ci_newstate (dfa, nodes, hash);
+  if (BE (new_state == NULL, 0))
+    *err = REG_ESPACE;
+
+  return new_state;
+}
+
+/* Search for the state whose node_set is equivalent to NODES and
+   whose context is equivalent to CONTEXT.
+   Return the pointer to the state, if we found it in the DFA.
+   Otherwise create the new one and return it.  In case of an error
+   return NULL and set the error code in ERR.
+   Note: - We assume NULL as the invalid state, then it is possible that
+          return value is NULL and ERR is REG_NOERROR.
+        - We never return non-NULL value in case of any errors, it is for
+          optimization.  */
+
+static re_dfastate_t *
+internal_function __attribute_warn_unused_result__
+re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
+                         const re_node_set *nodes, unsigned int context)
+{
+  re_hashval_t hash;
+  re_dfastate_t *new_state;
+  struct re_state_table_entry *spot;
+  Idx i;
+#ifdef lint
+  /* Suppress bogus uninitialized-variable warnings.  */
+  *err = REG_NOERROR;
+#endif
+  if (nodes->nelem == 0)
+    {
+      *err = REG_NOERROR;
+      return NULL;
+    }
+  hash = calc_state_hash (nodes, context);
+  spot = dfa->state_table + (hash & dfa->state_hash_mask);
+
+  for (i = 0 ; i < spot->num ; i++)
+    {
+      re_dfastate_t *state = spot->array[i];
+      if (state->hash == hash
+         && state->context == context
+         && re_node_set_compare (state->entrance_nodes, nodes))
+       return state;
+    }
+  /* There are no appropriate state in `dfa', create the new one.  */
+  new_state = create_cd_newstate (dfa, nodes, context, hash);
+  if (BE (new_state == NULL, 0))
+    *err = REG_ESPACE;
+
+  return new_state;
+}
+
+/* Finish initialization of the new state NEWSTATE, and using its hash value
+   HASH put in the appropriate bucket of DFA's state table.  Return value
+   indicates the error code if failed.  */
+
+static reg_errcode_t
+__attribute_warn_unused_result__
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
+               re_hashval_t hash)
+{
+  struct re_state_table_entry *spot;
+  reg_errcode_t err;
+  Idx i;
+
+  newstate->hash = hash;
+  err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
+  if (BE (err != REG_NOERROR, 0))
+    return REG_ESPACE;
+  for (i = 0; i < newstate->nodes.nelem; i++)
+    {
+      Idx elem = newstate->nodes.elems[i];
+      if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
+       if (BE (! re_node_set_insert_last (&newstate->non_eps_nodes, elem), 0))
+         return REG_ESPACE;
+    }
+
+  spot = dfa->state_table + (hash & dfa->state_hash_mask);
+  if (BE (spot->alloc <= spot->num, 0))
+    {
+      Idx new_alloc = 2 * spot->num + 2;
+      re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
+                                             new_alloc);
+      if (BE (new_array == NULL, 0))
+       return REG_ESPACE;
+      spot->array = new_array;
+      spot->alloc = new_alloc;
+    }
+  spot->array[spot->num++] = newstate;
+  return REG_NOERROR;
+}
+
+static void
+free_state (re_dfastate_t *state)
+{
+  re_node_set_free (&state->non_eps_nodes);
+  re_node_set_free (&state->inveclosure);
+  if (state->entrance_nodes != &state->nodes)
+    {
+      re_node_set_free (state->entrance_nodes);
+      re_free (state->entrance_nodes);
+    }
+  re_node_set_free (&state->nodes);
+  re_free (state->word_trtable);
+  re_free (state->trtable);
+  re_free (state);
+}
+
+/* Create the new state which is independ of contexts.
+   Return the new state if succeeded, otherwise return NULL.  */
+
+static re_dfastate_t *
+internal_function __attribute_warn_unused_result__
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+                   re_hashval_t hash)
+{
+  Idx i;
+  reg_errcode_t err;
+  re_dfastate_t *newstate;
+
+  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+  if (BE (newstate == NULL, 0))
+    return NULL;
+  err = re_node_set_init_copy (&newstate->nodes, nodes);
+  if (BE (err != REG_NOERROR, 0))
+    {
+      re_free (newstate);
+      return NULL;
+    }
+
+  newstate->entrance_nodes = &newstate->nodes;
+  for (i = 0 ; i < nodes->nelem ; i++)
+    {
+      re_token_t *node = dfa->nodes + nodes->elems[i];
+      re_token_type_t type = node->type;
+      if (type == CHARACTER && !node->constraint)
+       continue;
+#ifdef RE_ENABLE_I18N
+      newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+      /* If the state has the halt node, the state is a halt state.  */
+      if (type == END_OF_RE)
+       newstate->halt = 1;
+      else if (type == OP_BACK_REF)
+       newstate->has_backref = 1;
+      else if (type == ANCHOR || node->constraint)
+       newstate->has_constraint = 1;
+    }
+  err = register_state (dfa, newstate, hash);
+  if (BE (err != REG_NOERROR, 0))
+    {
+      free_state (newstate);
+      newstate = NULL;
+    }
+  return newstate;
+}
+
+/* Create the new state which is depend on the context CONTEXT.
+   Return the new state if succeeded, otherwise return NULL.  */
+
+static re_dfastate_t *
+internal_function __attribute_warn_unused_result__
+create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+                   unsigned int context, re_hashval_t hash)
+{
+  Idx i, nctx_nodes = 0;
+  reg_errcode_t err;
+  re_dfastate_t *newstate;
+
+  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+  if (BE (newstate == NULL, 0))
+    return NULL;
+  err = re_node_set_init_copy (&newstate->nodes, nodes);
+  if (BE (err != REG_NOERROR, 0))
+    {
+      re_free (newstate);
+      return NULL;
+    }
+
+  newstate->context = context;
+  newstate->entrance_nodes = &newstate->nodes;
+
+  for (i = 0 ; i < nodes->nelem ; i++)
+    {
+      re_token_t *node = dfa->nodes + nodes->elems[i];
+      re_token_type_t type = node->type;
+      unsigned int constraint = node->constraint;
+
+      if (type == CHARACTER && !constraint)
+       continue;
+#ifdef RE_ENABLE_I18N
+      newstate->accept_mb |= node->accept_mb;
+#endif /* RE_ENABLE_I18N */
+
+      /* If the state has the halt node, the state is a halt state.  */
+      if (type == END_OF_RE)
+       newstate->halt = 1;
+      else if (type == OP_BACK_REF)
+       newstate->has_backref = 1;
+
+      if (constraint)
+       {
+         if (newstate->entrance_nodes == &newstate->nodes)
+           {
+             newstate->entrance_nodes = re_malloc (re_node_set, 1);
+             if (BE (newstate->entrance_nodes == NULL, 0))
+               {
+                 free_state (newstate);
+                 return NULL;
+               }
+             if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
+                 != REG_NOERROR)
+               return NULL;
+             nctx_nodes = 0;
+             newstate->has_constraint = 1;
+           }
+
+         if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
+           {
+             re_node_set_remove_at (&newstate->nodes, i - nctx_nodes);
+             ++nctx_nodes;
+           }
+       }
+    }
+  err = register_state (dfa, newstate, hash);
+  if (BE (err != REG_NOERROR, 0))
+    {
+      free_state (newstate);
+      newstate = NULL;
+    }
+  return  newstate;
+}
diff --git a/gnulib/lib/regex_internal.h b/gnulib/lib/regex_internal.h
new file mode 100644 (file)
index 0000000..e18e7a0
--- /dev/null
@@ -0,0 +1,870 @@
+/* Extended regular expression matching and search library.
+   Copyright (C) 2002-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _REGEX_INTERNAL_H
+#define _REGEX_INTERNAL_H 1
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <langinfo.h>
+#ifndef _LIBC
+# include "localcharset.h"
+#endif
+#include <locale.h>
+
+#include <wchar.h>
+#include <wctype.h>
+#include <stdint.h>
+#if defined _LIBC
+# include <bits/libc-lock.h>
+#else
+# define __libc_lock_init(NAME) do { } while (0)
+# define __libc_lock_lock(NAME) do { } while (0)
+# define __libc_lock_unlock(NAME) do { } while (0)
+#endif
+
+/* In case that the system doesn't have isblank().  */
+#if !defined _LIBC && ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#endif
+
+#ifdef _LIBC
+# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
+#  define _RE_DEFINE_LOCALE_FUNCTIONS 1
+#   include <locale/localeinfo.h>
+#   include <locale/elem-hash.h>
+#   include <locale/coll-lookup.h>
+# endif
+#endif
+
+/* This is for other GNU distributions with internationalized messages.  */
+#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+#  undef gettext
+#  define gettext(msgid) \
+  INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
+# endif
+#else
+# define gettext(msgid) (msgid)
+#endif
+
+#ifndef gettext_noop
+/* This define is so xgettext can find the internationalizable
+   strings.  */
+# define gettext_noop(String) String
+#endif
+
+/* For loser systems without the definition.  */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
+# define RE_ENABLE_I18N
+#endif
+
+#if __GNUC__ >= 3
+# define BE(expr, val) __builtin_expect (expr, val)
+#else
+# define BE(expr, val) (expr)
+# ifdef _LIBC
+#  define inline
+# endif
+#endif
+
+/* Number of ASCII characters.  */
+#define ASCII_CHARS 0x80
+
+/* Number of single byte characters.  */
+#define SBC_MAX (UCHAR_MAX + 1)
+
+#define COLL_ELEM_LEN_MAX 8
+
+/* The character which represents newline.  */
+#define NEWLINE_CHAR '\n'
+#define WIDE_NEWLINE_CHAR L'\n'
+
+/* Rename to standard API for using out of glibc.  */
+#ifndef _LIBC
+# define __wctype wctype
+# define __iswctype iswctype
+# define __btowc btowc
+# define __wcrtomb wcrtomb
+# define __mbrtowc mbrtowc
+# define __regfree regfree
+# define attribute_hidden
+#endif /* not _LIBC */
+
+#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+# define __attribute(arg) __attribute__ (arg)
+#else
+# define __attribute(arg)
+#endif
+
+typedef __re_idx_t Idx;
+
+/* Special return value for failure to match.  */
+#define REG_MISSING ((Idx) -1)
+
+/* Special return value for internal error.  */
+#define REG_ERROR ((Idx) -2)
+
+/* Test whether N is a valid index, and is not one of the above.  */
+#ifdef _REGEX_LARGE_OFFSETS
+# define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR)
+#else
+# define REG_VALID_INDEX(n) (0 <= (n))
+#endif
+
+/* Test whether N is a valid nonzero index.  */
+#ifdef _REGEX_LARGE_OFFSETS
+# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1))
+#else
+# define REG_VALID_NONZERO_INDEX(n) (0 < (n))
+#endif
+
+/* A hash value, suitable for computing hash tables.  */
+typedef __re_size_t re_hashval_t;
+
+/* An integer used to represent a set of bits.  It must be unsigned,
+   and must be at least as wide as unsigned int.  */
+typedef unsigned long int bitset_word_t;
+/* All bits set in a bitset_word_t.  */
+#define BITSET_WORD_MAX ULONG_MAX
+
+/* Number of bits in a bitset_word_t.  For portability to hosts with
+   padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
+   instead, deduce it directly from BITSET_WORD_MAX.  Avoid
+   greater-than-32-bit integers and unconditional shifts by more than
+   31 bits, as they're not portable.  */
+#if BITSET_WORD_MAX == 0xffffffffUL
+# define BITSET_WORD_BITS 32
+#elif BITSET_WORD_MAX >> 31 >> 4 == 1
+# define BITSET_WORD_BITS 36
+#elif BITSET_WORD_MAX >> 31 >> 16 == 1
+# define BITSET_WORD_BITS 48
+#elif BITSET_WORD_MAX >> 31 >> 28 == 1
+# define BITSET_WORD_BITS 60
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
+# define BITSET_WORD_BITS 64
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
+# define BITSET_WORD_BITS 72
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
+# define BITSET_WORD_BITS 128
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
+# define BITSET_WORD_BITS 256
+#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
+# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
+# if BITSET_WORD_BITS <= SBC_MAX
+#  error "Invalid SBC_MAX"
+# endif
+#else
+# error "Add case for new bitset_word_t size"
+#endif
+
+/* Number of bitset_word_t values in a bitset_t.  */
+#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
+
+typedef bitset_word_t bitset_t[BITSET_WORDS];
+typedef bitset_word_t *re_bitset_ptr_t;
+typedef const bitset_word_t *re_const_bitset_ptr_t;
+
+#define PREV_WORD_CONSTRAINT 0x0001
+#define PREV_NOTWORD_CONSTRAINT 0x0002
+#define NEXT_WORD_CONSTRAINT 0x0004
+#define NEXT_NOTWORD_CONSTRAINT 0x0008
+#define PREV_NEWLINE_CONSTRAINT 0x0010
+#define NEXT_NEWLINE_CONSTRAINT 0x0020
+#define PREV_BEGBUF_CONSTRAINT 0x0040
+#define NEXT_ENDBUF_CONSTRAINT 0x0080
+#define WORD_DELIM_CONSTRAINT 0x0100
+#define NOT_WORD_DELIM_CONSTRAINT 0x0200
+
+typedef enum
+{
+  INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+  WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
+  WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+  INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+  LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
+  LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
+  BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
+  BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
+  WORD_DELIM = WORD_DELIM_CONSTRAINT,
+  NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
+} re_context_type;
+
+typedef struct
+{
+  Idx alloc;
+  Idx nelem;
+  Idx *elems;
+} re_node_set;
+
+typedef enum
+{
+  NON_TYPE = 0,
+
+  /* Node type, These are used by token, node, tree.  */
+  CHARACTER = 1,
+  END_OF_RE = 2,
+  SIMPLE_BRACKET = 3,
+  OP_BACK_REF = 4,
+  OP_PERIOD = 5,
+#ifdef RE_ENABLE_I18N
+  COMPLEX_BRACKET = 6,
+  OP_UTF8_PERIOD = 7,
+#endif /* RE_ENABLE_I18N */
+
+  /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
+     when the debugger shows values of this enum type.  */
+#define EPSILON_BIT 8
+  OP_OPEN_SUBEXP = EPSILON_BIT | 0,
+  OP_CLOSE_SUBEXP = EPSILON_BIT | 1,
+  OP_ALT = EPSILON_BIT | 2,
+  OP_DUP_ASTERISK = EPSILON_BIT | 3,
+  ANCHOR = EPSILON_BIT | 4,
+
+  /* Tree type, these are used only by tree. */
+  CONCAT = 16,
+  SUBEXP = 17,
+
+  /* Token type, these are used only by token.  */
+  OP_DUP_PLUS = 18,
+  OP_DUP_QUESTION,
+  OP_OPEN_BRACKET,
+  OP_CLOSE_BRACKET,
+  OP_CHARSET_RANGE,
+  OP_OPEN_DUP_NUM,
+  OP_CLOSE_DUP_NUM,
+  OP_NON_MATCH_LIST,
+  OP_OPEN_COLL_ELEM,
+  OP_CLOSE_COLL_ELEM,
+  OP_OPEN_EQUIV_CLASS,
+  OP_CLOSE_EQUIV_CLASS,
+  OP_OPEN_CHAR_CLASS,
+  OP_CLOSE_CHAR_CLASS,
+  OP_WORD,
+  OP_NOTWORD,
+  OP_SPACE,
+  OP_NOTSPACE,
+  BACK_SLASH
+
+} re_token_type_t;
+
+#ifdef RE_ENABLE_I18N
+typedef struct
+{
+  /* Multibyte characters.  */
+  wchar_t *mbchars;
+
+  /* Collating symbols.  */
+# ifdef _LIBC
+  int32_t *coll_syms;
+# endif
+
+  /* Equivalence classes. */
+# ifdef _LIBC
+  int32_t *equiv_classes;
+# endif
+
+  /* Range expressions. */
+# ifdef _LIBC
+  uint32_t *range_starts;
+  uint32_t *range_ends;
+# else /* not _LIBC */
+  wchar_t *range_starts;
+  wchar_t *range_ends;
+# endif /* not _LIBC */
+
+  /* Character classes. */
+  wctype_t *char_classes;
+
+  /* If this character set is the non-matching list.  */
+  unsigned int non_match : 1;
+
+  /* # of multibyte characters.  */
+  Idx nmbchars;
+
+  /* # of collating symbols.  */
+  Idx ncoll_syms;
+
+  /* # of equivalence classes. */
+  Idx nequiv_classes;
+
+  /* # of range expressions. */
+  Idx nranges;
+
+  /* # of character classes. */
+  Idx nchar_classes;
+} re_charset_t;
+#endif /* RE_ENABLE_I18N */
+
+typedef struct
+{
+  union
+  {
+    unsigned char c;           /* for CHARACTER */
+    re_bitset_ptr_t sbcset;    /* for SIMPLE_BRACKET */
+#ifdef RE_ENABLE_I18N
+    re_charset_t *mbcset;      /* for COMPLEX_BRACKET */
+#endif /* RE_ENABLE_I18N */
+    Idx idx;                   /* for BACK_REF */
+    re_context_type ctx_type;  /* for ANCHOR */
+  } opr;
+#if __GNUC__ >= 2 && !__STRICT_ANSI__
+  re_token_type_t type : 8;
+#else
+  re_token_type_t type;
+#endif
+  unsigned int constraint : 10;        /* context constraint */
+  unsigned int duplicated : 1;
+  unsigned int opt_subexp : 1;
+#ifdef RE_ENABLE_I18N
+  unsigned int accept_mb : 1;
+  /* These 2 bits can be moved into the union if needed (e.g. if running out
+     of bits; move opr.c to opr.c.c and move the flags to opr.c.flags).  */
+  unsigned int mb_partial : 1;
+#endif
+  unsigned int word_char : 1;
+} re_token_t;
+
+#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT)
+
+struct re_string_t
+{
+  /* Indicate the raw buffer which is the original string passed as an
+     argument of regexec(), re_search(), etc..  */
+  const unsigned char *raw_mbs;
+  /* Store the multibyte string.  In case of "case insensitive mode" like
+     REG_ICASE, upper cases of the string are stored, otherwise MBS points
+     the same address that RAW_MBS points.  */
+  unsigned char *mbs;
+#ifdef RE_ENABLE_I18N
+  /* Store the wide character string which is corresponding to MBS.  */
+  wint_t *wcs;
+  Idx *offsets;
+  mbstate_t cur_state;
+#endif
+  /* Index in RAW_MBS.  Each character mbs[i] corresponds to
+     raw_mbs[raw_mbs_idx + i].  */
+  Idx raw_mbs_idx;
+  /* The length of the valid characters in the buffers.  */
+  Idx valid_len;
+  /* The corresponding number of bytes in raw_mbs array.  */
+  Idx valid_raw_len;
+  /* The length of the buffers MBS and WCS.  */
+  Idx bufs_len;
+  /* The index in MBS, which is updated by re_string_fetch_byte.  */
+  Idx cur_idx;
+  /* length of RAW_MBS array.  */
+  Idx raw_len;
+  /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN.  */
+  Idx len;
+  /* End of the buffer may be shorter than its length in the cases such
+     as re_match_2, re_search_2.  Then, we use STOP for end of the buffer
+     instead of LEN.  */
+  Idx raw_stop;
+  /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS.  */
+  Idx stop;
+
+  /* The context of mbs[0].  We store the context independently, since
+     the context of mbs[0] may be different from raw_mbs[0], which is
+     the beginning of the input string.  */
+  unsigned int tip_context;
+  /* The translation passed as a part of an argument of re_compile_pattern.  */
+  RE_TRANSLATE_TYPE trans;
+  /* Copy of re_dfa_t's word_char.  */
+  re_const_bitset_ptr_t word_char;
+  /* true if REG_ICASE.  */
+  unsigned char icase;
+  unsigned char is_utf8;
+  unsigned char map_notascii;
+  unsigned char mbs_allocated;
+  unsigned char offsets_needed;
+  unsigned char newline_anchor;
+  unsigned char word_ops_used;
+  int mb_cur_max;
+};
+typedef struct re_string_t re_string_t;
+
+
+struct re_dfa_t;
+typedef struct re_dfa_t re_dfa_t;
+
+#ifndef _LIBC
+# if defined __i386__ && !defined __EMX__
+#  define internal_function   __attribute ((regparm (3), stdcall))
+# else
+#  define internal_function
+# endif
+#endif
+
+static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
+                                               Idx new_buf_len)
+     internal_function;
+#ifdef RE_ENABLE_I18N
+static void build_wcs_buffer (re_string_t *pstr) internal_function;
+static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
+     internal_function;
+#endif /* RE_ENABLE_I18N */
+static void build_upper_buffer (re_string_t *pstr) internal_function;
+static void re_string_translate_buffer (re_string_t *pstr) internal_function;
+static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
+                                         int eflags)
+     internal_function __attribute ((pure));
+#define re_string_peek_byte(pstr, offset) \
+  ((pstr)->mbs[(pstr)->cur_idx + offset])
+#define re_string_fetch_byte(pstr) \
+  ((pstr)->mbs[(pstr)->cur_idx++])
+#define re_string_first_byte(pstr, idx) \
+  ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF)
+#define re_string_is_single_byte_char(pstr, idx) \
+  ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \
+                               || (pstr)->wcs[(idx) + 1] != WEOF))
+#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx)
+#define re_string_cur_idx(pstr) ((pstr)->cur_idx)
+#define re_string_get_buffer(pstr) ((pstr)->mbs)
+#define re_string_length(pstr) ((pstr)->len)
+#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx])
+#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
+#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
+
+#include <alloca.h>
+
+#ifndef _LIBC
+# if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+   and a page size can be as small as 4096 bytes.  So we cannot safely
+   allocate anything larger than 4096 bytes.  Also care for the possibility
+   of a few compiler-allocated temporary stack slots.  */
+#  define __libc_use_alloca(n) ((n) < 4032)
+# else
+/* alloca is implemented with malloc, so just use malloc.  */
+#  define __libc_use_alloca(n) 0
+#  undef alloca
+#  define alloca(n) malloc (n)
+# endif
+#endif
+
+#ifndef MAX
+# define MAX(a,b) ((a) < (b) ? (b) : (a))
+#endif
+
+#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
+#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
+#define re_free(p) free (p)
+
+struct bin_tree_t
+{
+  struct bin_tree_t *parent;
+  struct bin_tree_t *left;
+  struct bin_tree_t *right;
+  struct bin_tree_t *first;
+  struct bin_tree_t *next;
+
+  re_token_t token;
+
+  /* `node_idx' is the index in dfa->nodes, if `type' == 0.
+     Otherwise `type' indicate the type of this node.  */
+  Idx node_idx;
+};
+typedef struct bin_tree_t bin_tree_t;
+
+#define BIN_TREE_STORAGE_SIZE \
+  ((1024 - sizeof (void *)) / sizeof (bin_tree_t))
+
+struct bin_tree_storage_t
+{
+  struct bin_tree_storage_t *next;
+  bin_tree_t data[BIN_TREE_STORAGE_SIZE];
+};
+typedef struct bin_tree_storage_t bin_tree_storage_t;
+
+#define CONTEXT_WORD 1
+#define CONTEXT_NEWLINE (CONTEXT_WORD << 1)
+#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1)
+#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1)
+
+#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD)
+#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE)
+#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF)
+#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF)
+#define IS_ORDINARY_CONTEXT(c) ((c) == 0)
+
+#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
+#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
+#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_')
+#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
+
+#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
+ ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+  || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+  || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\
+  || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context)))
+
+#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \
+ ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \
+  || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \
+  || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \
+  || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context)))
+
+struct re_dfastate_t
+{
+  re_hashval_t hash;
+  re_node_set nodes;
+  re_node_set non_eps_nodes;
+  re_node_set inveclosure;
+  re_node_set *entrance_nodes;
+  struct re_dfastate_t **trtable, **word_trtable;
+  unsigned int context : 4;
+  unsigned int halt : 1;
+  /* If this state can accept `multi byte'.
+     Note that we refer to multibyte characters, and multi character
+     collating elements as `multi byte'.  */
+  unsigned int accept_mb : 1;
+  /* If this state has backreference node(s).  */
+  unsigned int has_backref : 1;
+  unsigned int has_constraint : 1;
+};
+typedef struct re_dfastate_t re_dfastate_t;
+
+struct re_state_table_entry
+{
+  Idx num;
+  Idx alloc;
+  re_dfastate_t **array;
+};
+
+/* Array type used in re_sub_match_last_t and re_sub_match_top_t.  */
+
+typedef struct
+{
+  Idx next_idx;
+  Idx alloc;
+  re_dfastate_t **array;
+} state_array_t;
+
+/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP.  */
+
+typedef struct
+{
+  Idx node;
+  Idx str_idx; /* The position NODE match at.  */
+  state_array_t path;
+} re_sub_match_last_t;
+
+/* Store information about the node NODE whose type is OP_OPEN_SUBEXP.
+   And information about the node, whose type is OP_CLOSE_SUBEXP,
+   corresponding to NODE is stored in LASTS.  */
+
+typedef struct
+{
+  Idx str_idx;
+  Idx node;
+  state_array_t *path;
+  Idx alasts; /* Allocation size of LASTS.  */
+  Idx nlasts; /* The number of LASTS.  */
+  re_sub_match_last_t **lasts;
+} re_sub_match_top_t;
+
+struct re_backref_cache_entry
+{
+  Idx node;
+  Idx str_idx;
+  Idx subexp_from;
+  Idx subexp_to;
+  char more;
+  char unused;
+  unsigned short int eps_reachable_subexps_map;
+};
+
+typedef struct
+{
+  /* The string object corresponding to the input string.  */
+  re_string_t input;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+  const re_dfa_t *const dfa;
+#else
+  const re_dfa_t *dfa;
+#endif
+  /* EFLAGS of the argument of regexec.  */
+  int eflags;
+  /* Where the matching ends.  */
+  Idx match_last;
+  Idx last_node;
+  /* The state log used by the matcher.  */
+  re_dfastate_t **state_log;
+  Idx state_log_top;
+  /* Back reference cache.  */
+  Idx nbkref_ents;
+  Idx abkref_ents;
+  struct re_backref_cache_entry *bkref_ents;
+  int max_mb_elem_len;
+  Idx nsub_tops;
+  Idx asub_tops;
+  re_sub_match_top_t **sub_tops;
+} re_match_context_t;
+
+typedef struct
+{
+  re_dfastate_t **sifted_states;
+  re_dfastate_t **limited_states;
+  Idx last_node;
+  Idx last_str_idx;
+  re_node_set limits;
+} re_sift_context_t;
+
+struct re_fail_stack_ent_t
+{
+  Idx idx;
+  Idx node;
+  regmatch_t *regs;
+  re_node_set eps_via_nodes;
+};
+
+struct re_fail_stack_t
+{
+  Idx num;
+  Idx alloc;
+  struct re_fail_stack_ent_t *stack;
+};
+
+struct re_dfa_t
+{
+  re_token_t *nodes;
+  size_t nodes_alloc;
+  size_t nodes_len;
+  Idx *nexts;
+  Idx *org_indices;
+  re_node_set *edests;
+  re_node_set *eclosures;
+  re_node_set *inveclosures;
+  struct re_state_table_entry *state_table;
+  re_dfastate_t *init_state;
+  re_dfastate_t *init_state_word;
+  re_dfastate_t *init_state_nl;
+  re_dfastate_t *init_state_begbuf;
+  bin_tree_t *str_tree;
+  bin_tree_storage_t *str_tree_storage;
+  re_bitset_ptr_t sb_char;
+  int str_tree_storage_idx;
+
+  /* number of subexpressions `re_nsub' is in regex_t.  */
+  re_hashval_t state_hash_mask;
+  Idx init_node;
+  Idx nbackref; /* The number of backreference in this dfa.  */
+
+  /* Bitmap expressing which backreference is used.  */
+  bitset_word_t used_bkref_map;
+  bitset_word_t completed_bkref_map;
+
+  unsigned int has_plural_match : 1;
+  /* If this dfa has "multibyte node", which is a backreference or
+     a node which can accept multibyte character or multi character
+     collating element.  */
+  unsigned int has_mb_node : 1;
+  unsigned int is_utf8 : 1;
+  unsigned int map_notascii : 1;
+  unsigned int word_ops_used : 1;
+  int mb_cur_max;
+  bitset_t word_char;
+  reg_syntax_t syntax;
+  Idx *subexp_map;
+#ifdef DEBUG
+  char* re_str;
+#endif
+#ifdef _LIBC
+  __libc_lock_define (, lock)
+#endif
+};
+
+#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
+#define re_node_set_remove(set,id) \
+  (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1))
+#define re_node_set_empty(p) ((p)->nelem = 0)
+#define re_node_set_free(set) re_free ((set)->elems)
+\f
+
+typedef enum
+{
+  SB_CHAR,
+  MB_CHAR,
+  EQUIV_CLASS,
+  COLL_SYM,
+  CHAR_CLASS
+} bracket_elem_type;
+
+typedef struct
+{
+  bracket_elem_type type;
+  union
+  {
+    unsigned char ch;
+    unsigned char *name;
+    wchar_t wch;
+  } opr;
+} bracket_elem_t;
+
+
+/* Inline functions for bitset_t operation.  */
+
+static inline void
+bitset_set (bitset_t set, Idx i)
+{
+  set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
+}
+
+static inline void
+bitset_clear (bitset_t set, Idx i)
+{
+  set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
+}
+
+static inline bool
+bitset_contain (const bitset_t set, Idx i)
+{
+  return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
+}
+
+static inline void
+bitset_empty (bitset_t set)
+{
+  memset (set, '\0', sizeof (bitset_t));
+}
+
+static inline void
+bitset_set_all (bitset_t set)
+{
+  memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
+  if (SBC_MAX % BITSET_WORD_BITS != 0)
+    set[BITSET_WORDS - 1] =
+      ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
+}
+
+static inline void
+bitset_copy (bitset_t dest, const bitset_t src)
+{
+  memcpy (dest, src, sizeof (bitset_t));
+}
+
+static inline void
+bitset_not (bitset_t set)
+{
+  int bitset_i;
+  for (bitset_i = 0; bitset_i < SBC_MAX / BITSET_WORD_BITS; ++bitset_i)
+    set[bitset_i] = ~set[bitset_i];
+  if (SBC_MAX % BITSET_WORD_BITS != 0)
+    set[BITSET_WORDS - 1] =
+      ((((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1)
+       & ~set[BITSET_WORDS - 1]);
+}
+
+static inline void
+bitset_merge (bitset_t dest, const bitset_t src)
+{
+  int bitset_i;
+  for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+    dest[bitset_i] |= src[bitset_i];
+}
+
+static inline void
+bitset_mask (bitset_t dest, const bitset_t src)
+{
+  int bitset_i;
+  for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i)
+    dest[bitset_i] &= src[bitset_i];
+}
+
+#ifdef RE_ENABLE_I18N
+/* Inline functions for re_string.  */
+static inline int
+internal_function __attribute ((pure))
+re_string_char_size_at (const re_string_t *pstr, Idx idx)
+{
+  int byte_idx;
+  if (pstr->mb_cur_max == 1)
+    return 1;
+  for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx)
+    if (pstr->wcs[idx + byte_idx] != WEOF)
+      break;
+  return byte_idx;
+}
+
+static inline wint_t
+internal_function __attribute ((pure))
+re_string_wchar_at (const re_string_t *pstr, Idx idx)
+{
+  if (pstr->mb_cur_max == 1)
+    return (wint_t) pstr->mbs[idx];
+  return (wint_t) pstr->wcs[idx];
+}
+
+static int
+internal_function __attribute ((pure))
+re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+{
+# ifdef _LIBC
+  const unsigned char *p, *extra;
+  const int32_t *table, *indirect;
+  int32_t tmp;
+#  include <locale/weight.h>
+  uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+
+  if (nrules != 0)
+    {
+      table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+      extra = (const unsigned char *)
+       _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+      indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_INDIRECTMB);
+      p = pstr->mbs + idx;
+      tmp = findidx (&p);
+      return p - pstr->mbs - idx;
+    }
+  else
+# endif /* _LIBC */
+    return 1;
+}
+#endif /* RE_ENABLE_I18N */
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+#  define __GNUC_PREREQ(maj, min) \
+         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+#  define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#if __GNUC_PREREQ (3,4)
+# undef __attribute_warn_unused_result__
+# define __attribute_warn_unused_result__ \
+   __attribute__ ((__warn_unused_result__))
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+
+#endif /*  _REGEX_INTERNAL_H */
diff --git a/gnulib/lib/regexec.c b/gnulib/lib/regexec.c
new file mode 100644 (file)
index 0000000..421a354
--- /dev/null
@@ -0,0 +1,4417 @@
+/* Extended regular expression matching and search library.
+   Copyright (C) 2002-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
+                                    Idx n) internal_function;
+static void match_ctx_clean (re_match_context_t *mctx) internal_function;
+static void match_ctx_free (re_match_context_t *cache) internal_function;
+static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
+                                         Idx str_idx, Idx from, Idx to)
+     internal_function;
+static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
+     internal_function;
+static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
+                                          Idx str_idx) internal_function;
+static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
+                                                   Idx node, Idx str_idx)
+     internal_function;
+static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+                          re_dfastate_t **limited_sts, Idx last_node,
+                          Idx last_str_idx)
+     internal_function;
+static reg_errcode_t re_search_internal (const regex_t *preg,
+                                        const char *string, Idx length,
+                                        Idx start, Idx last_start, Idx stop,
+                                        size_t nmatch, regmatch_t pmatch[],
+                                        int eflags) internal_function;
+static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
+                                 const char *string1, Idx length1,
+                                 const char *string2, Idx length2,
+                                 Idx start, regoff_t range,
+                                 struct re_registers *regs,
+                                 Idx stop, bool ret_len) internal_function;
+static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
+                               const char *string, Idx length, Idx start,
+                               regoff_t range, Idx stop,
+                               struct re_registers *regs,
+                               bool ret_len) internal_function;
+static unsigned int re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
+                                 Idx nregs, int regs_allocated)
+     internal_function;
+static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
+     internal_function;
+static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
+                          Idx *p_match_first) internal_function;
+static Idx check_halt_state_context (const re_match_context_t *mctx,
+                                    const re_dfastate_t *state, Idx idx)
+     internal_function;
+static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+                        regmatch_t *prev_idx_match, Idx cur_node,
+                        Idx cur_idx, Idx nmatch) internal_function;
+static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
+                                     Idx str_idx, Idx dest_node, Idx nregs,
+                                     regmatch_t *regs,
+                                     re_node_set *eps_via_nodes)
+     internal_function;
+static reg_errcode_t set_regs (const regex_t *preg,
+                              const re_match_context_t *mctx,
+                              size_t nmatch, regmatch_t *pmatch,
+                              bool fl_backtrack) internal_function;
+static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs)
+     internal_function;
+
+#ifdef RE_ENABLE_I18N
+static int sift_states_iter_mb (const re_match_context_t *mctx,
+                               re_sift_context_t *sctx,
+                               Idx node_idx, Idx str_idx, Idx max_str_idx)
+     internal_function;
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
+                                          re_sift_context_t *sctx)
+     internal_function;
+static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
+                                         re_sift_context_t *sctx, Idx str_idx,
+                                         re_node_set *cur_dest)
+     internal_function;
+static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
+                                             re_sift_context_t *sctx,
+                                             Idx str_idx,
+                                             re_node_set *dest_nodes)
+     internal_function;
+static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
+                                           re_node_set *dest_nodes,
+                                           const re_node_set *candidates)
+     internal_function;
+static bool check_dst_limits (const re_match_context_t *mctx,
+                             const re_node_set *limits,
+                             Idx dst_node, Idx dst_idx, Idx src_node,
+                             Idx src_idx) internal_function;
+static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
+                                       int boundaries, Idx subexp_idx,
+                                       Idx from_node, Idx bkref_idx)
+     internal_function;
+static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
+                                     Idx limit, Idx subexp_idx,
+                                     Idx node, Idx str_idx,
+                                     Idx bkref_idx) internal_function;
+static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
+                                         re_node_set *dest_nodes,
+                                         const re_node_set *candidates,
+                                         re_node_set *limits,
+                                         struct re_backref_cache_entry *bkref_ents,
+                                         Idx str_idx) internal_function;
+static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
+                                       re_sift_context_t *sctx,
+                                       Idx str_idx, const re_node_set *candidates)
+     internal_function;
+static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
+                                       re_dfastate_t **dst,
+                                       re_dfastate_t **src, Idx num)
+     internal_function;
+static re_dfastate_t *find_recover_state (reg_errcode_t *err,
+                                        re_match_context_t *mctx) internal_function;
+static re_dfastate_t *transit_state (reg_errcode_t *err,
+                                    re_match_context_t *mctx,
+                                    re_dfastate_t *state) internal_function;
+static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
+                                           re_match_context_t *mctx,
+                                           re_dfastate_t *next_state)
+     internal_function;
+static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
+                                               re_node_set *cur_nodes,
+                                               Idx str_idx) internal_function;
+#if 0
+static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
+                                       re_match_context_t *mctx,
+                                       re_dfastate_t *pstate)
+     internal_function;
+#endif
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
+                                      re_dfastate_t *pstate)
+     internal_function;
+#endif /* RE_ENABLE_I18N */
+static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
+                                         const re_node_set *nodes)
+     internal_function;
+static reg_errcode_t get_subexp (re_match_context_t *mctx,
+                                Idx bkref_node, Idx bkref_str_idx)
+     internal_function;
+static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
+                                    const re_sub_match_top_t *sub_top,
+                                    re_sub_match_last_t *sub_last,
+                                    Idx bkref_node, Idx bkref_str)
+     internal_function;
+static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+                            Idx subexp_idx, int type) internal_function;
+static reg_errcode_t check_arrival (re_match_context_t *mctx,
+                                   state_array_t *path, Idx top_node,
+                                   Idx top_str, Idx last_node, Idx last_str,
+                                   int type) internal_function;
+static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
+                                                  Idx str_idx,
+                                                  re_node_set *cur_nodes,
+                                                  re_node_set *next_nodes)
+     internal_function;
+static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
+                                              re_node_set *cur_nodes,
+                                              Idx ex_subexp, int type)
+     internal_function;
+static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
+                                                  re_node_set *dst_nodes,
+                                                  Idx target, Idx ex_subexp,
+                                                  int type) internal_function;
+static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
+                                        re_node_set *cur_nodes, Idx cur_str,
+                                        Idx subexp_num, int type)
+     internal_function;
+static bool build_trtable (const re_dfa_t *dfa,
+                          re_dfastate_t *state) internal_function;
+#ifdef RE_ENABLE_I18N
+static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
+                                   const re_string_t *input, Idx idx)
+     internal_function;
+# ifdef _LIBC
+static unsigned int find_collation_sequence_value (const unsigned char *mbs,
+                                                  size_t name_len)
+     internal_function;
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
+                                      const re_dfastate_t *state,
+                                      re_node_set *states_node,
+                                      bitset_t *states_ch) internal_function;
+static bool check_node_accept (const re_match_context_t *mctx,
+                              const re_token_t *node, Idx idx)
+     internal_function;
+static reg_errcode_t extend_buffers (re_match_context_t *mctx)
+     internal_function;
+\f
+/* Entry point for POSIX code.  */
+
+/* regexec searches for a given pattern, specified by PREG, in the
+   string STRING.
+
+   If NMATCH is zero or REG_NOSUB was set in the cflags argument to
+   `regcomp', we ignore PMATCH.  Otherwise, we assume PMATCH has at
+   least NMATCH elements, and we set them to the offsets of the
+   corresponding matched substrings.
+
+   EFLAGS specifies `execution flags' which affect matching: if
+   REG_NOTBOL is set, then ^ does not match at the beginning of the
+   string; if REG_NOTEOL is set, then $ does not match at the end.
+
+   We return 0 if we find a match and REG_NOMATCH if not.  */
+
+int
+regexec (preg, string, nmatch, pmatch, eflags)
+    const regex_t *_Restrict_ preg;
+    const char *_Restrict_ string;
+    size_t nmatch;
+    regmatch_t pmatch[_Restrict_arr_];
+    int eflags;
+{
+  reg_errcode_t err;
+  Idx start, length;
+#ifdef _LIBC
+  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+#endif
+
+  if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+    return REG_BADPAT;
+
+  if (eflags & REG_STARTEND)
+    {
+      start = pmatch[0].rm_so;
+      length = pmatch[0].rm_eo;
+    }
+  else
+    {
+      start = 0;
+      length = strlen (string);
+    }
+
+  __libc_lock_lock (dfa->lock);
+  if (preg->no_sub)
+    err = re_search_internal (preg, string, length, start, length,
+                             length, 0, NULL, eflags);
+  else
+    err = re_search_internal (preg, string, length, start, length,
+                             length, nmatch, pmatch, eflags);
+  __libc_lock_unlock (dfa->lock);
+  return err != REG_NOERROR;
+}
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
+__typeof__ (__regexec) __compat_regexec;
+
+int
+attribute_compat_text_section
+__compat_regexec (const regex_t *_Restrict_ preg,
+                 const char *_Restrict_ string, size_t nmatch,
+                 regmatch_t pmatch[], int eflags)
+{
+  return regexec (preg, string, nmatch, pmatch,
+                 eflags & (REG_NOTBOL | REG_NOTEOL));
+}
+compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
+# endif
+#endif
+
+/* Entry points for GNU code.  */
+
+/* re_match, re_search, re_match_2, re_search_2
+
+   The former two functions operate on STRING with length LENGTH,
+   while the later two operate on concatenation of STRING1 and STRING2
+   with lengths LENGTH1 and LENGTH2, respectively.
+
+   re_match() matches the compiled pattern in BUFP against the string,
+   starting at index START.
+
+   re_search() first tries matching at index START, then it tries to match
+   starting from index START + 1, and so on.  The last start position tried
+   is START + RANGE.  (Thus RANGE = 0 forces re_search to operate the same
+   way as re_match().)
+
+   The parameter STOP of re_{match,search}_2 specifies that no match exceeding
+   the first STOP characters of the concatenation of the strings should be
+   concerned.
+
+   If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
+   and all groups is stored in REGS.  (For the "_2" variants, the offsets are
+   computed relative to the concatenation, not relative to the individual
+   strings.)
+
+   On success, re_match* functions return the length of the match, re_search*
+   return the position of the start of the match.  Return value -1 means no
+   match was found and -2 indicates an internal error.  */
+
+regoff_t
+re_match (bufp, string, length, start, regs)
+    struct re_pattern_buffer *bufp;
+    const char *string;
+    Idx length, start;
+    struct re_registers *regs;
+{
+  return re_search_stub (bufp, string, length, start, 0, length, regs, true);
+}
+#ifdef _LIBC
+weak_alias (__re_match, re_match)
+#endif
+
+regoff_t
+re_search (bufp, string, length, start, range, regs)
+    struct re_pattern_buffer *bufp;
+    const char *string;
+    Idx length, start;
+    regoff_t range;
+    struct re_registers *regs;
+{
+  return re_search_stub (bufp, string, length, start, range, length, regs,
+                        false);
+}
+#ifdef _LIBC
+weak_alias (__re_search, re_search)
+#endif
+
+regoff_t
+re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
+    struct re_pattern_buffer *bufp;
+    const char *string1, *string2;
+    Idx length1, length2, start, stop;
+    struct re_registers *regs;
+{
+  return re_search_2_stub (bufp, string1, length1, string2, length2,
+                          start, 0, regs, stop, true);
+}
+#ifdef _LIBC
+weak_alias (__re_match_2, re_match_2)
+#endif
+
+regoff_t
+re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
+    struct re_pattern_buffer *bufp;
+    const char *string1, *string2;
+    Idx length1, length2, start, stop;
+    regoff_t range;
+    struct re_registers *regs;
+{
+  return re_search_2_stub (bufp, string1, length1, string2, length2,
+                          start, range, regs, stop, false);
+}
+#ifdef _LIBC
+weak_alias (__re_search_2, re_search_2)
+#endif
+
+static regoff_t
+internal_function
+re_search_2_stub (struct re_pattern_buffer *bufp,
+                 const char *string1, Idx length1,
+                 const char *string2, Idx length2,
+                 Idx start, regoff_t range, struct re_registers *regs,
+                 Idx stop, bool ret_len)
+{
+  const char *str;
+  regoff_t rval;
+  Idx len = length1 + length2;
+  char *s = NULL;
+
+  if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
+    return -2;
+
+  /* Concatenate the strings.  */
+  if (length2 > 0)
+    if (length1 > 0)
+      {
+       s = re_malloc (char, len);
+
+       if (BE (s == NULL, 0))
+         return -2;
+#ifdef _LIBC
+       memcpy (__mempcpy (s, string1, length1), string2, length2);
+#else
+       memcpy (s, string1, length1);
+       memcpy (s + length1, string2, length2);
+#endif
+       str = s;
+      }
+    else
+      str = string2;
+  else
+    str = string1;
+
+  rval = re_search_stub (bufp, str, len, start, range, stop, regs,
+                        ret_len);
+  re_free (s);
+  return rval;
+}
+
+/* The parameters have the same meaning as those of re_search.
+   Additional parameters:
+   If RET_LEN is true the length of the match is returned (re_match style);
+   otherwise the position of the match is returned.  */
+
+static regoff_t
+internal_function
+re_search_stub (struct re_pattern_buffer *bufp,
+               const char *string, Idx length,
+               Idx start, regoff_t range, Idx stop, struct re_registers *regs,
+               bool ret_len)
+{
+  reg_errcode_t result;
+  regmatch_t *pmatch;
+  Idx nregs;
+  regoff_t rval;
+  int eflags = 0;
+#ifdef _LIBC
+  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+#endif
+  Idx last_start = start + range;
+
+  /* Check for out-of-range.  */
+  if (BE (start < 0 || start > length, 0))
+    return -1;
+  if (BE (length < last_start || (0 <= range && last_start < start), 0))
+    last_start = length;
+  else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+    last_start = 0;
+
+  __libc_lock_lock (dfa->lock);
+
+  eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
+  eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+
+  /* Compile fastmap if we haven't yet.  */
+  if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
+    re_compile_fastmap (bufp);
+
+  if (BE (bufp->no_sub, 0))
+    regs = NULL;
+
+  /* We need at least 1 register.  */
+  if (regs == NULL)
+    nregs = 1;
+  else if (BE (bufp->regs_allocated == REGS_FIXED
+              && regs->num_regs <= bufp->re_nsub, 0))
+    {
+      nregs = regs->num_regs;
+      if (BE (nregs < 1, 0))
+       {
+         /* Nothing can be copied to regs.  */
+         regs = NULL;
+         nregs = 1;
+       }
+    }
+  else
+    nregs = bufp->re_nsub + 1;
+  pmatch = re_malloc (regmatch_t, nregs);
+  if (BE (pmatch == NULL, 0))
+    {
+      rval = -2;
+      goto out;
+    }
+
+  result = re_search_internal (bufp, string, length, start, last_start, stop,
+                              nregs, pmatch, eflags);
+
+  rval = 0;
+
+  /* I hope we needn't fill ther regs with -1's when no match was found.  */
+  if (result != REG_NOERROR)
+    rval = -1;
+  else if (regs != NULL)
+    {
+      /* If caller wants register contents data back, copy them.  */
+      bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
+                                          bufp->regs_allocated);
+      if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
+       rval = -2;
+    }
+
+  if (BE (rval == 0, 1))
+    {
+      if (ret_len)
+       {
+         assert (pmatch[0].rm_so == start);
+         rval = pmatch[0].rm_eo - start;
+       }
+      else
+       rval = pmatch[0].rm_so;
+    }
+  re_free (pmatch);
+ out:
+  __libc_lock_unlock (dfa->lock);
+  return rval;
+}
+
+static unsigned int
+internal_function
+re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
+             int regs_allocated)
+{
+  int rval = REGS_REALLOCATE;
+  Idx i;
+  Idx need_regs = nregs + 1;
+  /* We need one extra element beyond `num_regs' for the `-1' marker GNU code
+     uses.  */
+
+  /* Have the register data arrays been allocated?  */
+  if (regs_allocated == REGS_UNALLOCATED)
+    { /* No.  So allocate them with malloc.  */
+      regs->start = re_malloc (regoff_t, need_regs);
+      if (BE (regs->start == NULL, 0))
+       return REGS_UNALLOCATED;
+      regs->end = re_malloc (regoff_t, need_regs);
+      if (BE (regs->end == NULL, 0))
+       {
+         re_free (regs->start);
+         return REGS_UNALLOCATED;
+       }
+      regs->num_regs = need_regs;
+    }
+  else if (regs_allocated == REGS_REALLOCATE)
+    { /* Yes.  If we need more elements than were already
+        allocated, reallocate them.  If we need fewer, just
+        leave it alone.  */
+      if (BE (need_regs > regs->num_regs, 0))
+       {
+         regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
+         regoff_t *new_end;
+         if (BE (new_start == NULL, 0))
+           return REGS_UNALLOCATED;
+         new_end = re_realloc (regs->end, regoff_t, need_regs);
+         if (BE (new_end == NULL, 0))
+           {
+             re_free (new_start);
+             return REGS_UNALLOCATED;
+           }
+         regs->start = new_start;
+         regs->end = new_end;
+         regs->num_regs = need_regs;
+       }
+    }
+  else
+    {
+      assert (regs_allocated == REGS_FIXED);
+      /* This function may not be called with REGS_FIXED and nregs too big.  */
+      assert (regs->num_regs >= nregs);
+      rval = REGS_FIXED;
+    }
+
+  /* Copy the regs.  */
+  for (i = 0; i < nregs; ++i)
+    {
+      regs->start[i] = pmatch[i].rm_so;
+      regs->end[i] = pmatch[i].rm_eo;
+    }
+  for ( ; i < regs->num_regs; ++i)
+    regs->start[i] = regs->end[i] = -1;
+
+  return rval;
+}
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+   ENDS.  Subsequent matches using PATTERN_BUFFER and REGS will use
+   this memory for recording register information.  STARTS and ENDS
+   must be allocated using the malloc library routine, and must each
+   be at least NUM_REGS * sizeof (regoff_t) bytes long.
+
+   If NUM_REGS == 0, then subsequent matches should allocate their own
+   register data.
+
+   Unless this function is called, the first search or match using
+   PATTERN_BUFFER will allocate its own register data, without
+   freeing the old data.  */
+
+void
+re_set_registers (bufp, regs, num_regs, starts, ends)
+    struct re_pattern_buffer *bufp;
+    struct re_registers *regs;
+    __re_size_t num_regs;
+    regoff_t *starts, *ends;
+{
+  if (num_regs)
+    {
+      bufp->regs_allocated = REGS_REALLOCATE;
+      regs->num_regs = num_regs;
+      regs->start = starts;
+      regs->end = ends;
+    }
+  else
+    {
+      bufp->regs_allocated = REGS_UNALLOCATED;
+      regs->num_regs = 0;
+      regs->start = regs->end = NULL;
+    }
+}
+#ifdef _LIBC
+weak_alias (__re_set_registers, re_set_registers)
+#endif
+\f
+/* Entry points compatible with 4.2 BSD regex library.  We don't define
+   them unless specifically requested.  */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+int
+# ifdef _LIBC
+weak_function
+# endif
+re_exec (s)
+     const char *s;
+{
+  return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
+}
+#endif /* _REGEX_RE_COMP */
+\f
+/* Internal entry point.  */
+
+/* Searches for a compiled pattern PREG in the string STRING, whose
+   length is LENGTH.  NMATCH, PMATCH, and EFLAGS have the same
+   meaning as with regexec.  LAST_START is START + RANGE, where
+   START and RANGE have the same meaning as with re_search.
+   Return REG_NOERROR if we find a match, and REG_NOMATCH if not,
+   otherwise return the error code.
+   Note: We assume front end functions already check ranges.
+   (0 <= LAST_START && LAST_START <= LENGTH)  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+re_search_internal (const regex_t *preg,
+                   const char *string, Idx length,
+                   Idx start, Idx last_start, Idx stop,
+                   size_t nmatch, regmatch_t pmatch[],
+                   int eflags)
+{
+  reg_errcode_t err;
+  const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
+  Idx left_lim, right_lim;
+  int incr;
+  bool fl_longest_match;
+  int match_kind;
+  Idx match_first;
+  Idx match_last = REG_MISSING;
+  Idx extra_nmatch;
+  bool sb;
+  int ch;
+#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+  re_match_context_t mctx = { .dfa = dfa };
+#else
+  re_match_context_t mctx;
+#endif
+  char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
+                   && start != last_start && !preg->can_be_null)
+                  ? preg->fastmap : NULL);
+  RE_TRANSLATE_TYPE t = preg->translate;
+
+#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+  memset (&mctx, '\0', sizeof (re_match_context_t));
+  mctx.dfa = dfa;
+#endif
+
+  extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
+  nmatch -= extra_nmatch;
+
+  /* Check if the DFA haven't been compiled.  */
+  if (BE (preg->used == 0 || dfa->init_state == NULL
+         || dfa->init_state_word == NULL || dfa->init_state_nl == NULL
+         || dfa->init_state_begbuf == NULL, 0))
+    return REG_NOMATCH;
+
+#ifdef DEBUG
+  /* We assume front-end functions already check them.  */
+  assert (0 <= last_start && last_start <= length);
+#endif
+
+  /* If initial states with non-begbuf contexts have no elements,
+     the regex must be anchored.  If preg->newline_anchor is set,
+     we'll never use init_state_nl, so do not check it.  */
+  if (dfa->init_state->nodes.nelem == 0
+      && dfa->init_state_word->nodes.nelem == 0
+      && (dfa->init_state_nl->nodes.nelem == 0
+         || !preg->newline_anchor))
+    {
+      if (start != 0 && last_start != 0)
+        return REG_NOMATCH;
+      start = last_start = 0;
+    }
+
+  /* We must check the longest matching, if nmatch > 0.  */
+  fl_longest_match = (nmatch != 0 || dfa->nbackref);
+
+  err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
+                           preg->translate, (preg->syntax & RE_ICASE) != 0,
+                           dfa);
+  if (BE (err != REG_NOERROR, 0))
+    goto free_return;
+  mctx.input.stop = stop;
+  mctx.input.raw_stop = stop;
+  mctx.input.newline_anchor = preg->newline_anchor;
+
+  err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
+  if (BE (err != REG_NOERROR, 0))
+    goto free_return;
+
+  /* We will log all the DFA states through which the dfa pass,
+     if nmatch > 1, or this dfa has "multibyte node", which is a
+     back-reference or a node which can accept multibyte character or
+     multi character collating element.  */
+  if (nmatch > 1 || dfa->has_mb_node)
+    {
+      /* Avoid overflow.  */
+      if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= mctx.input.bufs_len, 0))
+       {
+         err = REG_ESPACE;
+         goto free_return;
+       }
+
+      mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
+      if (BE (mctx.state_log == NULL, 0))
+       {
+         err = REG_ESPACE;
+         goto free_return;
+       }
+    }
+  else
+    mctx.state_log = NULL;
+
+  match_first = start;
+  mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+                          : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
+
+  /* Check incrementally whether of not the input string match.  */
+  incr = (last_start < start) ? -1 : 1;
+  left_lim = (last_start < start) ? last_start : start;
+  right_lim = (last_start < start) ? start : last_start;
+  sb = dfa->mb_cur_max == 1;
+  match_kind =
+    (fastmap
+     ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
+       | (start <= last_start ? 2 : 0)
+       | (t != NULL ? 1 : 0))
+     : 8);
+
+  for (;; match_first += incr)
+    {
+      err = REG_NOMATCH;
+      if (match_first < left_lim || right_lim < match_first)
+       goto free_return;
+
+      /* Advance as rapidly as possible through the string, until we
+        find a plausible place to start matching.  This may be done
+        with varying efficiency, so there are various possibilities:
+        only the most common of them are specialized, in order to
+        save on code size.  We use a switch statement for speed.  */
+      switch (match_kind)
+       {
+       case 8:
+         /* No fastmap.  */
+         break;
+
+       case 7:
+         /* Fastmap with single-byte translation, match forward.  */
+         while (BE (match_first < right_lim, 1)
+                && !fastmap[t[(unsigned char) string[match_first]]])
+           ++match_first;
+         goto forward_match_found_start_or_reached_end;
+
+       case 6:
+         /* Fastmap without translation, match forward.  */
+         while (BE (match_first < right_lim, 1)
+                && !fastmap[(unsigned char) string[match_first]])
+           ++match_first;
+
+       forward_match_found_start_or_reached_end:
+         if (BE (match_first == right_lim, 0))
+           {
+             ch = match_first >= length
+                      ? 0 : (unsigned char) string[match_first];
+             if (!fastmap[t ? t[ch] : ch])
+               goto free_return;
+           }
+         break;
+
+       case 4:
+       case 5:
+         /* Fastmap without multi-byte translation, match backwards.  */
+         while (match_first >= left_lim)
+           {
+             ch = match_first >= length
+                      ? 0 : (unsigned char) string[match_first];
+             if (fastmap[t ? t[ch] : ch])
+               break;
+             --match_first;
+           }
+         if (match_first < left_lim)
+           goto free_return;
+         break;
+
+       default:
+         /* In this case, we can't determine easily the current byte,
+            since it might be a component byte of a multibyte
+            character.  Then we use the constructed buffer instead.  */
+         for (;;)
+           {
+             /* If MATCH_FIRST is out of the valid range, reconstruct the
+                buffers.  */
+             __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
+             if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0))
+               {
+                 err = re_string_reconstruct (&mctx.input, match_first,
+                                              eflags);
+                 if (BE (err != REG_NOERROR, 0))
+                   goto free_return;
+
+                 offset = match_first - mctx.input.raw_mbs_idx;
+               }
+             /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
+                Note that MATCH_FIRST must not be smaller than 0.  */
+             ch = (match_first >= length
+                   ? 0 : re_string_byte_at (&mctx.input, offset));
+             if (fastmap[ch])
+               break;
+             match_first += incr;
+             if (match_first < left_lim || match_first > right_lim)
+               {
+                 err = REG_NOMATCH;
+                 goto free_return;
+               }
+           }
+         break;
+       }
+
+      /* Reconstruct the buffers so that the matcher can assume that
+        the matching starts from the beginning of the buffer.  */
+      err = re_string_reconstruct (&mctx.input, match_first, eflags);
+      if (BE (err != REG_NOERROR, 0))
+       goto free_return;
+
+#ifdef RE_ENABLE_I18N
+     /* Don't consider this char as a possible match start if it part,
+       yet isn't the head, of a multibyte character.  */
+      if (!sb && !re_string_first_byte (&mctx.input, 0))
+       continue;
+#endif
+
+      /* It seems to be appropriate one, then use the matcher.  */
+      /* We assume that the matching starts from 0.  */
+      mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
+      match_last = check_matching (&mctx, fl_longest_match,
+                                  start <= last_start ? &match_first : NULL);
+      if (match_last != REG_MISSING)
+       {
+         if (BE (match_last == REG_ERROR, 0))
+           {
+             err = REG_ESPACE;
+             goto free_return;
+           }
+         else
+           {
+             mctx.match_last = match_last;
+             if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
+               {
+                 re_dfastate_t *pstate = mctx.state_log[match_last];
+                 mctx.last_node = check_halt_state_context (&mctx, pstate,
+                                                            match_last);
+               }
+             if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
+                 || dfa->nbackref)
+               {
+                 err = prune_impossible_nodes (&mctx);
+                 if (err == REG_NOERROR)
+                   break;
+                 if (BE (err != REG_NOMATCH, 0))
+                   goto free_return;
+                 match_last = REG_MISSING;
+               }
+             else
+               break; /* We found a match.  */
+           }
+       }
+
+      match_ctx_clean (&mctx);
+    }
+
+#ifdef DEBUG
+  assert (match_last != REG_MISSING);
+  assert (err == REG_NOERROR);
+#endif
+
+  /* Set pmatch[] if we need.  */
+  if (nmatch > 0)
+    {
+      Idx reg_idx;
+
+      /* Initialize registers.  */
+      for (reg_idx = 1; reg_idx < nmatch; ++reg_idx)
+       pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1;
+
+      /* Set the points where matching start/end.  */
+      pmatch[0].rm_so = 0;
+      pmatch[0].rm_eo = mctx.match_last;
+      /* FIXME: This function should fail if mctx.match_last exceeds
+        the maximum possible regoff_t value.  We need a new error
+        code REG_OVERFLOW.  */
+
+      if (!preg->no_sub && nmatch > 1)
+       {
+         err = set_regs (preg, &mctx, nmatch, pmatch,
+                         dfa->has_plural_match && dfa->nbackref > 0);
+         if (BE (err != REG_NOERROR, 0))
+           goto free_return;
+       }
+
+      /* At last, add the offset to the each registers, since we slided
+        the buffers so that we could assume that the matching starts
+        from 0.  */
+      for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+       if (pmatch[reg_idx].rm_so != -1)
+         {
+#ifdef RE_ENABLE_I18N
+           if (BE (mctx.input.offsets_needed != 0, 0))
+             {
+               pmatch[reg_idx].rm_so =
+                 (pmatch[reg_idx].rm_so == mctx.input.valid_len
+                  ? mctx.input.valid_raw_len
+                  : mctx.input.offsets[pmatch[reg_idx].rm_so]);
+               pmatch[reg_idx].rm_eo =
+                 (pmatch[reg_idx].rm_eo == mctx.input.valid_len
+                  ? mctx.input.valid_raw_len
+                  : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
+             }
+#else
+           assert (mctx.input.offsets_needed == 0);
+#endif
+           pmatch[reg_idx].rm_so += match_first;
+           pmatch[reg_idx].rm_eo += match_first;
+         }
+      for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx)
+       {
+         pmatch[nmatch + reg_idx].rm_so = -1;
+         pmatch[nmatch + reg_idx].rm_eo = -1;
+       }
+
+      if (dfa->subexp_map)
+       for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
+         if (dfa->subexp_map[reg_idx] != reg_idx)
+           {
+             pmatch[reg_idx + 1].rm_so
+               = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
+             pmatch[reg_idx + 1].rm_eo
+               = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
+           }
+    }
+
+ free_return:
+  re_free (mctx.state_log);
+  if (dfa->nbackref)
+    match_ctx_free (&mctx);
+  re_string_destruct (&mctx.input);
+  return err;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+prune_impossible_nodes (re_match_context_t *mctx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx halt_node, match_last;
+  reg_errcode_t ret;
+  re_dfastate_t **sifted_states;
+  re_dfastate_t **lim_states = NULL;
+  re_sift_context_t sctx;
+#ifdef DEBUG
+  assert (mctx->state_log != NULL);
+#endif
+  match_last = mctx->match_last;
+  halt_node = mctx->last_node;
+
+  /* Avoid overflow.  */
+  if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= match_last, 0))
+    return REG_ESPACE;
+
+  sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
+  if (BE (sifted_states == NULL, 0))
+    {
+      ret = REG_ESPACE;
+      goto free_return;
+    }
+  if (dfa->nbackref)
+    {
+      lim_states = re_malloc (re_dfastate_t *, match_last + 1);
+      if (BE (lim_states == NULL, 0))
+       {
+         ret = REG_ESPACE;
+         goto free_return;
+       }
+      while (1)
+       {
+         memset (lim_states, '\0',
+                 sizeof (re_dfastate_t *) * (match_last + 1));
+         sift_ctx_init (&sctx, sifted_states, lim_states, halt_node,
+                        match_last);
+         ret = sift_states_backward (mctx, &sctx);
+         re_node_set_free (&sctx.limits);
+         if (BE (ret != REG_NOERROR, 0))
+             goto free_return;
+         if (sifted_states[0] != NULL || lim_states[0] != NULL)
+           break;
+         do
+           {
+             --match_last;
+             if (! REG_VALID_INDEX (match_last))
+               {
+                 ret = REG_NOMATCH;
+                 goto free_return;
+               }
+           } while (mctx->state_log[match_last] == NULL
+                    || !mctx->state_log[match_last]->halt);
+         halt_node = check_halt_state_context (mctx,
+                                               mctx->state_log[match_last],
+                                               match_last);
+       }
+      ret = merge_state_array (dfa, sifted_states, lim_states,
+                              match_last + 1);
+      re_free (lim_states);
+      lim_states = NULL;
+      if (BE (ret != REG_NOERROR, 0))
+       goto free_return;
+    }
+  else
+    {
+      sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
+      ret = sift_states_backward (mctx, &sctx);
+      re_node_set_free (&sctx.limits);
+      if (BE (ret != REG_NOERROR, 0))
+       goto free_return;
+      if (sifted_states[0] == NULL)
+       {
+         ret = REG_NOMATCH;
+         goto free_return;
+       }
+    }
+  re_free (mctx->state_log);
+  mctx->state_log = sifted_states;
+  sifted_states = NULL;
+  mctx->last_node = halt_node;
+  mctx->match_last = match_last;
+  ret = REG_NOERROR;
+ free_return:
+  re_free (sifted_states);
+  re_free (lim_states);
+  return ret;
+}
+
+/* Acquire an initial state and return it.
+   We must select appropriate initial state depending on the context,
+   since initial states may have constraints like "\<", "^", etc..  */
+
+static inline re_dfastate_t *
+__attribute ((always_inline)) internal_function
+acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+                           Idx idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  if (dfa->init_state->has_constraint)
+    {
+      unsigned int context;
+      context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
+      if (IS_WORD_CONTEXT (context))
+       return dfa->init_state_word;
+      else if (IS_ORDINARY_CONTEXT (context))
+       return dfa->init_state;
+      else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context))
+       return dfa->init_state_begbuf;
+      else if (IS_NEWLINE_CONTEXT (context))
+       return dfa->init_state_nl;
+      else if (IS_BEGBUF_CONTEXT (context))
+       {
+         /* It is relatively rare case, then calculate on demand.  */
+         return re_acquire_state_context (err, dfa,
+                                          dfa->init_state->entrance_nodes,
+                                          context);
+       }
+      else
+       /* Must not happen?  */
+       return dfa->init_state;
+    }
+  else
+    return dfa->init_state;
+}
+
+/* Check whether the regular expression match input string INPUT or not,
+   and return the index where the matching end.  Return REG_MISSING if
+   there is no match, and return REG_ERROR in case of an error.
+   FL_LONGEST_MATCH means we want the POSIX longest matching.
+   If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
+   next place where we may want to try matching.
+   Note that the matcher assume that the maching starts from the current
+   index of the buffer.  */
+
+static Idx
+internal_function __attribute_warn_unused_result__
+check_matching (re_match_context_t *mctx, bool fl_longest_match,
+               Idx *p_match_first)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err;
+  Idx match = 0;
+  Idx match_last = REG_MISSING;
+  Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+  re_dfastate_t *cur_state;
+  bool at_init_state = p_match_first != NULL;
+  Idx next_start_idx = cur_str_idx;
+
+  err = REG_NOERROR;
+  cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
+  /* An initial state must not be NULL (invalid).  */
+  if (BE (cur_state == NULL, 0))
+    {
+      assert (err == REG_ESPACE);
+      return REG_ERROR;
+    }
+
+  if (mctx->state_log != NULL)
+    {
+      mctx->state_log[cur_str_idx] = cur_state;
+
+      /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
+        later.  E.g. Processing back references.  */
+      if (BE (dfa->nbackref, 0))
+       {
+         at_init_state = false;
+         err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+
+         if (cur_state->has_backref)
+           {
+             err = transit_state_bkref (mctx, &cur_state->nodes);
+             if (BE (err != REG_NOERROR, 0))
+               return err;
+           }
+       }
+    }
+
+  /* If the RE accepts NULL string.  */
+  if (BE (cur_state->halt, 0))
+    {
+      if (!cur_state->has_constraint
+         || check_halt_state_context (mctx, cur_state, cur_str_idx))
+       {
+         if (!fl_longest_match)
+           return cur_str_idx;
+         else
+           {
+             match_last = cur_str_idx;
+             match = 1;
+           }
+       }
+    }
+
+  while (!re_string_eoi (&mctx->input))
+    {
+      re_dfastate_t *old_state = cur_state;
+      Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
+
+      if (BE (next_char_idx >= mctx->input.bufs_len, 0)
+         || (BE (next_char_idx >= mctx->input.valid_len, 0)
+             && mctx->input.valid_len < mctx->input.len))
+       {
+         err = extend_buffers (mctx);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             assert (err == REG_ESPACE);
+             return REG_ERROR;
+           }
+       }
+
+      cur_state = transit_state (&err, mctx, cur_state);
+      if (mctx->state_log != NULL)
+       cur_state = merge_state_with_log (&err, mctx, cur_state);
+
+      if (cur_state == NULL)
+       {
+         /* Reached the invalid state or an error.  Try to recover a valid
+            state using the state log, if available and if we have not
+            already found a valid (even if not the longest) match.  */
+         if (BE (err != REG_NOERROR, 0))
+           return REG_ERROR;
+
+         if (mctx->state_log == NULL
+             || (match && !fl_longest_match)
+             || (cur_state = find_recover_state (&err, mctx)) == NULL)
+           break;
+       }
+
+      if (BE (at_init_state, 0))
+       {
+         if (old_state == cur_state)
+           next_start_idx = next_char_idx;
+         else
+           at_init_state = false;
+       }
+
+      if (cur_state->halt)
+       {
+         /* Reached a halt state.
+            Check the halt state can satisfy the current context.  */
+         if (!cur_state->has_constraint
+             || check_halt_state_context (mctx, cur_state,
+                                          re_string_cur_idx (&mctx->input)))
+           {
+             /* We found an appropriate halt state.  */
+             match_last = re_string_cur_idx (&mctx->input);
+             match = 1;
+
+             /* We found a match, do not modify match_first below.  */
+             p_match_first = NULL;
+             if (!fl_longest_match)
+               break;
+           }
+       }
+    }
+
+  if (p_match_first)
+    *p_match_first += next_start_idx;
+
+  return match_last;
+}
+
+/* Check NODE match the current context.  */
+
+static bool
+internal_function
+check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
+{
+  re_token_type_t type = dfa->nodes[node].type;
+  unsigned int constraint = dfa->nodes[node].constraint;
+  if (type != END_OF_RE)
+    return false;
+  if (!constraint)
+    return true;
+  if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context))
+    return false;
+  return true;
+}
+
+/* Check the halt state STATE match the current context.
+   Return 0 if not match, if the node, STATE has, is a halt node and
+   match the context, return the node.  */
+
+static Idx
+internal_function
+check_halt_state_context (const re_match_context_t *mctx,
+                         const re_dfastate_t *state, Idx idx)
+{
+  Idx i;
+  unsigned int context;
+#ifdef DEBUG
+  assert (state->halt);
+#endif
+  context = re_string_context_at (&mctx->input, idx, mctx->eflags);
+  for (i = 0; i < state->nodes.nelem; ++i)
+    if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
+      return state->nodes.elems[i];
+  return 0;
+}
+
+/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
+   corresponding to the DFA).
+   Return the destination node, and update EPS_VIA_NODES;
+   return REG_MISSING in case of errors.  */
+
+static Idx
+internal_function
+proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
+                  Idx *pidx, Idx node, re_node_set *eps_via_nodes,
+                  struct re_fail_stack_t *fs)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx i;
+  bool ok;
+  if (IS_EPSILON_NODE (dfa->nodes[node].type))
+    {
+      re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
+      re_node_set *edests = &dfa->edests[node];
+      Idx dest_node;
+      ok = re_node_set_insert (eps_via_nodes, node);
+      if (BE (! ok, 0))
+       return REG_ERROR;
+      /* Pick up a valid destination, or return REG_MISSING if none
+        is found.  */
+      for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i)
+       {
+         Idx candidate = edests->elems[i];
+         if (!re_node_set_contains (cur_nodes, candidate))
+           continue;
+          if (dest_node == REG_MISSING)
+           dest_node = candidate;
+
+         else
+           {
+             /* In order to avoid infinite loop like "(a*)*", return the second
+                epsilon-transition if the first was already considered.  */
+             if (re_node_set_contains (eps_via_nodes, dest_node))
+               return candidate;
+
+             /* Otherwise, push the second epsilon-transition on the fail stack.  */
+             else if (fs != NULL
+                      && push_fail_stack (fs, *pidx, candidate, nregs, regs,
+                                          eps_via_nodes))
+               return REG_ERROR;
+
+             /* We know we are going to exit.  */
+             break;
+           }
+       }
+      return dest_node;
+    }
+  else
+    {
+      Idx naccepted = 0;
+      re_token_type_t type = dfa->nodes[node].type;
+
+#ifdef RE_ENABLE_I18N
+      if (dfa->nodes[node].accept_mb)
+       naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
+      else
+#endif /* RE_ENABLE_I18N */
+      if (type == OP_BACK_REF)
+       {
+         Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
+         naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
+         if (fs != NULL)
+           {
+             if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
+               return REG_MISSING;
+             else if (naccepted)
+               {
+                 char *buf = (char *) re_string_get_buffer (&mctx->input);
+                 if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+                             naccepted) != 0)
+                   return REG_MISSING;
+               }
+           }
+
+         if (naccepted == 0)
+           {
+             Idx dest_node;
+             ok = re_node_set_insert (eps_via_nodes, node);
+             if (BE (! ok, 0))
+               return REG_ERROR;
+             dest_node = dfa->edests[node].elems[0];
+             if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+                                       dest_node))
+               return dest_node;
+           }
+       }
+
+      if (naccepted != 0
+         || check_node_accept (mctx, dfa->nodes + node, *pidx))
+       {
+         Idx dest_node = dfa->nexts[node];
+         *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted;
+         if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
+                    || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
+                                              dest_node)))
+           return REG_MISSING;
+         re_node_set_empty (eps_via_nodes);
+         return dest_node;
+       }
+    }
+  return REG_MISSING;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
+                Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+  reg_errcode_t err;
+  Idx num = fs->num++;
+  if (fs->num == fs->alloc)
+    {
+      struct re_fail_stack_ent_t *new_array;
+      new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t)
+                                      * fs->alloc * 2));
+      if (new_array == NULL)
+       return REG_ESPACE;
+      fs->alloc *= 2;
+      fs->stack = new_array;
+    }
+  fs->stack[num].idx = str_idx;
+  fs->stack[num].node = dest_node;
+  fs->stack[num].regs = re_malloc (regmatch_t, nregs);
+  if (fs->stack[num].regs == NULL)
+    return REG_ESPACE;
+  memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
+  err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
+  return err;
+}
+
+static Idx
+internal_function
+pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
+               regmatch_t *regs, re_node_set *eps_via_nodes)
+{
+  Idx num = --fs->num;
+  assert (REG_VALID_INDEX (num));
+  *pidx = fs->stack[num].idx;
+  memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
+  re_node_set_free (eps_via_nodes);
+  re_free (fs->stack[num].regs);
+  *eps_via_nodes = fs->stack[num].eps_via_nodes;
+  return fs->stack[num].node;
+}
+
+/* Set the positions where the subexpressions are starts/ends to registers
+   PMATCH.
+   Note: We assume that pmatch[0] is already set, and
+   pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
+         regmatch_t *pmatch, bool fl_backtrack)
+{
+  const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
+  Idx idx, cur_node;
+  re_node_set eps_via_nodes;
+  struct re_fail_stack_t *fs;
+  struct re_fail_stack_t fs_body = { 0, 2, NULL };
+  regmatch_t *prev_idx_match;
+  bool prev_idx_match_malloced = false;
+
+#ifdef DEBUG
+  assert (nmatch > 1);
+  assert (mctx->state_log != NULL);
+#endif
+  if (fl_backtrack)
+    {
+      fs = &fs_body;
+      fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc);
+      if (fs->stack == NULL)
+       return REG_ESPACE;
+    }
+  else
+    fs = NULL;
+
+  cur_node = dfa->init_node;
+  re_node_set_init_empty (&eps_via_nodes);
+
+  if (__libc_use_alloca (nmatch * sizeof (regmatch_t)))
+    prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
+  else
+    {
+      prev_idx_match = re_malloc (regmatch_t, nmatch);
+      if (prev_idx_match == NULL)
+       {
+         free_fail_stack_return (fs);
+         return REG_ESPACE;
+       }
+      prev_idx_match_malloced = true;
+    }
+  memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+
+  for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
+    {
+      update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
+
+      if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
+       {
+         Idx reg_idx;
+         if (fs)
+           {
+             for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
+               if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
+                 break;
+             if (reg_idx == nmatch)
+               {
+                 re_node_set_free (&eps_via_nodes);
+                 if (prev_idx_match_malloced)
+                   re_free (prev_idx_match);
+                 return free_fail_stack_return (fs);
+               }
+             cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+                                        &eps_via_nodes);
+           }
+         else
+           {
+             re_node_set_free (&eps_via_nodes);
+             if (prev_idx_match_malloced)
+               re_free (prev_idx_match);
+             return REG_NOERROR;
+           }
+       }
+
+      /* Proceed to next node.  */
+      cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
+                                   &eps_via_nodes, fs);
+
+      if (BE (! REG_VALID_INDEX (cur_node), 0))
+       {
+         if (BE (cur_node == REG_ERROR, 0))
+           {
+             re_node_set_free (&eps_via_nodes);
+             if (prev_idx_match_malloced)
+               re_free (prev_idx_match);
+             free_fail_stack_return (fs);
+             return REG_ESPACE;
+           }
+         if (fs)
+           cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
+                                      &eps_via_nodes);
+         else
+           {
+             re_node_set_free (&eps_via_nodes);
+             if (prev_idx_match_malloced)
+               re_free (prev_idx_match);
+             return REG_NOMATCH;
+           }
+       }
+    }
+  re_node_set_free (&eps_via_nodes);
+  if (prev_idx_match_malloced)
+    re_free (prev_idx_match);
+  return free_fail_stack_return (fs);
+}
+
+static reg_errcode_t
+internal_function
+free_fail_stack_return (struct re_fail_stack_t *fs)
+{
+  if (fs)
+    {
+      Idx fs_idx;
+      for (fs_idx = 0; fs_idx < fs->num; ++fs_idx)
+       {
+         re_node_set_free (&fs->stack[fs_idx].eps_via_nodes);
+         re_free (fs->stack[fs_idx].regs);
+       }
+      re_free (fs->stack);
+    }
+  return REG_NOERROR;
+}
+
+static void
+internal_function
+update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
+            regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
+{
+  int type = dfa->nodes[cur_node].type;
+  if (type == OP_OPEN_SUBEXP)
+    {
+      Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
+
+      /* We are at the first node of this sub expression.  */
+      if (reg_num < nmatch)
+       {
+         pmatch[reg_num].rm_so = cur_idx;
+         pmatch[reg_num].rm_eo = -1;
+       }
+    }
+  else if (type == OP_CLOSE_SUBEXP)
+    {
+      Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
+      if (reg_num < nmatch)
+       {
+         /* We are at the last node of this sub expression.  */
+         if (pmatch[reg_num].rm_so < cur_idx)
+           {
+             pmatch[reg_num].rm_eo = cur_idx;
+             /* This is a non-empty match or we are not inside an optional
+                subexpression.  Accept this right away.  */
+             memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
+           }
+         else
+           {
+             if (dfa->nodes[cur_node].opt_subexp
+                 && prev_idx_match[reg_num].rm_so != -1)
+               /* We transited through an empty match for an optional
+                  subexpression, like (a?)*, and this is not the subexp's
+                  first match.  Copy back the old content of the registers
+                  so that matches of an inner subexpression are undone as
+                  well, like in ((a?))*.  */
+               memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch);
+             else
+               /* We completed a subexpression, but it may be part of
+                  an optional one, so do not update PREV_IDX_MATCH.  */
+               pmatch[reg_num].rm_eo = cur_idx;
+           }
+       }
+    }
+}
+
+/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0
+   and sift the nodes in each states according to the following rules.
+   Updated state_log will be wrote to STATE_LOG.
+
+   Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if...
+     1. When STR_IDX == MATCH_LAST(the last index in the state_log):
+       If `a' isn't the LAST_NODE and `a' can't epsilon transit to
+       the LAST_NODE, we throw away the node `a'.
+     2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts
+       string `s' and transit to `b':
+       i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
+          away the node `a'.
+       ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
+           thrown away, we throw away the node `a'.
+     3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
+       i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
+          node `a'.
+       ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
+           we throw away the node `a'.  */
+
+#define STATE_NODE_CONTAINS(state,node) \
+  ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
+
+static reg_errcode_t
+internal_function
+sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
+{
+  reg_errcode_t err;
+  int null_cnt = 0;
+  Idx str_idx = sctx->last_str_idx;
+  re_node_set cur_dest;
+
+#ifdef DEBUG
+  assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
+#endif
+
+  /* Build sifted state_log[str_idx].  It has the nodes which can epsilon
+     transit to the last_node and the last_node itself.  */
+  err = re_node_set_init_1 (&cur_dest, sctx->last_node);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+  err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+  if (BE (err != REG_NOERROR, 0))
+    goto free_return;
+
+  /* Then check each states in the state_log.  */
+  while (str_idx > 0)
+    {
+      /* Update counters.  */
+      null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0;
+      if (null_cnt > mctx->max_mb_elem_len)
+       {
+         memset (sctx->sifted_states, '\0',
+                 sizeof (re_dfastate_t *) * str_idx);
+         re_node_set_free (&cur_dest);
+         return REG_NOERROR;
+       }
+      re_node_set_empty (&cur_dest);
+      --str_idx;
+
+      if (mctx->state_log[str_idx])
+       {
+         err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
+         if (BE (err != REG_NOERROR, 0))
+           goto free_return;
+       }
+
+      /* Add all the nodes which satisfy the following conditions:
+        - It can epsilon transit to a node in CUR_DEST.
+        - It is in CUR_SRC.
+        And update state_log.  */
+      err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
+      if (BE (err != REG_NOERROR, 0))
+       goto free_return;
+    }
+  err = REG_NOERROR;
+ free_return:
+  re_node_set_free (&cur_dest);
+  return err;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
+                    Idx str_idx, re_node_set *cur_dest)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
+  Idx i;
+
+  /* Then build the next sifted state.
+     We build the next sifted state on `cur_dest', and update
+     `sifted_states[str_idx]' with `cur_dest'.
+     Note:
+     `cur_dest' is the sifted state from `state_log[str_idx + 1]'.
+     `cur_src' points the node_set of the old `state_log[str_idx]'
+     (with the epsilon nodes pre-filtered out).  */
+  for (i = 0; i < cur_src->nelem; i++)
+    {
+      Idx prev_node = cur_src->elems[i];
+      int naccepted = 0;
+      bool ok;
+
+#ifdef DEBUG
+      re_token_type_t type = dfa->nodes[prev_node].type;
+      assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+      /* If the node may accept `multi byte'.  */
+      if (dfa->nodes[prev_node].accept_mb)
+       naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
+                                        str_idx, sctx->last_str_idx);
+#endif /* RE_ENABLE_I18N */
+
+      /* We don't check backreferences here.
+        See update_cur_sifted_state().  */
+      if (!naccepted
+         && check_node_accept (mctx, dfa->nodes + prev_node, str_idx)
+         && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1],
+                                 dfa->nexts[prev_node]))
+       naccepted = 1;
+
+      if (naccepted == 0)
+       continue;
+
+      if (sctx->limits.nelem)
+       {
+         Idx to_idx = str_idx + naccepted;
+         if (check_dst_limits (mctx, &sctx->limits,
+                               dfa->nexts[prev_node], to_idx,
+                               prev_node, str_idx))
+           continue;
+       }
+      ok = re_node_set_insert (cur_dest, prev_node);
+      if (BE (! ok, 0))
+       return REG_ESPACE;
+    }
+
+  return REG_NOERROR;
+}
+
+/* Helper functions.  */
+
+static reg_errcode_t
+internal_function
+clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
+{
+  Idx top = mctx->state_log_top;
+
+  if (next_state_log_idx >= mctx->input.bufs_len
+      || (next_state_log_idx >= mctx->input.valid_len
+         && mctx->input.valid_len < mctx->input.len))
+    {
+      reg_errcode_t err;
+      err = extend_buffers (mctx);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+    }
+
+  if (top < next_state_log_idx)
+    {
+      memset (mctx->state_log + top + 1, '\0',
+             sizeof (re_dfastate_t *) * (next_state_log_idx - top));
+      mctx->state_log_top = next_state_log_idx;
+    }
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
+                  re_dfastate_t **src, Idx num)
+{
+  Idx st_idx;
+  reg_errcode_t err;
+  for (st_idx = 0; st_idx < num; ++st_idx)
+    {
+      if (dst[st_idx] == NULL)
+       dst[st_idx] = src[st_idx];
+      else if (src[st_idx] != NULL)
+       {
+         re_node_set merged_set;
+         err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
+                                       &src[st_idx]->nodes);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+         dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
+         re_node_set_free (&merged_set);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+    }
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function
+update_cur_sifted_state (const re_match_context_t *mctx,
+                        re_sift_context_t *sctx, Idx str_idx,
+                        re_node_set *dest_nodes)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err = REG_NOERROR;
+  const re_node_set *candidates;
+  candidates = ((mctx->state_log[str_idx] == NULL) ? NULL
+               : &mctx->state_log[str_idx]->nodes);
+
+  if (dest_nodes->nelem == 0)
+    sctx->sifted_states[str_idx] = NULL;
+  else
+    {
+      if (candidates)
+       {
+         /* At first, add the nodes which can epsilon transit to a node in
+            DEST_NODE.  */
+         err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+
+         /* Then, check the limitations in the current sift_context.  */
+         if (sctx->limits.nelem)
+           {
+             err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
+                                        mctx->bkref_ents, str_idx);
+             if (BE (err != REG_NOERROR, 0))
+               return err;
+           }
+       }
+
+      sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+    }
+
+  if (candidates && mctx->state_log[str_idx]->has_backref)
+    {
+      err = sift_states_bkref (mctx, sctx, str_idx, candidates);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+    }
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
+                      const re_node_set *candidates)
+{
+  reg_errcode_t err = REG_NOERROR;
+  Idx i;
+
+  re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+
+  if (!state->inveclosure.alloc)
+    {
+      err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
+      if (BE (err != REG_NOERROR, 0))
+       return REG_ESPACE;
+      for (i = 0; i < dest_nodes->nelem; i++)
+       {
+         err = re_node_set_merge (&state->inveclosure,
+                                  dfa->inveclosures + dest_nodes->elems[i]);
+         if (BE (err != REG_NOERROR, 0))
+           return REG_ESPACE;
+       }
+    }
+  return re_node_set_add_intersect (dest_nodes, candidates,
+                                   &state->inveclosure);
+}
+
+static reg_errcode_t
+internal_function
+sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
+                      const re_node_set *candidates)
+{
+    Idx ecl_idx;
+    reg_errcode_t err;
+    re_node_set *inv_eclosure = dfa->inveclosures + node;
+    re_node_set except_nodes;
+    re_node_set_init_empty (&except_nodes);
+    for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+      {
+       Idx cur_node = inv_eclosure->elems[ecl_idx];
+       if (cur_node == node)
+         continue;
+       if (IS_EPSILON_NODE (dfa->nodes[cur_node].type))
+         {
+           Idx edst1 = dfa->edests[cur_node].elems[0];
+           Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
+                        ? dfa->edests[cur_node].elems[1] : REG_MISSING);
+           if ((!re_node_set_contains (inv_eclosure, edst1)
+                && re_node_set_contains (dest_nodes, edst1))
+               || (REG_VALID_NONZERO_INDEX (edst2)
+                   && !re_node_set_contains (inv_eclosure, edst2)
+                   && re_node_set_contains (dest_nodes, edst2)))
+             {
+               err = re_node_set_add_intersect (&except_nodes, candidates,
+                                                dfa->inveclosures + cur_node);
+               if (BE (err != REG_NOERROR, 0))
+                 {
+                   re_node_set_free (&except_nodes);
+                   return err;
+                 }
+             }
+         }
+      }
+    for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx)
+      {
+       Idx cur_node = inv_eclosure->elems[ecl_idx];
+       if (!re_node_set_contains (&except_nodes, cur_node))
+         {
+           Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1;
+           re_node_set_remove_at (dest_nodes, idx);
+         }
+      }
+    re_node_set_free (&except_nodes);
+    return REG_NOERROR;
+}
+
+static bool
+internal_function
+check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
+                 Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx lim_idx, src_pos, dst_pos;
+
+  Idx dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx);
+  Idx src_bkref_idx = search_cur_bkref_entry (mctx, src_idx);
+  for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+    {
+      Idx subexp_idx;
+      struct re_backref_cache_entry *ent;
+      ent = mctx->bkref_ents + limits->elems[lim_idx];
+      subexp_idx = dfa->nodes[ent->node].opr.idx;
+
+      dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+                                          subexp_idx, dst_node, dst_idx,
+                                          dst_bkref_idx);
+      src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx],
+                                          subexp_idx, src_node, src_idx,
+                                          src_bkref_idx);
+
+      /* In case of:
+        <src> <dst> ( <subexp> )
+        ( <subexp> ) <src> <dst>
+        ( <subexp1> <src> <subexp2> <dst> <subexp3> )  */
+      if (src_pos == dst_pos)
+       continue; /* This is unrelated limitation.  */
+      else
+       return true;
+    }
+  return false;
+}
+
+static int
+internal_function
+check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
+                            Idx subexp_idx, Idx from_node, Idx bkref_idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  const re_node_set *eclosures = dfa->eclosures + from_node;
+  Idx node_idx;
+
+  /* Else, we are on the boundary: examine the nodes on the epsilon
+     closure.  */
+  for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx)
+    {
+      Idx node = eclosures->elems[node_idx];
+      switch (dfa->nodes[node].type)
+       {
+       case OP_BACK_REF:
+         if (bkref_idx != REG_MISSING)
+           {
+             struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
+             do
+               {
+                 Idx dst;
+                 int cpos;
+
+                 if (ent->node != node)
+                   continue;
+
+                 if (subexp_idx < BITSET_WORD_BITS
+                     && !(ent->eps_reachable_subexps_map
+                          & ((bitset_word_t) 1 << subexp_idx)))
+                   continue;
+
+                 /* Recurse trying to reach the OP_OPEN_SUBEXP and
+                    OP_CLOSE_SUBEXP cases below.  But, if the
+                    destination node is the same node as the source
+                    node, don't recurse because it would cause an
+                    infinite loop: a regex that exhibits this behavior
+                    is ()\1*\1*  */
+                 dst = dfa->edests[node].elems[0];
+                 if (dst == from_node)
+                   {
+                     if (boundaries & 1)
+                       return -1;
+                     else /* if (boundaries & 2) */
+                       return 0;
+                   }
+
+                 cpos =
+                   check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+                                                dst, bkref_idx);
+                 if (cpos == -1 /* && (boundaries & 1) */)
+                   return -1;
+                 if (cpos == 0 && (boundaries & 2))
+                   return 0;
+
+                 if (subexp_idx < BITSET_WORD_BITS)
+                   ent->eps_reachable_subexps_map
+                     &= ~((bitset_word_t) 1 << subexp_idx);
+               }
+             while (ent++->more);
+           }
+         break;
+
+       case OP_OPEN_SUBEXP:
+         if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx)
+           return -1;
+         break;
+
+       case OP_CLOSE_SUBEXP:
+         if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx)
+           return 0;
+         break;
+
+       default:
+           break;
+       }
+    }
+
+  return (boundaries & 2) ? 1 : 0;
+}
+
+static int
+internal_function
+check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
+                          Idx subexp_idx, Idx from_node, Idx str_idx,
+                          Idx bkref_idx)
+{
+  struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
+  int boundaries;
+
+  /* If we are outside the range of the subexpression, return -1 or 1.  */
+  if (str_idx < lim->subexp_from)
+    return -1;
+
+  if (lim->subexp_to < str_idx)
+    return 1;
+
+  /* If we are within the subexpression, return 0.  */
+  boundaries = (str_idx == lim->subexp_from);
+  boundaries |= (str_idx == lim->subexp_to) << 1;
+  if (boundaries == 0)
+    return 0;
+
+  /* Else, examine epsilon closure.  */
+  return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx,
+                                     from_node, bkref_idx);
+}
+
+/* Check the limitations of sub expressions LIMITS, and remove the nodes
+   which are against limitations from DEST_NODES. */
+
+static reg_errcode_t
+internal_function
+check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
+                    const re_node_set *candidates, re_node_set *limits,
+                    struct re_backref_cache_entry *bkref_ents, Idx str_idx)
+{
+  reg_errcode_t err;
+  Idx node_idx, lim_idx;
+
+  for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx)
+    {
+      Idx subexp_idx;
+      struct re_backref_cache_entry *ent;
+      ent = bkref_ents + limits->elems[lim_idx];
+
+      if (str_idx <= ent->subexp_from || ent->str_idx < str_idx)
+       continue; /* This is unrelated limitation.  */
+
+      subexp_idx = dfa->nodes[ent->node].opr.idx;
+      if (ent->subexp_to == str_idx)
+       {
+         Idx ops_node = REG_MISSING;
+         Idx cls_node = REG_MISSING;
+         for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+           {
+             Idx node = dest_nodes->elems[node_idx];
+             re_token_type_t type = dfa->nodes[node].type;
+             if (type == OP_OPEN_SUBEXP
+                 && subexp_idx == dfa->nodes[node].opr.idx)
+               ops_node = node;
+             else if (type == OP_CLOSE_SUBEXP
+                      && subexp_idx == dfa->nodes[node].opr.idx)
+               cls_node = node;
+           }
+
+         /* Check the limitation of the open subexpression.  */
+         /* Note that (ent->subexp_to = str_idx != ent->subexp_from).  */
+         if (REG_VALID_INDEX (ops_node))
+           {
+             err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
+                                          candidates);
+             if (BE (err != REG_NOERROR, 0))
+               return err;
+           }
+
+         /* Check the limitation of the close subexpression.  */
+         if (REG_VALID_INDEX (cls_node))
+           for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+             {
+               Idx node = dest_nodes->elems[node_idx];
+               if (!re_node_set_contains (dfa->inveclosures + node,
+                                          cls_node)
+                   && !re_node_set_contains (dfa->eclosures + node,
+                                             cls_node))
+                 {
+                   /* It is against this limitation.
+                      Remove it form the current sifted state.  */
+                   err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+                                                candidates);
+                   if (BE (err != REG_NOERROR, 0))
+                     return err;
+                   --node_idx;
+                 }
+             }
+       }
+      else /* (ent->subexp_to != str_idx)  */
+       {
+         for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
+           {
+             Idx node = dest_nodes->elems[node_idx];
+             re_token_type_t type = dfa->nodes[node].type;
+             if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP)
+               {
+                 if (subexp_idx != dfa->nodes[node].opr.idx)
+                   continue;
+                 /* It is against this limitation.
+                    Remove it form the current sifted state.  */
+                 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
+                                              candidates);
+                 if (BE (err != REG_NOERROR, 0))
+                   return err;
+               }
+           }
+       }
+    }
+  return REG_NOERROR;
+}
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
+                  Idx str_idx, const re_node_set *candidates)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err;
+  Idx node_idx, node;
+  re_sift_context_t local_sctx;
+  Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
+
+  if (first_idx == REG_MISSING)
+    return REG_NOERROR;
+
+  local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized.  */
+
+  for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
+    {
+      Idx enabled_idx;
+      re_token_type_t type;
+      struct re_backref_cache_entry *entry;
+      node = candidates->elems[node_idx];
+      type = dfa->nodes[node].type;
+      /* Avoid infinite loop for the REs like "()\1+".  */
+      if (node == sctx->last_node && str_idx == sctx->last_str_idx)
+       continue;
+      if (type != OP_BACK_REF)
+       continue;
+
+      entry = mctx->bkref_ents + first_idx;
+      enabled_idx = first_idx;
+      do
+       {
+         Idx subexp_len;
+         Idx to_idx;
+         Idx dst_node;
+         bool ok;
+         re_dfastate_t *cur_state;
+
+         if (entry->node != node)
+           continue;
+         subexp_len = entry->subexp_to - entry->subexp_from;
+         to_idx = str_idx + subexp_len;
+         dst_node = (subexp_len ? dfa->nexts[node]
+                     : dfa->edests[node].elems[0]);
+
+         if (to_idx > sctx->last_str_idx
+             || sctx->sifted_states[to_idx] == NULL
+             || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node)
+             || check_dst_limits (mctx, &sctx->limits, node,
+                                  str_idx, dst_node, to_idx))
+           continue;
+
+         if (local_sctx.sifted_states == NULL)
+           {
+             local_sctx = *sctx;
+             err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
+             if (BE (err != REG_NOERROR, 0))
+               goto free_return;
+           }
+         local_sctx.last_node = node;
+         local_sctx.last_str_idx = str_idx;
+         ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
+         if (BE (! ok, 0))
+           {
+             err = REG_ESPACE;
+             goto free_return;
+           }
+         cur_state = local_sctx.sifted_states[str_idx];
+         err = sift_states_backward (mctx, &local_sctx);
+         if (BE (err != REG_NOERROR, 0))
+           goto free_return;
+         if (sctx->limited_states != NULL)
+           {
+             err = merge_state_array (dfa, sctx->limited_states,
+                                      local_sctx.sifted_states,
+                                      str_idx + 1);
+             if (BE (err != REG_NOERROR, 0))
+               goto free_return;
+           }
+         local_sctx.sifted_states[str_idx] = cur_state;
+         re_node_set_remove (&local_sctx.limits, enabled_idx);
+
+         /* mctx->bkref_ents may have changed, reload the pointer.  */
+         entry = mctx->bkref_ents + enabled_idx;
+       }
+      while (enabled_idx++, entry++->more);
+    }
+  err = REG_NOERROR;
+ free_return:
+  if (local_sctx.sifted_states != NULL)
+    {
+      re_node_set_free (&local_sctx.limits);
+    }
+
+  return err;
+}
+
+
+#ifdef RE_ENABLE_I18N
+static int
+internal_function
+sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
+                    Idx node_idx, Idx str_idx, Idx max_str_idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  int naccepted;
+  /* Check the node can accept `multi byte'.  */
+  naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
+  if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
+      !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
+                           dfa->nexts[node_idx]))
+    /* The node can't accept the `multi byte', or the
+       destination was already thrown away, then the node
+       could't accept the current input `multi byte'.   */
+    naccepted = 0;
+  /* Otherwise, it is sure that the node could accept
+     `naccepted' bytes input.  */
+  return naccepted;
+}
+#endif /* RE_ENABLE_I18N */
+
+\f
+/* Functions for state transition.  */
+
+/* Return the next state to which the current state STATE will transit by
+   accepting the current input byte, and update STATE_LOG if necessary.
+   If STATE can accept a multibyte char/collating element/back reference
+   update the destination of STATE_LOG.  */
+
+static re_dfastate_t *
+internal_function __attribute_warn_unused_result__
+transit_state (reg_errcode_t *err, re_match_context_t *mctx,
+              re_dfastate_t *state)
+{
+  re_dfastate_t **trtable;
+  unsigned char ch;
+
+#ifdef RE_ENABLE_I18N
+  /* If the current state can accept multibyte.  */
+  if (BE (state->accept_mb, 0))
+    {
+      *err = transit_state_mb (mctx, state);
+      if (BE (*err != REG_NOERROR, 0))
+       return NULL;
+    }
+#endif /* RE_ENABLE_I18N */
+
+  /* Then decide the next state with the single byte.  */
+#if 0
+  if (0)
+    /* don't use transition table  */
+    return transit_state_sb (err, mctx, state);
+#endif
+
+  /* Use transition table  */
+  ch = re_string_fetch_byte (&mctx->input);
+  for (;;)
+    {
+      trtable = state->trtable;
+      if (BE (trtable != NULL, 1))
+       return trtable[ch];
+
+      trtable = state->word_trtable;
+      if (BE (trtable != NULL, 1))
+       {
+         unsigned int context;
+         context
+           = re_string_context_at (&mctx->input,
+                                   re_string_cur_idx (&mctx->input) - 1,
+                                   mctx->eflags);
+         if (IS_WORD_CONTEXT (context))
+           return trtable[ch + SBC_MAX];
+         else
+           return trtable[ch];
+       }
+
+      if (!build_trtable (mctx->dfa, state))
+       {
+         *err = REG_ESPACE;
+         return NULL;
+       }
+
+      /* Retry, we now have a transition table.  */
+    }
+}
+
+/* Update the state_log if we need */
+static re_dfastate_t *
+internal_function
+merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
+                     re_dfastate_t *next_state)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx cur_idx = re_string_cur_idx (&mctx->input);
+
+  if (cur_idx > mctx->state_log_top)
+    {
+      mctx->state_log[cur_idx] = next_state;
+      mctx->state_log_top = cur_idx;
+    }
+  else if (mctx->state_log[cur_idx] == 0)
+    {
+      mctx->state_log[cur_idx] = next_state;
+    }
+  else
+    {
+      re_dfastate_t *pstate;
+      unsigned int context;
+      re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
+      /* If (state_log[cur_idx] != 0), it implies that cur_idx is
+        the destination of a multibyte char/collating element/
+        back reference.  Then the next state is the union set of
+        these destinations and the results of the transition table.  */
+      pstate = mctx->state_log[cur_idx];
+      log_nodes = pstate->entrance_nodes;
+      if (next_state != NULL)
+       {
+         table_nodes = next_state->entrance_nodes;
+         *err = re_node_set_init_union (&next_nodes, table_nodes,
+                                            log_nodes);
+         if (BE (*err != REG_NOERROR, 0))
+           return NULL;
+       }
+      else
+       next_nodes = *log_nodes;
+      /* Note: We already add the nodes of the initial state,
+        then we don't need to add them here.  */
+
+      context = re_string_context_at (&mctx->input,
+                                     re_string_cur_idx (&mctx->input) - 1,
+                                     mctx->eflags);
+      next_state = mctx->state_log[cur_idx]
+       = re_acquire_state_context (err, dfa, &next_nodes, context);
+      /* We don't need to check errors here, since the return value of
+        this function is next_state and ERR is already set.  */
+
+      if (table_nodes != NULL)
+       re_node_set_free (&next_nodes);
+    }
+
+  if (BE (dfa->nbackref, 0) && next_state != NULL)
+    {
+      /* Check OP_OPEN_SUBEXP in the current state in case that we use them
+        later.  We must check them here, since the back references in the
+        next state might use them.  */
+      *err = check_subexp_matching_top (mctx, &next_state->nodes,
+                                       cur_idx);
+      if (BE (*err != REG_NOERROR, 0))
+       return NULL;
+
+      /* If the next state has back references.  */
+      if (next_state->has_backref)
+       {
+         *err = transit_state_bkref (mctx, &next_state->nodes);
+         if (BE (*err != REG_NOERROR, 0))
+           return NULL;
+         next_state = mctx->state_log[cur_idx];
+       }
+    }
+
+  return next_state;
+}
+
+/* Skip bytes in the input that correspond to part of a
+   multi-byte match, then look in the log for a state
+   from which to restart matching.  */
+static re_dfastate_t *
+internal_function
+find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
+{
+  re_dfastate_t *cur_state;
+  do
+    {
+      Idx max = mctx->state_log_top;
+      Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+
+      do
+       {
+         if (++cur_str_idx > max)
+           return NULL;
+         re_string_skip_bytes (&mctx->input, 1);
+       }
+      while (mctx->state_log[cur_str_idx] == NULL);
+
+      cur_state = merge_state_with_log (err, mctx, NULL);
+    }
+  while (*err == REG_NOERROR && cur_state == NULL);
+  return cur_state;
+}
+
+/* Helper functions for transit_state.  */
+
+/* From the node set CUR_NODES, pick up the nodes whose types are
+   OP_OPEN_SUBEXP and which have corresponding back references in the regular
+   expression. And register them to use them later for evaluating the
+   correspoding back references.  */
+
+static reg_errcode_t
+internal_function
+check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
+                          Idx str_idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx node_idx;
+  reg_errcode_t err;
+
+  /* TODO: This isn't efficient.
+          Because there might be more than one nodes whose types are
+          OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+          nodes.
+          E.g. RE: (a){2}  */
+  for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx)
+    {
+      Idx node = cur_nodes->elems[node_idx];
+      if (dfa->nodes[node].type == OP_OPEN_SUBEXP
+         && dfa->nodes[node].opr.idx < BITSET_WORD_BITS
+         && (dfa->used_bkref_map
+             & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
+       {
+         err = match_ctx_add_subtop (mctx, node, str_idx);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+    }
+  return REG_NOERROR;
+}
+
+#if 0
+/* Return the next state to which the current state STATE will transit by
+   accepting the current input byte.  */
+
+static re_dfastate_t *
+transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
+                 re_dfastate_t *state)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  re_node_set next_nodes;
+  re_dfastate_t *next_state;
+  Idx node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
+  unsigned int context;
+
+  *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
+  if (BE (*err != REG_NOERROR, 0))
+    return NULL;
+  for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
+    {
+      Idx cur_node = state->nodes.elems[node_cnt];
+      if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx))
+       {
+         *err = re_node_set_merge (&next_nodes,
+                                   dfa->eclosures + dfa->nexts[cur_node]);
+         if (BE (*err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return NULL;
+           }
+       }
+    }
+  context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
+  next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
+  /* We don't need to check errors here, since the return value of
+     this function is next_state and ERR is already set.  */
+
+  re_node_set_free (&next_nodes);
+  re_string_skip_bytes (&mctx->input, 1);
+  return next_state;
+}
+#endif
+
+#ifdef RE_ENABLE_I18N
+static reg_errcode_t
+internal_function
+transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err;
+  Idx i;
+
+  for (i = 0; i < pstate->nodes.nelem; ++i)
+    {
+      re_node_set dest_nodes, *new_nodes;
+      Idx cur_node_idx = pstate->nodes.elems[i];
+      int naccepted;
+      Idx dest_idx;
+      unsigned int context;
+      re_dfastate_t *dest_state;
+
+      if (!dfa->nodes[cur_node_idx].accept_mb)
+       continue;
+
+      if (dfa->nodes[cur_node_idx].constraint)
+       {
+         context = re_string_context_at (&mctx->input,
+                                         re_string_cur_idx (&mctx->input),
+                                         mctx->eflags);
+         if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
+                                          context))
+           continue;
+       }
+
+      /* How many bytes the node can accept?  */
+      naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input,
+                                          re_string_cur_idx (&mctx->input));
+      if (naccepted == 0)
+       continue;
+
+      /* The node can accepts `naccepted' bytes.  */
+      dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
+      mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
+                              : mctx->max_mb_elem_len);
+      err = clean_state_log_if_needed (mctx, dest_idx);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+#ifdef DEBUG
+      assert (dfa->nexts[cur_node_idx] != REG_MISSING);
+#endif
+      new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
+
+      dest_state = mctx->state_log[dest_idx];
+      if (dest_state == NULL)
+       dest_nodes = *new_nodes;
+      else
+       {
+         err = re_node_set_init_union (&dest_nodes,
+                                       dest_state->entrance_nodes, new_nodes);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+      context = re_string_context_at (&mctx->input, dest_idx - 1,
+                                     mctx->eflags);
+      mctx->state_log[dest_idx]
+       = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+      if (dest_state != NULL)
+       re_node_set_free (&dest_nodes);
+      if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0))
+       return err;
+    }
+  return REG_NOERROR;
+}
+#endif /* RE_ENABLE_I18N */
+
+static reg_errcode_t
+internal_function
+transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err;
+  Idx i;
+  Idx cur_str_idx = re_string_cur_idx (&mctx->input);
+
+  for (i = 0; i < nodes->nelem; ++i)
+    {
+      Idx dest_str_idx, prev_nelem, bkc_idx;
+      Idx node_idx = nodes->elems[i];
+      unsigned int context;
+      const re_token_t *node = dfa->nodes + node_idx;
+      re_node_set *new_dest_nodes;
+
+      /* Check whether `node' is a backreference or not.  */
+      if (node->type != OP_BACK_REF)
+       continue;
+
+      if (node->constraint)
+       {
+         context = re_string_context_at (&mctx->input, cur_str_idx,
+                                         mctx->eflags);
+         if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+           continue;
+       }
+
+      /* `node' is a backreference.
+        Check the substring which the substring matched.  */
+      bkc_idx = mctx->nbkref_ents;
+      err = get_subexp (mctx, node_idx, cur_str_idx);
+      if (BE (err != REG_NOERROR, 0))
+       goto free_return;
+
+      /* And add the epsilon closures (which is `new_dest_nodes') of
+        the backreference to appropriate state_log.  */
+#ifdef DEBUG
+      assert (dfa->nexts[node_idx] != REG_MISSING);
+#endif
+      for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
+       {
+         Idx subexp_len;
+         re_dfastate_t *dest_state;
+         struct re_backref_cache_entry *bkref_ent;
+         bkref_ent = mctx->bkref_ents + bkc_idx;
+         if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx)
+           continue;
+         subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from;
+         new_dest_nodes = (subexp_len == 0
+                           ? dfa->eclosures + dfa->edests[node_idx].elems[0]
+                           : dfa->eclosures + dfa->nexts[node_idx]);
+         dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
+                         - bkref_ent->subexp_from);
+         context = re_string_context_at (&mctx->input, dest_str_idx - 1,
+                                         mctx->eflags);
+         dest_state = mctx->state_log[dest_str_idx];
+         prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
+                       : mctx->state_log[cur_str_idx]->nodes.nelem);
+         /* Add `new_dest_node' to state_log.  */
+         if (dest_state == NULL)
+           {
+             mctx->state_log[dest_str_idx]
+               = re_acquire_state_context (&err, dfa, new_dest_nodes,
+                                           context);
+             if (BE (mctx->state_log[dest_str_idx] == NULL
+                     && err != REG_NOERROR, 0))
+               goto free_return;
+           }
+         else
+           {
+             re_node_set dest_nodes;
+             err = re_node_set_init_union (&dest_nodes,
+                                           dest_state->entrance_nodes,
+                                           new_dest_nodes);
+             if (BE (err != REG_NOERROR, 0))
+               {
+                 re_node_set_free (&dest_nodes);
+                 goto free_return;
+               }
+             mctx->state_log[dest_str_idx]
+               = re_acquire_state_context (&err, dfa, &dest_nodes, context);
+             re_node_set_free (&dest_nodes);
+             if (BE (mctx->state_log[dest_str_idx] == NULL
+                     && err != REG_NOERROR, 0))
+               goto free_return;
+           }
+         /* We need to check recursively if the backreference can epsilon
+            transit.  */
+         if (subexp_len == 0
+             && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem)
+           {
+             err = check_subexp_matching_top (mctx, new_dest_nodes,
+                                              cur_str_idx);
+             if (BE (err != REG_NOERROR, 0))
+               goto free_return;
+             err = transit_state_bkref (mctx, new_dest_nodes);
+             if (BE (err != REG_NOERROR, 0))
+               goto free_return;
+           }
+       }
+    }
+  err = REG_NOERROR;
+ free_return:
+  return err;
+}
+
+/* Enumerate all the candidates which the backreference BKREF_NODE can match
+   at BKREF_STR_IDX, and register them by match_ctx_add_entry().
+   Note that we might collect inappropriate candidates here.
+   However, the cost of checking them strictly here is too high, then we
+   delay these checking for prune_impossible_nodes().  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  Idx subexp_num, sub_top_idx;
+  const char *buf = (const char *) re_string_get_buffer (&mctx->input);
+  /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX.  */
+  Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
+  if (cache_idx != REG_MISSING)
+    {
+      const struct re_backref_cache_entry *entry
+       = mctx->bkref_ents + cache_idx;
+      do
+       if (entry->node == bkref_node)
+         return REG_NOERROR; /* We already checked it.  */
+      while (entry++->more);
+    }
+
+  subexp_num = dfa->nodes[bkref_node].opr.idx;
+
+  /* For each sub expression  */
+  for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)
+    {
+      reg_errcode_t err;
+      re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];
+      re_sub_match_last_t *sub_last;
+      Idx sub_last_idx, sl_str, bkref_str_off;
+
+      if (dfa->nodes[sub_top->node].opr.idx != subexp_num)
+       continue; /* It isn't related.  */
+
+      sl_str = sub_top->str_idx;
+      bkref_str_off = bkref_str_idx;
+      /* At first, check the last node of sub expressions we already
+        evaluated.  */
+      for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)
+       {
+         regoff_t sl_str_diff;
+         sub_last = sub_top->lasts[sub_last_idx];
+         sl_str_diff = sub_last->str_idx - sl_str;
+         /* The matched string by the sub expression match with the substring
+            at the back reference?  */
+         if (sl_str_diff > 0)
+           {
+             if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0))
+               {
+                 /* Not enough chars for a successful match.  */
+                 if (bkref_str_off + sl_str_diff > mctx->input.len)
+                   break;
+
+                 err = clean_state_log_if_needed (mctx,
+                                                  bkref_str_off
+                                                  + sl_str_diff);
+                 if (BE (err != REG_NOERROR, 0))
+                   return err;
+                 buf = (const char *) re_string_get_buffer (&mctx->input);
+               }
+             if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0)
+               /* We don't need to search this sub expression any more.  */
+               break;
+           }
+         bkref_str_off += sl_str_diff;
+         sl_str += sl_str_diff;
+         err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+                               bkref_str_idx);
+
+         /* Reload buf, since the preceding call might have reallocated
+            the buffer.  */
+         buf = (const char *) re_string_get_buffer (&mctx->input);
+
+         if (err == REG_NOMATCH)
+           continue;
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+
+      if (sub_last_idx < sub_top->nlasts)
+       continue;
+      if (sub_last_idx > 0)
+       ++sl_str;
+      /* Then, search for the other last nodes of the sub expression.  */
+      for (; sl_str <= bkref_str_idx; ++sl_str)
+       {
+         Idx cls_node;
+         regoff_t sl_str_off;
+         const re_node_set *nodes;
+         sl_str_off = sl_str - sub_top->str_idx;
+         /* The matched string by the sub expression match with the substring
+            at the back reference?  */
+         if (sl_str_off > 0)
+           {
+             if (BE (bkref_str_off >= mctx->input.valid_len, 0))
+               {
+                 /* If we are at the end of the input, we cannot match.  */
+                 if (bkref_str_off >= mctx->input.len)
+                   break;
+
+                 err = extend_buffers (mctx);
+                 if (BE (err != REG_NOERROR, 0))
+                   return err;
+
+                 buf = (const char *) re_string_get_buffer (&mctx->input);
+               }
+             if (buf [bkref_str_off++] != buf[sl_str - 1])
+               break; /* We don't need to search this sub expression
+                         any more.  */
+           }
+         if (mctx->state_log[sl_str] == NULL)
+           continue;
+         /* Does this state have a ')' of the sub expression?  */
+         nodes = &mctx->state_log[sl_str]->nodes;
+         cls_node = find_subexp_node (dfa, nodes, subexp_num,
+                                      OP_CLOSE_SUBEXP);
+         if (cls_node == REG_MISSING)
+           continue; /* No.  */
+         if (sub_top->path == NULL)
+           {
+             sub_top->path = calloc (sizeof (state_array_t),
+                                     sl_str - sub_top->str_idx + 1);
+             if (sub_top->path == NULL)
+               return REG_ESPACE;
+           }
+         /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node
+            in the current context?  */
+         err = check_arrival (mctx, sub_top->path, sub_top->node,
+                              sub_top->str_idx, cls_node, sl_str,
+                              OP_CLOSE_SUBEXP);
+         if (err == REG_NOMATCH)
+             continue;
+         if (BE (err != REG_NOERROR, 0))
+             return err;
+         sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
+         if (BE (sub_last == NULL, 0))
+           return REG_ESPACE;
+         err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
+                               bkref_str_idx);
+         if (err == REG_NOMATCH)
+           continue;
+       }
+    }
+  return REG_NOERROR;
+}
+
+/* Helper functions for get_subexp().  */
+
+/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR.
+   If it can arrive, register the sub expression expressed with SUB_TOP
+   and SUB_LAST.  */
+
+static reg_errcode_t
+internal_function
+get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
+               re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
+{
+  reg_errcode_t err;
+  Idx to_idx;
+  /* Can the subexpression arrive the back reference?  */
+  err = check_arrival (mctx, &sub_last->path, sub_last->node,
+                      sub_last->str_idx, bkref_node, bkref_str,
+                      OP_OPEN_SUBEXP);
+  if (err != REG_NOERROR)
+    return err;
+  err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
+                            sub_last->str_idx);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+  to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
+  return clean_state_log_if_needed (mctx, to_idx);
+}
+
+/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX.
+   Search '(' if FL_OPEN, or search ')' otherwise.
+   TODO: This function isn't efficient...
+        Because there might be more than one nodes whose types are
+        OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all
+        nodes.
+        E.g. RE: (a){2}  */
+
+static Idx
+internal_function
+find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+                 Idx subexp_idx, int type)
+{
+  Idx cls_idx;
+  for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
+    {
+      Idx cls_node = nodes->elems[cls_idx];
+      const re_token_t *node = dfa->nodes + cls_node;
+      if (node->type == type
+         && node->opr.idx == subexp_idx)
+       return cls_node;
+    }
+  return REG_MISSING;
+}
+
+/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
+   LAST_NODE at LAST_STR.  We record the path onto PATH since it will be
+   heavily reused.
+   Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
+              Idx top_str, Idx last_node, Idx last_str, int type)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err = REG_NOERROR;
+  Idx subexp_num, backup_cur_idx, str_idx, null_cnt;
+  re_dfastate_t *cur_state = NULL;
+  re_node_set *cur_nodes, next_nodes;
+  re_dfastate_t **backup_state_log;
+  unsigned int context;
+
+  subexp_num = dfa->nodes[top_node].opr.idx;
+  /* Extend the buffer if we need.  */
+  if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0))
+    {
+      re_dfastate_t **new_array;
+      Idx old_alloc = path->alloc;
+      Idx new_alloc = old_alloc + last_str + mctx->max_mb_elem_len + 1;
+      if (BE (new_alloc < old_alloc, 0)
+         || BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0))
+       return REG_ESPACE;
+      new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
+      if (BE (new_array == NULL, 0))
+       return REG_ESPACE;
+      path->array = new_array;
+      path->alloc = new_alloc;
+      memset (new_array + old_alloc, '\0',
+             sizeof (re_dfastate_t *) * (path->alloc - old_alloc));
+    }
+
+  str_idx = path->next_idx ? path->next_idx : top_str;
+
+  /* Temporary modify MCTX.  */
+  backup_state_log = mctx->state_log;
+  backup_cur_idx = mctx->input.cur_idx;
+  mctx->state_log = path->array;
+  mctx->input.cur_idx = str_idx;
+
+  /* Setup initial node set.  */
+  context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+  if (str_idx == top_str)
+    {
+      err = re_node_set_init_1 (&next_nodes, top_node);
+      if (BE (err != REG_NOERROR, 0))
+       return err;
+      err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+      if (BE (err != REG_NOERROR, 0))
+       {
+         re_node_set_free (&next_nodes);
+         return err;
+       }
+    }
+  else
+    {
+      cur_state = mctx->state_log[str_idx];
+      if (cur_state && cur_state->has_backref)
+       {
+         err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+      else
+       re_node_set_init_empty (&next_nodes);
+    }
+  if (str_idx == top_str || (cur_state && cur_state->has_backref))
+    {
+      if (next_nodes.nelem)
+       {
+         err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+                                   subexp_num, type);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return err;
+           }
+       }
+      cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+      if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+       {
+         re_node_set_free (&next_nodes);
+         return err;
+       }
+      mctx->state_log[str_idx] = cur_state;
+    }
+
+  for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
+    {
+      re_node_set_empty (&next_nodes);
+      if (mctx->state_log[str_idx + 1])
+       {
+         err = re_node_set_merge (&next_nodes,
+                                  &mctx->state_log[str_idx + 1]->nodes);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return err;
+           }
+       }
+      if (cur_state)
+       {
+         err = check_arrival_add_next_nodes (mctx, str_idx,
+                                             &cur_state->non_eps_nodes,
+                                             &next_nodes);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return err;
+           }
+       }
+      ++str_idx;
+      if (next_nodes.nelem)
+       {
+         err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return err;
+           }
+         err = expand_bkref_cache (mctx, &next_nodes, str_idx,
+                                   subexp_num, type);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&next_nodes);
+             return err;
+           }
+       }
+      context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
+      cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
+      if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+       {
+         re_node_set_free (&next_nodes);
+         return err;
+       }
+      mctx->state_log[str_idx] = cur_state;
+      null_cnt = cur_state == NULL ? null_cnt + 1 : 0;
+    }
+  re_node_set_free (&next_nodes);
+  cur_nodes = (mctx->state_log[last_str] == NULL ? NULL
+              : &mctx->state_log[last_str]->nodes);
+  path->next_idx = str_idx;
+
+  /* Fix MCTX.  */
+  mctx->state_log = backup_state_log;
+  mctx->input.cur_idx = backup_cur_idx;
+
+  /* Then check the current node set has the node LAST_NODE.  */
+  if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
+    return REG_NOERROR;
+
+  return REG_NOMATCH;
+}
+
+/* Helper functions for check_arrival.  */
+
+/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them
+   to NEXT_NODES.
+   TODO: This function is similar to the functions transit_state*(),
+        however this function has many additional works.
+        Can't we unify them?  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
+                             re_node_set *cur_nodes, re_node_set *next_nodes)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  bool ok;
+  Idx cur_idx;
+#ifdef RE_ENABLE_I18N
+  reg_errcode_t err = REG_NOERROR;
+#endif
+  re_node_set union_set;
+  re_node_set_init_empty (&union_set);
+  for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
+    {
+      int naccepted = 0;
+      Idx cur_node = cur_nodes->elems[cur_idx];
+#ifdef DEBUG
+      re_token_type_t type = dfa->nodes[cur_node].type;
+      assert (!IS_EPSILON_NODE (type));
+#endif
+#ifdef RE_ENABLE_I18N
+      /* If the node may accept `multi byte'.  */
+      if (dfa->nodes[cur_node].accept_mb)
+       {
+         naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
+                                              str_idx);
+         if (naccepted > 1)
+           {
+             re_dfastate_t *dest_state;
+             Idx next_node = dfa->nexts[cur_node];
+             Idx next_idx = str_idx + naccepted;
+             dest_state = mctx->state_log[next_idx];
+             re_node_set_empty (&union_set);
+             if (dest_state)
+               {
+                 err = re_node_set_merge (&union_set, &dest_state->nodes);
+                 if (BE (err != REG_NOERROR, 0))
+                   {
+                     re_node_set_free (&union_set);
+                     return err;
+                   }
+               }
+             ok = re_node_set_insert (&union_set, next_node);
+             if (BE (! ok, 0))
+               {
+                 re_node_set_free (&union_set);
+                 return REG_ESPACE;
+               }
+             mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
+                                                           &union_set);
+             if (BE (mctx->state_log[next_idx] == NULL
+                     && err != REG_NOERROR, 0))
+               {
+                 re_node_set_free (&union_set);
+                 return err;
+               }
+           }
+       }
+#endif /* RE_ENABLE_I18N */
+      if (naccepted
+         || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
+       {
+         ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
+         if (BE (! ok, 0))
+           {
+             re_node_set_free (&union_set);
+             return REG_ESPACE;
+           }
+       }
+    }
+  re_node_set_free (&union_set);
+  return REG_NOERROR;
+}
+
+/* For all the nodes in CUR_NODES, add the epsilon closures of them to
+   CUR_NODES, however exclude the nodes which are:
+    - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN.
+    - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN.
+*/
+
+static reg_errcode_t
+internal_function
+check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
+                         Idx ex_subexp, int type)
+{
+  reg_errcode_t err;
+  Idx idx, outside_node;
+  re_node_set new_nodes;
+#ifdef DEBUG
+  assert (cur_nodes->nelem);
+#endif
+  err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
+  if (BE (err != REG_NOERROR, 0))
+    return err;
+  /* Create a new node set NEW_NODES with the nodes which are epsilon
+     closures of the node in CUR_NODES.  */
+
+  for (idx = 0; idx < cur_nodes->nelem; ++idx)
+    {
+      Idx cur_node = cur_nodes->elems[idx];
+      const re_node_set *eclosure = dfa->eclosures + cur_node;
+      outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
+      if (outside_node == REG_MISSING)
+       {
+         /* There are no problematic nodes, just merge them.  */
+         err = re_node_set_merge (&new_nodes, eclosure);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&new_nodes);
+             return err;
+           }
+       }
+      else
+       {
+         /* There are problematic nodes, re-calculate incrementally.  */
+         err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
+                                             ex_subexp, type);
+         if (BE (err != REG_NOERROR, 0))
+           {
+             re_node_set_free (&new_nodes);
+             return err;
+           }
+       }
+    }
+  re_node_set_free (cur_nodes);
+  *cur_nodes = new_nodes;
+  return REG_NOERROR;
+}
+
+/* Helper function for check_arrival_expand_ecl.
+   Check incrementally the epsilon closure of TARGET, and if it isn't
+   problematic append it to DST_NODES.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
+                             Idx target, Idx ex_subexp, int type)
+{
+  Idx cur_node;
+  for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
+    {
+      bool ok;
+
+      if (dfa->nodes[cur_node].type == type
+         && dfa->nodes[cur_node].opr.idx == ex_subexp)
+       {
+         if (type == OP_CLOSE_SUBEXP)
+           {
+             ok = re_node_set_insert (dst_nodes, cur_node);
+             if (BE (! ok, 0))
+               return REG_ESPACE;
+           }
+         break;
+       }
+      ok = re_node_set_insert (dst_nodes, cur_node);
+      if (BE (! ok, 0))
+       return REG_ESPACE;
+      if (dfa->edests[cur_node].nelem == 0)
+       break;
+      if (dfa->edests[cur_node].nelem == 2)
+       {
+         reg_errcode_t err;
+         err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
+                                             dfa->edests[cur_node].elems[1],
+                                             ex_subexp, type);
+         if (BE (err != REG_NOERROR, 0))
+           return err;
+       }
+      cur_node = dfa->edests[cur_node].elems[0];
+    }
+  return REG_NOERROR;
+}
+
+
+/* For all the back references in the current state, calculate the
+   destination of the back references by the appropriate entry
+   in MCTX->BKREF_ENTS.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
+                   Idx cur_str, Idx subexp_num, int type)
+{
+  const re_dfa_t *const dfa = mctx->dfa;
+  reg_errcode_t err;
+  Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
+  struct re_backref_cache_entry *ent;
+
+  if (cache_idx_start == REG_MISSING)
+    return REG_NOERROR;
+
+ restart:
+  ent = mctx->bkref_ents + cache_idx_start;
+  do
+    {
+      Idx to_idx, next_node;
+
+      /* Is this entry ENT is appropriate?  */
+      if (!re_node_set_contains (cur_nodes, ent->node))
+       continue; /* No.  */
+
+      to_idx = cur_str + ent->subexp_to - ent->subexp_from;
+      /* Calculate the destination of the back reference, and append it
+        to MCTX->STATE_LOG.  */
+      if (to_idx == cur_str)
+       {
+         /* The backreference did epsilon transit, we must re-check all the
+            node in the current state.  */
+         re_node_set new_dests;
+         reg_errcode_t err2, err3;
+         next_node = dfa->edests[ent->node].elems[0];
+         if (re_node_set_contains (cur_nodes, next_node))
+           continue;
+         err = re_node_set_init_1 (&new_dests, next_node);
+         err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
+         err3 = re_node_set_merge (cur_nodes, &new_dests);
+         re_node_set_free (&new_dests);
+         if (BE (err != REG_NOERROR || err2 != REG_NOERROR
+                 || err3 != REG_NOERROR, 0))
+           {
+             err = (err != REG_NOERROR ? err
+                    : (err2 != REG_NOERROR ? err2 : err3));
+             return err;
+           }
+         /* TODO: It is still inefficient...  */
+         goto restart;
+       }
+      else
+       {
+         re_node_set union_set;
+         next_node = dfa->nexts[ent->node];
+         if (mctx->state_log[to_idx])
+           {
+             bool ok;
+             if (re_node_set_contains (&mctx->state_log[to_idx]->nodes,
+                                       next_node))
+               continue;
+             err = re_node_set_init_copy (&union_set,
+                                          &mctx->state_log[to_idx]->nodes);
+             ok = re_node_set_insert (&union_set, next_node);
+             if (BE (err != REG_NOERROR || ! ok, 0))
+               {
+                 re_node_set_free (&union_set);
+                 err = err != REG_NOERROR ? err : REG_ESPACE;
+                 return err;
+               }
+           }
+         else
+           {
+             err = re_node_set_init_1 (&union_set, next_node);
+             if (BE (err != REG_NOERROR, 0))
+               return err;
+           }
+         mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
+         re_node_set_free (&union_set);
+         if (BE (mctx->state_log[to_idx] == NULL
+                 && err != REG_NOERROR, 0))
+           return err;
+       }
+    }
+  while (ent++->more);
+  return REG_NOERROR;
+}
+
+/* Build transition table for the state.
+   Return true if successful.  */
+
+static bool
+internal_function
+build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
+{
+  reg_errcode_t err;
+  Idx i, j;
+  int ch;
+  bool need_word_trtable = false;
+  bitset_word_t elem, mask;
+  bool dests_node_malloced = false;
+  bool dest_states_malloced = false;
+  Idx ndests; /* Number of the destination states from `state'.  */
+  re_dfastate_t **trtable;
+  re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
+  re_node_set follows, *dests_node;
+  bitset_t *dests_ch;
+  bitset_t acceptable;
+
+  struct dests_alloc
+  {
+    re_node_set dests_node[SBC_MAX];
+    bitset_t dests_ch[SBC_MAX];
+  } *dests_alloc;
+
+  /* We build DFA states which corresponds to the destination nodes
+     from `state'.  `dests_node[i]' represents the nodes which i-th
+     destination state contains, and `dests_ch[i]' represents the
+     characters which i-th destination state accepts.  */
+  if (__libc_use_alloca (sizeof (struct dests_alloc)))
+    dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
+  else
+    {
+      dests_alloc = re_malloc (struct dests_alloc, 1);
+      if (BE (dests_alloc == NULL, 0))
+       return false;
+      dests_node_malloced = true;
+    }
+  dests_node = dests_alloc->dests_node;
+  dests_ch = dests_alloc->dests_ch;
+
+  /* Initialize transiton table.  */
+  state->word_trtable = state->trtable = NULL;
+
+  /* At first, group all nodes belonging to `state' into several
+     destinations.  */
+  ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
+  if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0))
+    {
+      if (dests_node_malloced)
+       free (dests_alloc);
+      if (ndests == 0)
+       {
+         state->trtable = (re_dfastate_t **)
+           calloc (sizeof (re_dfastate_t *), SBC_MAX);
+          if (BE (state->trtable == NULL, 0))
+            return false;
+         return true;
+       }
+      return false;
+    }
+
+  err = re_node_set_alloc (&follows, ndests + 1);
+  if (BE (err != REG_NOERROR, 0))
+    goto out_free;
+
+  /* Avoid arithmetic overflow in size calculation.  */
+  if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
+           / (3 * sizeof (re_dfastate_t *)))
+          < ndests),
+         0))
+    goto out_free;
+
+  if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
+                        + ndests * 3 * sizeof (re_dfastate_t *)))
+    dest_states = (re_dfastate_t **)
+      alloca (ndests * 3 * sizeof (re_dfastate_t *));
+  else
+    {
+      dest_states = (re_dfastate_t **)
+       malloc (ndests * 3 * sizeof (re_dfastate_t *));
+      if (BE (dest_states == NULL, 0))
+       {
+out_free:
+         if (dest_states_malloced)
+           free (dest_states);
+         re_node_set_free (&follows);
+         for (i = 0; i < ndests; ++i)
+           re_node_set_free (dests_node + i);
+         if (dests_node_malloced)
+           free (dests_alloc);
+         return false;
+       }
+      dest_states_malloced = true;
+    }
+  dest_states_word = dest_states + ndests;
+  dest_states_nl = dest_states_word + ndests;
+  bitset_empty (acceptable);
+
+  /* Then build the states for all destinations.  */
+  for (i = 0; i < ndests; ++i)
+    {
+      Idx next_node;
+      re_node_set_empty (&follows);
+      /* Merge the follows of this destination states.  */
+      for (j = 0; j < dests_node[i].nelem; ++j)
+       {
+         next_node = dfa->nexts[dests_node[i].elems[j]];
+         if (next_node != REG_MISSING)
+           {
+             err = re_node_set_merge (&follows, dfa->eclosures + next_node);
+             if (BE (err != REG_NOERROR, 0))
+               goto out_free;
+           }
+       }
+      dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
+      if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0))
+       goto out_free;
+      /* If the new state has context constraint,
+        build appropriate states for these contexts.  */
+      if (dest_states[i]->has_constraint)
+       {
+         dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
+                                                         CONTEXT_WORD);
+         if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0))
+           goto out_free;
+
+         if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
+           need_word_trtable = true;
+
+         dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
+                                                       CONTEXT_NEWLINE);
+         if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
+           goto out_free;
+       }
+      else
+       {
+         dest_states_word[i] = dest_states[i];
+         dest_states_nl[i] = dest_states[i];
+       }
+      bitset_merge (acceptable, dests_ch[i]);
+    }
+
+  if (!BE (need_word_trtable, 0))
+    {
+      /* We don't care about whether the following character is a word
+        character, or we are in a single-byte character set so we can
+        discern by looking at the character code: allocate a
+        256-entry transition table.  */
+      trtable = state->trtable =
+       (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+      if (BE (trtable == NULL, 0))
+       goto out_free;
+
+      /* For all characters ch...:  */
+      for (i = 0; i < BITSET_WORDS; ++i)
+       for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+            elem;
+            mask <<= 1, elem >>= 1, ++ch)
+         if (BE (elem & 1, 0))
+           {
+             /* There must be exactly one destination which accepts
+                character ch.  See group_nodes_into_DFAstates.  */
+             for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+               ;
+
+             /* j-th destination accepts the word character ch.  */
+             if (dfa->word_char[i] & mask)
+               trtable[ch] = dest_states_word[j];
+             else
+               trtable[ch] = dest_states[j];
+           }
+    }
+  else
+    {
+      /* We care about whether the following character is a word
+        character, and we are in a multi-byte character set: discern
+        by looking at the character code: build two 256-entry
+        transition tables, one starting at trtable[0] and one
+        starting at trtable[SBC_MAX].  */
+      trtable = state->word_trtable =
+       (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+      if (BE (trtable == NULL, 0))
+       goto out_free;
+
+      /* For all characters ch...:  */
+      for (i = 0; i < BITSET_WORDS; ++i)
+       for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
+            elem;
+            mask <<= 1, elem >>= 1, ++ch)
+         if (BE (elem & 1, 0))
+           {
+             /* There must be exactly one destination which accepts
+                character ch.  See group_nodes_into_DFAstates.  */
+             for (j = 0; (dests_ch[j][i] & mask) == 0; ++j)
+               ;
+
+             /* j-th destination accepts the word character ch.  */
+             trtable[ch] = dest_states[j];
+             trtable[ch + SBC_MAX] = dest_states_word[j];
+           }
+    }
+
+  /* new line */
+  if (bitset_contain (acceptable, NEWLINE_CHAR))
+    {
+      /* The current state accepts newline character.  */
+      for (j = 0; j < ndests; ++j)
+       if (bitset_contain (dests_ch[j], NEWLINE_CHAR))
+         {
+           /* k-th destination accepts newline character.  */
+           trtable[NEWLINE_CHAR] = dest_states_nl[j];
+           if (need_word_trtable)
+             trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j];
+           /* There must be only one destination which accepts
+              newline.  See group_nodes_into_DFAstates.  */
+           break;
+         }
+    }
+
+  if (dest_states_malloced)
+    free (dest_states);
+
+  re_node_set_free (&follows);
+  for (i = 0; i < ndests; ++i)
+    re_node_set_free (dests_node + i);
+
+  if (dests_node_malloced)
+    free (dests_alloc);
+
+  return true;
+}
+
+/* Group all nodes belonging to STATE into several destinations.
+   Then for all destinations, set the nodes belonging to the destination
+   to DESTS_NODE[i] and set the characters accepted by the destination
+   to DEST_CH[i].  This function return the number of destinations.  */
+
+static Idx
+internal_function
+group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
+                           re_node_set *dests_node, bitset_t *dests_ch)
+{
+  reg_errcode_t err;
+  bool ok;
+  Idx i, j, k;
+  Idx ndests; /* Number of the destinations from `state'.  */
+  bitset_t accepts; /* Characters a node can accept.  */
+  const re_node_set *cur_nodes = &state->nodes;
+  bitset_empty (accepts);
+  ndests = 0;
+
+  /* For all the nodes belonging to `state',  */
+  for (i = 0; i < cur_nodes->nelem; ++i)
+    {
+      re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
+      re_token_type_t type = node->type;
+      unsigned int constraint = node->constraint;
+
+      /* Enumerate all single byte character this node can accept.  */
+      if (type == CHARACTER)
+       bitset_set (accepts, node->opr.c);
+      else if (type == SIMPLE_BRACKET)
+       {
+         bitset_merge (accepts, node->opr.sbcset);
+       }
+      else if (type == OP_PERIOD)
+       {
+#ifdef RE_ENABLE_I18N
+         if (dfa->mb_cur_max > 1)
+           bitset_merge (accepts, dfa->sb_char);
+         else
+#endif
+           bitset_set_all (accepts);
+         if (!(dfa->syntax & RE_DOT_NEWLINE))
+           bitset_clear (accepts, '\n');
+         if (dfa->syntax & RE_DOT_NOT_NULL)
+           bitset_clear (accepts, '\0');
+       }
+#ifdef RE_ENABLE_I18N
+      else if (type == OP_UTF8_PERIOD)
+       {
+         if (ASCII_CHARS % BITSET_WORD_BITS == 0)
+           memset (accepts, -1, ASCII_CHARS / CHAR_BIT);
+         else
+           bitset_merge (accepts, utf8_sb_map);
+         if (!(dfa->syntax & RE_DOT_NEWLINE))
+           bitset_clear (accepts, '\n');
+         if (dfa->syntax & RE_DOT_NOT_NULL)
+           bitset_clear (accepts, '\0');
+       }
+#endif
+      else
+       continue;
+
+      /* Check the `accepts' and sift the characters which are not
+        match it the context.  */
+      if (constraint)
+       {
+         if (constraint & NEXT_NEWLINE_CONSTRAINT)
+           {
+             bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR);
+             bitset_empty (accepts);
+             if (accepts_newline)
+               bitset_set (accepts, NEWLINE_CHAR);
+             else
+               continue;
+           }
+         if (constraint & NEXT_ENDBUF_CONSTRAINT)
+           {
+             bitset_empty (accepts);
+             continue;
+           }
+
+         if (constraint & NEXT_WORD_CONSTRAINT)
+           {
+             bitset_word_t any_set = 0;
+             if (type == CHARACTER && !node->word_char)
+               {
+                 bitset_empty (accepts);
+                 continue;
+               }
+#ifdef RE_ENABLE_I18N
+             if (dfa->mb_cur_max > 1)
+               for (j = 0; j < BITSET_WORDS; ++j)
+                 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
+             else
+#endif
+               for (j = 0; j < BITSET_WORDS; ++j)
+                 any_set |= (accepts[j] &= dfa->word_char[j]);
+             if (!any_set)
+               continue;
+           }
+         if (constraint & NEXT_NOTWORD_CONSTRAINT)
+           {
+             bitset_word_t any_set = 0;
+             if (type == CHARACTER && node->word_char)
+               {
+                 bitset_empty (accepts);
+                 continue;
+               }
+#ifdef RE_ENABLE_I18N
+             if (dfa->mb_cur_max > 1)
+               for (j = 0; j < BITSET_WORDS; ++j)
+                 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
+             else
+#endif
+               for (j = 0; j < BITSET_WORDS; ++j)
+                 any_set |= (accepts[j] &= ~dfa->word_char[j]);
+             if (!any_set)
+               continue;
+           }
+       }
+
+      /* Then divide `accepts' into DFA states, or create a new
+        state.  Above, we make sure that accepts is not empty.  */
+      for (j = 0; j < ndests; ++j)
+       {
+         bitset_t intersec; /* Intersection sets, see below.  */
+         bitset_t remains;
+         /* Flags, see below.  */
+         bitset_word_t has_intersec, not_subset, not_consumed;
+
+         /* Optimization, skip if this state doesn't accept the character.  */
+         if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
+           continue;
+
+         /* Enumerate the intersection set of this state and `accepts'.  */
+         has_intersec = 0;
+         for (k = 0; k < BITSET_WORDS; ++k)
+           has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
+         /* And skip if the intersection set is empty.  */
+         if (!has_intersec)
+           continue;
+
+         /* Then check if this state is a subset of `accepts'.  */
+         not_subset = not_consumed = 0;
+         for (k = 0; k < BITSET_WORDS; ++k)
+           {
+             not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k];
+             not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
+           }
+
+         /* If this state isn't a subset of `accepts', create a
+            new group state, which has the `remains'. */
+         if (not_subset)
+           {
+             bitset_copy (dests_ch[ndests], remains);
+             bitset_copy (dests_ch[j], intersec);
+             err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
+             if (BE (err != REG_NOERROR, 0))
+               goto error_return;
+             ++ndests;
+           }
+
+         /* Put the position in the current group. */
+         ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
+         if (BE (! ok, 0))
+           goto error_return;
+
+         /* If all characters are consumed, go to next node. */
+         if (!not_consumed)
+           break;
+       }
+      /* Some characters remain, create a new group. */
+      if (j == ndests)
+       {
+         bitset_copy (dests_ch[ndests], accepts);
+         err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
+         if (BE (err != REG_NOERROR, 0))
+           goto error_return;
+         ++ndests;
+         bitset_empty (accepts);
+       }
+    }
+  return ndests;
+ error_return:
+  for (j = 0; j < ndests; ++j)
+    re_node_set_free (dests_node + j);
+  return REG_MISSING;
+}
+
+#ifdef RE_ENABLE_I18N
+/* Check how many bytes the node `dfa->nodes[node_idx]' accepts.
+   Return the number of the bytes the node accepts.
+   STR_IDX is the current index of the input string.
+
+   This function handles the nodes which can accept one character, or
+   one collating element like '.', '[a-z]', opposite to the other nodes
+   can only accept one byte.  */
+
+static int
+internal_function
+check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
+                        const re_string_t *input, Idx str_idx)
+{
+  const re_token_t *node = dfa->nodes + node_idx;
+  int char_len, elem_len;
+  Idx i;
+
+  if (BE (node->type == OP_UTF8_PERIOD, 0))
+    {
+      unsigned char c = re_string_byte_at (input, str_idx), d;
+      if (BE (c < 0xc2, 1))
+       return 0;
+
+      if (str_idx + 2 > input->len)
+       return 0;
+
+      d = re_string_byte_at (input, str_idx + 1);
+      if (c < 0xe0)
+       return (d < 0x80 || d > 0xbf) ? 0 : 2;
+      else if (c < 0xf0)
+       {
+         char_len = 3;
+         if (c == 0xe0 && d < 0xa0)
+           return 0;
+       }
+      else if (c < 0xf8)
+       {
+         char_len = 4;
+         if (c == 0xf0 && d < 0x90)
+           return 0;
+       }
+      else if (c < 0xfc)
+       {
+         char_len = 5;
+         if (c == 0xf8 && d < 0x88)
+           return 0;
+       }
+      else if (c < 0xfe)
+       {
+         char_len = 6;
+         if (c == 0xfc && d < 0x84)
+           return 0;
+       }
+      else
+       return 0;
+
+      if (str_idx + char_len > input->len)
+       return 0;
+
+      for (i = 1; i < char_len; ++i)
+       {
+         d = re_string_byte_at (input, str_idx + i);
+         if (d < 0x80 || d > 0xbf)
+           return 0;
+       }
+      return char_len;
+    }
+
+  char_len = re_string_char_size_at (input, str_idx);
+  if (node->type == OP_PERIOD)
+    {
+      if (char_len <= 1)
+       return 0;
+      /* FIXME: I don't think this if is needed, as both '\n'
+        and '\0' are char_len == 1.  */
+      /* '.' accepts any one character except the following two cases.  */
+      if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
+          re_string_byte_at (input, str_idx) == '\n') ||
+         ((dfa->syntax & RE_DOT_NOT_NULL) &&
+          re_string_byte_at (input, str_idx) == '\0'))
+       return 0;
+      return char_len;
+    }
+
+  elem_len = re_string_elem_size_at (input, str_idx);
+  if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
+    return 0;
+
+  if (node->type == COMPLEX_BRACKET)
+    {
+      const re_charset_t *cset = node->opr.mbcset;
+# ifdef _LIBC
+      const unsigned char *pin
+       = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
+      Idx j;
+      uint32_t nrules;
+# endif /* _LIBC */
+      int match_len = 0;
+      wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
+                   ? re_string_wchar_at (input, str_idx) : 0);
+
+      /* match with multibyte character?  */
+      for (i = 0; i < cset->nmbchars; ++i)
+       if (wc == cset->mbchars[i])
+         {
+           match_len = char_len;
+           goto check_node_accept_bytes_match;
+         }
+      /* match with character_class?  */
+      for (i = 0; i < cset->nchar_classes; ++i)
+       {
+         wctype_t wt = cset->char_classes[i];
+         if (__iswctype (wc, wt))
+           {
+             match_len = char_len;
+             goto check_node_accept_bytes_match;
+           }
+       }
+
+# ifdef _LIBC
+      nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+      if (nrules != 0)
+       {
+         unsigned int in_collseq = 0;
+         const int32_t *table, *indirect;
+         const unsigned char *weights, *extra;
+         const char *collseqwc;
+         int32_t idx;
+         /* This #include defines a local function!  */
+#  include <locale/weight.h>
+
+         /* match with collating_symbol?  */
+         if (cset->ncoll_syms)
+           extra = (const unsigned char *)
+             _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+         for (i = 0; i < cset->ncoll_syms; ++i)
+           {
+             const unsigned char *coll_sym = extra + cset->coll_syms[i];
+             /* Compare the length of input collating element and
+                the length of current collating element.  */
+             if (*coll_sym != elem_len)
+               continue;
+             /* Compare each bytes.  */
+             for (j = 0; j < *coll_sym; j++)
+               if (pin[j] != coll_sym[1 + j])
+                 break;
+             if (j == *coll_sym)
+               {
+                 /* Match if every bytes is equal.  */
+                 match_len = j;
+                 goto check_node_accept_bytes_match;
+               }
+           }
+
+         if (cset->nranges)
+           {
+             if (elem_len <= char_len)
+               {
+                 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+                 in_collseq = __collseq_table_lookup (collseqwc, wc);
+               }
+             else
+               in_collseq = find_collation_sequence_value (pin, elem_len);
+           }
+         /* match with range expression?  */
+         for (i = 0; i < cset->nranges; ++i)
+           if (cset->range_starts[i] <= in_collseq
+               && in_collseq <= cset->range_ends[i])
+             {
+               match_len = elem_len;
+               goto check_node_accept_bytes_match;
+             }
+
+         /* match with equivalence_class?  */
+         if (cset->nequiv_classes)
+           {
+             const unsigned char *cp = pin;
+             table = (const int32_t *)
+               _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+             weights = (const unsigned char *)
+               _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+             extra = (const unsigned char *)
+               _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+             indirect = (const int32_t *)
+               _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+             int32_t idx = findidx (&cp);
+             if (idx > 0)
+               for (i = 0; i < cset->nequiv_classes; ++i)
+                 {
+                   int32_t equiv_class_idx = cset->equiv_classes[i];
+                   size_t weight_len = weights[idx & 0xffffff];
+                   if (weight_len == weights[equiv_class_idx & 0xffffff]
+                       && (idx >> 24) == (equiv_class_idx >> 24))
+                     {
+                       Idx cnt = 0;
+
+                       idx &= 0xffffff;
+                       equiv_class_idx &= 0xffffff;
+
+                       while (cnt <= weight_len
+                              && (weights[equiv_class_idx + 1 + cnt]
+                                  == weights[idx + 1 + cnt]))
+                         ++cnt;
+                       if (cnt > weight_len)
+                         {
+                           match_len = elem_len;
+                           goto check_node_accept_bytes_match;
+                         }
+                     }
+                 }
+           }
+       }
+      else
+# endif /* _LIBC */
+       {
+         /* match with range expression?  */
+#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && __STRICT_ANSI__)
+         wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
+#else
+         wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+         cmp_buf[2] = wc;
+#endif
+         for (i = 0; i < cset->nranges; ++i)
+           {
+             cmp_buf[0] = cset->range_starts[i];
+             cmp_buf[4] = cset->range_ends[i];
+             if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
+                 && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+               {
+                 match_len = char_len;
+                 goto check_node_accept_bytes_match;
+               }
+           }
+       }
+    check_node_accept_bytes_match:
+      if (!cset->non_match)
+       return match_len;
+      else
+       {
+         if (match_len > 0)
+           return 0;
+         else
+           return (elem_len > char_len) ? elem_len : char_len;
+       }
+    }
+  return 0;
+}
+
+# ifdef _LIBC
+static unsigned int
+internal_function
+find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
+{
+  uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+  if (nrules == 0)
+    {
+      if (mbs_len == 1)
+       {
+         /* No valid character.  Match it as a single byte character.  */
+         const unsigned char *collseq = (const unsigned char *)
+           _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
+         return collseq[mbs[0]];
+       }
+      return UINT_MAX;
+    }
+  else
+    {
+      int32_t idx;
+      const unsigned char *extra = (const unsigned char *)
+       _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+      int32_t extrasize = (const unsigned char *)
+       _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra;
+
+      for (idx = 0; idx < extrasize;)
+       {
+         int mbs_cnt;
+         bool found = false;
+         int32_t elem_mbs_len;
+         /* Skip the name of collating element name.  */
+         idx = idx + extra[idx] + 1;
+         elem_mbs_len = extra[idx++];
+         if (mbs_len == elem_mbs_len)
+           {
+             for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
+               if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
+                 break;
+             if (mbs_cnt == elem_mbs_len)
+               /* Found the entry.  */
+               found = true;
+           }
+         /* Skip the byte sequence of the collating element.  */
+         idx += elem_mbs_len;
+         /* Adjust for the alignment.  */
+         idx = (idx + 3) & ~3;
+         /* Skip the collation sequence value.  */
+         idx += sizeof (uint32_t);
+         /* Skip the wide char sequence of the collating element.  */
+         idx = idx + sizeof (uint32_t) * (extra[idx] + 1);
+         /* If we found the entry, return the sequence value.  */
+         if (found)
+           return *(uint32_t *) (extra + idx);
+         /* Skip the collation sequence value.  */
+         idx += sizeof (uint32_t);
+       }
+      return UINT_MAX;
+    }
+}
+# endif /* _LIBC */
+#endif /* RE_ENABLE_I18N */
+
+/* Check whether the node accepts the byte which is IDX-th
+   byte of the INPUT.  */
+
+static bool
+internal_function
+check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
+                  Idx idx)
+{
+  unsigned char ch;
+  ch = re_string_byte_at (&mctx->input, idx);
+  switch (node->type)
+    {
+    case CHARACTER:
+      if (node->opr.c != ch)
+        return false;
+      break;
+
+    case SIMPLE_BRACKET:
+      if (!bitset_contain (node->opr.sbcset, ch))
+        return false;
+      break;
+
+#ifdef RE_ENABLE_I18N
+    case OP_UTF8_PERIOD:
+      if (ch >= ASCII_CHARS)
+        return false;
+      /* FALLTHROUGH */
+#endif
+    case OP_PERIOD:
+      if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
+         || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
+       return false;
+      break;
+
+    default:
+      return false;
+    }
+
+  if (node->constraint)
+    {
+      /* The node has constraints.  Check whether the current context
+        satisfies the constraints.  */
+      unsigned int context = re_string_context_at (&mctx->input, idx,
+                                                  mctx->eflags);
+      if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
+       return false;
+    }
+
+  return true;
+}
+
+/* Extend the buffers, if the buffers have run out.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+extend_buffers (re_match_context_t *mctx)
+{
+  reg_errcode_t ret;
+  re_string_t *pstr = &mctx->input;
+
+  /* Avoid overflow.  */
+  if (BE (SIZE_MAX / 2 / sizeof (re_dfastate_t *) <= pstr->bufs_len, 0))
+    return REG_ESPACE;
+
+  /* Double the lengthes of the buffers.  */
+  ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+  if (BE (ret != REG_NOERROR, 0))
+    return ret;
+
+  if (mctx->state_log != NULL)
+    {
+      /* And double the length of state_log.  */
+      /* XXX We have no indication of the size of this buffer.  If this
+        allocation fail we have no indication that the state_log array
+        does not have the right size.  */
+      re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
+                                             pstr->bufs_len + 1);
+      if (BE (new_array == NULL, 0))
+       return REG_ESPACE;
+      mctx->state_log = new_array;
+    }
+
+  /* Then reconstruct the buffers.  */
+  if (pstr->icase)
+    {
+#ifdef RE_ENABLE_I18N
+      if (pstr->mb_cur_max > 1)
+       {
+         ret = build_wcs_upper_buffer (pstr);
+         if (BE (ret != REG_NOERROR, 0))
+           return ret;
+       }
+      else
+#endif /* RE_ENABLE_I18N  */
+       build_upper_buffer (pstr);
+    }
+  else
+    {
+#ifdef RE_ENABLE_I18N
+      if (pstr->mb_cur_max > 1)
+       build_wcs_buffer (pstr);
+      else
+#endif /* RE_ENABLE_I18N  */
+       {
+         if (pstr->trans != NULL)
+           re_string_translate_buffer (pstr);
+       }
+    }
+  return REG_NOERROR;
+}
+
+\f
+/* Functions for matching context.  */
+
+/* Initialize MCTX.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
+{
+  mctx->eflags = eflags;
+  mctx->match_last = REG_MISSING;
+  if (n > 0)
+    {
+      /* Avoid overflow.  */
+      size_t max_object_size =
+       MAX (sizeof (struct re_backref_cache_entry),
+            sizeof (re_sub_match_top_t *));
+      if (BE (SIZE_MAX / max_object_size < n, 0))
+       return REG_ESPACE;
+
+      mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
+      mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
+      if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
+       return REG_ESPACE;
+    }
+  /* Already zero-ed by the caller.
+     else
+       mctx->bkref_ents = NULL;
+     mctx->nbkref_ents = 0;
+     mctx->nsub_tops = 0;  */
+  mctx->abkref_ents = n;
+  mctx->max_mb_elem_len = 1;
+  mctx->asub_tops = n;
+  return REG_NOERROR;
+}
+
+/* Clean the entries which depend on the current input in MCTX.
+   This function must be invoked when the matcher changes the start index
+   of the input, or changes the input string.  */
+
+static void
+internal_function
+match_ctx_clean (re_match_context_t *mctx)
+{
+  Idx st_idx;
+  for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
+    {
+      Idx sl_idx;
+      re_sub_match_top_t *top = mctx->sub_tops[st_idx];
+      for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
+       {
+         re_sub_match_last_t *last = top->lasts[sl_idx];
+         re_free (last->path.array);
+         re_free (last);
+       }
+      re_free (top->lasts);
+      if (top->path)
+       {
+         re_free (top->path->array);
+         re_free (top->path);
+       }
+      free (top);
+    }
+
+  mctx->nsub_tops = 0;
+  mctx->nbkref_ents = 0;
+}
+
+/* Free all the memory associated with MCTX.  */
+
+static void
+internal_function
+match_ctx_free (re_match_context_t *mctx)
+{
+  /* First, free all the memory associated with MCTX->SUB_TOPS.  */
+  match_ctx_clean (mctx);
+  re_free (mctx->sub_tops);
+  re_free (mctx->bkref_ents);
+}
+
+/* Add a new backreference entry to MCTX.
+   Note that we assume that caller never call this function with duplicate
+   entry, and call with STR_IDX which isn't smaller than any existing entry.
+*/
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
+                    Idx to)
+{
+  if (mctx->nbkref_ents >= mctx->abkref_ents)
+    {
+      struct re_backref_cache_entry* new_entry;
+      new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
+                             mctx->abkref_ents * 2);
+      if (BE (new_entry == NULL, 0))
+       {
+         re_free (mctx->bkref_ents);
+         return REG_ESPACE;
+       }
+      mctx->bkref_ents = new_entry;
+      memset (mctx->bkref_ents + mctx->nbkref_ents, '\0',
+             sizeof (struct re_backref_cache_entry) * mctx->abkref_ents);
+      mctx->abkref_ents *= 2;
+    }
+  if (mctx->nbkref_ents > 0
+      && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx)
+    mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1;
+
+  mctx->bkref_ents[mctx->nbkref_ents].node = node;
+  mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx;
+  mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from;
+  mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to;
+
+  /* This is a cache that saves negative results of check_dst_limits_calc_pos.
+     If bit N is clear, means that this entry won't epsilon-transition to
+     an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression.  If
+     it is set, check_dst_limits_calc_pos_1 will recurse and try to find one
+     such node.
+
+     A backreference does not epsilon-transition unless it is empty, so set
+     to all zeros if FROM != TO.  */
+  mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map
+    = (from == to ? -1 : 0);
+
+  mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
+  if (mctx->max_mb_elem_len < to - from)
+    mctx->max_mb_elem_len = to - from;
+  return REG_NOERROR;
+}
+
+/* Return the first entry with the same str_idx, or REG_MISSING if none is
+   found.  Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX.  */
+
+static Idx
+internal_function
+search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
+{
+  Idx left, right, mid, last;
+  last = right = mctx->nbkref_ents;
+  for (left = 0; left < right;)
+    {
+      mid = (left + right) / 2;
+      if (mctx->bkref_ents[mid].str_idx < str_idx)
+       left = mid + 1;
+      else
+       right = mid;
+    }
+  if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
+    return left;
+  else
+    return REG_MISSING;
+}
+
+/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
+   at STR_IDX.  */
+
+static reg_errcode_t
+internal_function __attribute_warn_unused_result__
+match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
+{
+#ifdef DEBUG
+  assert (mctx->sub_tops != NULL);
+  assert (mctx->asub_tops > 0);
+#endif
+  if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
+    {
+      Idx new_asub_tops = mctx->asub_tops * 2;
+      re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
+                                                  re_sub_match_top_t *,
+                                                  new_asub_tops);
+      if (BE (new_array == NULL, 0))
+       return REG_ESPACE;
+      mctx->sub_tops = new_array;
+      mctx->asub_tops = new_asub_tops;
+    }
+  mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
+  if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0))
+    return REG_ESPACE;
+  mctx->sub_tops[mctx->nsub_tops]->node = node;
+  mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
+  return REG_NOERROR;
+}
+
+/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
+   at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP.  */
+
+static re_sub_match_last_t *
+internal_function
+match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
+{
+  re_sub_match_last_t *new_entry;
+  if (BE (subtop->nlasts == subtop->alasts, 0))
+    {
+      Idx new_alasts = 2 * subtop->alasts + 1;
+      re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
+                                                   re_sub_match_last_t *,
+                                                   new_alasts);
+      if (BE (new_array == NULL, 0))
+       return NULL;
+      subtop->lasts = new_array;
+      subtop->alasts = new_alasts;
+    }
+  new_entry = calloc (1, sizeof (re_sub_match_last_t));
+  if (BE (new_entry != NULL, 1))
+    {
+      subtop->lasts[subtop->nlasts] = new_entry;
+      new_entry->node = node;
+      new_entry->str_idx = str_idx;
+      ++subtop->nlasts;
+    }
+  return new_entry;
+}
+
+static void
+internal_function
+sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
+              re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
+{
+  sctx->sifted_states = sifted_sts;
+  sctx->limited_states = limited_sts;
+  sctx->last_node = last_node;
+  sctx->last_str_idx = last_str_idx;
+  re_node_set_init_empty (&sctx->limits);
+}
diff --git a/gnulib/lib/safe-alloc.c b/gnulib/lib/safe-alloc.c
new file mode 100644 (file)
index 0000000..eaf7b5e
--- /dev/null
@@ -0,0 +1,121 @@
+/* safe-alloc.c: safer memory allocation
+
+   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 Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Daniel Berrange <berrange@redhat.com>, 2008 */
+
+#include <config.h>
+
+/* Specification.  */
+#include "safe-alloc.h"
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <errno.h>
+
+
+/* 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
+   nonnegative.  This is a macro, not an inline function, so that it
+   works correctly even when SIZE_MAX < N.
+
+   By gnulib convention, SIZE_MAX represents overflow in size
+   calculations, so the conservative dividend to use here is
+   SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+   However, malloc (SIZE_MAX) fails on all known hosts where
+   sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
+   exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+   branch when S is known to be 1.
+
+   This is the same as xalloc_oversized from xalloc.h
+*/
+#define safe_alloc_oversized(n, s)                                      \
+  ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+
+
+/**
+ * safe_alloc_alloc_n:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of memory 'count' elements long,
+ * each with 'size' bytes. Return the address of the
+ * allocated memory in 'ptrptr'.  The newly allocated
+ * memory is filled with zeros.
+ *
+ * Return -1 on failure to allocate, zero on success
+ */
+int
+safe_alloc_alloc_n (void *ptrptr, size_t size, size_t count, int zeroed)
+{
+  if (size == 0 || count == 0)
+    {
+      *(void **) ptrptr = NULL;
+      return 0;
+    }
+
+  if (safe_alloc_oversized (count, size))
+    {
+      errno = ENOMEM;
+      return -1;
+    }
+
+  if (zeroed)
+    *(void **) ptrptr = calloc (count, size);
+  else
+    *(void **) ptrptr = malloc (count * size);
+
+  if (*(void **) ptrptr == NULL)
+    return -1;
+  return 0;
+}
+
+/**
+ * safe_alloc_realloc_n:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements in array
+ *
+ * Resize the block of memory in 'ptrptr' to be an array of
+ * 'count' elements, each 'size' bytes in length. Update 'ptrptr'
+ * with the address of the newly allocated memory. On failure,
+ * 'ptrptr' is not changed and still points to the original memory
+ * block. The newly allocated memory is filled with zeros.
+ *
+ * Return -1 on failure to allocate, zero on success
+ */
+int
+safe_alloc_realloc_n (void *ptrptr, size_t size, size_t count)
+{
+  void *tmp;
+  if (size == 0 || count == 0)
+    {
+      free (*(void **) ptrptr);
+      *(void **) ptrptr = NULL;
+      return 0;
+    }
+  if (safe_alloc_oversized (count, size))
+    {
+      errno = ENOMEM;
+      return -1;
+    }
+  tmp = realloc (*(void **) ptrptr, size * count);
+  if (!tmp)
+    return -1;
+  *(void **) ptrptr = tmp;
+  return 0;
+}
diff --git a/gnulib/lib/safe-alloc.h b/gnulib/lib/safe-alloc.h
new file mode 100644 (file)
index 0000000..7044380
--- /dev/null
@@ -0,0 +1,121 @@
+/* safe-alloc.h: safer memory allocation
+
+   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 Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Daniel Berrange <berrange@redhat.com>, 2008 */
+
+#ifndef SAFE_ALLOC_H_
+# define SAFE_ALLOC_H_
+
+# include <stdlib.h>
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+#  define __GNUC_PREREQ(maj, min)                                       \
+  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+#  define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+# ifndef _GL_ATTRIBUTE_RETURN_CHECK
+#  if __GNUC_PREREQ (3, 4)
+#   define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+#  else
+#   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)
+  _GL_ATTRIBUTE_RETURN_CHECK;
+
+int
+safe_alloc_realloc_n (void *ptrptr, size_t size, size_t count)
+  _GL_ATTRIBUTE_RETURN_CHECK;
+
+/**
+ * ALLOC:
+ * @ptr: pointer to hold address of allocated memory
+ *
+ * Allocate sizeof(*ptr) bytes of memory and store
+ * the address of allocated memory in 'ptr'. Fill the
+ * newly allocated memory with zeros.
+ *
+ * Return -1 on failure to allocate, zero on success
+ */
+# define ALLOC(ptr)                                     \
+  safe_alloc_alloc_n (&(ptr), sizeof (*(ptr)), 1, 1)
+
+/**
+ * ALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Fill the newly allocated memory with zeros.
+ *
+ * Return -1 on failure, 0 on success
+ */
+# define ALLOC_N(ptr, count)                                    \
+  safe_alloc_alloc_n (&(ptr), sizeof (*(ptr)), (count), 1)
+
+/**
+ * ALLOC_N_UNINITIALIZED:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Do not initialize the new memory at all.
+ *
+ * Return -1 on failure to allocate, zero on success
+ */
+# define ALLOC_N_UNINITIALIZED(ptr, count)                      \
+  safe_alloc_alloc_n (&(ptr), sizeof (*(ptr)), (count), 0)
+
+/**
+ * REALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Fill the newly allocated memory with zeros
+ *
+ * Return -1 on failure to reallocate, zero on success
+ */
+# define REALLOC_N(ptr, count)                                  \
+  safe_alloc_realloc_n (&(ptr), sizeof (*(ptr)), (count))
+
+/**
+ * FREE:
+ * @ptr: pointer holding address to be freed
+ *
+ * Free the memory stored in 'ptr' and update to point
+ * to NULL.
+ */
+# define FREE(ptr)                              \
+  do                                            \
+    {                                           \
+      free (ptr);                               \
+      (ptr) = NULL;                             \
+    }                                           \
+  while (0)
+
+#endif /* SAFE_ALLOC_H_ */
diff --git a/gnulib/lib/se-context.in.h b/gnulib/lib/se-context.in.h
new file mode 100644 (file)
index 0000000..cb7419a
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef SELINUX_CONTEXT_H
+# define SELINUX_CONTEXT_H
+
+# include <errno.h>
+
+/* The definition of _GL_UNUSED_PARAMETER is copied here.  */
+
+typedef int context_t;
+static inline context_t context_new (char const *s _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return 0; }
+static inline char *context_str (context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return (void *) 0; }
+static inline void context_free (context_t c _GL_UNUSED_PARAMETER) {}
+
+static inline int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
+                                    char const *s _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
+                                    char const *s _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
+                                     char const *s _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
+                                    char const *s _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+
+#endif
diff --git a/gnulib/lib/se-selinux.in.h b/gnulib/lib/se-selinux.in.h
new file mode 100644 (file)
index 0000000..4b2a9a2
--- /dev/null
@@ -0,0 +1,97 @@
+/* Replacement <selinux/selinux.h> for platforms that lack it.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GL_SELINUX_SELINUX_H
+# define _GL_SELINUX_SELINUX_H
+
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+@PRAGMA_COLUMNS@
+
+# if HAVE_SELINUX_SELINUX_H
+
+#@INCLUDE_NEXT@ @NEXT_SELINUX_SELINUX_H@
+
+# else
+
+#  include <sys/types.h>
+#  include <errno.h>
+
+/* 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
+
+static inline int getcon (security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline void freecon (security_context_t con _GL_UNUSED_PARAMETER) {}
+
+
+static inline int getfscreatecon (security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int setfscreatecon (security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int matchpathcon (char const *file _GL_UNUSED_PARAMETER,
+                                mode_t m _GL_UNUSED_PARAMETER,
+                                security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int getfilecon (char const *file _GL_UNUSED_PARAMETER,
+                              security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
+                               security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int fgetfilecon (int fd,
+                               security_context_t *con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int setfilecon (char const *file _GL_UNUSED_PARAMETER,
+                              security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
+                               security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int fsetfilecon (int fd _GL_UNUSED_PARAMETER,
+                               security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+
+static inline int security_check_context
+    (security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int security_check_context_raw
+    (security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int setexeccon (security_context_t con _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int security_compute_create
+    (security_context_t scon _GL_UNUSED_PARAMETER,
+     security_context_t tcon _GL_UNUSED_PARAMETER,
+     security_class_t tclass _GL_UNUSED_PARAMETER,
+     security_context_t *newcon _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+static inline int matchpathcon_init_prefix
+    (char const *path _GL_UNUSED_PARAMETER,
+     char const *prefix _GL_UNUSED_PARAMETER)
+  { errno = ENOTSUP; return -1; }
+
+#   define GNULIB_defined_security_types 1
+#  endif
+
+# endif
+#endif /* _GL_SELINUX_SELINUX_H */
diff --git a/gnulib/lib/size_max.h b/gnulib/lib/size_max.h
new file mode 100644 (file)
index 0000000..7ea0c2e
--- /dev/null
@@ -0,0 +1,31 @@
+/* size_max.h -- declare SIZE_MAX through system headers
+   Copyright (C) 2005-2006, 2009-2011 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef GNULIB_SIZE_MAX_H
+#define GNULIB_SIZE_MAX_H
+
+/* Get SIZE_MAX declaration on systems like Solaris 7/8/9.  */
+# include <limits.h>
+/* Get SIZE_MAX declaration on systems like glibc 2.  */
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+/* On systems where these include files don't define it, SIZE_MAX is defined
+   in config.h.  */
+
+#endif /* GNULIB_SIZE_MAX_H */
diff --git a/gnulib/lib/stat.c b/gnulib/lib/stat.c
new file mode 100644 (file)
index 0000000..2ddb5d1
--- /dev/null
@@ -0,0 +1,105 @@
+/* Work around platform bugs in stat.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* written by Eric Blake */
+
+#include <config.h>
+
+/* Get the original definition of stat.  It might be defined as a macro.  */
+#define __need_system_sys_stat_h
+#include <sys/types.h>
+#include <sys/stat.h>
+#undef __need_system_sys_stat_h
+
+static inline int
+orig_stat (const char *filename, struct stat *buf)
+{
+  return stat (filename, buf);
+}
+
+/* Specification.  */
+#include <sys/stat.h>
+
+#include <errno.h>
+#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
+   being 0 on success) which this wrapper does not work around.  But
+   at least this implementation provides the ability to emulate fchdir
+   correctly.  */
+
+int
+rpl_stat (char const *name, struct stat *st)
+{
+  int result = orig_stat (name, st);
+#if REPLACE_FUNC_STAT_FILE
+  /* Solaris 9 mistakenly succeeds when given a non-directory with a
+     trailing slash.  */
+  if (result == 0 && !S_ISDIR (st->st_mode))
+    {
+      size_t len = strlen (name);
+      if (ISSLASH (name[len - 1]))
+        {
+          errno = ENOTDIR;
+          return -1;
+        }
+    }
+#endif /* REPLACE_FUNC_STAT_FILE */
+#if REPLACE_FUNC_STAT_DIR
+  if (result == -1 && errno == ENOENT)
+    {
+      /* Due to mingw's oddities, there are some directories (like
+         c:\) where stat() only succeeds with a trailing slash, and
+         other directories (like c:\windows) where stat() only
+         succeeds without a trailing slash.  But we want the two to be
+         synonymous, since chdir() manages either style.  Likewise, Mingw also
+         reports ENOENT for names longer than PATH_MAX, when we want
+         ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
+         Fortunately, mingw PATH_MAX is small enough for stack
+         allocation.  */
+      char fixed_name[PATH_MAX + 1] = {0};
+      size_t len = strlen (name);
+      bool check_dir = false;
+      if (PATH_MAX <= len)
+        errno = ENAMETOOLONG;
+      else if (len)
+        {
+          strcpy (fixed_name, name);
+          if (ISSLASH (fixed_name[len - 1]))
+            {
+              check_dir = true;
+              while (len && ISSLASH (fixed_name[len - 1]))
+                fixed_name[--len] = '\0';
+              if (!len)
+                fixed_name[0] = '/';
+            }
+          else
+            fixed_name[len++] = '/';
+          result = orig_stat (fixed_name, st);
+          if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
+            {
+              result = -1;
+              errno = ENOTDIR;
+            }
+        }
+    }
+#endif /* REPLACE_FUNC_STAT_DIR */
+  return result;
+}
diff --git a/gnulib/lib/stdbool.in.h b/gnulib/lib/stdbool.in.h
new file mode 100644 (file)
index 0000000..12efde3
--- /dev/null
@@ -0,0 +1,122 @@
+/* Copyright (C) 2001-2003, 2006-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GL_STDBOOL_H
+#define _GL_STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */
+
+/* Usage suggestions:
+
+   Programs that use <stdbool.h> should be aware of some limitations
+   and standards compliance issues.
+
+   Standards compliance:
+
+       - <stdbool.h> must be #included before 'bool', 'false', 'true'
+         can be used.
+
+       - You cannot assume that sizeof (bool) == 1.
+
+       - Programs should not undefine the macros bool, true, and false,
+         as C99 lists that as an "obsolescent feature".
+
+   Limitations of this substitute, when used in a C89 environment:
+
+       - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+       - You cannot assume that _Bool is a typedef; it might be a macro.
+
+       - Bit-fields of type 'bool' are not supported.  Portable code
+         should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
+
+       - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+         performed in such a way that every nonzero value gets converted
+         to 'true', and zero gets converted to 'false'.  This doesn't work
+         with this substitute.  With this substitute, only the values 0 and 1
+         give the expected result when converted to _Bool' or 'bool'.
+
+       - C99 allows the use of (_Bool)0.0 in constant expressions, but
+         this substitute cannot always provide this property.
+
+   Also, it is suggested that programs use 'bool' rather than '_Bool';
+   this isn't required, but 'bool' is more common.  */
+
+
+/* 7.16. Boolean type and values */
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#if defined __BEOS__ && !defined __HAIKU__
+# include <OS.h> /* defines bool but not _Bool */
+# undef false
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, we define true and false as
+   enum constants, not only as macros.
+   It is tempting to write
+      typedef enum { false = 0, true = 1 } _Bool;
+   so that gdb prints values of type 'bool' symbolically. But if we do
+   this, values of type '_Bool' may promote to 'int' or 'unsigned int'
+   (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+   (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the
+   enum; this ensures that '_Bool' promotes to 'int'.  */
+#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
+  /* A compiler known to have 'bool'.  */
+  /* If the compiler already has both 'bool' and '_Bool', we can assume they
+     are the same types.  */
+# if !@HAVE__BOOL@
+typedef bool _Bool;
+# endif
+#else
+# if !defined __GNUC__
+   /* If @HAVE__BOOL@:
+        Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
+        the built-in _Bool type is used.  See
+          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+        Similar bugs are likely with other compilers as well; this file
+        wouldn't be used if <stdbool.h> was working.
+        So we override the _Bool type.
+      If !@HAVE__BOOL@:
+        Need to define _Bool ourselves. As 'signed char' or as an enum type?
+        Use of a typedef, with SunPRO C, leads to a stupid
+          "warning: _Bool is a keyword in ISO C99".
+        Use of an enum type, with IRIX cc, leads to a stupid
+          "warning(1185): enumerated type mixed with another type".
+        Even the existence of an enum type, without a typedef,
+          "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
+        The only benefit of the enum, debuggability, is not important
+        with these compilers.  So use 'signed char' and no enum.  */
+#  define _Bool signed char
+# else
+   /* With this compiler, trust the _Bool type if the compiler has it.  */
+#  if !@HAVE__BOOL@
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+#  endif
+# endif
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives.  */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _GL_STDBOOL_H */
diff --git a/gnulib/lib/stddef.in.h b/gnulib/lib/stddef.in.h
new file mode 100644 (file)
index 0000000..b3fc2b5
--- /dev/null
@@ -0,0 +1,87 @@
+/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake.  */
+
+/*
+ * POSIX 2008 <stddef.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/stddef.h.html>
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_wchar_t || defined __need_size_t  \
+  || defined __need_ptrdiff_t || defined __need_NULL \
+  || defined __need_wint_t
+/* Special invocation convention inside gcc header files.  In
+   particular, gcc provides a version of <stddef.h> that blindly
+   redefines NULL even when __need_wint_t was defined, even though
+   wint_t is not normally provided by <stddef.h>.  Hence, we must
+   remember if special invocation has ever been used to obtain wint_t,
+   in which case we need to clean up NULL yet again.  */
+
+# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T)
+#  ifdef __need_wint_t
+#   undef _GL_STDDEF_H
+#   define _GL_STDDEF_WINT_T
+#  endif
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+# endif
+
+#else
+/* Normal invocation convention.  */
+
+# ifndef _GL_STDDEF_H
+
+/* The include_next requires a split double-inclusion guard.  */
+
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+
+#  ifndef _GL_STDDEF_H
+#   define _GL_STDDEF_H
+
+/* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */
+#if @REPLACE_NULL@
+# undef NULL
+# ifdef __cplusplus
+   /* ISO C++ says that the macro NULL must expand to an integer constant
+      expression, hence '((void *) 0)' is not allowed in C++.  */
+#  if __GNUG__ >= 3
+    /* GNU C++ has a __null macro that behaves like an integer ('int' or
+       'long') but has the same size as a pointer.  Use that, to avoid
+       warnings.  */
+#   define NULL __null
+#  else
+#   define NULL 0L
+#  endif
+# else
+#  define NULL ((void *) 0)
+# endif
+#endif
+
+/* Some platforms lack wchar_t.  */
+#if !@HAVE_WCHAR_T@
+# define wchar_t int
+#endif
+
+#  endif /* _GL_STDDEF_H */
+# endif /* _GL_STDDEF_H */
+#endif /* __need_XXX */
diff --git a/gnulib/lib/stdint.in.h b/gnulib/lib/stdint.in.h
new file mode 100644 (file)
index 0000000..1140c12
--- /dev/null
@@ -0,0 +1,592 @@
+/* Copyright (C) 2001-2002, 2004-2011 Free Software Foundation, Inc.
+   Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
+   This file is part of gnulib.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/*
+ * ISO C 99 <stdint.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/stdint.h.html>
+ */
+
+#ifndef _GL_STDINT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* When including a system file that in turn includes <inttypes.h>,
+   use the system <inttypes.h>, not our substitute.  This avoids
+   problems with (for example) VMS, whose <sys/bitypes.h> includes
+   <inttypes.h>.  */
+#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+/* Get those types that are already defined in other system include
+   files, so that we can "#define int8_t signed char" below without
+   worrying about a later system include file containing a "typedef
+   signed char int8_t;" that will get messed up by our macro.  Our
+   macros should all be consistent with the system versions, except
+   for the "fast" types and macros, which we recommend against using
+   in public interfaces due to compiler differences.  */
+
+#if @HAVE_STDINT_H@
+# if defined __sgi && ! defined __c99
+   /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
+      with "This header file is to be used only for c99 mode compilations"
+      diagnostics.  */
+#  define __STDINT_H__
+# endif
+  /* Other systems may have an incomplete or buggy <stdint.h>.
+     Include it before <inttypes.h>, since any "#include <stdint.h>"
+     in <inttypes.h> would reinclude us, skipping our contents because
+     _GL_STDINT_H is defined.
+     The include_next requires a split double-inclusion guard.  */
+# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+#endif
+
+#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
+#define _GL_STDINT_H
+
+/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
+   IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
+   AIX 5.2 <sys/types.h> isn't needed and causes troubles.
+   MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
+   relies on the system <stdint.h> definitions, so include
+   <sys/types.h> after @NEXT_STDINT_H@.  */
+#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+# include <sys/types.h>
+#endif
+
+/* Get LONG_MIN, LONG_MAX, ULONG_MAX.  */
+#include <limits.h>
+
+#if @HAVE_INTTYPES_H@
+  /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
+     int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
+     <inttypes.h> also defines intptr_t and uintptr_t.  */
+# include <inttypes.h>
+#elif @HAVE_SYS_INTTYPES_H@
+  /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
+     the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.  */
+# include <sys/inttypes.h>
+#endif
+
+#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
+  /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
+     int{8,16,32,64}_t and __BIT_TYPES_DEFINED__.  In libc5 >= 5.2.2 it is
+     included by <sys/types.h>.  */
+# include <sys/bitypes.h>
+#endif
+
+#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+/* Minimum and maximum values for a integer type under the usual assumption.
+   Return an unspecified value if BITS == 0, adding a check to pacify
+   picky compilers.  */
+
+#define _STDINT_MIN(signed, bits, zero) \
+  ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero))
+
+#define _STDINT_MAX(signed, bits, zero) \
+  ((signed) \
+   ? ~ _STDINT_MIN (signed, bits, zero) \
+   : /* The expression for the unsigned case.  The subtraction of (signed) \
+        is a nop in the unsigned case and avoids "signed integer overflow" \
+        warnings in the signed case.  */ \
+     ((((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
+   types have 8, 16, 32, optionally 64 bits.  */
+
+#undef int8_t
+#undef uint8_t
+typedef signed char gl_int8_t;
+typedef unsigned char gl_uint8_t;
+#define int8_t gl_int8_t
+#define uint8_t gl_uint8_t
+
+#undef int16_t
+#undef uint16_t
+typedef short int gl_int16_t;
+typedef unsigned short int gl_uint16_t;
+#define int16_t gl_int16_t
+#define uint16_t gl_uint16_t
+
+#undef int32_t
+#undef uint32_t
+typedef int gl_int32_t;
+typedef unsigned int gl_uint32_t;
+#define int32_t gl_int32_t
+#define uint32_t gl_uint32_t
+
+/* If the system defines INT64_MAX, assume int64_t works.  That way,
+   if the underlying platform defines int64_t to be a 64-bit long long
+   int, the code below won't mistakenly define it to be a 64-bit long
+   int, which would mess up C++ name mangling.  We must use #ifdef
+   rather than #if, to avoid an error with HP-UX 10.20 cc.  */
+
+#ifdef INT64_MAX
+# define GL_INT64_T
+#else
+/* Do not undefine int64_t if gnulib is not being used with 64-bit
+   types, since otherwise it breaks platforms like Tandem/NSK.  */
+# if LONG_MAX >> 31 >> 31 == 1
+#  undef int64_t
+typedef long int gl_int64_t;
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif defined _MSC_VER
+#  undef int64_t
+typedef __int64 gl_int64_t;
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif @HAVE_LONG_LONG_INT@
+#  undef int64_t
+typedef long long int gl_int64_t;
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# endif
+#endif
+
+#ifdef UINT64_MAX
+# define GL_UINT64_T
+#else
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+#  undef uint64_t
+typedef unsigned long int gl_uint64_t;
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif defined _MSC_VER
+#  undef uint64_t
+typedef unsigned __int64 gl_uint64_t;
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+#  undef uint64_t
+typedef unsigned long long int gl_uint64_t;
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# endif
+#endif
+
+/* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
+#define _UINT8_T
+#define _UINT32_T
+#define _UINT64_T
+
+
+/* 7.18.1.2. Minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
+   are the same as the corresponding N_t types.  */
+
+#undef int_least8_t
+#undef uint_least8_t
+#undef int_least16_t
+#undef uint_least16_t
+#undef int_least32_t
+#undef uint_least32_t
+#undef int_least64_t
+#undef uint_least64_t
+#define int_least8_t int8_t
+#define uint_least8_t uint8_t
+#define int_least16_t int16_t
+#define uint_least16_t uint16_t
+#define int_least32_t int32_t
+#define uint_least32_t uint32_t
+#ifdef GL_INT64_T
+# define int_least64_t int64_t
+#endif
+#ifdef GL_UINT64_T
+# define uint_least64_t uint64_t
+#endif
+
+/* 7.18.1.3. Fastest minimum-width integer types */
+
+/* Note: Other <stdint.h> substitutes may define these types differently.
+   It is not recommended to use these types in public header files. */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
+   are taken from the same list of types.  Assume that 'long int'
+   is fast enough for all narrower integers.  */
+
+#undef int_fast8_t
+#undef uint_fast8_t
+#undef int_fast16_t
+#undef uint_fast16_t
+#undef int_fast32_t
+#undef uint_fast32_t
+#undef int_fast64_t
+#undef uint_fast64_t
+typedef long int gl_int_fast8_t;
+typedef unsigned long int gl_uint_fast8_t;
+typedef long int gl_int_fast16_t;
+typedef unsigned long int gl_uint_fast16_t;
+typedef long int gl_int_fast32_t;
+typedef unsigned long int gl_uint_fast32_t;
+#define int_fast8_t gl_int_fast8_t
+#define uint_fast8_t gl_uint_fast8_t
+#define int_fast16_t gl_int_fast16_t
+#define uint_fast16_t gl_uint_fast16_t
+#define int_fast32_t gl_int_fast32_t
+#define uint_fast32_t gl_uint_fast32_t
+#ifdef GL_INT64_T
+# define int_fast64_t int64_t
+#endif
+#ifdef GL_UINT64_T
+# define uint_fast64_t uint64_t
+#endif
+
+/* 7.18.1.4. Integer types capable of holding object pointers */
+
+#undef intptr_t
+#undef uintptr_t
+typedef long int gl_intptr_t;
+typedef unsigned long int gl_uintptr_t;
+#define intptr_t gl_intptr_t
+#define uintptr_t gl_uintptr_t
+
+/* 7.18.1.5. Greatest-width integer types */
+
+/* Note: These types are compiler dependent. It may be unwise to use them in
+   public header files. */
+
+#undef intmax_t
+#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+typedef long long int gl_intmax_t;
+# define intmax_t gl_intmax_t
+#elif defined GL_INT64_T
+# define intmax_t int64_t
+#else
+typedef long int gl_intmax_t;
+# define intmax_t gl_intmax_t
+#endif
+
+#undef uintmax_t
+#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+typedef unsigned long long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
+#elif defined GL_UINT64_T
+# define uintmax_t uint64_t
+#else
+typedef unsigned long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
+#endif
+
+/* Verify that intmax_t and uintmax_t have the same size.  Too much code
+   breaks if this is not the case.  If this check fails, the reason is likely
+   to be found in the autoconf macros.  */
+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
+
+/* 7.18.2.1. Limits of exact-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits.  */
+
+#undef INT8_MIN
+#undef INT8_MAX
+#undef UINT8_MAX
+#define INT8_MIN  (~ INT8_MAX)
+#define INT8_MAX  127
+#define UINT8_MAX  255
+
+#undef INT16_MIN
+#undef INT16_MAX
+#undef UINT16_MAX
+#define INT16_MIN  (~ INT16_MAX)
+#define INT16_MAX  32767
+#define UINT16_MAX  65535
+
+#undef INT32_MIN
+#undef INT32_MAX
+#undef UINT32_MAX
+#define INT32_MIN  (~ INT32_MAX)
+#define INT32_MAX  2147483647
+#define UINT32_MAX  4294967295U
+
+#if defined GL_INT64_T && ! defined INT64_MAX
+/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
+   evaluates the latter incorrectly in preprocessor expressions.  */
+# define INT64_MIN  (- INTMAX_C (1) << 63)
+# define INT64_MAX  INTMAX_C (9223372036854775807)
+#endif
+
+#if defined GL_UINT64_T && ! defined UINT64_MAX
+# define UINT64_MAX  UINTMAX_C (18446744073709551615)
+#endif
+
+/* 7.18.2.2. Limits of minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
+   are the same as the corresponding N_t types.  */
+
+#undef INT_LEAST8_MIN
+#undef INT_LEAST8_MAX
+#undef UINT_LEAST8_MAX
+#define INT_LEAST8_MIN  INT8_MIN
+#define INT_LEAST8_MAX  INT8_MAX
+#define UINT_LEAST8_MAX  UINT8_MAX
+
+#undef INT_LEAST16_MIN
+#undef INT_LEAST16_MAX
+#undef UINT_LEAST16_MAX
+#define INT_LEAST16_MIN  INT16_MIN
+#define INT_LEAST16_MAX  INT16_MAX
+#define UINT_LEAST16_MAX  UINT16_MAX
+
+#undef INT_LEAST32_MIN
+#undef INT_LEAST32_MAX
+#undef UINT_LEAST32_MAX
+#define INT_LEAST32_MIN  INT32_MIN
+#define INT_LEAST32_MAX  INT32_MAX
+#define UINT_LEAST32_MAX  UINT32_MAX
+
+#undef INT_LEAST64_MIN
+#undef INT_LEAST64_MAX
+#ifdef GL_INT64_T
+# define INT_LEAST64_MIN  INT64_MIN
+# define INT_LEAST64_MAX  INT64_MAX
+#endif
+
+#undef UINT_LEAST64_MAX
+#ifdef GL_UINT64_T
+# define UINT_LEAST64_MAX  UINT64_MAX
+#endif
+
+/* 7.18.2.3. Limits of fastest minimum-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
+   are taken from the same list of types.  */
+
+#undef INT_FAST8_MIN
+#undef INT_FAST8_MAX
+#undef UINT_FAST8_MAX
+#define INT_FAST8_MIN  LONG_MIN
+#define INT_FAST8_MAX  LONG_MAX
+#define UINT_FAST8_MAX  ULONG_MAX
+
+#undef INT_FAST16_MIN
+#undef INT_FAST16_MAX
+#undef UINT_FAST16_MAX
+#define INT_FAST16_MIN  LONG_MIN
+#define INT_FAST16_MAX  LONG_MAX
+#define UINT_FAST16_MAX  ULONG_MAX
+
+#undef INT_FAST32_MIN
+#undef INT_FAST32_MAX
+#undef UINT_FAST32_MAX
+#define INT_FAST32_MIN  LONG_MIN
+#define INT_FAST32_MAX  LONG_MAX
+#define UINT_FAST32_MAX  ULONG_MAX
+
+#undef INT_FAST64_MIN
+#undef INT_FAST64_MAX
+#ifdef GL_INT64_T
+# define INT_FAST64_MIN  INT64_MIN
+# define INT_FAST64_MAX  INT64_MAX
+#endif
+
+#undef UINT_FAST64_MAX
+#ifdef GL_UINT64_T
+# define UINT_FAST64_MAX  UINT64_MAX
+#endif
+
+/* 7.18.2.4. Limits of integer types capable of holding object pointers */
+
+#undef INTPTR_MIN
+#undef INTPTR_MAX
+#undef UINTPTR_MAX
+#define INTPTR_MIN  LONG_MIN
+#define INTPTR_MAX  LONG_MAX
+#define UINTPTR_MAX  ULONG_MAX
+
+/* 7.18.2.5. Limits of greatest-width integer types */
+
+#undef INTMAX_MIN
+#undef INTMAX_MAX
+#ifdef INT64_MAX
+# define INTMAX_MIN  INT64_MIN
+# define INTMAX_MAX  INT64_MAX
+#else
+# define INTMAX_MIN  INT32_MIN
+# define INTMAX_MAX  INT32_MAX
+#endif
+
+#undef UINTMAX_MAX
+#ifdef UINT64_MAX
+# define UINTMAX_MAX  UINT64_MAX
+#else
+# define UINTMAX_MAX  UINT32_MAX
+#endif
+
+/* 7.18.3. Limits of other integer types */
+
+/* ptrdiff_t limits */
+#undef PTRDIFF_MIN
+#undef PTRDIFF_MAX
+#if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+#  define PTRDIFF_MIN  _STDINT_MIN (1, 64, 0l)
+#  define PTRDIFF_MAX  _STDINT_MAX (1, 64, 0l)
+# else
+#  define PTRDIFF_MIN  _STDINT_MIN (1, 32, 0)
+#  define PTRDIFF_MAX  _STDINT_MAX (1, 32, 0)
+# endif
+#else
+# define PTRDIFF_MIN  \
+    _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+# define PTRDIFF_MAX  \
+    _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+#endif
+
+/* sig_atomic_t limits */
+#undef SIG_ATOMIC_MIN
+#undef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MIN  \
+   _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
+                0@SIG_ATOMIC_T_SUFFIX@)
+#define SIG_ATOMIC_MAX  \
+   _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
+                0@SIG_ATOMIC_T_SUFFIX@)
+
+
+/* size_t limit */
+#undef SIZE_MAX
+#if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+#  define SIZE_MAX  _STDINT_MAX (0, 64, 0ul)
+# else
+#  define SIZE_MAX  _STDINT_MAX (0, 32, 0ul)
+# endif
+#else
+# define SIZE_MAX  _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
+#endif
+
+/* wchar_t limits */
+/* Get WCHAR_MIN, WCHAR_MAX.
+   This include is not on the top, above, because on OSF/1 4.0 we have a
+   sequence of nested includes
+   <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
+   <stdint.h> and assumes its types are already defined.  */
+#if @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
+#endif
+#undef WCHAR_MIN
+#undef WCHAR_MAX
+#define WCHAR_MIN  \
+   _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
+#define WCHAR_MAX  \
+   _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
+
+/* wint_t limits */
+#undef WINT_MIN
+#undef WINT_MAX
+#define WINT_MIN  \
+   _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+#define WINT_MAX  \
+   _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
+
+#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
+
+/* 7.18.4. Macros for integer constants */
+
+#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
+
+/* 7.18.4.1. Macros for minimum-width integer constants */
+/* According to ISO C 99 Technical Corrigendum 1 */
+
+/* Here we assume a standard architecture where the hardware integer
+   types have 8, 16, 32, optionally 64 bits, and int is 32 bits.  */
+
+#undef INT8_C
+#undef UINT8_C
+#define INT8_C(x) x
+#define UINT8_C(x) x
+
+#undef INT16_C
+#undef UINT16_C
+#define INT16_C(x) x
+#define UINT16_C(x) x
+
+#undef INT32_C
+#undef UINT32_C
+#define INT32_C(x) x
+#define UINT32_C(x) x ## U
+
+#undef INT64_C
+#undef UINT64_C
+#if LONG_MAX >> 31 >> 31 == 1
+# define INT64_C(x) x##L
+#elif defined _MSC_VER
+# define INT64_C(x) x##i64
+#elif @HAVE_LONG_LONG_INT@
+# define INT64_C(x) x##LL
+#endif
+#if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# define UINT64_C(x) x##UL
+#elif defined _MSC_VER
+# define UINT64_C(x) x##ui64
+#elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# define UINT64_C(x) x##ULL
+#endif
+
+/* 7.18.4.2. Macros for greatest-width integer constants */
+
+#undef INTMAX_C
+#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+# define INTMAX_C(x)   x##LL
+#elif defined GL_INT64_T
+# define INTMAX_C(x)   INT64_C(x)
+#else
+# define INTMAX_C(x)   x##L
+#endif
+
+#undef UINTMAX_C
+#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+# define UINTMAX_C(x)  x##ULL
+#elif defined GL_UINT64_T
+# define UINTMAX_C(x)  UINT64_C(x)
+#else
+# define UINTMAX_C(x)  x##UL
+#endif
+
+#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
+
+#endif /* _GL_STDINT_H */
+#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */
diff --git a/gnulib/lib/stdio.in.h b/gnulib/lib/stdio.in.h
new file mode 100644 (file)
index 0000000..9091497
--- /dev/null
@@ -0,0 +1,1102 @@
+/* A GNU-like <stdio.h>.
+
+   Copyright (C) 2004, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
+/* Special invocation convention:
+   - Inside glibc header files.
+   - On OSF/1 5.1 we have a sequence of nested includes
+     <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
+     <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
+     In this situation, the functions are not yet declared, therefore we cannot
+     provide the C++ aliases.  */
+
+#@INCLUDE_NEXT@ @NEXT_STDIO_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _GL_STDIO_H
+
+#define _GL_ALREADY_INCLUDING_STDIO_H
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_STDIO_H@
+
+#undef _GL_ALREADY_INCLUDING_STDIO_H
+
+#ifndef _GL_STDIO_H
+#define _GL_STDIO_H
+
+/* Get va_list.  Needed on many systems, including glibc 2.8.  */
+#include <stdarg.h>
+
+#include <stddef.h>
+
+/* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8
+   and eglibc 2.11.2.  */
+#include <sys/types.h>
+
+/* 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 _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 _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+#define _GL_ATTRIBUTE_FORMAT_PRINTF(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 \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Macros for stringification.  */
+#define _GL_STDIO_STRINGIZE(token) #token
+#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
+
+
+#if @GNULIB_DPRINTF@
+# if @REPLACE_DPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dprintf rpl_dprintf
+#  endif
+_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
+                                _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, ...)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                                _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (dprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef dprintf
+# if HAVE_RAW_DECL_DPRINTF
+_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
+                 "use gnulib module dprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_FCLOSE@
+/* Close STREAM and its underlying file descriptor.  */
+# if @REPLACE_FCLOSE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define fclose rpl_fclose
+#  endif
+_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (fclose);
+#elif defined GNULIB_POSIXCHECK
+# undef fclose
+/* Assume fclose is always declared.  */
+_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
+                 "use gnulib module fclose for portable POSIX compliance");
+#endif
+
+#if @GNULIB_FFLUSH@
+/* Flush all pending data on STREAM according to POSIX rules.  Both
+   output and seekable input streams are supported.
+   Note! LOSS OF DATA can occur if fflush is applied on an input stream
+   that is _not_seekable_ or on an update stream that is _not_seekable_
+   and in which the most recent operation was input.  Seekability can
+   be tested with lseek(fileno(fp),0,SEEK_CUR).  */
+# if @REPLACE_FFLUSH@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define fflush rpl_fflush
+#  endif
+_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
+_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
+# else
+_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
+# endif
+_GL_CXXALIASWARN (fflush);
+#elif defined GNULIB_POSIXCHECK
+# undef fflush
+/* Assume fflush is always declared.  */
+_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
+                 "use gnulib module fflush for portable POSIX compliance");
+#endif
+
+/* It is very rare that the developer ever has full control of stdin,
+   so any use of gets warrants an unconditional warning.  Assume it is
+   always declared, since it is required by C89.  */
+#undef gets
+_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+
+#if @GNULIB_FOPEN@
+# if @REPLACE_FOPEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fopen
+#   define fopen rpl_fopen
+#  endif
+_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
+                                 _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
+# else
+_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
+# endif
+_GL_CXXALIASWARN (fopen);
+#elif defined GNULIB_POSIXCHECK
+# undef fopen
+/* Assume fopen is always declared.  */
+_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
+                 "use gnulib module fopen for portability");
+#endif
+
+#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
+# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
+     || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define fprintf rpl_fprintf
+#  endif
+#  define GNULIB_overrides_fprintf 1
+_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                                _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (fprintf);
+#endif
+#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_fprintf
+#  undef fprintf
+# endif
+/* Assume fprintf is always declared.  */
+_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
+                 "use gnulib module fprintf-posix for portable "
+                 "POSIX compliance");
+#endif
+
+#if @GNULIB_FPURGE@
+/* Discard all pending buffered I/O data on STREAM.
+   STREAM must not be wide-character oriented.
+   When discarding pending output, the file position is set back to where it
+   was before the write calls.  When discarding pending input, the file
+   position is advanced to match the end of the previously read input.
+   Return 0 if successful.  Upon error, return -1 and set errno.  */
+# if @REPLACE_FPURGE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define fpurge rpl_fpurge
+#  endif
+_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
+# else
+#  if !@HAVE_DECL_FPURGE@
+_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
+# endif
+_GL_CXXALIASWARN (fpurge);
+#elif defined GNULIB_POSIXCHECK
+# undef fpurge
+# if HAVE_RAW_DECL_FPURGE
+_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
+                 "use gnulib module fpurge for portability");
+# endif
+#endif
+
+#if @GNULIB_FPUTC@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fputc
+#   define fputc rpl_fputc
+#  endif
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fputc);
+#endif
+
+#if @GNULIB_FPUTS@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fputs
+#   define fputs rpl_fputs
+#  endif
+_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
+                              _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fputs);
+#endif
+
+#if @GNULIB_FREOPEN@
+# if @REPLACE_FREOPEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef freopen
+#   define freopen rpl_freopen
+#  endif
+_GL_FUNCDECL_RPL (freopen, FILE *,
+                  (const char *filename, const char *mode, FILE *stream)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (freopen, FILE *,
+                  (const char *filename, const char *mode, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (freopen, FILE *,
+                  (const char *filename, const char *mode, FILE *stream));
+# endif
+_GL_CXXALIASWARN (freopen);
+#elif defined GNULIB_POSIXCHECK
+# undef freopen
+/* Assume freopen is always declared.  */
+_GL_WARN_ON_USE (freopen,
+                 "freopen on Win32 platforms is not POSIX compatible - "
+                 "use gnulib module freopen for portability");
+#endif
+
+
+/* Set up the following warnings, based on which modules are in use.
+   GNU Coding Standards discourage the use of fseek, since it imposes
+   an arbitrary limitation on some 32-bit hosts.  Remember that the
+   fseek module depends on the fseeko module, so we only have three
+   cases to consider:
+
+   1. The developer is not using either module.  Issue a warning under
+   GNULIB_POSIXCHECK for both functions, to remind them that both
+   functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
+   impact on this warning.
+
+   2. The developer is using both modules.  They may be unaware of the
+   arbitrary limitations of fseek, so issue a warning under
+   GNULIB_POSIXCHECK.  On the other hand, they may be using both
+   modules intentionally, so the developer can define
+   _GL_NO_LARGE_FILES in the compilation units where the use of fseek
+   is safe, to silence the warning.
+
+   3. The developer is using the fseeko module, but not fseek.  Gnulib
+   guarantees that fseek will still work around platform bugs in that
+   case, but we presume that the developer is aware of the pitfalls of
+   fseek and was trying to avoid it, so issue a warning even when
+   GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
+   defined to silence the warning in particular compilation units.
+   In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
+   fseek gets defined as a macro, it is recommended that the developer
+   uses the fseek module, even if he is not calling the fseek function.
+
+   Most gnulib clients that perform stream operations should fall into
+   category 3.  */
+
+#if @GNULIB_FSEEK@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FSEEK_WARN /* Category 2, above.  */
+#  undef fseek
+# endif
+# if @REPLACE_FSEEK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fseek
+#   define fseek rpl_fseek
+#  endif
+_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
+# else
+_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseek);
+#endif
+
+#if @GNULIB_FSEEKO@
+# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
+#  define _GL_FSEEK_WARN /* Category 3, above.  */
+#  undef fseek
+# endif
+# if @REPLACE_FSEEKO@
+/* Provide an fseeko function that is aware of a preceding fflush(), and which
+   detects pipes.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fseeko
+#   define fseeko rpl_fseeko
+#  endif
+_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
+                               _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
+# else
+#  if ! @HAVE_DECL_FSEEKO@
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseeko);
+# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
+   /* 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.  */
+#  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@
+  return rpl_fseeko (fp, offset, whence);
+#   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.  */
+# undef fseek
+# undef fseeko
+# if HAVE_RAW_DECL_FSEEKO
+_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
+                 "use gnulib module fseeko for portability");
+# endif
+#endif
+
+#ifdef _GL_FSEEK_WARN
+# undef _GL_FSEEK_WARN
+/* Here, either fseek is undefined (but C89 guarantees that it is
+   declared), or it is defined as rpl_fseek (declared above).  */
+_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
+                 "on 32-bit platforms - "
+                 "use fseeko function for handling of large files");
+#endif
+
+
+/* ftell, ftello.  See the comments on fseek/fseeko.  */
+
+#if @GNULIB_FTELL@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FTELL_WARN /* Category 2, above.  */
+#  undef ftell
+# endif
+# if @REPLACE_FTELL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef ftell
+#   define ftell rpl_ftell
+#  endif
+_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
+# else
+_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftell);
+#endif
+
+#if @GNULIB_FTELLO@
+# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
+#  define _GL_FTELL_WARN /* Category 3, above.  */
+#  undef ftell
+# endif
+# if @REPLACE_FTELLO@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef ftello
+#   define ftello rpl_ftello
+#  endif
+_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
+# else
+#  if ! @HAVE_DECL_FTELLO@
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftello);
+# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
+   /* 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.  */
+#  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@
+  return rpl_ftello (f);
+#   else
+  return ftello (f);
+#   endif
+}
+#   define GNULIB_defined_ftell_function 1
+#  endif
+# endif
+#elif defined GNULIB_POSIXCHECK
+# define _GL_FTELL_WARN /* Category 1, above.  */
+# undef ftell
+# undef ftello
+# if HAVE_RAW_DECL_FTELLO
+_GL_WARN_ON_USE (ftello, "ftello is unportable - "
+                 "use gnulib module ftello for portability");
+# endif
+#endif
+
+#ifdef _GL_FTELL_WARN
+# undef _GL_FTELL_WARN
+/* Here, either ftell is undefined (but C89 guarantees that it is
+   declared), or it is defined as rpl_ftell (declared above).  */
+_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
+                 "on 32-bit platforms - "
+                 "use ftello function for handling of large files");
+#endif
+
+
+#if @GNULIB_FWRITE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fwrite
+#   define fwrite rpl_fwrite
+#  endif
+_GL_FUNCDECL_RPL (fwrite, size_t,
+                  (const void *ptr, size_t s, size_t n, FILE *stream)
+                  _GL_ARG_NONNULL ((1, 4)));
+_GL_CXXALIAS_RPL (fwrite, size_t,
+                  (const void *ptr, size_t s, size_t n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fwrite, size_t,
+                  (const void *ptr, size_t s, size_t n, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fwrite);
+#endif
+
+#if @GNULIB_GETDELIM@
+/* Read input, up to (and including) the next occurrence of DELIMITER, from
+   STREAM, store it in *LINEPTR (and NUL-terminate it).
+   *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
+   bytes of space.  It is realloc'd as necessary.
+   Return the number of bytes read and stored at *LINEPTR (not including the
+   NUL terminator), or -1 on error or EOF.  */
+# if @REPLACE_GETDELIM@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getdelim
+#   define getdelim rpl_getdelim
+#  endif
+_GL_FUNCDECL_RPL (getdelim, ssize_t,
+                  (char **lineptr, size_t *linesize, int delimiter,
+                   FILE *stream)
+                  _GL_ARG_NONNULL ((1, 2, 4)));
+_GL_CXXALIAS_RPL (getdelim, ssize_t,
+                  (char **lineptr, size_t *linesize, int delimiter,
+                   FILE *stream));
+# else
+#  if !@HAVE_DECL_GETDELIM@
+_GL_FUNCDECL_SYS (getdelim, ssize_t,
+                  (char **lineptr, size_t *linesize, int delimiter,
+                   FILE *stream)
+                  _GL_ARG_NONNULL ((1, 2, 4)));
+#  endif
+_GL_CXXALIAS_SYS (getdelim, ssize_t,
+                  (char **lineptr, size_t *linesize, int delimiter,
+                   FILE *stream));
+# endif
+_GL_CXXALIASWARN (getdelim);
+#elif defined GNULIB_POSIXCHECK
+# undef getdelim
+# if HAVE_RAW_DECL_GETDELIM
+_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
+                 "use gnulib module getdelim for portability");
+# endif
+#endif
+
+#if @GNULIB_GETLINE@
+/* Read a line, up to (and including) the next newline, from STREAM, store it
+   in *LINEPTR (and NUL-terminate it).
+   *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
+   bytes of space.  It is realloc'd as necessary.
+   Return the number of bytes read and stored at *LINEPTR (not including the
+   NUL terminator), or -1 on error or EOF.  */
+# if @REPLACE_GETLINE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getline
+#   define getline rpl_getline
+#  endif
+_GL_FUNCDECL_RPL (getline, ssize_t,
+                  (char **lineptr, size_t *linesize, FILE *stream)
+                  _GL_ARG_NONNULL ((1, 2, 3)));
+_GL_CXXALIAS_RPL (getline, ssize_t,
+                  (char **lineptr, size_t *linesize, FILE *stream));
+# else
+#  if !@HAVE_DECL_GETLINE@
+_GL_FUNCDECL_SYS (getline, ssize_t,
+                  (char **lineptr, size_t *linesize, FILE *stream)
+                  _GL_ARG_NONNULL ((1, 2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (getline, ssize_t,
+                  (char **lineptr, size_t *linesize, FILE *stream));
+# endif
+# if @HAVE_DECL_GETLINE@
+_GL_CXXALIASWARN (getline);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getline
+# if HAVE_RAW_DECL_GETLINE
+_GL_WARN_ON_USE (getline, "getline is unportable - "
+                 "use gnulib module getline for portability");
+# endif
+#endif
+
+#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
+struct obstack;
+/* Grow an obstack with formatted output.  Return the number of
+   bytes added to OBS.  No trailing nul byte is added, and the
+   object should be closed with obstack_finish before use.  Upon
+   memory allocation error, call obstack_alloc_failed_handler.  Upon
+   other error, return -1.  */
+# if @REPLACE_OBSTACK_PRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define obstack_printf rpl_obstack_printf
+#  endif
+_GL_FUNCDECL_RPL (obstack_printf, int,
+                  (struct obstack *obs, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (obstack_printf, int,
+                  (struct obstack *obs, const char *format, ...));
+# else
+#  if !@HAVE_DECL_OBSTACK_PRINTF@
+_GL_FUNCDECL_SYS (obstack_printf, int,
+                  (struct obstack *obs, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (obstack_printf, int,
+                  (struct obstack *obs, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (obstack_printf);
+# if @REPLACE_OBSTACK_PRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define obstack_vprintf rpl_obstack_vprintf
+#  endif
+_GL_FUNCDECL_RPL (obstack_vprintf, int,
+                  (struct obstack *obs, const char *format, va_list args)
+                  _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));
+# else
+#  if !@HAVE_DECL_OBSTACK_PRINTF@
+_GL_FUNCDECL_SYS (obstack_vprintf, int,
+                  (struct obstack *obs, const char *format, va_list args)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (obstack_vprintf, int,
+                  (struct obstack *obs, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (obstack_vprintf);
+#endif
+
+#if @GNULIB_PERROR@
+/* Print a message to standard error, describing the value of ERRNO,
+   (if STRING is not NULL and not empty) prefixed with STRING and ": ",
+   and terminated with a newline.  */
+# if @REPLACE_PERROR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define perror rpl_perror
+#  endif
+_GL_FUNCDECL_RPL (perror, void, (const char *string));
+_GL_CXXALIAS_RPL (perror, void, (const char *string));
+# else
+_GL_CXXALIAS_SYS (perror, void, (const char *string));
+# endif
+_GL_CXXALIASWARN (perror);
+#elif defined GNULIB_POSIXCHECK
+# undef perror
+/* Assume perror is always declared.  */
+_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
+                 "use gnulib module perror for portability");
+#endif
+
+#if @GNULIB_POPEN@
+# if @REPLACE_POPEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef popen
+#   define popen rpl_popen
+#  endif
+_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
+                                 _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
+# else
+_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
+# endif
+_GL_CXXALIASWARN (popen);
+#elif defined GNULIB_POSIXCHECK
+# undef popen
+# if HAVE_RAW_DECL_POPEN
+_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
+                 "use gnulib module popen or pipe for more portability");
+# endif
+#endif
+
+#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
+# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
+     || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+#  if defined __GNUC__
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+/* Don't break __attribute__((format(printf,M,N))).  */
+#    define printf __printf__
+#   endif
+_GL_FUNCDECL_RPL_1 (__printf__, int,
+                    (const char *format, ...)
+                    __asm__ (@ASM_SYMBOL_PREFIX@
+                             _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+                    _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
+                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
+#  else
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define printf rpl_printf
+#   endif
+_GL_FUNCDECL_RPL (printf, int,
+                  (const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
+#  endif
+#  define GNULIB_overrides_printf 1
+# else
+_GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
+# endif
+_GL_CXXALIASWARN (printf);
+#endif
+#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_printf
+#  undef printf
+# endif
+/* Assume printf is always declared.  */
+_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
+                 "use gnulib module printf-posix for portable "
+                 "POSIX compliance");
+#endif
+
+#if @GNULIB_PUTC@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef putc
+#   define putc rpl_fputc
+#  endif
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
+# endif
+_GL_CXXALIASWARN (putc);
+#endif
+
+#if @GNULIB_PUTCHAR@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef putchar
+#   define putchar rpl_putchar
+#  endif
+_GL_FUNCDECL_RPL (putchar, int, (int c));
+_GL_CXXALIAS_RPL (putchar, int, (int c));
+# else
+_GL_CXXALIAS_SYS (putchar, int, (int c));
+# endif
+_GL_CXXALIASWARN (putchar);
+#endif
+
+#if @GNULIB_PUTS@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef puts
+#   define puts rpl_puts
+#  endif
+_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (puts, int, (const char *string));
+# else
+_GL_CXXALIAS_SYS (puts, int, (const char *string));
+# endif
+_GL_CXXALIASWARN (puts);
+#endif
+
+#if @GNULIB_REMOVE@
+# if @REPLACE_REMOVE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef remove
+#   define remove rpl_remove
+#  endif
+_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (remove, int, (const char *name));
+# else
+_GL_CXXALIAS_SYS (remove, int, (const char *name));
+# endif
+_GL_CXXALIASWARN (remove);
+#elif defined GNULIB_POSIXCHECK
+# undef remove
+/* Assume remove is always declared.  */
+_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
+                 "use gnulib module remove for more portability");
+#endif
+
+#if @GNULIB_RENAME@
+# if @REPLACE_RENAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef rename
+#   define rename rpl_rename
+#  endif
+_GL_FUNCDECL_RPL (rename, int,
+                  (const char *old_filename, const char *new_filename)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (rename, int,
+                  (const char *old_filename, const char *new_filename));
+# else
+_GL_CXXALIAS_SYS (rename, int,
+                  (const char *old_filename, const char *new_filename));
+# endif
+_GL_CXXALIASWARN (rename);
+#elif defined GNULIB_POSIXCHECK
+# undef rename
+/* Assume rename is always declared.  */
+_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
+                 "use gnulib module rename for more portability");
+#endif
+
+#if @GNULIB_RENAMEAT@
+# if @REPLACE_RENAMEAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef renameat
+#   define renameat rpl_renameat
+#  endif
+_GL_FUNCDECL_RPL (renameat, int,
+                  (int fd1, char const *file1, int fd2, char const *file2)
+                  _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (renameat, int,
+                  (int fd1, char const *file1, int fd2, char const *file2));
+# else
+#  if !@HAVE_RENAMEAT@
+_GL_FUNCDECL_SYS (renameat, int,
+                  (int fd1, char const *file1, int fd2, char const *file2)
+                  _GL_ARG_NONNULL ((2, 4)));
+#  endif
+_GL_CXXALIAS_SYS (renameat, int,
+                  (int fd1, char const *file1, int fd2, char const *file2));
+# endif
+_GL_CXXALIASWARN (renameat);
+#elif defined GNULIB_POSIXCHECK
+# undef renameat
+# if HAVE_RAW_DECL_RENAMEAT
+_GL_WARN_ON_USE (renameat, "renameat is not portable - "
+                 "use gnulib module renameat for portability");
+# endif
+#endif
+
+#if @GNULIB_SNPRINTF@
+# if @REPLACE_SNPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define snprintf rpl_snprintf
+#  endif
+_GL_FUNCDECL_RPL (snprintf, int,
+                  (char *str, size_t size, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
+                  _GL_ARG_NONNULL ((3)));
+_GL_CXXALIAS_RPL (snprintf, int,
+                  (char *str, size_t size, const char *format, ...));
+# else
+#  if !@HAVE_DECL_SNPRINTF@
+_GL_FUNCDECL_SYS (snprintf, int,
+                  (char *str, size_t size, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
+                  _GL_ARG_NONNULL ((3)));
+#  endif
+_GL_CXXALIAS_SYS (snprintf, int,
+                  (char *str, size_t size, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (snprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef snprintf
+# if HAVE_RAW_DECL_SNPRINTF
+_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
+                 "use gnulib module snprintf for portability");
+# endif
+#endif
+
+/* Some people would argue that sprintf should be handled like gets
+   (for example, OpenBSD issues a link warning for both functions),
+   since both can cause security holes due to buffer overruns.
+   However, we believe that sprintf can be used safely, and is more
+   efficient than snprintf in those safe cases; and as proof of our
+   belief, we use sprintf in several gnulib modules.  So this header
+   intentionally avoids adding a warning to sprintf except when
+   GNULIB_POSIXCHECK is defined.  */
+
+#if @GNULIB_SPRINTF_POSIX@
+# if @REPLACE_SPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define sprintf rpl_sprintf
+#  endif
+_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                                _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (sprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef sprintf
+/* Assume sprintf is always declared.  */
+_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
+                 "use gnulib module sprintf-posix for portable "
+                 "POSIX compliance");
+#endif
+
+#if @GNULIB_TMPFILE@
+# if @REPLACE_TMPFILE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define tmpfile rpl_tmpfile
+#  endif
+_GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
+_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
+# else
+_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
+# endif
+_GL_CXXALIASWARN (tmpfile);
+#elif defined GNULIB_POSIXCHECK
+# undef tmpfile
+# if HAVE_RAW_DECL_TMPFILE
+_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
+                 "use gnulib module tmpfile for portability");
+# endif
+#endif
+
+#if @GNULIB_VASPRINTF@
+/* Write formatted output to a string dynamically allocated with malloc().
+   If the memory allocation succeeds, store the address of the string in
+   *RESULT and return the number of resulting bytes, excluding the trailing
+   NUL.  Upon memory allocation error, or some other error, return -1.  */
+# if @REPLACE_VASPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define asprintf rpl_asprintf
+#  endif
+_GL_FUNCDECL_RPL (asprintf, int,
+                  (char **result, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (asprintf, int,
+                  (char **result, const char *format, ...));
+# else
+#  if !@HAVE_VASPRINTF@
+_GL_FUNCDECL_SYS (asprintf, int,
+                  (char **result, const char *format, ...)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (asprintf, int,
+                  (char **result, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (asprintf);
+# if @REPLACE_VASPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vasprintf rpl_vasprintf
+#  endif
+_GL_FUNCDECL_RPL (vasprintf, int,
+                  (char **result, const char *format, va_list args)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vasprintf, int,
+                  (char **result, const char *format, va_list args));
+# else
+#  if !@HAVE_VASPRINTF@
+_GL_FUNCDECL_SYS (vasprintf, int,
+                  (char **result, const char *format, va_list args)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (vasprintf, int,
+                  (char **result, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vasprintf);
+#endif
+
+#if @GNULIB_VDPRINTF@
+# if @REPLACE_VDPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vdprintf rpl_vdprintf
+#  endif
+_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
+                                 _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)
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                                 _GL_ARG_NONNULL ((2)));
+#  endif
+/* Need to cast, because on Solaris, the third parameter will likely be
+                                                    __va_list args.  */
+_GL_CXXALIAS_SYS_CAST (vdprintf, int,
+                       (int fd, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vdprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vdprintf
+# if HAVE_RAW_DECL_VDPRINTF
+_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
+                 "use gnulib module vdprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
+# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
+     || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vfprintf rpl_vfprintf
+#  endif
+#  define GNULIB_overrides_vfprintf 1
+_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                                 _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the third parameter is
+                                                      __va_list args
+   and GCC's fixincludes did not change this to __gnuc_va_list.  */
+_GL_CXXALIAS_SYS_CAST (vfprintf, int,
+                       (FILE *fp, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vfprintf);
+#endif
+#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_vfprintf
+#  undef vfprintf
+# endif
+/* Assume vfprintf is always declared.  */
+_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
+                 "use gnulib module vfprintf-posix for portable "
+                      "POSIX compliance");
+#endif
+
+#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
+# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
+     || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vprintf rpl_vprintf
+#  endif
+#  define GNULIB_overrides_vprintf 1
+_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
+                                _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the second parameter is
+                                                          __va_list args
+   and GCC's fixincludes did not change this to __gnuc_va_list.  */
+_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vprintf);
+#endif
+#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
+# if !GNULIB_overrides_vprintf
+#  undef vprintf
+# endif
+/* Assume vprintf is always declared.  */
+_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
+                 "use gnulib module vprintf-posix for portable "
+                 "POSIX compliance");
+#endif
+
+#if @GNULIB_VSNPRINTF@
+# if @REPLACE_VSNPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vsnprintf rpl_vsnprintf
+#  endif
+_GL_FUNCDECL_RPL (vsnprintf, int,
+                  (char *str, size_t size, const char *format, va_list args)
+                  _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));
+# else
+#  if !@HAVE_DECL_VSNPRINTF@
+_GL_FUNCDECL_SYS (vsnprintf, int,
+                  (char *str, size_t size, const char *format, va_list args)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
+                  _GL_ARG_NONNULL ((3)));
+#  endif
+_GL_CXXALIAS_SYS (vsnprintf, int,
+                  (char *str, size_t size, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vsnprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vsnprintf
+# if HAVE_RAW_DECL_VSNPRINTF
+_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
+                 "use gnulib module vsnprintf for portability");
+# endif
+#endif
+
+#if @GNULIB_VSPRINTF_POSIX@
+# if @REPLACE_VSPRINTF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define vsprintf rpl_vsprintf
+#  endif
+_GL_FUNCDECL_RPL (vsprintf, int,
+                  (char *str, const char *format, va_list args)
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vsprintf, int,
+                  (char *str, const char *format, va_list args));
+# else
+/* Need to cast, because on Solaris, the third parameter is
+                                                       __va_list args
+   and GCC's fixincludes did not change this to __gnuc_va_list.  */
+_GL_CXXALIAS_SYS_CAST (vsprintf, int,
+                       (char *str, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vsprintf);
+#elif defined GNULIB_POSIXCHECK
+# undef vsprintf
+/* Assume vsprintf is always declared.  */
+_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
+                 "use gnulib module vsprintf-posix for portable "
+                      "POSIX compliance");
+#endif
+
+
+#endif /* _GL_STDIO_H */
+#endif /* _GL_STDIO_H */
+#endif
diff --git a/gnulib/lib/stdlib.in.h b/gnulib/lib/stdlib.in.h
new file mode 100644 (file)
index 0000000..0829a96
--- /dev/null
@@ -0,0 +1,759 @@
+/* A GNU-like <stdlib.h>.
+
+   Copyright (C) 1995, 2001-2004, 2006-2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_malloc_and_calloc
+/* Special invocation convention inside glibc header files.  */
+
+#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _GL_STDLIB_H
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
+
+#ifndef _GL_STDLIB_H
+#define _GL_STDLIB_H
+
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
+/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.  */
+#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
+# include <sys/wait.h>
+#endif
+
+/* Solaris declares getloadavg() in <sys/loadavg.h>.  */
+#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
+# include <sys/loadavg.h>
+#endif
+
+#if @GNULIB_RANDOM_R@
+
+/* 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@ || !@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
+struct random_data
+{
+  int32_t *fptr;                /* Front pointer.  */
+  int32_t *rptr;                /* Rear pointer.  */
+  int32_t *state;               /* Array of state values.  */
+  int rand_type;                /* Type of random number generator.  */
+  int rand_deg;                 /* Degree of random number generator.  */
+  int rand_sep;                 /* Distance between front and rear.  */
+  int32_t *end_ptr;             /* Pointer behind state table.  */
+};
+#   define GNULIB_defined_struct_random_data 1
+#  endif
+# endif
+#endif
+
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
+/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
+/* But avoid namespace pollution on glibc systems and native Windows.  */
+# include <unistd.h>
+#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.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+/* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
+   with proper operation of xargs.  */
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#elif EXIT_FAILURE != 1
+# undef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+
+#if @GNULIB__EXIT@
+/* Terminate the current process with the given return code, without running
+   the 'atexit' handlers.  */
+# if !@HAVE__EXIT@
+_GL_FUNCDECL_SYS (_Exit, void, (int status) _GL_ATTRIBUTE_NORETURN);
+# endif
+_GL_CXXALIAS_SYS (_Exit, void, (int status));
+_GL_CXXALIASWARN (_Exit);
+#elif defined GNULIB_POSIXCHECK
+# undef _Exit
+# if HAVE_RAW_DECL__EXIT
+_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
+                 "use gnulib module _Exit for portability");
+# endif
+#endif
+
+
+#if @GNULIB_ATOLL@
+/* Parse a signed decimal integer.
+   Returns the value of the integer.  Errors are not detected.  */
+# if !@HAVE_ATOLL@
+_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
+_GL_CXXALIASWARN (atoll);
+#elif defined GNULIB_POSIXCHECK
+# undef atoll
+# if HAVE_RAW_DECL_ATOLL
+_GL_WARN_ON_USE (atoll, "atoll is unportable - "
+                 "use gnulib module atoll for portability");
+# endif
+#endif
+
+#if @GNULIB_CALLOC_POSIX@
+# if @REPLACE_CALLOC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef calloc
+#   define calloc rpl_calloc
+#  endif
+_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
+_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
+# else
+_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
+# endif
+_GL_CXXALIASWARN (calloc);
+#elif defined GNULIB_POSIXCHECK
+# undef calloc
+/* Assume calloc is always declared.  */
+_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
+                 "use gnulib module calloc-posix for portability");
+#endif
+
+#if @GNULIB_CANONICALIZE_FILE_NAME@
+# if @REPLACE_CANONICALIZE_FILE_NAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define canonicalize_file_name rpl_canonicalize_file_name
+#  endif
+_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
+                                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
+# else
+#  if !@HAVE_CANONICALIZE_FILE_NAME@
+_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
+                                                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
+# endif
+_GL_CXXALIASWARN (canonicalize_file_name);
+#elif defined GNULIB_POSIXCHECK
+# undef canonicalize_file_name
+# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
+_GL_WARN_ON_USE (canonicalize_file_name,
+                 "canonicalize_file_name is unportable - "
+                 "use gnulib module canonicalize-lgpl for portability");
+# endif
+#endif
+
+#if @GNULIB_GETLOADAVG@
+/* Store max(NELEM,3) load average numbers in LOADAVG[].
+   The three numbers are the load average of the last 1 minute, the last 5
+   minutes, and the last 15 minutes, respectively.
+   LOADAVG is an array of NELEM numbers.  */
+# if !@HAVE_DECL_GETLOADAVG@
+_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
+                                   _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
+_GL_CXXALIASWARN (getloadavg);
+#elif defined GNULIB_POSIXCHECK
+# undef getloadavg
+# if HAVE_RAW_DECL_GETLOADAVG
+_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
+                 "use gnulib module getloadavg for portability");
+# endif
+#endif
+
+#if @GNULIB_GETSUBOPT@
+/* Assuming *OPTIONP is a comma separated list of elements of the form
+   "token" or "token=value", getsubopt parses the first of these elements.
+   If the first element refers to a "token" that is member of the given
+   NULL-terminated array of tokens:
+     - It replaces the comma with a NUL byte, updates *OPTIONP to point past
+       the first option and the comma, sets *VALUEP to the value of the
+       element (or NULL if it doesn't contain an "=" sign),
+     - It returns the index of the "token" in the given array of tokens.
+   Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
+   For more details see the POSIX:2001 specification.
+   http://www.opengroup.org/susv3xsh/getsubopt.html */
+# if !@HAVE_GETSUBOPT@
+_GL_FUNCDECL_SYS (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep)
+                  _GL_ARG_NONNULL ((1, 2, 3)));
+# endif
+_GL_CXXALIAS_SYS (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep));
+_GL_CXXALIASWARN (getsubopt);
+#elif defined GNULIB_POSIXCHECK
+# undef getsubopt
+# if HAVE_RAW_DECL_GETSUBOPT
+_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
+                 "use gnulib module getsubopt for portability");
+# endif
+#endif
+
+#if @GNULIB_GRANTPT@
+/* Change the ownership and access permission of the slave side of the
+   pseudo-terminal whose master side is specified by FD.  */
+# if !@HAVE_GRANTPT@
+_GL_FUNCDECL_SYS (grantpt, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (grantpt, int, (int fd));
+_GL_CXXALIASWARN (grantpt);
+#elif defined GNULIB_POSIXCHECK
+# undef grantpt
+# if HAVE_RAW_DECL_GRANTPT
+_GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
+                 "use gnulib module grantpt for portability");
+# endif
+#endif
+
+#if @GNULIB_MALLOC_POSIX@
+# if @REPLACE_MALLOC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef malloc
+#   define malloc rpl_malloc
+#  endif
+_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
+_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
+# else
+_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
+# endif
+_GL_CXXALIASWARN (malloc);
+#elif defined GNULIB_POSIXCHECK
+# undef malloc
+/* Assume malloc is always declared.  */
+_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
+                 "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";
+   they are replaced with a string that makes the directory name unique.
+   Returns TEMPLATE, or a null pointer if it cannot get a unique name.
+   The directory is created mode 700.  */
+# if !@HAVE_MKDTEMP@
+_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
+_GL_CXXALIASWARN (mkdtemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkdtemp
+# if HAVE_RAW_DECL_MKDTEMP
+_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
+                 "use gnulib module mkdtemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKOSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   The file is then created, with the specified flags, ensuring it didn't exist
+   before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+# if !@HAVE_MKOSTEMP@
+_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
+                                 _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemp
+# if HAVE_RAW_DECL_MKOSTEMP
+_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
+                 "use gnulib module mkostemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKOSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE before a suffix of length
+   SUFFIXLEN must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   The file is then created, with the specified flags, ensuring it didn't exist
+   before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+# if !@HAVE_MKOSTEMPS@
+_GL_FUNCDECL_SYS (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/));
+_GL_CXXALIASWARN (mkostemps);
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemps
+# if HAVE_RAW_DECL_MKOSTEMPS
+_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
+                 "use gnulib module mkostemps for portability");
+# endif
+#endif
+
+#if @GNULIB_MKSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The file is then created, ensuring it didn't exist before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+# if @REPLACE_MKSTEMP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mkstemp rpl_mkstemp
+#  endif
+_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
+# else
+#  if ! @HAVE_MKSTEMP@
+_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
+# endif
+_GL_CXXALIASWARN (mkstemp);
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemp
+# if HAVE_RAW_DECL_MKSTEMP
+_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
+                 "use gnulib module mkstemp for portability");
+# endif
+#endif
+
+#if @GNULIB_MKSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE prior to a suffix of length
+   SUFFIXLEN must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The file is then created, ensuring it didn't exist before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+# if !@HAVE_MKSTEMPS@
+_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
+                                 _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
+_GL_CXXALIASWARN (mkstemps);
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemps
+# if HAVE_RAW_DECL_MKSTEMPS
+_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
+                 "use gnulib module mkstemps for portability");
+# endif
+#endif
+
+#if @GNULIB_PTSNAME@
+/* Return the pathname of the pseudo-terminal slave associated with
+   the master FD is open on, or NULL on errors.  */
+# if !@HAVE_PTSNAME@
+_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
+# endif
+_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
+_GL_CXXALIASWARN (ptsname);
+#elif defined GNULIB_POSIXCHECK
+# undef ptsname
+# if HAVE_RAW_DECL_PTSNAME
+_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
+                 "use gnulib module ptsname for portability");
+# endif
+#endif
+
+#if @GNULIB_PUTENV@
+# if @REPLACE_PUTENV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef putenv
+#   define putenv rpl_putenv
+#  endif
+_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (putenv, int, (char *string));
+# else
+_GL_CXXALIAS_SYS (putenv, int, (char *string));
+# endif
+_GL_CXXALIASWARN (putenv);
+#endif
+
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+#  ifndef RAND_MAX
+#   define RAND_MAX 2147483647
+#  endif
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
+                                 _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
+_GL_CXXALIASWARN (random_r);
+#elif defined GNULIB_POSIXCHECK
+# undef random_r
+# if HAVE_RAW_DECL_RANDOM_R
+_GL_WARN_ON_USE (random_r, "random_r is unportable - "
+                 "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (srandom_r, int,
+                  (unsigned int seed, struct random_data *rand_state));
+_GL_CXXALIASWARN (srandom_r);
+#elif defined GNULIB_POSIXCHECK
+# undef srandom_r
+# if HAVE_RAW_DECL_SRANDOM_R
+_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
+                 "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((2, 4)));
+# endif
+_GL_CXXALIAS_SYS (initstate_r, int,
+                  (unsigned int seed, char *buf, size_t buf_size,
+                   struct random_data *rand_state));
+_GL_CXXALIASWARN (initstate_r);
+#elif defined GNULIB_POSIXCHECK
+# undef initstate_r
+# if HAVE_RAW_DECL_INITSTATE_R
+_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
+                 "use gnulib module random_r for portability");
+# endif
+#endif
+
+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+_GL_FUNCDECL_SYS (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state)
+                  _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (setstate_r, int,
+                  (char *arg_state, struct random_data *rand_state));
+_GL_CXXALIASWARN (setstate_r);
+#elif defined GNULIB_POSIXCHECK
+# undef setstate_r
+# if HAVE_RAW_DECL_SETSTATE_R
+_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
+                 "use gnulib module random_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_REALLOC_POSIX@
+# if @REPLACE_REALLOC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef realloc
+#   define realloc rpl_realloc
+#  endif
+_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
+_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
+# else
+_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
+# endif
+_GL_CXXALIASWARN (realloc);
+#elif defined GNULIB_POSIXCHECK
+# undef realloc
+/* Assume realloc is always declared.  */
+_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
+                 "use gnulib module realloc-posix for portability");
+#endif
+
+#if @GNULIB_REALPATH@
+# if @REPLACE_REALPATH@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define realpath rpl_realpath
+#  endif
+_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
+                                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
+# else
+#  if !@HAVE_REALPATH@
+_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
+                                    _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
+# endif
+_GL_CXXALIASWARN (realpath);
+#elif defined GNULIB_POSIXCHECK
+# undef realpath
+# if HAVE_RAW_DECL_REALPATH
+_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
+                 "canonicalize or canonicalize-lgpl for portability");
+# endif
+#endif
+
+#if @GNULIB_RPMATCH@
+/* Test a user response to a question.
+   Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
+# if !@HAVE_RPMATCH@
+_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
+_GL_CXXALIASWARN (rpmatch);
+#elif defined GNULIB_POSIXCHECK
+# undef rpmatch
+# if HAVE_RAW_DECL_RPMATCH
+_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
+                 "use gnulib module rpmatch for portability");
+# endif
+#endif
+
+#if @GNULIB_SETENV@
+/* Set NAME to VALUE in the environment.
+   If REPLACE is nonzero, overwrite an existing value.  */
+# if @REPLACE_SETENV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef setenv
+#   define setenv rpl_setenv
+#  endif
+_GL_FUNCDECL_RPL (setenv, int,
+                  (const char *name, const char *value, int replace)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (setenv, int,
+                  (const char *name, const char *value, int replace));
+# else
+#  if !@HAVE_DECL_SETENV@
+_GL_FUNCDECL_SYS (setenv, int,
+                  (const char *name, const char *value, int replace)
+                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (setenv, int,
+                  (const char *name, const char *value, int replace));
+# endif
+# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
+_GL_CXXALIASWARN (setenv);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef setenv
+# if HAVE_RAW_DECL_SETENV
+_GL_WARN_ON_USE (setenv, "setenv is unportable - "
+                 "use gnulib module setenv for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOD@
+ /* Parse a double from STRING, updating ENDP if appropriate.  */
+# if @REPLACE_STRTOD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strtod rpl_strtod
+#  endif
+_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
+                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
+# else
+#  if !@HAVE_STRTOD@
+_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
+                                  _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
+# endif
+_GL_CXXALIASWARN (strtod);
+#elif defined GNULIB_POSIXCHECK
+# undef strtod
+# if HAVE_RAW_DECL_STRTOD
+_GL_WARN_ON_USE (strtod, "strtod is unportable - "
+                 "use gnulib module strtod for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOLL@
+/* Parse a signed integer whose textual representation starts at STRING.
+   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+   "0x").
+   If ENDPTR is not NULL, the address of the first byte after the integer is
+   stored in *ENDPTR.
+   Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
+   to ERANGE.  */
+# if !@HAVE_STRTOLL@
+_GL_FUNCDECL_SYS (strtoll, long long,
+                  (const char *string, char **endptr, int base)
+                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoll, long long,
+                  (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoll);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoll
+# if HAVE_RAW_DECL_STRTOLL
+_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
+                 "use gnulib module strtoll for portability");
+# endif
+#endif
+
+#if @GNULIB_STRTOULL@
+/* Parse an unsigned integer whose textual representation starts at STRING.
+   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+   "0x").
+   If ENDPTR is not NULL, the address of the first byte after the integer is
+   stored in *ENDPTR.
+   Upon overflow, the return value is ULLONG_MAX, and errno is set to
+   ERANGE.  */
+# if !@HAVE_STRTOULL@
+_GL_FUNCDECL_SYS (strtoull, unsigned long long,
+                  (const char *string, char **endptr, int base)
+                  _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (strtoull, unsigned long long,
+                  (const char *string, char **endptr, int base));
+_GL_CXXALIASWARN (strtoull);
+#elif defined GNULIB_POSIXCHECK
+# undef strtoull
+# if HAVE_RAW_DECL_STRTOULL
+_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
+                 "use gnulib module strtoull for portability");
+# endif
+#endif
+
+#if @GNULIB_UNLOCKPT@
+/* Unlock the slave side of the pseudo-terminal whose master side is specified
+   by FD, so that it can be opened.  */
+# if !@HAVE_UNLOCKPT@
+_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
+_GL_CXXALIASWARN (unlockpt);
+#elif defined GNULIB_POSIXCHECK
+# undef unlockpt
+# if HAVE_RAW_DECL_UNLOCKPT
+_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
+                 "use gnulib module unlockpt for portability");
+# endif
+#endif
+
+#if @GNULIB_UNSETENV@
+/* Remove the variable NAME from the environment.  */
+# if @REPLACE_UNSETENV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unsetenv
+#   define unsetenv rpl_unsetenv
+#  endif
+_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
+# else
+#  if !@HAVE_DECL_UNSETENV@
+_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
+# endif
+# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
+_GL_CXXALIASWARN (unsetenv);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unsetenv
+# if HAVE_RAW_DECL_UNSETENV
+_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
+                 "use gnulib module unsetenv for portability");
+# 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 */
+#endif
diff --git a/gnulib/lib/stpcpy.c b/gnulib/lib/stpcpy.c
new file mode 100644 (file)
index 0000000..f465d07
--- /dev/null
@@ -0,0 +1,49 @@
+/* stpcpy.c -- copy a string and return pointer to end of new string
+   Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2011 Free Software
+   Foundation, Inc.
+
+   NOTE: The canonical source of this file is maintained with the GNU C Library.
+   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#undef __stpcpy
+#ifdef _LIBC
+# undef stpcpy
+#endif
+
+#ifndef weak_alias
+# define __stpcpy stpcpy
+#endif
+
+/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST.  */
+char *
+__stpcpy (char *dest, const char *src)
+{
+  register char *d = dest;
+  register const char *s = src;
+
+  do
+    *d++ = *s;
+  while (*s++ != '\0');
+
+  return d - 1;
+}
+#ifdef weak_alias
+weak_alias (__stpcpy, stpcpy)
+#endif
diff --git a/gnulib/lib/stpncpy.c b/gnulib/lib/stpncpy.c
new file mode 100644 (file)
index 0000000..1c42891
--- /dev/null
@@ -0,0 +1,92 @@
+/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2011 Free Software
+ * Foundation, Inc.
+
+   NOTE: The canonical source of this file is maintained with the GNU C Library.
+   Bugs can be reported to bug-glibc@gnu.org.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or 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/>.  */
+
+/* This is almost copied from strncpy.c, written by Torbjorn Granlund.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <string.h>
+
+#ifndef weak_alias
+# define __stpncpy stpncpy
+#endif
+
+/* Copy no more than N bytes of SRC to DST, returning a pointer past the
+   last non-NUL byte written into DST.  */
+char *
+__stpncpy (char *dest, const char *src, size_t n)
+{
+  char c;
+  char *s = dest;
+
+  if (n >= 4)
+    {
+      size_t n4 = n >> 2;
+
+      for (;;)
+        {
+          c = *src++;
+          *dest++ = c;
+          if (c == '\0')
+            break;
+          c = *src++;
+          *dest++ = c;
+          if (c == '\0')
+            break;
+          c = *src++;
+          *dest++ = c;
+          if (c == '\0')
+            break;
+          c = *src++;
+          *dest++ = c;
+          if (c == '\0')
+            break;
+          if (--n4 == 0)
+            goto last_chars;
+        }
+      n -= dest - s;
+      goto zero_fill;
+    }
+
+ last_chars:
+  n &= 3;
+  if (n == 0)
+    return dest;
+
+  for (;;)
+    {
+      c = *src++;
+      --n;
+      *dest++ = c;
+      if (c == '\0')
+        break;
+      if (n == 0)
+        return dest;
+    }
+
+ zero_fill:
+  while (n-- > 0)
+    dest[n] = '\0';
+
+  return dest - 1;
+}
+#ifdef weak_alias
+weak_alias (__stpncpy, stpncpy)
+#endif
diff --git a/gnulib/lib/str-two-way.h b/gnulib/lib/str-two-way.h
new file mode 100644 (file)
index 0000000..a8b31c3
--- /dev/null
@@ -0,0 +1,453 @@
+/* Byte-wise substring search, using the Two-Way algorithm.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Eric Blake <ebb9@byu.net>, 2008.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Before including this file, you need to include <config.h> and
+   <string.h>, and define:
+     RESULT_TYPE             A macro that expands to the return type.
+     AVAILABLE(h, h_l, j, n_l)
+                             A macro that returns nonzero if there are
+                             at least N_L bytes left starting at H[J].
+                             H is 'unsigned char *', H_L, J, and N_L
+                             are 'size_t'; H_L is an lvalue.  For
+                             NUL-terminated searches, H_L can be
+                             modified each iteration to avoid having
+                             to compute the end of H up front.
+
+  For case-insensitivity, you may optionally define:
+     CMP_FUNC(p1, p2, l)     A macro that returns 0 iff the first L
+                             characters of P1 and P2 are equal.
+     CANON_ELEMENT(c)        A macro that canonicalizes an element right after
+                             it has been fetched from one of the two strings.
+                             The argument is an 'unsigned char'; the result
+                             must be an 'unsigned char' as well.
+
+  This file undefines the macros documented above, and defines
+  LONG_NEEDLE_THRESHOLD.
+*/
+
+#include <limits.h>
+#include <stdint.h>
+
+/* 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,
+   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
+   worthwhile.  Small needles should not compute a table, since it
+   adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a
+   speedup no greater than a factor of NEEDLE_LEN.  The larger the
+   needle, the better the potential performance gain.  On the other
+   hand, on non-POSIX systems with CHAR_BIT larger than eight, the
+   memory required for the table is prohibitive.  */
+#if CHAR_BIT < 10
+# define LONG_NEEDLE_THRESHOLD 32U
+#else
+# define LONG_NEEDLE_THRESHOLD SIZE_MAX
+#endif
+
+#ifndef MAX
+# define MAX(a, b) ((a < b) ? (b) : (a))
+#endif
+
+#ifndef CANON_ELEMENT
+# define CANON_ELEMENT(c) c
+#endif
+#ifndef CMP_FUNC
+# define CMP_FUNC memcmp
+#endif
+
+/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN.
+   Return the index of the first byte in the right half, and set
+   *PERIOD to the global period of the right half.
+
+   The global period of a string is the smallest index (possibly its
+   length) at which all remaining bytes in the string are repetitions
+   of the prefix (the last repetition may be a subset of the prefix).
+
+   When NEEDLE is factored into two halves, a local period is the
+   length of the smallest word that shares a suffix with the left half
+   and shares a prefix with the right half.  All factorizations of a
+   non-empty NEEDLE have a local period of at least 1 and no greater
+   than NEEDLE_LEN.
+
+   A critical factorization has the property that the local period
+   equals the global period.  All strings have at least one critical
+   factorization with the left half smaller than the global period.
+   And while some strings have more than one critical factorization,
+   it is provable that with an ordered alphabet, at least one of the
+   critical factorizations corresponds to a maximal suffix.
+
+   Given an ordered alphabet, a critical factorization can be computed
+   in linear time, with 2 * NEEDLE_LEN comparisons, by computing the
+   shorter of two ordered maximal suffixes.  The ordered maximal
+   suffixes are determined by lexicographic comparison while tracking
+   periodicity.  */
+static size_t
+critical_factorization (const unsigned char *needle, size_t needle_len,
+                        size_t *period)
+{
+  /* 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.  */
+  size_t p; /* Intermediate period.  */
+  unsigned char a, b; /* Current comparison bytes.  */
+
+  /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered
+     out 0-length needles.  */
+  if (needle_len < 3)
+    {
+      *period = 1;
+      return needle_len - 1;
+    }
+
+  /* Invariants:
+     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]
+     1 <= k <= p
+  */
+
+  /* Perform lexicographic search.  */
+  max_suffix = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix + k]);
+      if (a < b)
+        {
+          /* Suffix is smaller, period is entire prefix so far.  */
+          j += k;
+          k = 1;
+          p = j - max_suffix;
+        }
+      else if (a == b)
+        {
+          /* Advance through repetition of the current period.  */
+          if (k != p)
+            ++k;
+          else
+            {
+              j += p;
+              k = 1;
+            }
+        }
+      else /* b < a */
+        {
+          /* Suffix is larger, start over from current location.  */
+          max_suffix = j++;
+          k = p = 1;
+        }
+    }
+  *period = p;
+
+  /* Perform reverse lexicographic search.  */
+  max_suffix_rev = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix_rev + k]);
+      if (b < a)
+        {
+          /* Suffix is smaller, period is entire prefix so far.  */
+          j += k;
+          k = 1;
+          p = j - max_suffix_rev;
+        }
+      else if (a == b)
+        {
+          /* Advance through repetition of the current period.  */
+          if (k != p)
+            ++k;
+          else
+            {
+              j += p;
+              k = 1;
+            }
+        }
+      else /* a < b */
+        {
+          /* Suffix is larger, start over from current location.  */
+          max_suffix_rev = j++;
+          k = p = 1;
+        }
+    }
+
+  /* Choose the shorter suffix.  Return the index of the first byte of
+     the right half, rather than the last byte of the left half.
+
+     For some examples, 'banana' has two critical factorizations, both
+     exposed by the two lexicographic extreme suffixes of 'anana' and
+     'nana', where both suffixes have a period of 2.  On the other
+     hand, with 'aab' and 'bba', both strings have a single critical
+     factorization of the last byte, with the suffix having a period
+     of 1.  While the maximal lexicographic suffix of 'aab' is 'b',
+     the maximal lexicographic suffix of 'bba' is 'ba', which is not a
+     critical factorization.  Conversely, the maximal reverse
+     lexicographic suffix of 'a' works for 'bba', but not 'ab' for
+     'aab'.  The shorter suffix of the two will always be a critical
+     factorization.  */
+  if (max_suffix_rev + 1 < max_suffix + 1)
+    return max_suffix + 1;
+  *period = p;
+  return max_suffix_rev + 1;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 2 * NEEDLE_LEN comparisons.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.  */
+static RETURN_TYPE
+two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
+                      const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch in the left half can
+         only advance by the period, so use memory to avoid rescanning
+         known occurrences of the period in the right half.  */
+      size_t memory = 0;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Scan for matches in right half.  */
+          i = MAX (suffix, memory);
+          while (i < needle_len && (CANON_ELEMENT (needle[i])
+                                    == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i + 1 < memory + 1)
+                return (RETURN_TYPE) (haystack + j);
+              /* No match, so remember how many repetitions of period
+                 on the right half were scanned.  */
+              j += period;
+              memory = needle_len - period;
+            }
+          else
+            {
+              j += i - suffix + 1;
+              memory = 0;
+            }
+        }
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+         required, and any mismatch results in a maximal shift.  */
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Scan for matches in right half.  */
+          i = suffix;
+          while (i < needle_len && (CANON_ELEMENT (needle[i])
+                                    == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+                                       == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i == SIZE_MAX)
+                return (RETURN_TYPE) (haystack + j);
+              j += period;
+            }
+          else
+            j += i - suffix + 1;
+        }
+    }
+  return NULL;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching,
+   and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
+   sublinear performance is not possible.  */
+static RETURN_TYPE
+two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
+                     const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+  size_t shift_table[1U << CHAR_BIT]; /* See below.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Populate shift_table.  For each possible byte value c,
+     shift_table[c] is the distance from the last occurrence of c to
+     the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE.
+     shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0.  */
+  for (i = 0; i < 1U << CHAR_BIT; i++)
+    shift_table[i] = needle_len;
+  for (i = 0; i < needle_len; i++)
+    shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1;
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch in the left half can
+         only advance by the period, so use memory to avoid rescanning
+         known occurrences of the period in the right half.  */
+      size_t memory = 0;
+      size_t shift;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Check the last byte first; if it does not match, then
+             shift to the next possible match location.  */
+          shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+          if (0 < shift)
+            {
+              if (memory && shift < period)
+                {
+                  /* Since needle is periodic, but the last period has
+                     a byte out of place, there can be no match until
+                     after the mismatch.  */
+                  shift = needle_len - period;
+                }
+              memory = 0;
+              j += shift;
+              continue;
+            }
+          /* Scan for matches in right half.  The last byte has
+             already been matched, by virtue of the shift table.  */
+          i = MAX (suffix, memory);
+          while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len - 1 <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i + 1 < memory + 1)
+                return (RETURN_TYPE) (haystack + j);
+              /* No match, so remember how many repetitions of period
+                 on the right half were scanned.  */
+              j += period;
+              memory = needle_len - period;
+            }
+          else
+            {
+              j += i - suffix + 1;
+              memory = 0;
+            }
+        }
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+         required, and any mismatch results in a maximal shift.  */
+      size_t shift;
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Check the last byte first; if it does not match, then
+             shift to the next possible match location.  */
+          shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+          if (0 < shift)
+            {
+              j += shift;
+              continue;
+            }
+          /* Scan for matches in right half.  The last byte has
+             already been matched, by virtue of the shift table.  */
+          i = suffix;
+          while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len - 1 <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+                                       == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i == SIZE_MAX)
+                return (RETURN_TYPE) (haystack + j);
+              j += period;
+            }
+          else
+            j += i - suffix + 1;
+        }
+    }
+  return NULL;
+}
+
+#undef AVAILABLE
+#undef CANON_ELEMENT
+#undef CMP_FUNC
+#undef MAX
+#undef RETURN_TYPE
diff --git a/gnulib/lib/streq.h b/gnulib/lib/streq.h
new file mode 100644 (file)
index 0000000..73cfa29
--- /dev/null
@@ -0,0 +1,176 @@
+/* Optimized string comparison.
+   Copyright (C) 2001-2002, 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 Lesser General Public License as published
+   by the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>.  */
+
+#ifndef _GL_STREQ_H
+#define _GL_STREQ_H
+
+#include <string.h>
+
+/* STREQ allows to optimize string comparison with a small literal string.
+     STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+   is semantically equivalent to
+     strcmp (s, "EUC-KR") == 0
+   just faster.  */
+
+/* Help GCC to generate good code for string comparisons with
+   immediate strings. */
+#if defined (__GNUC__) && defined (__OPTIMIZE__)
+
+static inline int
+streq9 (const char *s1, const char *s2)
+{
+  return strcmp (s1 + 9, s2 + 9) == 0;
+}
+
+static inline int
+streq8 (const char *s1, const char *s2, char s28)
+{
+  if (s1[8] == s28)
+    {
+      if (s28 == 0)
+        return 1;
+      else
+        return streq9 (s1, s2);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq7 (const char *s1, const char *s2, char s27, char s28)
+{
+  if (s1[7] == s27)
+    {
+      if (s27 == 0)
+        return 1;
+      else
+        return streq8 (s1, s2, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
+{
+  if (s1[6] == s26)
+    {
+      if (s26 == 0)
+        return 1;
+      else
+        return streq7 (s1, s2, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
+{
+  if (s1[5] == s25)
+    {
+      if (s25 == 0)
+        return 1;
+      else
+        return streq6 (s1, s2, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[4] == s24)
+    {
+      if (s24 == 0)
+        return 1;
+      else
+        return streq5 (s1, s2, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[3] == s23)
+    {
+      if (s23 == 0)
+        return 1;
+      else
+        return streq4 (s1, s2, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[2] == s22)
+    {
+      if (s22 == 0)
+        return 1;
+      else
+        return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[1] == s21)
+    {
+      if (s21 == 0)
+        return 1;
+      else
+        return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[0] == s20)
+    {
+      if (s20 == 0)
+        return 1;
+      else
+        return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
+
+#else
+
+#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  (strcmp (s1, s2) == 0)
+
+#endif
+
+#endif /* _GL_STREQ_H */
diff --git a/gnulib/lib/string.in.h b/gnulib/lib/string.in.h
new file mode 100644 (file)
index 0000000..d86d283
--- /dev/null
@@ -0,0 +1,970 @@
+/* A GNU-like <string.h>.
+
+   Copyright (C) 1995-1996, 2001-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GL_STRING_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_STRING_H@
+
+#ifndef _GL_STRING_H
+#define _GL_STRING_H
+
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
+/* MirBSD defines mbslen as a macro.  */
+#if @GNULIB_MBSLEN@ && defined __MirBSD__
+# include <wchar.h>
+#endif
+
+/* 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
+# define _GL_ATTRIBUTE_PURE /* empty */
+#endif
+
+/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+/* Return the first instance of C within N bytes of S, or NULL.  */
+#if @GNULIB_MEMCHR@
+# if @REPLACE_MEMCHR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define memchr rpl_memchr
+#  endif
+_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
+                                  _GL_ATTRIBUTE_PURE
+                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
+# else
+#  if ! @HAVE_MEMCHR@
+_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
+                                  _GL_ATTRIBUTE_PURE
+                                  _GL_ARG_NONNULL ((1)));
+#  endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C" { const void * std::memchr (const void *, int, size_t); }
+       extern "C++" { void * std::memchr (void *, int, size_t); }  */
+_GL_CXXALIAS_SYS_CAST2 (memchr,
+                        void *, (void const *__s, int __c, size_t __n),
+                        void const *, (void const *__s, int __c, size_t __n));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
+_GL_CXXALIASWARN1 (memchr, void const *,
+                   (void const *__s, int __c, size_t __n));
+# else
+_GL_CXXALIASWARN (memchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memchr
+/* Assume memchr is always declared.  */
+_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
+                 "use gnulib module memchr for portability" );
+#endif
+
+/* Return the first occurrence of NEEDLE in HAYSTACK.  */
+#if @GNULIB_MEMMEM@
+# if @REPLACE_MEMMEM@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define memmem rpl_memmem
+#  endif
+_GL_FUNCDECL_RPL (memmem, void *,
+                  (void const *__haystack, size_t __haystack_len,
+                   void const *__needle, size_t __needle_len)
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (memmem, void *,
+                  (void const *__haystack, size_t __haystack_len,
+                   void const *__needle, size_t __needle_len));
+# else
+#  if ! @HAVE_DECL_MEMMEM@
+_GL_FUNCDECL_SYS (memmem, void *,
+                  (void const *__haystack, size_t __haystack_len,
+                   void const *__needle, size_t __needle_len)
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 3)));
+#  endif
+_GL_CXXALIAS_SYS (memmem, void *,
+                  (void const *__haystack, size_t __haystack_len,
+                   void const *__needle, size_t __needle_len));
+# endif
+_GL_CXXALIASWARN (memmem);
+#elif defined GNULIB_POSIXCHECK
+# undef memmem
+# if HAVE_RAW_DECL_MEMMEM
+_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
+                 "use gnulib module memmem-simple for portability, "
+                 "and module memmem for speed" );
+# endif
+#endif
+
+/* Copy N bytes of SRC to DEST, return pointer to bytes after the
+   last written byte.  */
+#if @GNULIB_MEMPCPY@
+# if ! @HAVE_MEMPCPY@
+_GL_FUNCDECL_SYS (mempcpy, void *,
+                  (void *restrict __dest, void const *restrict __src,
+                   size_t __n)
+                  _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (mempcpy, void *,
+                  (void *restrict __dest, void const *restrict __src,
+                   size_t __n));
+_GL_CXXALIASWARN (mempcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef mempcpy
+# if HAVE_RAW_DECL_MEMPCPY
+_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
+                 "use gnulib module mempcpy for portability");
+# endif
+#endif
+
+/* Search backwards through a block for a byte (specified as an int).  */
+#if @GNULIB_MEMRCHR@
+# if ! @HAVE_DECL_MEMRCHR@
+_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
+                                   _GL_ATTRIBUTE_PURE
+                                   _GL_ARG_NONNULL ((1)));
+# endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C++" { const void * std::memrchr (const void *, int, size_t); }
+       extern "C++" { void * std::memrchr (void *, int, size_t); }  */
+_GL_CXXALIAS_SYS_CAST2 (memrchr,
+                        void *, (void const *, int, size_t),
+                        void const *, (void const *, int, size_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
+_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
+# else
+_GL_CXXALIASWARN (memrchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef memrchr
+# if HAVE_RAW_DECL_MEMRCHR
+_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
+                 "use gnulib module memrchr for portability");
+# endif
+#endif
+
+/* Find the first occurrence of C in S.  More efficient than
+   memchr(S,C,N), at the expense of undefined behavior if C does not
+   occur within N bytes.  */
+#if @GNULIB_RAWMEMCHR@
+# if ! @HAVE_RAWMEMCHR@
+_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
+                                     _GL_ATTRIBUTE_PURE
+                                     _GL_ARG_NONNULL ((1)));
+# endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C++" { const void * std::rawmemchr (const void *, int); }
+       extern "C++" { void * std::rawmemchr (void *, int); }  */
+_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
+                        void *, (void const *__s, int __c_in),
+                        void const *, (void const *__s, int __c_in));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
+_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
+# else
+_GL_CXXALIASWARN (rawmemchr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef rawmemchr
+# if HAVE_RAW_DECL_RAWMEMCHR
+_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
+                 "use gnulib module rawmemchr for portability");
+# endif
+#endif
+
+/* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
+#if @GNULIB_STPCPY@
+# if ! @HAVE_STPCPY@
+_GL_FUNCDECL_SYS (stpcpy, char *,
+                  (char *restrict __dst, char const *restrict __src)
+                  _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (stpcpy, char *,
+                  (char *restrict __dst, char const *restrict __src));
+_GL_CXXALIASWARN (stpcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef stpcpy
+# if HAVE_RAW_DECL_STPCPY
+_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
+                 "use gnulib module stpcpy for portability");
+# endif
+#endif
+
+/* Copy no more than N bytes of SRC to DST, returning a pointer past the
+   last non-NUL byte written into DST.  */
+#if @GNULIB_STPNCPY@
+# if @REPLACE_STPNCPY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef stpncpy
+#   define stpncpy rpl_stpncpy
+#  endif
+_GL_FUNCDECL_RPL (stpncpy, char *,
+                  (char *restrict __dst, char const *restrict __src,
+                   size_t __n)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (stpncpy, char *,
+                  (char *restrict __dst, char const *restrict __src,
+                   size_t __n));
+# else
+#  if ! @HAVE_STPNCPY@
+_GL_FUNCDECL_SYS (stpncpy, char *,
+                  (char *restrict __dst, char const *restrict __src,
+                   size_t __n)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (stpncpy, char *,
+                  (char *restrict __dst, char const *restrict __src,
+                   size_t __n));
+# endif
+_GL_CXXALIASWARN (stpncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef stpncpy
+# if HAVE_RAW_DECL_STPNCPY
+_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
+                 "use gnulib module stpncpy for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strchr() does not work with multibyte strings if the locale encoding is
+   GB18030 and the character to be searched is a digit.  */
+# undef strchr
+/* Assume strchr is always declared.  */
+_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
+                 "in some multibyte locales - "
+                 "use mbschr if you care about internationalization");
+#endif
+
+/* Find the first occurrence of C in S or the final NUL byte.  */
+#if @GNULIB_STRCHRNUL@
+# if ! @HAVE_STRCHRNUL@
+_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
+                                     _GL_ATTRIBUTE_PURE
+                                     _GL_ARG_NONNULL ((1)));
+# endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C++" { const char * std::strchrnul (const char *, int); }
+       extern "C++" { char * std::strchrnul (char *, int); }  */
+_GL_CXXALIAS_SYS_CAST2 (strchrnul,
+                        char *, (char const *__s, int __c_in),
+                        char const *, (char const *__s, int __c_in));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
+_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
+# else
+_GL_CXXALIASWARN (strchrnul);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strchrnul
+# if HAVE_RAW_DECL_STRCHRNUL
+_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
+                 "use gnulib module strchrnul for portability");
+# endif
+#endif
+
+/* Duplicate S, returning an identical malloc'd string.  */
+#if @GNULIB_STRDUP@
+# if @REPLACE_STRDUP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strdup
+#   define strdup rpl_strdup
+#  endif
+_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
+# else
+#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
+    /* strdup exists as a function and as a macro.  Get rid of the macro.  */
+#   undef strdup
+#  endif
+#  if !(@HAVE_DECL_STRDUP@ || defined strdup)
+_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
+# endif
+_GL_CXXALIASWARN (strdup);
+#elif defined GNULIB_POSIXCHECK
+# undef strdup
+# if HAVE_RAW_DECL_STRDUP
+_GL_WARN_ON_USE (strdup, "strdup is unportable - "
+                 "use gnulib module strdup for portability");
+# endif
+#endif
+
+/* Append no more than N characters from SRC onto DEST.  */
+#if @GNULIB_STRNCAT@
+# if @REPLACE_STRNCAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strncat
+#   define strncat rpl_strncat
+#  endif
+_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
+                                   _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
+# else
+_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
+# endif
+_GL_CXXALIASWARN (strncat);
+#elif defined GNULIB_POSIXCHECK
+# undef strncat
+# if HAVE_RAW_DECL_STRNCAT
+_GL_WARN_ON_USE (strncat, "strncat is unportable - "
+                 "use gnulib module strncat for portability");
+# endif
+#endif
+
+/* Return a newly allocated copy of at most N bytes of STRING.  */
+#if @GNULIB_STRNDUP@
+# if @REPLACE_STRNDUP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strndup
+#   define strndup rpl_strndup
+#  endif
+_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
+# else
+#  if ! @HAVE_DECL_STRNDUP@
+_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
+                                   _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
+# endif
+_GL_CXXALIASWARN (strndup);
+#elif defined GNULIB_POSIXCHECK
+# undef strndup
+# if HAVE_RAW_DECL_STRNDUP
+_GL_WARN_ON_USE (strndup, "strndup is unportable - "
+                 "use gnulib module strndup for portability");
+# endif
+#endif
+
+/* Find the length (number of bytes) of STRING, but scan at most
+   MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
+   return MAXLEN.  */
+#if @GNULIB_STRNLEN@
+# if @REPLACE_STRNLEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strnlen
+#   define strnlen rpl_strnlen
+#  endif
+_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
+                                   _GL_ATTRIBUTE_PURE
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
+# else
+#  if ! @HAVE_DECL_STRNLEN@
+_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
+                                   _GL_ATTRIBUTE_PURE
+                                   _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
+# endif
+_GL_CXXALIASWARN (strnlen);
+#elif defined GNULIB_POSIXCHECK
+# undef strnlen
+# if HAVE_RAW_DECL_STRNLEN
+_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
+                 "use gnulib module strnlen for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strcspn() assumes the second argument is a list of single-byte characters.
+   Even in this simple case, it does not work with multibyte strings if the
+   locale encoding is GB18030 and one of the characters to be searched is a
+   digit.  */
+# undef strcspn
+/* Assume strcspn is always declared.  */
+_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
+                 "in multibyte locales - "
+                 "use mbscspn if you care about internationalization");
+#endif
+
+/* Find the first occurrence in S of any character in ACCEPT.  */
+#if @GNULIB_STRPBRK@
+# if ! @HAVE_STRPBRK@
+_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
+                                   _GL_ATTRIBUTE_PURE
+                                   _GL_ARG_NONNULL ((1, 2)));
+# endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C" { const char * strpbrk (const char *, const char *); }
+       extern "C++" { char * strpbrk (char *, const char *); }  */
+_GL_CXXALIAS_SYS_CAST2 (strpbrk,
+                        char *, (char const *__s, char const *__accept),
+                        const char *, (char const *__s, char const *__accept));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
+_GL_CXXALIASWARN1 (strpbrk, char const *,
+                   (char const *__s, char const *__accept));
+# else
+_GL_CXXALIASWARN (strpbrk);
+# endif
+# if defined GNULIB_POSIXCHECK
+/* strpbrk() assumes the second argument is a list of single-byte characters.
+   Even in this simple case, it does not work with multibyte strings if the
+   locale encoding is GB18030 and one of the characters to be searched is a
+   digit.  */
+#  undef strpbrk
+_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
+                 "in multibyte locales - "
+                 "use mbspbrk if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strpbrk
+# if HAVE_RAW_DECL_STRPBRK
+_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
+                 "use gnulib module strpbrk for portability");
+# endif
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strspn() assumes the second argument is a list of single-byte characters.
+   Even in this simple case, it cannot work with multibyte strings.  */
+# undef strspn
+/* Assume strspn is always declared.  */
+_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
+                 "in multibyte locales - "
+                 "use mbsspn if you care about internationalization");
+#endif
+
+#if defined GNULIB_POSIXCHECK
+/* strrchr() does not work with multibyte strings if the locale encoding is
+   GB18030 and the character to be searched is a digit.  */
+# undef strrchr
+/* Assume strrchr is always declared.  */
+_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
+                 "in some multibyte locales - "
+                 "use mbsrchr if you care about internationalization");
+#endif
+
+/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
+   If one is found, overwrite it with a NUL, and advance *STRINGP
+   to point to the next char after it.  Otherwise, set *STRINGP to NULL.
+   If *STRINGP was already NULL, nothing happens.
+   Return the old value of *STRINGP.
+
+   This is a variant of strtok() that is multithread-safe and supports
+   empty fields.
+
+   Caveat: It modifies the original string.
+   Caveat: These functions cannot be used on constant strings.
+   Caveat: The identity of the delimiting character is lost.
+   Caveat: It doesn't work with multibyte strings unless all of the delimiter
+           characters are ASCII characters < 0x30.
+
+   See also strtok_r().  */
+#if @GNULIB_STRSEP@
+# if ! @HAVE_STRSEP@
+_GL_FUNCDECL_SYS (strsep, char *,
+                  (char **restrict __stringp, char const *restrict __delim)
+                  _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (strsep, char *,
+                  (char **restrict __stringp, char const *restrict __delim));
+_GL_CXXALIASWARN (strsep);
+# if defined GNULIB_POSIXCHECK
+#  undef strsep
+_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
+                 "in multibyte locales - "
+                 "use mbssep if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strsep
+# if HAVE_RAW_DECL_STRSEP
+_GL_WARN_ON_USE (strsep, "strsep is unportable - "
+                 "use gnulib module strsep for portability");
+# endif
+#endif
+
+#if @GNULIB_STRSTR@
+# if @REPLACE_STRSTR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strstr rpl_strstr
+#  endif
+_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
+                                  _GL_ATTRIBUTE_PURE
+                                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
+# else
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C++" { const char * strstr (const char *, const char *); }
+       extern "C++" { char * strstr (char *, const char *); }  */
+_GL_CXXALIAS_SYS_CAST2 (strstr,
+                        char *, (const char *haystack, const char *needle),
+                        const char *, (const char *haystack, const char *needle));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
+_GL_CXXALIASWARN1 (strstr, const char *,
+                   (const char *haystack, const char *needle));
+# else
+_GL_CXXALIASWARN (strstr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+/* strstr() does not work with multibyte strings if the locale encoding is
+   different from UTF-8:
+   POSIX says that it operates on "strings", and "string" in POSIX is defined
+   as a sequence of bytes, not of characters.  */
+# undef strstr
+/* Assume strstr is always declared.  */
+_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
+                 "work correctly on character strings in most "
+                 "multibyte locales - "
+                 "use mbsstr if you care about internationalization, "
+                 "or use strstr if you care about speed");
+#endif
+
+/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
+   comparison.  */
+#if @GNULIB_STRCASESTR@
+# if @REPLACE_STRCASESTR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strcasestr rpl_strcasestr
+#  endif
+_GL_FUNCDECL_RPL (strcasestr, char *,
+                  (const char *haystack, const char *needle)
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strcasestr, char *,
+                  (const char *haystack, const char *needle));
+# else
+#  if ! @HAVE_STRCASESTR@
+_GL_FUNCDECL_SYS (strcasestr, char *,
+                  (const char *haystack, const char *needle)
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+  /* On some systems, this function is defined as an overloaded function:
+       extern "C++" { const char * strcasestr (const char *, const char *); }
+       extern "C++" { char * strcasestr (char *, const char *); }  */
+_GL_CXXALIAS_SYS_CAST2 (strcasestr,
+                        char *, (const char *haystack, const char *needle),
+                        const char *, (const char *haystack, const char *needle));
+# endif
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
+_GL_CXXALIASWARN1 (strcasestr, const char *,
+                   (const char *haystack, const char *needle));
+# else
+_GL_CXXALIASWARN (strcasestr);
+# endif
+#elif defined GNULIB_POSIXCHECK
+/* strcasestr() does not work with multibyte strings:
+   It is a glibc extension, and glibc implements it only for unibyte
+   locales.  */
+# undef strcasestr
+# if HAVE_RAW_DECL_STRCASESTR
+_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
+                 "strings in multibyte locales - "
+                 "use mbscasestr if you care about "
+                 "internationalization, or use c-strcasestr if you want "
+                 "a locale independent function");
+# endif
+#endif
+
+/* Parse S into tokens separated by characters in DELIM.
+   If S is NULL, the saved pointer in SAVE_PTR is used as
+   the next starting point.  For example:
+        char s[] = "-abc-=-def";
+        char *sp;
+        x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
+        x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
+        x = strtok_r(NULL, "=", &sp);   // x = NULL
+                // s = "abc\0-def\0"
+
+   This is a variant of strtok() that is multithread-safe.
+
+   For the POSIX documentation for this function, see:
+   http://www.opengroup.org/susv3xsh/strtok.html
+
+   Caveat: It modifies the original string.
+   Caveat: These functions cannot be used on constant strings.
+   Caveat: The identity of the delimiting character is lost.
+   Caveat: It doesn't work with multibyte strings unless all of the delimiter
+           characters are ASCII characters < 0x30.
+
+   See also strsep().  */
+#if @GNULIB_STRTOK_R@
+# if @REPLACE_STRTOK_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strtok_r
+#   define strtok_r rpl_strtok_r
+#  endif
+_GL_FUNCDECL_RPL (strtok_r, char *,
+                  (char *restrict s, char const *restrict delim,
+                   char **restrict save_ptr)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (strtok_r, char *,
+                  (char *restrict s, char const *restrict delim,
+                   char **restrict save_ptr));
+# else
+#  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK
+#   undef strtok_r
+#  endif
+#  if ! @HAVE_DECL_STRTOK_R@
+_GL_FUNCDECL_SYS (strtok_r, char *,
+                  (char *restrict s, char const *restrict delim,
+                   char **restrict save_ptr)
+                  _GL_ARG_NONNULL ((2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (strtok_r, char *,
+                  (char *restrict s, char const *restrict delim,
+                   char **restrict save_ptr));
+# endif
+_GL_CXXALIASWARN (strtok_r);
+# if defined GNULIB_POSIXCHECK
+_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
+                 "strings in multibyte locales - "
+                 "use mbstok_r if you care about internationalization");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtok_r
+# if HAVE_RAW_DECL_STRTOK_R
+_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
+                 "use gnulib module strtok_r for portability");
+# endif
+#endif
+
+
+/* The following functions are not specified by POSIX.  They are gnulib
+   extensions.  */
+
+#if @GNULIB_MBSLEN@
+/* Return the number of multibyte characters in the character string STRING.
+   This considers multibyte characters, unlike strlen, which counts bytes.  */
+# ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */
+#  undef mbslen
+# endif
+# if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mbslen rpl_mbslen
+#  endif
+_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
+# else
+_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
+# endif
+_GL_CXXALIASWARN (mbslen);
+#endif
+
+#if @GNULIB_MBSNLEN@
+/* Return the number of multibyte characters in the character string starting
+   at STRING and ending at STRING + LEN.  */
+_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
+     _GL_ARG_NONNULL ((1));
+#endif
+
+#if @GNULIB_MBSCHR@
+/* Locate the first single-byte character C in the character string STRING,
+   and return a pointer to it.  Return NULL if C is not found in STRING.
+   Unlike strchr(), this function works correctly in multibyte locales with
+   encodings such as GB18030.  */
+# if defined __hpux
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mbschr rpl_mbschr /* avoid collision with HP-UX function */
+#  endif
+_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
+                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
+                                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbschr);
+#endif
+
+#if @GNULIB_MBSRCHR@
+/* Locate the last single-byte character C in the character string STRING,
+   and return a pointer to it.  Return NULL if C is not found in STRING.
+   Unlike strrchr(), this function works correctly in multibyte locales with
+   encodings such as GB18030.  */
+# if defined __hpux
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
+#  endif
+_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
+# else
+_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
+# endif
+_GL_CXXALIASWARN (mbsrchr);
+#endif
+
+#if @GNULIB_MBSSTR@
+/* Find the first occurrence of the character string NEEDLE in the character
+   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
+   Unlike strstr(), this function works correctly in multibyte locales with
+   encodings different from UTF-8.  */
+_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCASECMP@
+/* Compare the character strings S1 and S2, ignoring case, returning less than,
+   equal to or greater than zero if S1 is lexicographically less than, equal to
+   or greater than S2.
+   Note: This function may, in multibyte locales, return 0 for strings of
+   different lengths!
+   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
+_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSNCASECMP@
+/* Compare the initial segment of the character string S1 consisting of at most
+   N characters with the initial segment of the character string S2 consisting
+   of at most N characters, ignoring case, returning less than, equal to or
+   greater than zero if the initial segment of S1 is lexicographically less
+   than, equal to or greater than the initial segment of S2.
+   Note: This function may, in multibyte locales, return 0 for initial segments
+   of different lengths!
+   Unlike strncasecmp(), this function works correctly in multibyte locales.
+   But beware that N is not a byte count but a character count!  */
+_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSPCASECMP@
+/* Compare the initial segment of the character string STRING consisting of
+   at most mbslen (PREFIX) characters with the character string PREFIX,
+   ignoring case.  If the two match, return a pointer to the first byte
+   after this prefix in STRING.  Otherwise, return NULL.
+   Note: This function may, in multibyte locales, return non-NULL if STRING
+   is of smaller length than PREFIX!
+   Unlike strncasecmp(), this function works correctly in multibyte
+   locales.  */
+_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCASESTR@
+/* Find the first occurrence of the character string NEEDLE in the character
+   string HAYSTACK, using case-insensitive comparison.
+   Note: This function may, in multibyte locales, return success even if
+   strlen (haystack) < strlen (needle) !
+   Unlike strcasestr(), this function works correctly in multibyte locales.  */
+_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSCSPN@
+/* Find the first occurrence in the character string STRING of any character
+   in the character string ACCEPT.  Return the number of bytes from the
+   beginning of the string to this occurrence, or to the end of the string
+   if none exists.
+   Unlike strcspn(), this function works correctly in multibyte locales.  */
+_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSPBRK@
+/* Find the first occurrence in the character string STRING of any character
+   in the character string ACCEPT.  Return the pointer to it, or NULL if none
+   exists.
+   Unlike strpbrk(), this function works correctly in multibyte locales.  */
+# if defined __hpux
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
+#  endif
+_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
+                                   _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
+# else
+_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
+                                   _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
+# endif
+_GL_CXXALIASWARN (mbspbrk);
+#endif
+
+#if @GNULIB_MBSSPN@
+/* Find the first occurrence in the character string STRING of any character
+   not in the character string REJECT.  Return the number of bytes from the
+   beginning of the string to this occurrence, or to the end of the string
+   if none exists.
+   Unlike strspn(), this function works correctly in multibyte locales.  */
+_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSSEP@
+/* Search the next delimiter (multibyte character listed in the character
+   string DELIM) starting at the character string *STRINGP.
+   If one is found, overwrite it with a NUL, and advance *STRINGP to point
+   to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
+   If *STRINGP was already NULL, nothing happens.
+   Return the old value of *STRINGP.
+
+   This is a variant of mbstok_r() that supports empty fields.
+
+   Caveat: It modifies the original string.
+   Caveat: These functions cannot be used on constant strings.
+   Caveat: The identity of the delimiting character is lost.
+
+   See also mbstok_r().  */
+_GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
+     _GL_ARG_NONNULL ((1, 2));
+#endif
+
+#if @GNULIB_MBSTOK_R@
+/* Parse the character string STRING into tokens separated by characters in
+   the character string DELIM.
+   If STRING is NULL, the saved pointer in SAVE_PTR is used as
+   the next starting point.  For example:
+        char s[] = "-abc-=-def";
+        char *sp;
+        x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
+        x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
+        x = mbstok_r(NULL, "=", &sp);   // x = NULL
+                // s = "abc\0-def\0"
+
+   Caveat: It modifies the original string.
+   Caveat: These functions cannot be used on constant strings.
+   Caveat: The identity of the delimiting character is lost.
+
+   See also mbssep().  */
+_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr)
+     _GL_ARG_NONNULL ((2, 3));
+#endif
+
+/* Map any int, typically from errno, into an error message.  */
+#if @GNULIB_STRERROR@
+# if @REPLACE_STRERROR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strerror
+#   define strerror rpl_strerror
+#  endif
+_GL_FUNCDECL_RPL (strerror, char *, (int));
+_GL_CXXALIAS_RPL (strerror, char *, (int));
+# else
+_GL_CXXALIAS_SYS (strerror, char *, (int));
+# endif
+_GL_CXXALIASWARN (strerror);
+#elif defined GNULIB_POSIXCHECK
+# undef strerror
+/* Assume strerror is always declared.  */
+_GL_WARN_ON_USE (strerror, "strerror is unportable - "
+                 "use gnulib module strerror to guarantee non-NULL result");
+#endif
+
+/* Map any int, typically from errno, into an error message.  Multithread-safe.
+   Uses the POSIX declaration, not the glibc declaration.  */
+#if @GNULIB_STRERROR_R@
+# if @REPLACE_STRERROR_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef strerror_r
+#   define strerror_r rpl_strerror_r
+#  endif
+_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
+                                   _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# else
+#  if !@HAVE_DECL_STRERROR_R@
+_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
+                                   _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
+# endif
+# if @HAVE_DECL_STRERROR_R@
+_GL_CXXALIASWARN (strerror_r);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strerror_r
+# if HAVE_RAW_DECL_STRERROR_R
+_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
+                 "use gnulib module strerror_r-posix for portability");
+# endif
+#endif
+
+#if @GNULIB_STRSIGNAL@
+# if @REPLACE_STRSIGNAL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strsignal rpl_strsignal
+#  endif
+_GL_FUNCDECL_RPL (strsignal, char *, (int __sig));
+_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
+# else
+#  if ! @HAVE_DECL_STRSIGNAL@
+_GL_FUNCDECL_SYS (strsignal, char *, (int __sig));
+#  endif
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is
+   'const char *'.  */
+_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
+# endif
+_GL_CXXALIASWARN (strsignal);
+#elif defined GNULIB_POSIXCHECK
+# undef strsignal
+# if HAVE_RAW_DECL_STRSIGNAL
+_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
+                 "use gnulib module strsignal for portability");
+# endif
+#endif
+
+#if @GNULIB_STRVERSCMP@
+# if !@HAVE_STRVERSCMP@
+_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
+                                   _GL_ARG_NONNULL ((1, 2)));
+# endif
+_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
+_GL_CXXALIASWARN (strverscmp);
+#elif defined GNULIB_POSIXCHECK
+# undef strverscmp
+# if HAVE_RAW_DECL_STRVERSCMP
+_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
+                 "use gnulib module strverscmp for portability");
+# endif
+#endif
+
+
+#endif /* _GL_STRING_H */
+#endif /* _GL_STRING_H */
diff --git a/gnulib/lib/strndup.c b/gnulib/lib/strndup.c
new file mode 100644 (file)
index 0000000..06c6b84
--- /dev/null
@@ -0,0 +1,37 @@
+/* A replacement function, for systems that lack strndup.
+
+   Copyright (C) 1996-1998, 2001-2003, 2005-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 Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <stdlib.h>
+
+char *
+strndup (char const *s, size_t n)
+{
+  size_t len = strnlen (s, n);
+  char *new = malloc (len + 1);
+
+  if (new == NULL)
+    return NULL;
+
+  new[len] = '\0';
+  return memcpy (new, s, len);
+}
diff --git a/gnulib/lib/strnlen.c b/gnulib/lib/strnlen.c
new file mode 100644 (file)
index 0000000..44f7b45
--- /dev/null
@@ -0,0 +1,31 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+   Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+#include <string.h>
+
+/* Find the length of STRING, but scan at most MAXLEN characters.
+   If no '\0' terminator is found in that many characters, return MAXLEN.  */
+
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+  const char *end = memchr (string, '\0', maxlen);
+  return end ? (size_t) (end - string) : maxlen;
+}
diff --git a/gnulib/lib/strnlen1.c b/gnulib/lib/strnlen1.c
new file mode 100644 (file)
index 0000000..299bd65
--- /dev/null
@@ -0,0 +1,35 @@
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+   Copyright (C) 2005-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "strnlen1.h"
+
+#include <string.h>
+
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+   If no '\0' terminator is found in that many characters, return MAXLEN.  */
+/* This is the same as strnlen (string, maxlen - 1) + 1.  */
+size_t
+strnlen1 (const char *string, size_t maxlen)
+{
+  const char *end = (const char *) memchr (string, '\0', maxlen);
+  if (end != NULL)
+    return end - string + 1;
+  else
+    return maxlen;
+}
diff --git a/gnulib/lib/strnlen1.h b/gnulib/lib/strnlen1.h
new file mode 100644 (file)
index 0000000..cb0f756
--- /dev/null
@@ -0,0 +1,39 @@
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+   Copyright (C) 2005, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _STRNLEN1_H
+#define _STRNLEN1_H
+
+#include <stddef.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
+   If no '\0' terminator is found in that many characters, return MAXLEN.  */
+/* This is the same as strnlen (string, maxlen - 1) + 1.  */
+extern size_t strnlen1 (const char *string, size_t maxlen);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _STRNLEN1_H */
diff --git a/gnulib/lib/strstr.c b/gnulib/lib/strstr.c
new file mode 100644 (file)
index 0000000..65d69e0
--- /dev/null
@@ -0,0 +1,83 @@
+/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2011 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This particular implementation was written by Eric Blake, 2008.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Specification of strstr.  */
+#include <string.h>
+
+#include <stdbool.h>
+
+#ifndef _LIBC
+# define __builtin_expect(expr, val)   (expr)
+#endif
+
+#define RETURN_TYPE char *
+#define AVAILABLE(h, h_l, j, n_l)                       \
+  (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l))     \
+   && ((h_l) = (j) + (n_l)))
+#include "str-two-way.h"
+
+/* Return the first occurrence of NEEDLE in HAYSTACK.  Return HAYSTACK
+   if NEEDLE is empty, otherwise NULL if NEEDLE is not found in
+   HAYSTACK.  */
+char *
+strstr (const char *haystack_start, const char *needle_start)
+{
+  const char *haystack = haystack_start;
+  const char *needle = needle_start;
+  size_t needle_len; /* Length of NEEDLE.  */
+  size_t haystack_len; /* Known minimum length of HAYSTACK.  */
+  bool ok = true; /* True if NEEDLE is prefix of HAYSTACK.  */
+
+  /* Determine length of NEEDLE, and in the process, make sure
+     HAYSTACK is at least as long (no point processing all of a long
+     NEEDLE if HAYSTACK is too short).  */
+  while (*haystack && *needle)
+    ok &= *haystack++ == *needle++;
+  if (*needle)
+    return NULL;
+  if (ok)
+    return (char *) haystack_start;
+
+  /* Reduce the size of haystack using strchr, since it has a smaller
+     linear coefficient than the Two-Way algorithm.  */
+  needle_len = needle - needle_start;
+  haystack = strchr (haystack_start + 1, *needle_start);
+  if (!haystack || __builtin_expect (needle_len == 1, 0))
+    return (char *) haystack;
+  needle -= needle_len;
+  haystack_len = (haystack > haystack_start + needle_len ? 1
+                  : needle_len + haystack_start - haystack);
+
+  /* Perform the search.  Abstract memory is considered to be an array
+     of 'unsigned char' values, not an array of 'char' values.  See
+     ISO C 99 section 6.2.6.1.  */
+  if (needle_len < LONG_NEEDLE_THRESHOLD)
+    return two_way_short_needle ((const unsigned char *) haystack,
+                                 haystack_len,
+                                 (const unsigned char *) needle, needle_len);
+  return two_way_long_needle ((const unsigned char *) haystack, haystack_len,
+                              (const unsigned char *) needle, needle_len);
+}
+
+#undef LONG_NEEDLE_THRESHOLD
diff --git a/gnulib/lib/sys_stat.in.h b/gnulib/lib/sys_stat.in.h
new file mode 100644 (file)
index 0000000..0ce19ed
--- /dev/null
@@ -0,0 +1,646 @@
+/* Provide a more complete sys/stat header file.
+   Copyright (C) 2005-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
+
+/* This file is supposed to be used on platforms where <sys/stat.h> is
+   incomplete.  It is intended to provide definitions and prototypes
+   needed by an application.  Start with what the system provides.  */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_system_sys_stat_h
+/* Special invocation convention.  */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _GL_SYS_STAT_H
+
+/* Get nlink_t.  */
+#include <sys/types.h>
+
+/* Get struct timespec.  */
+#include <time.h>
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
+
+#ifndef _GL_SYS_STAT_H
+#define _GL_SYS_STAT_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
+   headers that may declare mkdir().  */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# include <io.h>     /* mingw32, mingw64 */
+# include <direct.h> /* mingw64 */
+#endif
+
+#ifndef S_IFMT
+# define S_IFMT 0170000
+#endif
+
+#if STAT_MACROS_BROKEN
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISLNK
+# undef S_ISNAM
+# undef S_ISMPB
+# undef S_ISMPC
+# undef S_ISNWK
+# undef S_ISREG
+# undef S_ISSOCK
+#endif
+
+#ifndef S_ISBLK
+# ifdef S_IFBLK
+#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+# else
+#  define S_ISBLK(m) 0
+# endif
+#endif
+
+#ifndef S_ISCHR
+# ifdef S_IFCHR
+#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+# else
+#  define S_ISCHR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDIR
+# ifdef S_IFDIR
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# else
+#  define S_ISDIR(m) 0
+# endif
+#endif
+
+#ifndef S_ISDOOR /* Solaris 2.5 and up */
+# define S_ISDOOR(m) 0
+#endif
+
+#ifndef S_ISFIFO
+# ifdef S_IFIFO
+#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+# else
+#  define S_ISFIFO(m) 0
+# endif
+#endif
+
+#ifndef S_ISLNK
+# ifdef S_IFLNK
+#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+#  define S_ISLNK(m) 0
+# endif
+#endif
+
+#ifndef S_ISMPB /* V7 */
+# ifdef S_IFMPB
+#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+# else
+#  define S_ISMPB(m) 0
+#  define S_ISMPC(m) 0
+# endif
+#endif
+
+#ifndef S_ISNAM /* Xenix */
+# ifdef S_IFNAM
+#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
+# else
+#  define S_ISNAM(m) 0
+# endif
+#endif
+
+#ifndef S_ISNWK /* HP/UX */
+# ifdef S_IFNWK
+#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+# else
+#  define S_ISNWK(m) 0
+# endif
+#endif
+
+#ifndef S_ISPORT /* Solaris 10 and up */
+# define S_ISPORT(m) 0
+#endif
+
+#ifndef S_ISREG
+# ifdef S_IFREG
+#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# else
+#  define S_ISREG(m) 0
+# endif
+#endif
+
+#ifndef S_ISSOCK
+# ifdef S_IFSOCK
+#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+# else
+#  define S_ISSOCK(m) 0
+# endif
+#endif
+
+
+#ifndef S_TYPEISMQ
+# define S_TYPEISMQ(p) 0
+#endif
+
+#ifndef S_TYPEISTMO
+# define S_TYPEISTMO(p) 0
+#endif
+
+
+#ifndef S_TYPEISSEM
+# ifdef S_INSEM
+#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
+# else
+#  define S_TYPEISSEM(p) 0
+# endif
+#endif
+
+#ifndef S_TYPEISSHM
+# ifdef S_INSHD
+#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
+# else
+#  define S_TYPEISSHM(p) 0
+# endif
+#endif
+
+/* high performance ("contiguous data") */
+#ifndef S_ISCTG
+# define S_ISCTG(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with data  */
+#ifndef S_ISOFD
+# define S_ISOFD(p) 0
+#endif
+
+/* Cray DMF (data migration facility): off line, with no data  */
+#ifndef S_ISOFL
+# define S_ISOFL(p) 0
+#endif
+
+/* 4.4BSD whiteout */
+#ifndef S_ISWHT
+# define S_ISWHT(m) 0
+#endif
+
+/* If any of the following are undefined,
+   define them to their de facto standard values.  */
+#if !S_ISUID
+# define S_ISUID 04000
+#endif
+#if !S_ISGID
+# define S_ISGID 02000
+#endif
+
+/* S_ISVTX is a common extension to POSIX.  */
+#ifndef S_ISVTX
+# define S_ISVTX 01000
+#endif
+
+#if !S_IRUSR && S_IREAD
+# define S_IRUSR S_IREAD
+#endif
+#if !S_IRUSR
+# define S_IRUSR 00400
+#endif
+#if !S_IRGRP
+# define S_IRGRP (S_IRUSR >> 3)
+#endif
+#if !S_IROTH
+# define S_IROTH (S_IRUSR >> 6)
+#endif
+
+#if !S_IWUSR && S_IWRITE
+# define S_IWUSR S_IWRITE
+#endif
+#if !S_IWUSR
+# define S_IWUSR 00200
+#endif
+#if !S_IWGRP
+# define S_IWGRP (S_IWUSR >> 3)
+#endif
+#if !S_IWOTH
+# define S_IWOTH (S_IWUSR >> 6)
+#endif
+
+#if !S_IXUSR && S_IEXEC
+# define S_IXUSR S_IEXEC
+#endif
+#if !S_IXUSR
+# define S_IXUSR 00100
+#endif
+#if !S_IXGRP
+# define S_IXGRP (S_IXUSR >> 3)
+#endif
+#if !S_IXOTH
+# define S_IXOTH (S_IXUSR >> 6)
+#endif
+
+#if !S_IRWXU
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+#endif
+#if !S_IRWXG
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+#endif
+#if !S_IRWXO
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+#endif
+
+/* S_IXUGO is a common extension to POSIX.  */
+#if !S_IXUGO
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+#endif
+
+#ifndef S_IRWXUGO
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
+#endif
+
+/* Macros for futimens and utimensat.  */
+#ifndef UTIME_NOW
+# define UTIME_NOW (-1)
+# define UTIME_OMIT (-2)
+#endif
+
+
+#if @GNULIB_FCHMODAT@
+# if !@HAVE_FCHMODAT@
+_GL_FUNCDECL_SYS (fchmodat, int,
+                  (int fd, char const *file, mode_t mode, int flag)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (fchmodat, int,
+                  (int fd, char const *file, mode_t mode, int flag));
+_GL_CXXALIASWARN (fchmodat);
+#elif defined GNULIB_POSIXCHECK
+# undef fchmodat
+# if HAVE_RAW_DECL_FCHMODAT
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @REPLACE_FSTAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  define fstat rpl_fstat
+# endif
+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
+#else
+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
+#endif
+_GL_CXXALIASWARN (fstat);
+
+
+#if @GNULIB_FSTATAT@
+# if @REPLACE_FSTATAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fstatat
+#   define fstatat rpl_fstatat
+#  endif
+_GL_FUNCDECL_RPL (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags)
+                  _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags));
+# else
+#  if !@HAVE_FSTATAT@
+_GL_FUNCDECL_SYS (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags)
+                  _GL_ARG_NONNULL ((2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (fstatat, int,
+                  (int fd, char const *name, struct stat *st, int flags));
+# endif
+_GL_CXXALIASWARN (fstatat);
+#elif defined GNULIB_POSIXCHECK
+# undef fstatat
+# if HAVE_RAW_DECL_FSTATAT
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FUTIMENS@
+# if @REPLACE_FUTIMENS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef futimens
+#   define futimens rpl_futimens
+#  endif
+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
+# else
+#  if !@HAVE_FUTIMENS@
+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
+#  endif
+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
+# endif
+_GL_CXXALIASWARN (futimens);
+#elif defined GNULIB_POSIXCHECK
+# undef futimens
+# if HAVE_RAW_DECL_FUTIMENS
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
+                 "use gnulib module futimens for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LCHMOD@
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
+   denotes a symbolic link.  */
+# if !@HAVE_LCHMOD@
+/* The lchmod replacement follows symbolic links.  Callers should take
+   this into account; lchmod should be applied only to arguments that
+   are known to not be symbolic links.  On hosts that lack lchmod,
+   this can lead to race conditions between the check and the
+   invocation of lchmod, but we know of no workarounds that are
+   reliable in general.  You might try requesting support for lchmod
+   from your operating system supplier.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lchmod chmod
+#  endif
+/* Need to cast, because on mingw, the second parameter of chmod is
+                                                int mode.  */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+                         (const char *filename, mode_t mode));
+# else
+#  if 0 /* assume already declared */
+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
+# endif
+# if @HAVE_LCHMOD@
+_GL_CXXALIASWARN (lchmod);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchmod
+# if HAVE_RAW_DECL_LCHMOD
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
+                 "use gnulib module lchmod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
+/* mingw does not support symlinks, therefore it does not have lstat.  But
+   without links, stat does just fine.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lstat stat
+#  endif
+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
+# elif @REPLACE_LSTAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef lstat
+#   define lstat rpl_lstat
+#  endif
+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
+                              _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
+# else
+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
+# endif
+# if @HAVE_LSTAT@
+_GL_CXXALIASWARN (lstat);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+                 "use gnulib module lstat for portability");
+# endif
+#endif
+
+
+#if @REPLACE_MKDIR@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  undef mkdir
+#  define mkdir rpl_mkdir
+# endif
+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+#else
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
+   Additionally, it declares _mkdir (and depending on compile flags, an
+   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+   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
+#  endif
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
+# else
+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
+# endif
+#endif
+_GL_CXXALIASWARN (mkdir);
+
+
+#if @GNULIB_MKDIRAT@
+# if !@HAVE_MKDIRAT@
+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
+                                _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkdirat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkdirat
+# if HAVE_RAW_DECL_MKDIRAT
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFO@
+# if @REPLACE_MKFIFO@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mkfifo
+#   define mkfifo rpl_mkfifo
+#  endif
+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
+# else
+#  if !@HAVE_MKFIFO@
+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
+# endif
+_GL_CXXALIASWARN (mkfifo);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifo
+# if HAVE_RAW_DECL_MKFIFO
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
+                 "use gnulib module mkfifo for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKFIFOAT@
+# if !@HAVE_MKFIFOAT@
+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
+                                 _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
+_GL_CXXALIASWARN (mkfifoat);
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifoat
+# if HAVE_RAW_DECL_MKFIFOAT
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
+                 "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNOD@
+# if @REPLACE_MKNOD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mknod
+#   define mknod rpl_mknod
+#  endif
+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# else
+#  if !@HAVE_MKNOD@
+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
+                              _GL_ARG_NONNULL ((1)));
+#  endif
+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
+# endif
+_GL_CXXALIASWARN (mknod);
+#elif defined GNULIB_POSIXCHECK
+# undef mknod
+# if HAVE_RAW_DECL_MKNOD
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
+                 "use gnulib module mknod for portability");
+# endif
+#endif
+
+
+#if @GNULIB_MKNODAT@
+# if !@HAVE_MKNODAT@
+_GL_FUNCDECL_SYS (mknodat, int,
+                  (int fd, char const *file, mode_t mode, dev_t dev)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (mknodat, int,
+                  (int fd, char const *file, mode_t mode, dev_t dev));
+_GL_CXXALIASWARN (mknodat);
+#elif defined GNULIB_POSIXCHECK
+# undef mknodat
+# if HAVE_RAW_DECL_MKNODAT
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
+                 "use gnulib module mkfifoat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_STAT@
+# if @REPLACE_STAT@
+/* We can't use the object-like #define stat rpl_stat, because of
+   struct stat.  This means that rpl_stat will not be used if the user
+   does (stat)(a,b).  Oh well.  */
+#  undef stat
+#  ifdef _LARGE_FILES
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+       so we have to replace stat64() instead of stat(). */
+#   define stat stat64
+#   undef stat64
+#   define stat64(name, st) rpl_stat (name, st)
+#  else /* !_LARGE_FILES */
+#   define stat(name, st) rpl_stat (name, st)
+#  endif /* !_LARGE_FILES */
+_GL_EXTERN_C int stat (const char *name, struct stat *buf)
+                      _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef stat
+# if HAVE_RAW_DECL_STAT
+_GL_WARN_ON_USE (stat, "stat is unportable - "
+                 "use gnulib module stat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UTIMENSAT@
+# if @REPLACE_UTIMENSAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef utimensat
+#   define utimensat rpl_utimensat
+#  endif
+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag)
+                                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag));
+# else
+#  if !@HAVE_UTIMENSAT@
+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag)
+                                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
+                                   struct timespec const times[2], int flag));
+# endif
+_GL_CXXALIASWARN (utimensat);
+#elif defined GNULIB_POSIXCHECK
+# undef utimensat
+# if HAVE_RAW_DECL_UTIMENSAT
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
+                 "use gnulib module utimensat for portability");
+# endif
+#endif
+
+
+#endif /* _GL_SYS_STAT_H */
+#endif /* _GL_SYS_STAT_H */
+#endif
diff --git a/gnulib/lib/sys_wait.in.h b/gnulib/lib/sys_wait.in.h
new file mode 100644 (file)
index 0000000..91d5bfa
--- /dev/null
@@ -0,0 +1,130 @@
+/* A POSIX-like <sys/wait.h>.
+   Copyright (C) 2001-2003, 2005-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+
+#ifndef _GL_SYS_WAIT_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard.  */
+#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
+#endif
+
+#ifndef _GL_SYS_WAIT_H
+#define _GL_SYS_WAIT_H
+
+/* Get pid_t.  */
+#include <sys/types.h>
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+/* Unix API.  */
+
+/* The following macros apply to an argument x, that is a status of a process,
+   as returned by waitpid().
+   On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
+   WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs
+   have to use the abstract macros.  */
+
+/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
+   is true.  */
+# ifndef WIFSIGNALED
+#  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
+# endif
+# ifndef WIFEXITED
+#  define WIFEXITED(x) (WTERMSIG (x) == 0)
+# endif
+# ifndef WIFSTOPPED
+#  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
+# endif
+
+/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */
+# ifndef WTERMSIG
+#  define WTERMSIG(x) ((x) & 0x7f)
+# endif
+
+/* The exit status. Only to be accessed if WIFEXITED(x) is true.  */
+# ifndef WEXITSTATUS
+#  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
+# endif
+
+/* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true.  */
+# ifndef WSTOPSIG
+#  define WSTOPSIG(x) (((x) >> 8) & 0x7f)
+# endif
+
+/* True if the process dumped core.  Not standardized by POSIX.  */
+# ifndef WCOREDUMP
+#  define WCOREDUMP(x) ((x) & 0x80)
+# endif
+
+#else
+/* Native Windows API.  */
+
+# include <signal.h> /* for SIGTERM */
+
+/* The following macros apply to an argument x, that is a status of a process,
+   as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
+   This value is simply an 'int', not composed of bit fields.  */
+
+/* When an unhandled fatal signal terminates a process, the exit code is 3.  */
+# define WIFSIGNALED(x) ((x) == 3)
+# define WIFEXITED(x) ((x) != 3)
+# define WIFSTOPPED(x) 0
+
+/* The signal that terminated a process is not known posthum.  */
+# define WTERMSIG(x) SIGTERM
+
+# define WEXITSTATUS(x) (x)
+
+/* There are no stopping signals.  */
+# define WSTOPSIG(x) 0
+
+/* There are no core dumps.  */
+# define WCOREDUMP(x) 0
+
+#endif
+
+
+/* Declarations of functions.  */
+
+#if @GNULIB_WAITPID@
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+# endif
+_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
+_GL_CXXALIASWARN (waitpid);
+#elif defined GNULIB_POSIXCHECK
+# undef waitpid
+# if HAVE_RAW_DECL_WAITPID
+_GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
+                 "use gnulib module sys_wait for portability");
+# endif
+#endif
+
+
+#endif /* _GL_SYS_WAIT_H */
+#endif /* _GL_SYS_WAIT_H */
diff --git a/gnulib/lib/time.in.h b/gnulib/lib/time.in.h
new file mode 100644 (file)
index 0000000..8c17915
--- /dev/null
@@ -0,0 +1,249 @@
+/* A more-standard <time.h>.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Don't get in the way of glibc when it includes time.h merely to
+   declare a few standard symbols, rather than to declare all the
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
+   recursively; if that is happening, just include the system <time.h>
+   without adding our own declarations.  */
+#if (defined __need_time_t || defined __need_clock_t \
+     || defined __need_timespec \
+     || defined _GL_TIME_H)
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+#else
+
+# define _GL_TIME_H
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+/* NetBSD 5.0 mis-defines NULL.  */
+# include <stddef.h>
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
+   Or they define it with the wrong member names or define it in <sys/time.h>
+   (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
+   pthreads-win32 library defines it in <pthread.h>.  */
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+#   include <sys/time.h>
+#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+#   include <pthread.h>
+/* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
+#   undef asctime_r
+#   undef ctime_r
+#   undef gmtime_r
+#   undef localtime_r
+#   undef rand_r
+#   undef strtok_r
+#  else
+
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+
+#   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
+}
+#   endif
+
+#  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
+   point, and it is much easier to write code that doesn't have to
+   worry about that corner case, so we force the issue.  */
+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
+   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
+# if @GNULIB_NANOSLEEP@
+#  if @REPLACE_NANOSLEEP@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define nanosleep rpl_nanosleep
+#   endif
+_GL_FUNCDECL_RPL (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
+#  else
+#   if ! @HAVE_NANOSLEEP@
+_GL_FUNCDECL_SYS (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
+                  _GL_ARG_NONNULL ((1)));
+#   endif
+_GL_CXXALIAS_SYS (nanosleep, int,
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
+#  endif
+_GL_CXXALIASWARN (nanosleep);
+# endif
+
+/* Return the 'time_t' representation of TP and normalize TP.  */
+# if @GNULIB_MKTIME@
+#  if @REPLACE_MKTIME@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define mktime rpl_mktime
+#   endif
+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
+#  else
+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
+#  endif
+_GL_CXXALIASWARN (mktime);
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
+   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
+   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
+# if @GNULIB_TIME_R@
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef localtime_r
+#    define localtime_r rpl_localtime_r
+#   endif
+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result)
+                                            _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result));
+#  else
+#   if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result)
+                                            _GL_ARG_NONNULL ((1, 2)));
+#   endif
+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+                                             struct tm *restrict __result));
+#  endif
+#  if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (localtime_r);
+#  endif
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef gmtime_r
+#    define gmtime_r rpl_gmtime_r
+#   endif
+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result)
+                                         _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result));
+#  else
+#   if ! @HAVE_DECL_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result)
+                                         _GL_ARG_NONNULL ((1, 2)));
+#   endif
+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+                                          struct tm *restrict __result));
+#  endif
+#  if @HAVE_DECL_LOCALTIME_R@
+_GL_CXXALIASWARN (gmtime_r);
+#  endif
+# endif
+
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
+   the resulting broken-down time into TM.  See
+   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
+# if @GNULIB_STRPTIME@
+#  if ! @HAVE_STRPTIME@
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
+                                     char const *restrict __format,
+                                     struct tm *restrict __tm)
+                                    _GL_ARG_NONNULL ((1, 2, 3)));
+#  endif
+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
+                                     char const *restrict __format,
+                                     struct tm *restrict __tm));
+_GL_CXXALIASWARN (strptime);
+# endif
+
+/* Convert TM to a time_t value, assuming UTC.  */
+# if @GNULIB_TIMEGM@
+#  if @REPLACE_TIMEGM@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef timegm
+#    define timegm rpl_timegm
+#   endif
+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
+#  else
+#   if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+#   endif
+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
+#  endif
+_GL_CXXALIASWARN (timegm);
+# endif
+
+/* Encourage applications to avoid unsafe functions that can overrun
+   buffers when given outlandish struct tm values.  Portable
+   applications should use strftime (or even sprintf) instead.  */
+# if defined GNULIB_POSIXCHECK
+#  undef asctime
+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef asctime_r
+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef ctime
+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+# if defined GNULIB_POSIXCHECK
+#  undef ctime_r
+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
+                 "better use strftime (or even sprintf) instead");
+# endif
+
+#endif
diff --git a/gnulib/lib/unistd.in.h b/gnulib/lib/unistd.in.h
new file mode 100644 (file)
index 0000000..1713c33
--- /dev/null
@@ -0,0 +1,1381 @@
+/* Substitute for and wrapper around <unistd.h>.
+   Copyright (C) 2003-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Special invocation convention:
+   - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
+     but we need to ensure that both the system <unistd.h> and <winsock2.h>
+     are completely included before we replace gethostname.  */
+#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
+  && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
+/* <unistd.h> is being indirectly included for the first time from
+   <winsock2.h>; avoid declaring any overrides.  */
+# if @HAVE_UNISTD_H@
+#  @INCLUDE_NEXT@ @NEXT_UNISTD_H@
+# else
+#  error unexpected; report this to bug-gnulib@gnu.org
+# endif
+# define _GL_WINSOCK2_H_WITNESS
+
+/* Normal invocation.  */
+#elif !defined _GL_UNISTD_H
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_UNISTD_H@
+# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
+#endif
+
+/* Get all possible declarations of gethostname().  */
+#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
+  && !defined _GL_INCLUDING_WINSOCK2_H
+# define _GL_INCLUDING_WINSOCK2_H
+# include <winsock2.h>
+# undef _GL_INCLUDING_WINSOCK2_H
+#endif
+
+#if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
+#define _GL_UNISTD_H
+
+/* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
+#include <stddef.h>
+
+/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
+/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
+     || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
+         && defined __CYGWIN__)) \
+    && ! defined __GLIBC__
+# include <stdio.h>
+#endif
+
+/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
+    && ! defined __GLIBC__
+# include <fcntl.h>
+#endif
+
+/* mingw fails to declare _exit in <unistd.h>.  */
+/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
+/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* mingw declares getcwd in <io.h>, not in <unistd.h>.  */
+#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
+     && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# include <io.h>
+#endif
+
+/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
+   NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
+     || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
+    && !defined __GLIBC__
+# include <netdb.h>
+#endif
+
+#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
+     || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
+/* Get ssize_t.  */
+# include <sys/types.h>
+#endif
+
+/* Get getopt(), optarg, optind, opterr, optopt.
+   But avoid namespace pollution on glibc systems.  */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
+# include <getopt.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+#if @GNULIB_GETHOSTNAME@
+/* Get all possible declarations of gethostname().  */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+#  if !defined _GL_SYS_SOCKET_H
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef socket
+#    define socket              socket_used_without_including_sys_socket_h
+#    undef connect
+#    define connect             connect_used_without_including_sys_socket_h
+#    undef accept
+#    define accept              accept_used_without_including_sys_socket_h
+#    undef bind
+#    define bind                bind_used_without_including_sys_socket_h
+#    undef getpeername
+#    define getpeername         getpeername_used_without_including_sys_socket_h
+#    undef getsockname
+#    define getsockname         getsockname_used_without_including_sys_socket_h
+#    undef getsockopt
+#    define getsockopt          getsockopt_used_without_including_sys_socket_h
+#    undef listen
+#    define listen              listen_used_without_including_sys_socket_h
+#    undef recv
+#    define recv                recv_used_without_including_sys_socket_h
+#    undef send
+#    define send                send_used_without_including_sys_socket_h
+#    undef recvfrom
+#    define recvfrom            recvfrom_used_without_including_sys_socket_h
+#    undef sendto
+#    define sendto              sendto_used_without_including_sys_socket_h
+#    undef setsockopt
+#    define setsockopt          setsockopt_used_without_including_sys_socket_h
+#    undef shutdown
+#    define shutdown            shutdown_used_without_including_sys_socket_h
+#   else
+     _GL_WARN_ON_USE (socket,
+                      "socket() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (connect,
+                      "connect() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (accept,
+                      "accept() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (bind,
+                      "bind() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getpeername,
+                      "getpeername() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getsockname,
+                      "getsockname() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (getsockopt,
+                      "getsockopt() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (listen,
+                      "listen() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (recv,
+                      "recv() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (send,
+                      "send() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (recvfrom,
+                      "recvfrom() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (sendto,
+                      "sendto() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (setsockopt,
+                      "setsockopt() used without including <sys/socket.h>");
+     _GL_WARN_ON_USE (shutdown,
+                      "shutdown() used without including <sys/socket.h>");
+#   endif
+#  endif
+#  if !defined _GL_SYS_SELECT_H
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef select
+#    define select              select_used_without_including_sys_select_h
+#   else
+     _GL_WARN_ON_USE (select,
+                      "select() used without including <sys/select.h>");
+#   endif
+#  endif
+# endif
+#endif
+
+
+/* OS/2 EMX lacks these macros.  */
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+# define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+# define STDERR_FILENO 2
+#endif
+
+/* Ensure *_OK macros exist.  */
+#ifndef F_OK
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+#endif
+
+
+/* Declare overridden functions.  */
+
+
+#if defined GNULIB_POSIXCHECK
+/* The access() function is a security risk.  */
+_GL_WARN_ON_USE (access, "the access function is a security risk - "
+                 "use the gnulib module faccessat instead");
+#endif
+
+
+#if @GNULIB_CHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+   to GID (if GID is not -1).  Follow symbolic links.
+   Return 0 if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/chown.html>.  */
+# if @REPLACE_CHOWN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef chown
+#   define chown rpl_chown
+#  endif
+_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
+                              _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
+# else
+#  if !@HAVE_CHOWN@
+_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
+                              _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
+# endif
+_GL_CXXALIASWARN (chown);
+#elif defined GNULIB_POSIXCHECK
+# undef chown
+# if HAVE_RAW_DECL_CHOWN
+_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
+                 "doesn't treat a uid or gid of -1 on some systems - "
+                 "use gnulib module chown for portability");
+# endif
+#endif
+
+
+#if @GNULIB_CLOSE@
+# if @REPLACE_CLOSE@
+/* Automatically included by modules that need a replacement for close.  */
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close rpl_close
+#  endif
+_GL_FUNCDECL_RPL (close, int, (int fd));
+_GL_CXXALIAS_RPL (close, int, (int fd));
+# else
+_GL_CXXALIAS_SYS (close, int, (int fd));
+# endif
+_GL_CXXALIASWARN (close);
+#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+# undef close
+# define close close_used_without_requesting_gnulib_module_close
+#elif defined GNULIB_POSIXCHECK
+# undef close
+/* Assume close is always declared.  */
+_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
+                 "use gnulib module close for portability");
+#endif
+
+
+#if @REPLACE_DUP@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  define dup rpl_dup
+# endif
+_GL_FUNCDECL_RPL (dup, int, (int oldfd));
+_GL_CXXALIAS_RPL (dup, int, (int oldfd));
+#else
+_GL_CXXALIAS_SYS (dup, int, (int oldfd));
+#endif
+_GL_CXXALIASWARN (dup);
+
+
+#if @GNULIB_DUP2@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
+   NEWFD = OLDFD, otherwise close NEWFD first if it is open.
+   Return newfd if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/dup2.html>.  */
+# if @REPLACE_DUP2@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dup2 rpl_dup2
+#  endif
+_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
+_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
+# else
+#  if !@HAVE_DUP2@
+_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
+#  endif
+_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
+# endif
+_GL_CXXALIASWARN (dup2);
+#elif defined GNULIB_POSIXCHECK
+# undef dup2
+# if HAVE_RAW_DECL_DUP2
+_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
+                 "use gnulib module dup2 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_DUP3@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
+   specified flags.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   Close NEWFD first if it is open.
+   Return newfd if successful, otherwise -1 and errno set.
+   See the Linux man page at
+   <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
+# if @HAVE_DUP3@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define dup3 rpl_dup3
+#  endif
+_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
+# else
+_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
+_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
+# endif
+_GL_CXXALIASWARN (dup3);
+#elif defined GNULIB_POSIXCHECK
+# undef dup3
+# if HAVE_RAW_DECL_DUP3
+_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
+                 "use gnulib module dup3 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_ENVIRON@
+# if !@HAVE_DECL_ENVIRON@
+/* Set of environment variables and values.  An array of strings of the form
+   "VARIABLE=VALUE", terminated with a NULL.  */
+#  if defined __APPLE__ && defined __MACH__
+#   include <crt_externs.h>
+#   define environ (*_NSGetEnviron ())
+#  else
+#   ifdef __cplusplus
+extern "C" {
+#   endif
+extern char **environ;
+#   ifdef __cplusplus
+}
+#   endif
+#  endif
+# endif
+#elif defined GNULIB_POSIXCHECK
+# if HAVE_RAW_DECL_ENVIRON
+static inline char ***
+rpl_environ (void)
+{
+  return &environ;
+}
+_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
+                 "use gnulib module environ for portability");
+#  undef environ
+#  define environ (*rpl_environ ())
+# endif
+#endif
+
+
+#if @GNULIB_EUIDACCESS@
+/* Like access(), except that it uses the effective user id and group id of
+   the current process.  */
+# if !@HAVE_EUIDACCESS@
+_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
+                                   _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
+_GL_CXXALIASWARN (euidaccess);
+# if defined GNULIB_POSIXCHECK
+/* Like access(), this function is a security risk.  */
+_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
+                 "use the gnulib module faccessat instead");
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef euidaccess
+# if HAVE_RAW_DECL_EUIDACCESS
+_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
+                 "use gnulib module euidaccess for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FACCESSAT@
+# if !@HAVE_FACCESSAT@
+_GL_FUNCDECL_SYS (faccessat, int,
+                  (int fd, char const *file, int mode, int flag)
+                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (faccessat, int,
+                  (int fd, char const *file, int mode, int flag));
+_GL_CXXALIASWARN (faccessat);
+#elif defined GNULIB_POSIXCHECK
+# undef faccessat
+# if HAVE_RAW_DECL_FACCESSAT
+_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
+                 "use gnulib module faccessat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FCHDIR@
+/* Change the process' current working directory to the directory on which
+   the given file descriptor is open.
+   Return 0 if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
+# if ! @HAVE_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
+
+/* Gnulib internal hooks needed to maintain the fchdir metadata.  */
+_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
+     _GL_ARG_NONNULL ((2));
+_GL_EXTERN_C void _gl_unregister_fd (int fd);
+_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
+_GL_EXTERN_C const char *_gl_directory_name (int fd);
+
+# else
+#  if !@HAVE_DECL_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
+#  endif
+# endif
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
+_GL_CXXALIASWARN (fchdir);
+#elif defined GNULIB_POSIXCHECK
+# undef fchdir
+# if HAVE_RAW_DECL_FCHDIR
+_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
+                 "use gnulib module fchdir for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FCHOWNAT@
+# if @REPLACE_FCHOWNAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fchownat
+#   define fchownat rpl_fchownat
+#  endif
+_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag));
+# else
+#  if !@HAVE_FCHOWNAT@
+_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
+                                  uid_t owner, gid_t group, int flag));
+# endif
+_GL_CXXALIASWARN (fchownat);
+#elif defined GNULIB_POSIXCHECK
+# undef fchownat
+# if HAVE_RAW_DECL_FCHOWNAT
+_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FSYNC@
+/* Synchronize changes to a file.
+   Return 0 if successful, otherwise -1 and errno set.
+   See POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/fsync.html>.  */
+# if !@HAVE_FSYNC@
+_GL_FUNCDECL_SYS (fsync, int, (int fd));
+# endif
+_GL_CXXALIAS_SYS (fsync, int, (int fd));
+_GL_CXXALIASWARN (fsync);
+#elif defined GNULIB_POSIXCHECK
+# undef fsync
+# if HAVE_RAW_DECL_FSYNC
+_GL_WARN_ON_USE (fsync, "fsync is unportable - "
+                 "use gnulib module fsync for portability");
+# endif
+#endif
+
+
+#if @GNULIB_FTRUNCATE@
+/* Change the size of the file to which FD is opened to become equal to LENGTH.
+   Return 0 if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
+# if !@HAVE_FTRUNCATE@
+_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
+# endif
+_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
+_GL_CXXALIASWARN (ftruncate);
+#elif defined GNULIB_POSIXCHECK
+# undef ftruncate
+# if HAVE_RAW_DECL_FTRUNCATE
+_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
+                 "use gnulib module ftruncate for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETCWD@
+/* Get the name of the current working directory, and put it in SIZE bytes
+   of BUF.
+   Return BUF if successful, or NULL if the directory couldn't be determined
+   or SIZE was too small.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/getcwd.html>.
+   Additionally, the gnulib module 'getcwd' guarantees the following GNU
+   extension: If BUF is NULL, an array is allocated with 'malloc'; the array
+   is SIZE bytes long, unless SIZE == 0, in which case it is as big as
+   necessary.  */
+# if @REPLACE_GETCWD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define getcwd rpl_getcwd
+#  endif
+_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
+_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
+# else
+/* Need to cast, because on mingw, the second parameter is
+                                                   int size.  */
+_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
+# endif
+_GL_CXXALIASWARN (getcwd);
+#elif defined GNULIB_POSIXCHECK
+# undef getcwd
+# if HAVE_RAW_DECL_GETCWD
+_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
+                 "use gnulib module getcwd for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETDOMAINNAME@
+/* Return the NIS domain name of the machine.
+   WARNING! The NIS domain name is unrelated to the fully qualified host name
+            of the machine.  It is also unrelated to email addresses.
+   WARNING! The NIS domain name is usually the empty string or "(none)" when
+            not using NIS.
+
+   Put up to LEN bytes of the NIS domain name into NAME.
+   Null terminate it if the name is shorter than LEN.
+   If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
+   Return 0 if successful, otherwise set errno and return -1.  */
+# if @REPLACE_GETDOMAINNAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getdomainname
+#   define getdomainname rpl_getdomainname
+#  endif
+_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
+                                      _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
+# else
+#  if !@HAVE_DECL_GETDOMAINNAME@
+_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
+                                      _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
+# endif
+_GL_CXXALIASWARN (getdomainname);
+#elif defined GNULIB_POSIXCHECK
+# undef getdomainname
+# if HAVE_RAW_DECL_GETDOMAINNAME
+_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
+                 "use gnulib module getdomainname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETDTABLESIZE@
+/* Return the maximum number of file descriptors in the current process.
+   In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
+# if !@HAVE_GETDTABLESIZE@
+_GL_FUNCDECL_SYS (getdtablesize, int, (void));
+# endif
+_GL_CXXALIAS_SYS (getdtablesize, int, (void));
+_GL_CXXALIASWARN (getdtablesize);
+#elif defined GNULIB_POSIXCHECK
+# undef getdtablesize
+# if HAVE_RAW_DECL_GETDTABLESIZE
+_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
+                 "use gnulib module getdtablesize for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETGROUPS@
+/* Return the supplemental groups that the current process belongs to.
+   It is unspecified whether the effective group id is in the list.
+   If N is 0, return the group count; otherwise, N describes how many
+   entries are available in GROUPS.  Return -1 and set errno if N is
+   not 0 and not large enough.  Fails with ENOSYS on some systems.  */
+# if @REPLACE_GETGROUPS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getgroups
+#   define getgroups rpl_getgroups
+#  endif
+_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
+_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
+# else
+#  if !@HAVE_GETGROUPS@
+_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
+#  endif
+_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
+# endif
+_GL_CXXALIASWARN (getgroups);
+#elif defined GNULIB_POSIXCHECK
+# undef getgroups
+# if HAVE_RAW_DECL_GETGROUPS
+_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
+                 "use gnulib module getgroups for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETHOSTNAME@
+/* Return the standard host name of the machine.
+   WARNING! The host name may or may not be fully qualified.
+
+   Put up to LEN bytes of the host name into NAME.
+   Null terminate it if the name is shorter than LEN.
+   If the host name is longer than LEN, set errno = EINVAL and return -1.
+   Return 0 if successful, otherwise set errno and return -1.  */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname rpl_gethostname
+#  endif
+_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
+# else
+#  if !@HAVE_GETHOSTNAME@
+_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+#  endif
+/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
+   parameter is
+                                                      int len.  */
+_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
+# endif
+_GL_CXXALIASWARN (gethostname);
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
+#elif defined GNULIB_POSIXCHECK
+# undef gethostname
+# if HAVE_RAW_DECL_GETHOSTNAME
+_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
+                 "use gnulib module gethostname for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETLOGIN@
+/* Returns the user's login name, or NULL if it cannot be found.  Upon error,
+   returns NULL with errno set.
+
+   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+   Most programs don't need to use this function, because the information is
+   available through environment variables:
+     ${LOGNAME-$USER}        on Unix platforms,
+     $USERNAME               on native Windows platforms.
+ */
+# if !@HAVE_GETLOGIN@
+_GL_FUNCDECL_SYS (getlogin, char *, (void));
+# endif
+_GL_CXXALIAS_SYS (getlogin, char *, (void));
+_GL_CXXALIASWARN (getlogin);
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin
+# if HAVE_RAW_DECL_GETLOGIN
+_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
+                 "use gnulib module getlogin for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETLOGIN_R@
+/* Copies the user's login name to NAME.
+   The array pointed to by NAME has room for SIZE bytes.
+
+   Returns 0 if successful.  Upon error, an error number is returned, or -1 in
+   the case that the login name cannot be found but no specific error is
+   provided (this case is hopefully rare but is left open by the POSIX spec).
+
+   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+
+   Most programs don't need to use this function, because the information is
+   available through environment variables:
+     ${LOGNAME-$USER}        on Unix platforms,
+     $USERNAME               on native Windows platforms.
+ */
+# if @REPLACE_GETLOGIN_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define getlogin_r rpl_getlogin_r
+#  endif
+_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
+# else
+#  if !@HAVE_DECL_GETLOGIN_R@
+_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
+                                   _GL_ARG_NONNULL ((1)));
+#  endif
+/* Need to cast, because on Solaris 10 systems, the second argument is
+                                                     int size.  */
+_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
+# endif
+_GL_CXXALIASWARN (getlogin_r);
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin_r
+# if HAVE_RAW_DECL_GETLOGIN_R
+_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
+                 "use gnulib module getlogin_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETPAGESIZE@
+# if @REPLACE_GETPAGESIZE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define getpagesize rpl_getpagesize
+#  endif
+_GL_FUNCDECL_RPL (getpagesize, int, (void));
+_GL_CXXALIAS_RPL (getpagesize, int, (void));
+# else
+#  if !@HAVE_GETPAGESIZE@
+#   if !defined getpagesize
+/* This is for POSIX systems.  */
+#    if !defined _gl_getpagesize && defined _SC_PAGESIZE
+#     if ! (defined __VMS && __VMS_VER < 70000000)
+#      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
+#     endif
+#    endif
+/* This is for older VMS.  */
+#    if !defined _gl_getpagesize && defined __VMS
+#     ifdef __ALPHA
+#      define _gl_getpagesize() 8192
+#     else
+#      define _gl_getpagesize() 512
+#     endif
+#    endif
+/* This is for BeOS.  */
+#    if !defined _gl_getpagesize && @HAVE_OS_H@
+#     include <OS.h>
+#     if defined B_PAGE_SIZE
+#      define _gl_getpagesize() B_PAGE_SIZE
+#     endif
+#    endif
+/* This is for AmigaOS4.0.  */
+#    if !defined _gl_getpagesize && defined __amigaos4__
+#     define _gl_getpagesize() 2048
+#    endif
+/* This is for older Unix systems.  */
+#    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
+#     include <sys/param.h>
+#     ifdef EXEC_PAGESIZE
+#      define _gl_getpagesize() EXEC_PAGESIZE
+#     else
+#      ifdef NBPG
+#       ifndef CLSIZE
+#        define CLSIZE 1
+#       endif
+#       define _gl_getpagesize() (NBPG * CLSIZE)
+#      else
+#       ifdef NBPC
+#        define _gl_getpagesize() NBPC
+#       endif
+#      endif
+#     endif
+#    endif
+#    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
+/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
+_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
+# endif
+# if @HAVE_DECL_GETPAGESIZE@
+_GL_CXXALIASWARN (getpagesize);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getpagesize
+# if HAVE_RAW_DECL_GETPAGESIZE
+_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
+                 "use gnulib module getpagesize for portability");
+# endif
+#endif
+
+
+#if @GNULIB_GETUSERSHELL@
+/* Return the next valid login shell on the system, or NULL when the end of
+   the list has been reached.  */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (getusershell, char *, (void));
+# endif
+_GL_CXXALIAS_SYS (getusershell, char *, (void));
+_GL_CXXALIASWARN (getusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef getusershell
+# if HAVE_RAW_DECL_GETUSERSHELL
+_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
+                 "use gnulib module getusershell for portability");
+# endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Rewind to pointer that is advanced at each getusershell() call.  */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (setusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (setusershell, void, (void));
+_GL_CXXALIASWARN (setusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef setusershell
+# if HAVE_RAW_DECL_SETUSERSHELL
+_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
+                 "use gnulib module getusershell for portability");
+# endif
+#endif
+
+#if @GNULIB_GETUSERSHELL@
+/* Free the pointer that is advanced at each getusershell() call and
+   associated resources.  */
+# if !@HAVE_DECL_GETUSERSHELL@
+_GL_FUNCDECL_SYS (endusershell, void, (void));
+# endif
+_GL_CXXALIAS_SYS (endusershell, void, (void));
+_GL_CXXALIASWARN (endusershell);
+#elif defined GNULIB_POSIXCHECK
+# undef endusershell
+# if HAVE_RAW_DECL_ENDUSERSHELL
+_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
+                 "use gnulib module getusershell for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LCHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+   to GID (if GID is not -1).  Do not follow symbolic links.
+   Return 0 if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/lchown.html>.  */
+# if @REPLACE_LCHOWN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef lchown
+#   define lchown rpl_lchown
+#  endif
+_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
+                               _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
+# else
+#  if !@HAVE_LCHOWN@
+_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
+                               _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
+# endif
+_GL_CXXALIASWARN (lchown);
+#elif defined GNULIB_POSIXCHECK
+# undef lchown
+# if HAVE_RAW_DECL_LCHOWN
+_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
+                 "use gnulib module lchown for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LINK@
+/* Create a new hard link for an existing file.
+   Return 0 if successful, otherwise -1 and errno set.
+   See POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/link.html>.  */
+# if @REPLACE_LINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define link rpl_link
+#  endif
+_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
+                             _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
+# else
+#  if !@HAVE_LINK@
+_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
+                             _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
+# endif
+_GL_CXXALIASWARN (link);
+#elif defined GNULIB_POSIXCHECK
+# undef link
+# if HAVE_RAW_DECL_LINK
+_GL_WARN_ON_USE (link, "link is unportable - "
+                 "use gnulib module link for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LINKAT@
+/* Create a new hard link for an existing file, relative to two
+   directories.  FLAG controls whether symlinks are followed.
+   Return 0 if successful, otherwise -1 and errno set.  */
+# if @REPLACE_LINKAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef linkat
+#   define linkat rpl_linkat
+#  endif
+_GL_FUNCDECL_RPL (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag)
+                  _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag));
+# else
+#  if !@HAVE_LINKAT@
+_GL_FUNCDECL_SYS (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag)
+                  _GL_ARG_NONNULL ((2, 4)));
+#  endif
+_GL_CXXALIAS_SYS (linkat, int,
+                  (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag));
+# endif
+_GL_CXXALIASWARN (linkat);
+#elif defined GNULIB_POSIXCHECK
+# undef linkat
+# if HAVE_RAW_DECL_LINKAT
+_GL_WARN_ON_USE (linkat, "linkat is unportable - "
+                 "use gnulib module linkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_LSEEK@
+/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
+   Return the new offset if successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/lseek.html>.  */
+# if @REPLACE_LSEEK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define lseek rpl_lseek
+#  endif
+_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+# else
+_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (lseek);
+#elif defined GNULIB_POSIXCHECK
+# undef lseek
+# if HAVE_RAW_DECL_LSEEK
+_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
+                 "systems - use gnulib module lseek for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PIPE@
+/* Create a pipe, defaulting to O_BINARY mode.
+   Store the read-end as fd[0] and the write-end as fd[1].
+   Return 0 upon success, or -1 with errno set upon failure.  */
+# if !@HAVE_PIPE@
+_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
+_GL_CXXALIASWARN (pipe);
+#elif defined GNULIB_POSIXCHECK
+# undef pipe
+# if HAVE_RAW_DECL_PIPE
+_GL_WARN_ON_USE (pipe, "pipe is unportable - "
+                 "use gnulib module pipe-posix for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PIPE2@
+/* Create a pipe, applying the given flags when opening the read-end of the
+   pipe and the write-end of the pipe.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   Store the read-end as fd[0] and the write-end as fd[1].
+   Return 0 upon success, or -1 with errno set upon failure.
+   See also the Linux man page at
+   <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
+# if @HAVE_PIPE2@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define pipe2 rpl_pipe2
+#  endif
+_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
+# else
+_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
+# endif
+_GL_CXXALIASWARN (pipe2);
+#elif defined GNULIB_POSIXCHECK
+# undef pipe2
+# if HAVE_RAW_DECL_PIPE2
+_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
+                 "use gnulib module pipe2 for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PREAD@
+/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
+   Return the number of bytes placed into BUF if successful, otherwise
+   set errno and return -1.  0 indicates EOF.  See the POSIX:2001
+   specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
+# if @REPLACE_PREAD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define pread rpl_pread
+#  endif
+_GL_FUNCDECL_RPL (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset));
+# else
+#  if !@HAVE_PREAD@
+_GL_FUNCDECL_SYS (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (pread, ssize_t,
+                  (int fd, void *buf, size_t bufsize, off_t offset));
+# endif
+_GL_CXXALIASWARN (pread);
+#elif defined GNULIB_POSIXCHECK
+# undef pread
+# if HAVE_RAW_DECL_PREAD
+_GL_WARN_ON_USE (pread, "pread is unportable - "
+                 "use gnulib module pread for portability");
+# endif
+#endif
+
+
+#if @GNULIB_PWRITE@
+/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
+   Return the number of bytes written if successful, otherwise
+   set errno and return -1.  0 indicates nothing written.  See the
+   POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/pwrite.html>.  */
+# if @REPLACE_PWRITE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define pwrite rpl_pwrite
+#  endif
+_GL_FUNCDECL_RPL (pwrite, ssize_t,
+                  (int fd, const void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (pwrite, ssize_t,
+                  (int fd, const void *buf, size_t bufsize, off_t offset));
+# else
+#  if !@HAVE_PWRITE@
+_GL_FUNCDECL_SYS (pwrite, ssize_t,
+                  (int fd, const void *buf, size_t bufsize, off_t offset)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (pwrite, ssize_t,
+                  (int fd, const void *buf, size_t bufsize, off_t offset));
+# endif
+_GL_CXXALIASWARN (pwrite);
+#elif defined GNULIB_POSIXCHECK
+# undef pwrite
+# if HAVE_RAW_DECL_PWRITE
+_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
+                 "use gnulib module pwrite for portability");
+# endif
+#endif
+
+
+#if @GNULIB_READLINK@
+/* Read the contents of the symbolic link FILE and place the first BUFSIZE
+   bytes of it into BUF.  Return the number of bytes placed into BUF if
+   successful, otherwise -1 and errno set.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/readlink.html>.  */
+# if @REPLACE_READLINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define readlink rpl_readlink
+#  endif
+_GL_FUNCDECL_RPL (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize));
+# else
+#  if !@HAVE_READLINK@
+_GL_FUNCDECL_SYS (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize)
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (readlink, ssize_t,
+                  (const char *file, char *buf, size_t bufsize));
+# endif
+_GL_CXXALIASWARN (readlink);
+#elif defined GNULIB_POSIXCHECK
+# undef readlink
+# if HAVE_RAW_DECL_READLINK
+_GL_WARN_ON_USE (readlink, "readlink is unportable - "
+                 "use gnulib module readlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_READLINKAT@
+# if !@HAVE_READLINKAT@
+_GL_FUNCDECL_SYS (readlinkat, ssize_t,
+                  (int fd, char const *file, char *buf, size_t len)
+                  _GL_ARG_NONNULL ((2, 3)));
+# endif
+_GL_CXXALIAS_SYS (readlinkat, ssize_t,
+                  (int fd, char const *file, char *buf, size_t len));
+_GL_CXXALIASWARN (readlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef readlinkat
+# if HAVE_RAW_DECL_READLINKAT
+_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
+                 "use gnulib module readlinkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_RMDIR@
+/* Remove the directory DIR.  */
+# if @REPLACE_RMDIR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define rmdir rpl_rmdir
+#  endif
+_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
+# else
+_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
+# endif
+_GL_CXXALIASWARN (rmdir);
+#elif defined GNULIB_POSIXCHECK
+# undef rmdir
+# if HAVE_RAW_DECL_RMDIR
+_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
+                 "use gnulib module rmdir for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SLEEP@
+/* Pause the execution of the current thread for N seconds.
+   Returns the number of seconds left to sleep.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
+# if @REPLACE_SLEEP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef sleep
+#   define sleep rpl_sleep
+#  endif
+_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
+_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
+# else
+#  if !@HAVE_SLEEP@
+_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
+#  endif
+_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
+# endif
+_GL_CXXALIASWARN (sleep);
+#elif defined GNULIB_POSIXCHECK
+# undef sleep
+# if HAVE_RAW_DECL_SLEEP
+_GL_WARN_ON_USE (sleep, "sleep is unportable - "
+                 "use gnulib module sleep for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SYMLINK@
+# if @REPLACE_SYMLINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef symlink
+#   define symlink rpl_symlink
+#  endif
+_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
+                                _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
+# else
+#  if !@HAVE_SYMLINK@
+_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
+                                _GL_ARG_NONNULL ((1, 2)));
+#  endif
+_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
+# endif
+_GL_CXXALIASWARN (symlink);
+#elif defined GNULIB_POSIXCHECK
+# undef symlink
+# if HAVE_RAW_DECL_SYMLINK
+_GL_WARN_ON_USE (symlink, "symlink is not portable - "
+                 "use gnulib module symlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_SYMLINKAT@
+# if !@HAVE_SYMLINKAT@
+_GL_FUNCDECL_SYS (symlinkat, int,
+                  (char const *contents, int fd, char const *file)
+                  _GL_ARG_NONNULL ((1, 3)));
+# endif
+_GL_CXXALIAS_SYS (symlinkat, int,
+                  (char const *contents, int fd, char const *file));
+_GL_CXXALIASWARN (symlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef symlinkat
+# if HAVE_RAW_DECL_SYMLINKAT
+_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
+                 "use gnulib module symlinkat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_TTYNAME_R@
+/* Store at most BUFLEN characters of the pathname of the terminal FD is
+   open on in BUF.  Return 0 on success, otherwise an error number.  */
+# if @REPLACE_TTYNAME_R@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef ttyname_r
+#   define ttyname_r rpl_ttyname_r
+#  endif
+_GL_FUNCDECL_RPL (ttyname_r, int,
+                  (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (ttyname_r, int,
+                  (int fd, char *buf, size_t buflen));
+# else
+#  if !@HAVE_DECL_TTYNAME_R@
+_GL_FUNCDECL_SYS (ttyname_r, int,
+                  (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (ttyname_r, int,
+                  (int fd, char *buf, size_t buflen));
+# endif
+_GL_CXXALIASWARN (ttyname_r);
+#elif defined GNULIB_POSIXCHECK
+# undef ttyname_r
+# if HAVE_RAW_DECL_TTYNAME_R
+_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
+                 "use gnulib module ttyname_r for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UNLINK@
+# if @REPLACE_UNLINK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unlink
+#   define unlink rpl_unlink
+#  endif
+_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (unlink, int, (char const *file));
+# else
+_GL_CXXALIAS_SYS (unlink, int, (char const *file));
+# endif
+_GL_CXXALIASWARN (unlink);
+#elif defined GNULIB_POSIXCHECK
+# undef unlink
+# if HAVE_RAW_DECL_UNLINK
+_GL_WARN_ON_USE (unlink, "unlink is not portable - "
+                 "use gnulib module unlink for portability");
+# endif
+#endif
+
+
+#if @GNULIB_UNLINKAT@
+# if @REPLACE_UNLINKAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef unlinkat
+#   define unlinkat rpl_unlinkat
+#  endif
+_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
+# else
+#  if !@HAVE_UNLINKAT@
+_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
+                                 _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
+# endif
+_GL_CXXALIASWARN (unlinkat);
+#elif defined GNULIB_POSIXCHECK
+# undef unlinkat
+# if HAVE_RAW_DECL_UNLINKAT
+_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+#if @GNULIB_USLEEP@
+/* Pause the execution of the current thread for N microseconds.
+   Returns 0 on completion, or -1 on range error.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
+# if @REPLACE_USLEEP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef usleep
+#   define usleep rpl_usleep
+#  endif
+_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
+_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
+# else
+#  if !@HAVE_USLEEP@
+_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
+#  endif
+_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
+# endif
+_GL_CXXALIASWARN (usleep);
+#elif defined GNULIB_POSIXCHECK
+# undef usleep
+# if HAVE_RAW_DECL_USLEEP
+_GL_WARN_ON_USE (usleep, "usleep is unportable - "
+                 "use gnulib module usleep for portability");
+# endif
+#endif
+
+
+#if @GNULIB_WRITE@
+/* Write up to COUNT bytes starting at BUF to file descriptor FD.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/write.html>.  */
+# if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef write
+#   define write rpl_write
+#  endif
+_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
+                                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
+# else
+/* Need to cast, because on mingw, the third parameter is
+                                                             unsigned int count
+   and the return type is 'int'.  */
+_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
+# endif
+_GL_CXXALIASWARN (write);
+#endif
+
+
+#endif /* _GL_UNISTD_H */
+#endif /* _GL_UNISTD_H */
diff --git a/gnulib/lib/vasnprintf.c b/gnulib/lib/vasnprintf.c
new file mode 100644 (file)
index 0000000..6d426a9
--- /dev/null
@@ -0,0 +1,5578 @@
+/* vsprintf with automatic memory allocation.
+   Copyright (C) 1999, 2002-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This file can be parametrized with the following macros:
+     VASNPRINTF         The name of the function being defined.
+     FCHAR_T            The element type of the format string.
+     DCHAR_T            The element type of the destination (result) string.
+     FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters
+                        in the format string are ASCII. MUST be set if
+                        FCHAR_T and DCHAR_T are not the same type.
+     DIRECTIVE          Structure denoting a format directive.
+                        Depends on FCHAR_T.
+     DIRECTIVES         Structure denoting the set of format directives of a
+                        format string.  Depends on FCHAR_T.
+     PRINTF_PARSE       Function that parses a format string.
+                        Depends on FCHAR_T.
+     DCHAR_CPY          memcpy like function for DCHAR_T[] arrays.
+     DCHAR_SET          memset like function for DCHAR_T[] arrays.
+     DCHAR_MBSNLEN      mbsnlen like function for DCHAR_T[] arrays.
+     SNPRINTF           The system's snprintf (or similar) function.
+                        This may be either snprintf or swprintf.
+     TCHAR_T            The element type of the argument and result string
+                        of the said SNPRINTF function.  This may be either
+                        char or wchar_t.  The code exploits that
+                        sizeof (TCHAR_T) | sizeof (DCHAR_T) and
+                        alignof (TCHAR_T) <= alignof (DCHAR_T).
+     DCHAR_IS_TCHAR     Set to 1 if DCHAR_T and TCHAR_T are the same type.
+     DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[].
+     DCHAR_IS_UINT8_T   Set to 1 if DCHAR_T is uint8_t.
+     DCHAR_IS_UINT16_T  Set to 1 if DCHAR_T is uint16_t.
+     DCHAR_IS_UINT32_T  Set to 1 if DCHAR_T is uint32_t.  */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+   This must come before <config.h> because <config.h> may include
+   <features.h>, and once <features.h> has been included, it's too late.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE    1
+#endif
+
+#ifndef VASNPRINTF
+# include <config.h>
+#endif
+#ifndef IN_LIBINTL
+# include <alloca.h>
+#endif
+
+/* Specification.  */
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+#  include "vasnwprintf.h"
+# else
+#  include "vasnprintf.h"
+# endif
+#endif
+
+#include <locale.h>     /* localeconv() */
+#include <stdio.h>      /* snprintf(), sprintf() */
+#include <stdlib.h>     /* abort(), malloc(), realloc(), free() */
+#include <string.h>     /* memcpy(), strlen() */
+#include <errno.h>      /* errno */
+#include <limits.h>     /* CHAR_BIT */
+#include <float.h>      /* DBL_MAX_EXP, LDBL_MAX_EXP */
+#if HAVE_NL_LANGINFO
+# include <langinfo.h>
+#endif
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+#  include "wprintf-parse.h"
+# else
+#  include "printf-parse.h"
+# endif
+#endif
+
+/* Checked size_t computations.  */
+#include "xsize.h"
+
+#include "verify.h"
+
+#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "float+.h"
+#endif
+
+#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnand-nolibm.h"
+#endif
+
+#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnanl-nolibm.h"
+# include "fpucw.h"
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnand-nolibm.h"
+# include "printf-frexp.h"
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+# include <math.h>
+# include "isnanl-nolibm.h"
+# include "printf-frexpl.h"
+# include "fpucw.h"
+#endif
+
+/* Default parameters.  */
+#ifndef VASNPRINTF
+# if WIDE_CHAR_VERSION
+#  define VASNPRINTF vasnwprintf
+#  define FCHAR_T wchar_t
+#  define DCHAR_T wchar_t
+#  define TCHAR_T wchar_t
+#  define DCHAR_IS_TCHAR 1
+#  define DIRECTIVE wchar_t_directive
+#  define DIRECTIVES wchar_t_directives
+#  define PRINTF_PARSE wprintf_parse
+#  define DCHAR_CPY wmemcpy
+#  define DCHAR_SET wmemset
+# else
+#  define VASNPRINTF vasnprintf
+#  define FCHAR_T char
+#  define DCHAR_T char
+#  define TCHAR_T char
+#  define DCHAR_IS_TCHAR 1
+#  define DIRECTIVE char_directive
+#  define DIRECTIVES char_directives
+#  define PRINTF_PARSE printf_parse
+#  define DCHAR_CPY memcpy
+#  define DCHAR_SET memset
+# endif
+#endif
+#if WIDE_CHAR_VERSION
+  /* TCHAR_T is wchar_t.  */
+# define USE_SNPRINTF 1
+# if HAVE_DECL__SNWPRINTF
+   /* On Windows, the function swprintf() has a different signature than
+      on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
+      instead.  The mingw function snwprintf() has fewer bugs than the
+      MSVCRT function _snwprintf(), so prefer that.  */
+#  if defined __MINGW32__
+#   define SNPRINTF snwprintf
+#  else
+#   define SNPRINTF _snwprintf
+#  endif
+# else
+   /* Unix.  */
+#  define SNPRINTF swprintf
+# endif
+#else
+  /* TCHAR_T is char.  */
+  /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'.
+     But don't use it on BeOS, since BeOS snprintf produces no output if the
+     size argument is >= 0x3000000.
+     Also don't use it on Linux libc5, since there snprintf with size = 1
+     writes any output without bounds, like sprintf.  */
+# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1)
+#  define USE_SNPRINTF 1
+# else
+#  define USE_SNPRINTF 0
+# endif
+# if HAVE_DECL__SNPRINTF
+   /* Windows.  The mingw function snprintf() has fewer bugs than the MSVCRT
+      function _snprintf(), so prefer that.  */
+#  if defined __MINGW32__
+#   define SNPRINTF snprintf
+    /* Here we need to call the native snprintf, not rpl_snprintf.  */
+#   undef snprintf
+#  else
+#   define SNPRINTF _snprintf
+#  endif
+# else
+   /* Unix.  */
+#  define SNPRINTF snprintf
+   /* Here we need to call the native snprintf, not rpl_snprintf.  */
+#  undef snprintf
+# endif
+#endif
+/* Here we need to call the native sprintf, not rpl_sprintf.  */
+#undef sprintf
+
+/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
+   warnings in this file.  Use -Dlint to suppress them.  */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
+/* Avoid some warnings from "gcc -Wshadow".
+   This file doesn't use the exp() and remainder() functions.  */
+#undef exp
+#define exp expo
+#undef remainder
+#define remainder rem
+
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
+# if (HAVE_STRNLEN && !defined _AIX)
+#  define local_strnlen strnlen
+# else
+#  ifndef local_strnlen_defined
+#   define local_strnlen_defined 1
+static size_t
+local_strnlen (const char *string, size_t maxlen)
+{
+  const char *end = memchr (string, '\0', maxlen);
+  return end ? (size_t) (end - string) : maxlen;
+}
+#  endif
+# endif
+#endif
+
+#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
+# if HAVE_WCSLEN
+#  define local_wcslen wcslen
+# else
+   /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
+      a dependency towards this library, here is a local substitute.
+      Define this substitute only once, even if this file is included
+      twice in the same compilation unit.  */
+#  ifndef local_wcslen_defined
+#   define local_wcslen_defined 1
+static size_t
+local_wcslen (const wchar_t *s)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; *ptr != (wchar_t) 0; ptr++)
+    ;
+  return ptr - s;
+}
+#  endif
+# endif
+#endif
+
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+# if HAVE_WCSNLEN
+#  define local_wcsnlen wcsnlen
+# else
+#  ifndef local_wcsnlen_defined
+#   define local_wcsnlen_defined 1
+static size_t
+local_wcsnlen (const wchar_t *s, size_t maxlen)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--)
+    ;
+  return ptr - s;
+}
+#  endif
+# endif
+#endif
+
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
+/* Determine the decimal-point character according to the current locale.  */
+# ifndef decimal_point_char_defined
+#  define decimal_point_char_defined 1
+static char
+decimal_point_char (void)
+{
+  const char *point;
+  /* Determine it in a multithread-safe way.  We know nl_langinfo is
+     multithread-safe on glibc systems and MacOS X systems, but is not required
+     to be multithread-safe by POSIX.  sprintf(), however, is multithread-safe.
+     localeconv() is rarely multithread-safe.  */
+#  if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__))
+  point = nl_langinfo (RADIXCHAR);
+#  elif 1
+  char pointbuf[5];
+  sprintf (pointbuf, "%#.0f", 1.0);
+  point = &pointbuf[1];
+#  else
+  point = localeconv () -> decimal_point;
+#  endif
+  /* The decimal point is always a single byte: either '.' or ','.  */
+  return (point[0] != '\0' ? point[0] : '.');
+}
+# endif
+#endif
+
+#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL
+
+/* Equivalent to !isfinite(x) || x == 0, but does not require libm.  */
+static int
+is_infinite_or_zero (double x)
+{
+  return isnand (x) || x + x == x;
+}
+
+#endif
+
+#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL
+
+/* Equivalent to !isfinite(x) || x == 0, but does not require libm.  */
+static int
+is_infinite_or_zerol (long double x)
+{
+  return isnanl (x) || x + x == x;
+}
+
+#endif
+
+#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+
+/* Converting 'long double' to decimal without rare rounding bugs requires
+   real bignums.  We use the naming conventions of GNU gmp, but vastly simpler
+   (and slower) algorithms.  */
+
+typedef unsigned int mp_limb_t;
+# define GMP_LIMB_BITS 32
+verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
+
+typedef unsigned long long mp_twolimb_t;
+# define GMP_TWOLIMB_BITS 64
+verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
+
+/* Representation of a bignum >= 0.  */
+typedef struct
+{
+  size_t nlimbs;
+  mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc().  */
+} mpn_t;
+
+/* Compute the product of two bignums >= 0.
+   Return the allocated memory in case of success, NULL in case of memory
+   allocation failure.  */
+static void *
+multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
+{
+  const mp_limb_t *p1;
+  const mp_limb_t *p2;
+  size_t len1;
+  size_t len2;
+
+  if (src1.nlimbs <= src2.nlimbs)
+    {
+      len1 = src1.nlimbs;
+      p1 = src1.limbs;
+      len2 = src2.nlimbs;
+      p2 = src2.limbs;
+    }
+  else
+    {
+      len1 = src2.nlimbs;
+      p1 = src2.limbs;
+      len2 = src1.nlimbs;
+      p2 = src1.limbs;
+    }
+  /* Now 0 <= len1 <= len2.  */
+  if (len1 == 0)
+    {
+      /* src1 or src2 is zero.  */
+      dest->nlimbs = 0;
+      dest->limbs = (mp_limb_t *) malloc (1);
+    }
+  else
+    {
+      /* Here 1 <= len1 <= len2.  */
+      size_t dlen;
+      mp_limb_t *dp;
+      size_t k, i, j;
+
+      dlen = len1 + len2;
+      dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
+      if (dp == NULL)
+        return NULL;
+      for (k = len2; k > 0; )
+        dp[--k] = 0;
+      for (i = 0; i < len1; i++)
+        {
+          mp_limb_t digit1 = p1[i];
+          mp_twolimb_t carry = 0;
+          for (j = 0; j < len2; j++)
+            {
+              mp_limb_t digit2 = p2[j];
+              carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+              carry += dp[i + j];
+              dp[i + j] = (mp_limb_t) carry;
+              carry = carry >> GMP_LIMB_BITS;
+            }
+          dp[i + len2] = (mp_limb_t) carry;
+        }
+      /* Normalise.  */
+      while (dlen > 0 && dp[dlen - 1] == 0)
+        dlen--;
+      dest->nlimbs = dlen;
+      dest->limbs = dp;
+    }
+  return dest->limbs;
+}
+
+/* Compute the quotient of a bignum a >= 0 and a bignum b > 0.
+   a is written as  a = q * b + r  with 0 <= r < b.  q is the quotient, r
+   the remainder.
+   Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd,
+   q is incremented.
+   Return the allocated memory in case of success, NULL in case of memory
+   allocation failure.  */
+static void *
+divide (mpn_t a, mpn_t b, mpn_t *q)
+{
+  /* Algorithm:
+     First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]]
+     with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS).
+     If m<n, then q:=0 and r:=a.
+     If m>=n=1, perform a single-precision division:
+       r:=0, j:=m,
+       while j>0 do
+         {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j =
+               = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r<b[0]<beta}
+         j:=j-1, r:=r*beta+a[j], q[j]:=floor(r/b[0]), r:=r-b[0]*q[j].
+       Normalise [q[m-1],...,q[0]], yields q.
+     If m>=n>1, perform a multiple-precision division:
+       We have a/b < beta^(m-n+1).
+       s:=intDsize-1-(highest bit in b[n-1]), 0<=s<intDsize.
+       Shift a and b left by s bits, copying them. r:=a.
+       r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2.
+       For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).}
+         Compute q* :
+           q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]).
+           In case of overflow (q* >= beta) set q* := beta-1.
+           Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2]
+           and c3 := b[n-2] * q*.
+           {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow
+            occurred.  Furthermore 0 <= c3 < beta^2.
+            If there was overflow and
+            r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2,
+            the next test can be skipped.}
+           While c3 > c2, {Here 0 <= c2 < c3 < beta^2}
+             Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2].
+           If q* > 0:
+             Put r := r - b * q* * beta^j. In detail:
+               [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]].
+               hence: u:=0, for i:=0 to n-1 do
+                              u := u + q* * b[i],
+                              r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry),
+                              u:=u div beta (+ 1, if carry in subtraction)
+                      r[n+j]:=r[n+j]-u.
+               {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1
+                               < q* + 1 <= beta,
+                the carry u does not overflow.}
+             If a negative carry occurs, put q* := q* - 1
+               and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]].
+         Set q[j] := q*.
+       Normalise [q[m-n],..,q[0]]; this yields the quotient q.
+       Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the
+       rest r.
+       The room for q[j] can be allocated at the memory location of r[n+j].
+     Finally, round-to-even:
+       Shift r left by 1 bit.
+       If r > b or if r = b and q[0] is odd, q := q+1.
+   */
+  const mp_limb_t *a_ptr = a.limbs;
+  size_t a_len = a.nlimbs;
+  const mp_limb_t *b_ptr = b.limbs;
+  size_t b_len = b.nlimbs;
+  mp_limb_t *roomptr;
+  mp_limb_t *tmp_roomptr = NULL;
+  mp_limb_t *q_ptr;
+  size_t q_len;
+  mp_limb_t *r_ptr;
+  size_t r_len;
+
+  /* Allocate room for a_len+2 digits.
+     (Need a_len+1 digits for the real division and 1 more digit for the
+     final rounding of q.)  */
+  roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t));
+  if (roomptr == NULL)
+    return NULL;
+
+  /* Normalise a.  */
+  while (a_len > 0 && a_ptr[a_len - 1] == 0)
+    a_len--;
+
+  /* Normalise b.  */
+  for (;;)
+    {
+      if (b_len == 0)
+        /* Division by zero.  */
+        abort ();
+      if (b_ptr[b_len - 1] == 0)
+        b_len--;
+      else
+        break;
+    }
+
+  /* Here m = a_len >= 0 and n = b_len > 0.  */
+
+  if (a_len < b_len)
+    {
+      /* m<n: trivial case.  q=0, r := copy of a.  */
+      r_ptr = roomptr;
+      r_len = a_len;
+      memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+      q_ptr = roomptr + a_len;
+      q_len = 0;
+    }
+  else if (b_len == 1)
+    {
+      /* n=1: single precision division.
+         beta^(m-1) <= a < beta^m  ==>  beta^(m-2) <= a/b < beta^m  */
+      r_ptr = roomptr;
+      q_ptr = roomptr + 1;
+      {
+        mp_limb_t den = b_ptr[0];
+        mp_limb_t remainder = 0;
+        const mp_limb_t *sourceptr = a_ptr + a_len;
+        mp_limb_t *destptr = q_ptr + a_len;
+        size_t count;
+        for (count = a_len; count > 0; count--)
+          {
+            mp_twolimb_t num =
+              ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
+            *--destptr = num / den;
+            remainder = num % den;
+          }
+        /* Normalise and store r.  */
+        if (remainder > 0)
+          {
+            r_ptr[0] = remainder;
+            r_len = 1;
+          }
+        else
+          r_len = 0;
+        /* Normalise q.  */
+        q_len = a_len;
+        if (q_ptr[q_len - 1] == 0)
+          q_len--;
+      }
+    }
+  else
+    {
+      /* n>1: multiple precision division.
+         beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n  ==>
+         beta^(m-n-1) <= a/b < beta^(m-n+1).  */
+      /* Determine s.  */
+      size_t s;
+      {
+        mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
+        s = 31;
+        if (msd >= 0x10000)
+          {
+            msd = msd >> 16;
+            s -= 16;
+          }
+        if (msd >= 0x100)
+          {
+            msd = msd >> 8;
+            s -= 8;
+          }
+        if (msd >= 0x10)
+          {
+            msd = msd >> 4;
+            s -= 4;
+          }
+        if (msd >= 0x4)
+          {
+            msd = msd >> 2;
+            s -= 2;
+          }
+        if (msd >= 0x2)
+          {
+            msd = msd >> 1;
+            s -= 1;
+          }
+      }
+      /* 0 <= s < GMP_LIMB_BITS.
+         Copy b, shifting it left by s bits.  */
+      if (s > 0)
+        {
+          tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
+          if (tmp_roomptr == NULL)
+            {
+              free (roomptr);
+              return NULL;
+            }
+          {
+            const mp_limb_t *sourceptr = b_ptr;
+            mp_limb_t *destptr = tmp_roomptr;
+            mp_twolimb_t accu = 0;
+            size_t count;
+            for (count = b_len; count > 0; count--)
+              {
+                accu += (mp_twolimb_t) *sourceptr++ << s;
+                *destptr++ = (mp_limb_t) accu;
+                accu = accu >> GMP_LIMB_BITS;
+              }
+            /* accu must be zero, since that was how s was determined.  */
+            if (accu != 0)
+              abort ();
+          }
+          b_ptr = tmp_roomptr;
+        }
+      /* Copy a, shifting it left by s bits, yields r.
+         Memory layout:
+         At the beginning: r = roomptr[0..a_len],
+         at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len]  */
+      r_ptr = roomptr;
+      if (s == 0)
+        {
+          memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+          r_ptr[a_len] = 0;
+        }
+      else
+        {
+          const mp_limb_t *sourceptr = a_ptr;
+          mp_limb_t *destptr = r_ptr;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = a_len; count > 0; count--)
+            {
+              accu += (mp_twolimb_t) *sourceptr++ << s;
+              *destptr++ = (mp_limb_t) accu;
+              accu = accu >> GMP_LIMB_BITS;
+            }
+          *destptr++ = (mp_limb_t) accu;
+        }
+      q_ptr = roomptr + b_len;
+      q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
+      {
+        size_t j = a_len - b_len; /* m-n */
+        mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
+        mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
+        mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
+          ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
+        /* Division loop, traversed m-n+1 times.
+           j counts down, b is unchanged, beta/2 <= b[n-1] < beta.  */
+        for (;;)
+          {
+            mp_limb_t q_star;
+            mp_limb_t c1;
+            if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
+              {
+                /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow.  */
+                mp_twolimb_t num =
+                  ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
+                  | r_ptr[j + b_len - 1];
+                q_star = num / b_msd;
+                c1 = num % b_msd;
+              }
+            else
+              {
+                /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1].  */
+                q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
+                /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
+                   <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
+                   <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
+                        {<= beta !}.
+                   If yes, jump directly to the subtraction loop.
+                   (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
+                    <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
+                if (r_ptr[j + b_len] > b_msd
+                    || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
+                  /* r[j+n] >= b[n-1]+1 or
+                     r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
+                     carry.  */
+                  goto subtract;
+              }
+            /* q_star = q*,
+               c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta).  */
+            {
+              mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
+                ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
+              mp_twolimb_t c3 = /* b[n-2] * q* */
+                (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
+              /* While c2 < c3, increase c2 and decrease c3.
+                 Consider c3-c2.  While it is > 0, decrease it by
+                 b[n-1]*beta+b[n-2].  Because of b[n-1]*beta+b[n-2] >= beta^2/2
+                 this can happen only twice.  */
+              if (c3 > c2)
+                {
+                  q_star = q_star - 1; /* q* := q* - 1 */
+                  if (c3 - c2 > b_msdd)
+                    q_star = q_star - 1; /* q* := q* - 1 */
+                }
+            }
+            if (q_star > 0)
+              subtract:
+              {
+                /* Subtract r := r - b * q* * beta^j.  */
+                mp_limb_t cr;
+                {
+                  const mp_limb_t *sourceptr = b_ptr;
+                  mp_limb_t *destptr = r_ptr + j;
+                  mp_twolimb_t carry = 0;
+                  size_t count;
+                  for (count = b_len; count > 0; count--)
+                    {
+                      /* Here 0 <= carry <= q*.  */
+                      carry =
+                        carry
+                        + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
+                        + (mp_limb_t) ~(*destptr);
+                      /* Here 0 <= carry <= beta*q* + beta-1.  */
+                      *destptr++ = ~(mp_limb_t) carry;
+                      carry = carry >> GMP_LIMB_BITS; /* <= q* */
+                    }
+                  cr = (mp_limb_t) carry;
+                }
+                /* Subtract cr from r_ptr[j + b_len], then forget about
+                   r_ptr[j + b_len].  */
+                if (cr > r_ptr[j + b_len])
+                  {
+                    /* Subtraction gave a carry.  */
+                    q_star = q_star - 1; /* q* := q* - 1 */
+                    /* Add b back.  */
+                    {
+                      const mp_limb_t *sourceptr = b_ptr;
+                      mp_limb_t *destptr = r_ptr + j;
+                      mp_limb_t carry = 0;
+                      size_t count;
+                      for (count = b_len; count > 0; count--)
+                        {
+                          mp_limb_t source1 = *sourceptr++;
+                          mp_limb_t source2 = *destptr;
+                          *destptr++ = source1 + source2 + carry;
+                          carry =
+                            (carry
+                             ? source1 >= (mp_limb_t) ~source2
+                             : source1 > (mp_limb_t) ~source2);
+                        }
+                    }
+                    /* Forget about the carry and about r[j+n].  */
+                  }
+              }
+            /* q* is determined.  Store it as q[j].  */
+            q_ptr[j] = q_star;
+            if (j == 0)
+              break;
+            j--;
+          }
+      }
+      r_len = b_len;
+      /* Normalise q.  */
+      if (q_ptr[q_len - 1] == 0)
+        q_len--;
+# if 0 /* Not needed here, since we need r only to compare it with b/2, and
+          b is shifted left by s bits.  */
+      /* Shift r right by s bits.  */
+      if (s > 0)
+        {
+          mp_limb_t ptr = r_ptr + r_len;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = r_len; count > 0; count--)
+            {
+              accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
+              accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
+              *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
+            }
+        }
+# endif
+      /* Normalise r.  */
+      while (r_len > 0 && r_ptr[r_len - 1] == 0)
+        r_len--;
+    }
+  /* Compare r << 1 with b.  */
+  if (r_len > b_len)
+    goto increment_q;
+  {
+    size_t i;
+    for (i = b_len;;)
+      {
+        mp_limb_t r_i =
+          (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
+          | (i < r_len ? r_ptr[i] << 1 : 0);
+        mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
+        if (r_i > b_i)
+          goto increment_q;
+        if (r_i < b_i)
+          goto keep_q;
+        if (i == 0)
+          break;
+        i--;
+      }
+  }
+  if (q_len > 0 && ((q_ptr[0] & 1) != 0))
+    /* q is odd.  */
+    increment_q:
+    {
+      size_t i;
+      for (i = 0; i < q_len; i++)
+        if (++(q_ptr[i]) != 0)
+          goto keep_q;
+      q_ptr[q_len++] = 1;
+    }
+  keep_q:
+  if (tmp_roomptr != NULL)
+    free (tmp_roomptr);
+  q->limbs = q_ptr;
+  q->nlimbs = q_len;
+  return roomptr;
+}
+
+/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal
+   representation.
+   Destroys the contents of a.
+   Return the allocated memory - containing the decimal digits in low-to-high
+   order, terminated with a NUL character - in case of success, NULL in case
+   of memory allocation failure.  */
+static char *
+convert_to_decimal (mpn_t a, size_t extra_zeroes)
+{
+  mp_limb_t *a_ptr = a.limbs;
+  size_t a_len = a.nlimbs;
+  /* 0.03345 is slightly larger than log(2)/(9*log(10)).  */
+  size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
+  char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes));
+  if (c_ptr != NULL)
+    {
+      char *d_ptr = c_ptr;
+      for (; extra_zeroes > 0; extra_zeroes--)
+        *d_ptr++ = '0';
+      while (a_len > 0)
+        {
+          /* Divide a by 10^9, in-place.  */
+          mp_limb_t remainder = 0;
+          mp_limb_t *ptr = a_ptr + a_len;
+          size_t count;
+          for (count = a_len; count > 0; count--)
+            {
+              mp_twolimb_t num =
+                ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
+              *ptr = num / 1000000000;
+              remainder = num % 1000000000;
+            }
+          /* Store the remainder as 9 decimal digits.  */
+          for (count = 9; count > 0; count--)
+            {
+              *d_ptr++ = '0' + (remainder % 10);
+              remainder = remainder / 10;
+            }
+          /* Normalize a.  */
+          if (a_ptr[a_len - 1] == 0)
+            a_len--;
+        }
+      /* Remove leading zeroes.  */
+      while (d_ptr > c_ptr && d_ptr[-1] == '0')
+        d_ptr--;
+      /* But keep at least one zero.  */
+      if (d_ptr == c_ptr)
+        *d_ptr++ = '0';
+      /* Terminate the string.  */
+      *d_ptr = '\0';
+    }
+  return c_ptr;
+}
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and >= 0:
+   write x as x = 2^e * m, where m is a bignum.
+   Return the allocated memory in case of success, NULL in case of memory
+   allocation failure.  */
+static void *
+decode_long_double (long double x, int *ep, mpn_t *mp)
+{
+  mpn_t m;
+  int exp;
+  long double y;
+  size_t i;
+
+  /* Allocate memory for result.  */
+  m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
+  m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
+  if (m.limbs == NULL)
+    return NULL;
+  /* Split into exponential part and mantissa.  */
+  y = frexpl (x, &exp);
+  if (!(y >= 0.0L && y < 1.0L))
+    abort ();
+  /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * LDBL_MANT_BIT), and the
+     latter is an integer.  */
+  /* Convert the mantissa (y * LDBL_MANT_BIT) to a sequence of limbs.
+     I'm not sure whether it's safe to cast a 'long double' value between
+     2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
+     'long double' values between 0 and 2^16 (to 'unsigned int' or 'int',
+     doesn't matter).  */
+#  if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0
+#   if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
+    {
+      mp_limb_t hi, lo;
+      y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2));
+      hi = (int) y;
+      y -= hi;
+      if (!(y >= 0.0L && y < 1.0L))
+        abort ();
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      lo = (int) y;
+      y -= lo;
+      if (!(y >= 0.0L && y < 1.0L))
+        abort ();
+      m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+    }
+#   else
+    {
+      mp_limb_t d;
+      y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS);
+      d = (int) y;
+      y -= d;
+      if (!(y >= 0.0L && y < 1.0L))
+        abort ();
+      m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
+    }
+#   endif
+#  endif
+  for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
+    {
+      mp_limb_t hi, lo;
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      hi = (int) y;
+      y -= hi;
+      if (!(y >= 0.0L && y < 1.0L))
+        abort ();
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      lo = (int) y;
+      y -= lo;
+      if (!(y >= 0.0L && y < 1.0L))
+        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 (!(y == 0.0L))
+    abort ();
+#  endif
+  /* Normalise.  */
+  while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
+    m.nlimbs--;
+  *mp = m;
+  *ep = exp - LDBL_MANT_BIT;
+  return m.limbs;
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and >= 0:
+   write x as x = 2^e * m, where m is a bignum.
+   Return the allocated memory in case of success, NULL in case of memory
+   allocation failure.  */
+static void *
+decode_double (double x, int *ep, mpn_t *mp)
+{
+  mpn_t m;
+  int exp;
+  double y;
+  size_t i;
+
+  /* Allocate memory for result.  */
+  m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
+  m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
+  if (m.limbs == NULL)
+    return NULL;
+  /* Split into exponential part and mantissa.  */
+  y = frexp (x, &exp);
+  if (!(y >= 0.0 && y < 1.0))
+    abort ();
+  /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * DBL_MANT_BIT), and the
+     latter is an integer.  */
+  /* Convert the mantissa (y * DBL_MANT_BIT) to a sequence of limbs.
+     I'm not sure whether it's safe to cast a 'double' value between
+     2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
+     'double' values between 0 and 2^16 (to 'unsigned int' or 'int',
+     doesn't matter).  */
+#  if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0
+#   if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2
+    {
+      mp_limb_t hi, lo;
+      y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2));
+      hi = (int) y;
+      y -= hi;
+      if (!(y >= 0.0 && y < 1.0))
+        abort ();
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      lo = (int) y;
+      y -= lo;
+      if (!(y >= 0.0 && y < 1.0))
+        abort ();
+      m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+    }
+#   else
+    {
+      mp_limb_t d;
+      y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS);
+      d = (int) y;
+      y -= d;
+      if (!(y >= 0.0 && y < 1.0))
+        abort ();
+      m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
+    }
+#   endif
+#  endif
+  for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
+    {
+      mp_limb_t hi, lo;
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      hi = (int) y;
+      y -= hi;
+      if (!(y >= 0.0 && y < 1.0))
+        abort ();
+      y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
+      lo = (int) y;
+      y -= lo;
+      if (!(y >= 0.0 && y < 1.0))
+        abort ();
+      m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
+    }
+  if (!(y == 0.0))
+    abort ();
+  /* Normalise.  */
+  while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
+    m.nlimbs--;
+  *mp = m;
+  *ep = exp - DBL_MANT_BIT;
+  return m.limbs;
+}
+
+# endif
+
+/* Assuming x = 2^e * m is finite and >= 0, and n is an integer:
+   Returns the decimal representation of round (x * 10^n).
+   Return the allocated memory - containing the decimal digits in low-to-high
+   order, terminated with a NUL character - in case of success, NULL in case
+   of memory allocation failure.  */
+static char *
+scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
+{
+  int s;
+  size_t extra_zeroes;
+  unsigned int abs_n;
+  unsigned int abs_s;
+  mp_limb_t *pow5_ptr;
+  size_t pow5_len;
+  unsigned int s_limbs;
+  unsigned int s_bits;
+  mpn_t pow5;
+  mpn_t z;
+  void *z_memory;
+  char *digits;
+
+  if (memory == NULL)
+    return NULL;
+  /* x = 2^e * m, hence
+     y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m)
+       = round (2^s * 5^n * m).  */
+  s = e + n;
+  extra_zeroes = 0;
+  /* Factor out a common power of 10 if possible.  */
+  if (s > 0 && n > 0)
+    {
+      extra_zeroes = (s < n ? s : n);
+      s -= extra_zeroes;
+      n -= extra_zeroes;
+    }
+  /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes.
+     Before converting to decimal, we need to compute
+     z = round (2^s * 5^n * m).  */
+  /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same
+     sign.  2.322 is slightly larger than log(5)/log(2).  */
+  abs_n = (n >= 0 ? n : -n);
+  abs_s = (s >= 0 ? s : -s);
+  pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
+                                    + abs_s / GMP_LIMB_BITS + 1)
+                                   * sizeof (mp_limb_t));
+  if (pow5_ptr == NULL)
+    {
+      free (memory);
+      return NULL;
+    }
+  /* Initialize with 1.  */
+  pow5_ptr[0] = 1;
+  pow5_len = 1;
+  /* Multiply with 5^|n|.  */
+  if (abs_n > 0)
+    {
+      static mp_limb_t const small_pow5[13 + 1] =
+        {
+          1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
+          48828125, 244140625, 1220703125
+        };
+      unsigned int n13;
+      for (n13 = 0; n13 <= abs_n; n13 += 13)
+        {
+          mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
+          size_t j;
+          mp_twolimb_t carry = 0;
+          for (j = 0; j < pow5_len; j++)
+            {
+              mp_limb_t digit2 = pow5_ptr[j];
+              carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+              pow5_ptr[j] = (mp_limb_t) carry;
+              carry = carry >> GMP_LIMB_BITS;
+            }
+          if (carry > 0)
+            pow5_ptr[pow5_len++] = (mp_limb_t) carry;
+        }
+    }
+  s_limbs = abs_s / GMP_LIMB_BITS;
+  s_bits = abs_s % GMP_LIMB_BITS;
+  if (n >= 0 ? s >= 0 : s <= 0)
+    {
+      /* Multiply with 2^|s|.  */
+      if (s_bits > 0)
+        {
+          mp_limb_t *ptr = pow5_ptr;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = pow5_len; count > 0; count--)
+            {
+              accu += (mp_twolimb_t) *ptr << s_bits;
+              *ptr++ = (mp_limb_t) accu;
+              accu = accu >> GMP_LIMB_BITS;
+            }
+          if (accu > 0)
+            {
+              *ptr = (mp_limb_t) accu;
+              pow5_len++;
+            }
+        }
+      if (s_limbs > 0)
+        {
+          size_t count;
+          for (count = pow5_len; count > 0;)
+            {
+              count--;
+              pow5_ptr[s_limbs + count] = pow5_ptr[count];
+            }
+          for (count = s_limbs; count > 0;)
+            {
+              count--;
+              pow5_ptr[count] = 0;
+            }
+          pow5_len += s_limbs;
+        }
+      pow5.limbs = pow5_ptr;
+      pow5.nlimbs = pow5_len;
+      if (n >= 0)
+        {
+          /* Multiply m with pow5.  No division needed.  */
+          z_memory = multiply (m, pow5, &z);
+        }
+      else
+        {
+          /* Divide m by pow5 and round.  */
+          z_memory = divide (m, pow5, &z);
+        }
+    }
+  else
+    {
+      pow5.limbs = pow5_ptr;
+      pow5.nlimbs = pow5_len;
+      if (n >= 0)
+        {
+          /* n >= 0, s < 0.
+             Multiply m with pow5, then divide by 2^|s|.  */
+          mpn_t numerator;
+          mpn_t denominator;
+          void *tmp_memory;
+          tmp_memory = multiply (m, pow5, &numerator);
+          if (tmp_memory == NULL)
+            {
+              free (pow5_ptr);
+              free (memory);
+              return NULL;
+            }
+          /* Construct 2^|s|.  */
+          {
+            mp_limb_t *ptr = pow5_ptr + pow5_len;
+            size_t i;
+            for (i = 0; i < s_limbs; i++)
+              ptr[i] = 0;
+            ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
+            denominator.limbs = ptr;
+            denominator.nlimbs = s_limbs + 1;
+          }
+          z_memory = divide (numerator, denominator, &z);
+          free (tmp_memory);
+        }
+      else
+        {
+          /* n < 0, s > 0.
+             Multiply m with 2^s, then divide by pow5.  */
+          mpn_t numerator;
+          mp_limb_t *num_ptr;
+          num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
+                                          * sizeof (mp_limb_t));
+          if (num_ptr == NULL)
+            {
+              free (pow5_ptr);
+              free (memory);
+              return NULL;
+            }
+          {
+            mp_limb_t *destptr = num_ptr;
+            {
+              size_t i;
+              for (i = 0; i < s_limbs; i++)
+                *destptr++ = 0;
+            }
+            if (s_bits > 0)
+              {
+                const mp_limb_t *sourceptr = m.limbs;
+                mp_twolimb_t accu = 0;
+                size_t count;
+                for (count = m.nlimbs; count > 0; count--)
+                  {
+                    accu += (mp_twolimb_t) *sourceptr++ << s_bits;
+                    *destptr++ = (mp_limb_t) accu;
+                    accu = accu >> GMP_LIMB_BITS;
+                  }
+                if (accu > 0)
+                  *destptr++ = (mp_limb_t) accu;
+              }
+            else
+              {
+                const mp_limb_t *sourceptr = m.limbs;
+                size_t count;
+                for (count = m.nlimbs; count > 0; count--)
+                  *destptr++ = *sourceptr++;
+              }
+            numerator.limbs = num_ptr;
+            numerator.nlimbs = destptr - num_ptr;
+          }
+          z_memory = divide (numerator, pow5, &z);
+          free (num_ptr);
+        }
+    }
+  free (pow5_ptr);
+  free (memory);
+
+  /* Here y = round (x * 10^n) = z * 10^extra_zeroes.  */
+
+  if (z_memory == NULL)
+    return NULL;
+  digits = convert_to_decimal (z, extra_zeroes);
+  free (z_memory);
+  return digits;
+}
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and >= 0, and n is an integer:
+   Returns the decimal representation of round (x * 10^n).
+   Return the allocated memory - containing the decimal digits in low-to-high
+   order, terminated with a NUL character - in case of success, NULL in case
+   of memory allocation failure.  */
+static char *
+scale10_round_decimal_long_double (long double x, int n)
+{
+  int e IF_LINT(= 0);
+  mpn_t m;
+  void *memory = decode_long_double (x, &e, &m);
+  return scale10_round_decimal_decoded (e, m, memory, n);
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and >= 0, and n is an integer:
+   Returns the decimal representation of round (x * 10^n).
+   Return the allocated memory - containing the decimal digits in low-to-high
+   order, terminated with a NUL character - in case of success, NULL in case
+   of memory allocation failure.  */
+static char *
+scale10_round_decimal_double (double x, int n)
+{
+  int e IF_LINT(= 0);
+  mpn_t m;
+  void *memory = decode_double (x, &e, &m);
+  return scale10_round_decimal_decoded (e, m, memory, n);
+}
+
+# endif
+
+# if NEED_PRINTF_LONG_DOUBLE
+
+/* Assuming x is finite and > 0:
+   Return an approximation for n with 10^n <= x < 10^(n+1).
+   The approximation is usually the right n, but may be off by 1 sometimes.  */
+static int
+floorlog10l (long double x)
+{
+  int exp;
+  long double y;
+  double z;
+  double l;
+
+  /* Split into exponential part and mantissa.  */
+  y = frexpl (x, &exp);
+  if (!(y >= 0.0L && y < 1.0L))
+    abort ();
+  if (y == 0.0L)
+    return INT_MIN;
+  if (y < 0.5L)
+    {
+      while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
+        {
+          y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+          exp -= GMP_LIMB_BITS;
+        }
+      if (y < (1.0L / (1 << 16)))
+        {
+          y *= 1.0L * (1 << 16);
+          exp -= 16;
+        }
+      if (y < (1.0L / (1 << 8)))
+        {
+          y *= 1.0L * (1 << 8);
+          exp -= 8;
+        }
+      if (y < (1.0L / (1 << 4)))
+        {
+          y *= 1.0L * (1 << 4);
+          exp -= 4;
+        }
+      if (y < (1.0L / (1 << 2)))
+        {
+          y *= 1.0L * (1 << 2);
+          exp -= 2;
+        }
+      if (y < (1.0L / (1 << 1)))
+        {
+          y *= 1.0L * (1 << 1);
+          exp -= 1;
+        }
+    }
+  if (!(y >= 0.5L && y < 1.0L))
+    abort ();
+  /* Compute an approximation for l = log2(x) = exp + log2(y).  */
+  l = exp;
+  z = y;
+  if (z < 0.70710678118654752444)
+    {
+      z *= 1.4142135623730950488;
+      l -= 0.5;
+    }
+  if (z < 0.8408964152537145431)
+    {
+      z *= 1.1892071150027210667;
+      l -= 0.25;
+    }
+  if (z < 0.91700404320467123175)
+    {
+      z *= 1.0905077326652576592;
+      l -= 0.125;
+    }
+  if (z < 0.9576032806985736469)
+    {
+      z *= 1.0442737824274138403;
+      l -= 0.0625;
+    }
+  /* Now 0.95 <= z <= 1.01.  */
+  z = 1 - z;
+  /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
+     Four terms are enough to get an approximation with error < 10^-7.  */
+  l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
+  /* Finally multiply with log(2)/log(10), yields an approximation for
+     log10(x).  */
+  l *= 0.30102999566398119523;
+  /* Round down to the next integer.  */
+  return (int) l + (l < 0 ? -1 : 0);
+}
+
+# endif
+
+# if NEED_PRINTF_DOUBLE
+
+/* Assuming x is finite and > 0:
+   Return an approximation for n with 10^n <= x < 10^(n+1).
+   The approximation is usually the right n, but may be off by 1 sometimes.  */
+static int
+floorlog10 (double x)
+{
+  int exp;
+  double y;
+  double z;
+  double l;
+
+  /* Split into exponential part and mantissa.  */
+  y = frexp (x, &exp);
+  if (!(y >= 0.0 && y < 1.0))
+    abort ();
+  if (y == 0.0)
+    return INT_MIN;
+  if (y < 0.5)
+    {
+      while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
+        {
+          y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+          exp -= GMP_LIMB_BITS;
+        }
+      if (y < (1.0 / (1 << 16)))
+        {
+          y *= 1.0 * (1 << 16);
+          exp -= 16;
+        }
+      if (y < (1.0 / (1 << 8)))
+        {
+          y *= 1.0 * (1 << 8);
+          exp -= 8;
+        }
+      if (y < (1.0 / (1 << 4)))
+        {
+          y *= 1.0 * (1 << 4);
+          exp -= 4;
+        }
+      if (y < (1.0 / (1 << 2)))
+        {
+          y *= 1.0 * (1 << 2);
+          exp -= 2;
+        }
+      if (y < (1.0 / (1 << 1)))
+        {
+          y *= 1.0 * (1 << 1);
+          exp -= 1;
+        }
+    }
+  if (!(y >= 0.5 && y < 1.0))
+    abort ();
+  /* Compute an approximation for l = log2(x) = exp + log2(y).  */
+  l = exp;
+  z = y;
+  if (z < 0.70710678118654752444)
+    {
+      z *= 1.4142135623730950488;
+      l -= 0.5;
+    }
+  if (z < 0.8408964152537145431)
+    {
+      z *= 1.1892071150027210667;
+      l -= 0.25;
+    }
+  if (z < 0.91700404320467123175)
+    {
+      z *= 1.0905077326652576592;
+      l -= 0.125;
+    }
+  if (z < 0.9576032806985736469)
+    {
+      z *= 1.0442737824274138403;
+      l -= 0.0625;
+    }
+  /* Now 0.95 <= z <= 1.01.  */
+  z = 1 - z;
+  /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
+     Four terms are enough to get an approximation with error < 10^-7.  */
+  l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
+  /* Finally multiply with log(2)/log(10), yields an approximation for
+     log10(x).  */
+  l *= 0.30102999566398119523;
+  /* Round down to the next integer.  */
+  return (int) l + (l < 0 ? -1 : 0);
+}
+
+# endif
+
+/* Tests whether a string of digits consists of exactly PRECISION zeroes and
+   a single '1' digit.  */
+static int
+is_borderline (const char *digits, size_t precision)
+{
+  for (; precision > 0; precision--, digits++)
+    if (*digits != '0')
+      return 0;
+  if (*digits != '1')
+    return 0;
+  digits++;
+  return *digits == '\0';
+}
+
+#endif
+
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
+
+/* Use a different function name, to make it possible that the 'wchar_t'
+   parametrization and the 'char' parametrization get compiled in the same
+   translation unit.  */
+# if WIDE_CHAR_VERSION
+#  define MAX_ROOM_NEEDED wmax_room_needed
+# else
+#  define MAX_ROOM_NEEDED max_room_needed
+# endif
+
+/* Returns the number of TCHAR_T units needed as temporary space for the result
+   of sprintf or SNPRINTF of a single conversion directive.  */
+static inline size_t
+MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
+                 arg_type type, int flags, size_t width, int has_precision,
+                 size_t precision, int pad_ourselves)
+{
+  size_t tmp_length;
+
+  switch (conversion)
+    {
+    case 'd': case 'i': case 'u':
+# if HAVE_LONG_LONG_INT
+      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                          * 0.30103 /* binary -> decimal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+# endif
+      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                          * 0.30103 /* binary -> decimal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+        tmp_length =
+          (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                          * 0.30103 /* binary -> decimal */
+                         )
+          + 1; /* turn floor into ceil */
+      if (tmp_length < precision)
+        tmp_length = precision;
+      /* Multiply by 2, as an estimate for FLAG_GROUP.  */
+      tmp_length = xsum (tmp_length, tmp_length);
+      /* Add 1, to account for a leading sign.  */
+      tmp_length = xsum (tmp_length, 1);
+      break;
+
+    case 'o':
+# if HAVE_LONG_LONG_INT
+      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                          * 0.333334 /* binary -> octal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+# endif
+      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                          * 0.333334 /* binary -> octal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+        tmp_length =
+          (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                          * 0.333334 /* binary -> octal */
+                         )
+          + 1; /* turn floor into ceil */
+      if (tmp_length < precision)
+        tmp_length = precision;
+      /* Add 1, to account for a leading sign.  */
+      tmp_length = xsum (tmp_length, 1);
+      break;
+
+    case 'x': case 'X':
+# if HAVE_LONG_LONG_INT
+      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                          * 0.25 /* binary -> hexadecimal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+# endif
+      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+        tmp_length =
+          (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                          * 0.25 /* binary -> hexadecimal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+        tmp_length =
+          (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                          * 0.25 /* binary -> hexadecimal */
+                         )
+          + 1; /* turn floor into ceil */
+      if (tmp_length < precision)
+        tmp_length = precision;
+      /* Add 2, to account for a leading sign or alternate form.  */
+      tmp_length = xsum (tmp_length, 2);
+      break;
+
+    case 'f': case 'F':
+      if (type == TYPE_LONGDOUBLE)
+        tmp_length =
+          (unsigned int) (LDBL_MAX_EXP
+                          * 0.30103 /* binary -> decimal */
+                          * 2 /* estimate for FLAG_GROUP */
+                         )
+          + 1 /* turn floor into ceil */
+          + 10; /* sign, decimal point etc. */
+      else
+        tmp_length =
+          (unsigned int) (DBL_MAX_EXP
+                          * 0.30103 /* binary -> decimal */
+                          * 2 /* estimate for FLAG_GROUP */
+                         )
+          + 1 /* turn floor into ceil */
+          + 10; /* sign, decimal point etc. */
+      tmp_length = xsum (tmp_length, precision);
+      break;
+
+    case 'e': case 'E': case 'g': case 'G':
+      tmp_length =
+        12; /* sign, decimal point, exponent etc. */
+      tmp_length = xsum (tmp_length, precision);
+      break;
+
+    case 'a': case 'A':
+      if (type == TYPE_LONGDOUBLE)
+        tmp_length =
+          (unsigned int) (LDBL_DIG
+                          * 0.831 /* decimal -> hexadecimal */
+                         )
+          + 1; /* turn floor into ceil */
+      else
+        tmp_length =
+          (unsigned int) (DBL_DIG
+                          * 0.831 /* decimal -> hexadecimal */
+                         )
+          + 1; /* turn floor into ceil */
+      if (tmp_length < precision)
+        tmp_length = precision;
+      /* Account for sign, decimal point etc. */
+      tmp_length = xsum (tmp_length, 12);
+      break;
+
+    case 'c':
+# if HAVE_WINT_T && !WIDE_CHAR_VERSION
+      if (type == TYPE_WIDE_CHAR)
+        tmp_length = MB_CUR_MAX;
+      else
+# endif
+        tmp_length = 1;
+      break;
+
+    case 's':
+# if HAVE_WCHAR_T
+      if (type == TYPE_WIDE_STRING)
+        {
+#  if WIDE_CHAR_VERSION
+          /* ISO C says about %ls in fwprintf:
+               "If the precision is not specified or is greater than the size
+                of the array, the array shall contain a null wide character."
+             So if there is a precision, we must not use wcslen.  */
+          const wchar_t *arg = ap->arg[arg_index].a.a_wide_string;
+
+          if (has_precision)
+            tmp_length = local_wcsnlen (arg, precision);
+          else
+            tmp_length = local_wcslen (arg);
+#  else
+          /* ISO C says about %ls in fprintf:
+               "If a precision is specified, no more than that many bytes are
+                written (including shift sequences, if any), and the array
+                shall contain a null wide character if, to equal the multibyte
+                character sequence length given by the precision, the function
+                would need to access a wide character one past the end of the
+                array."
+             So if there is a precision, we must not use wcslen.  */
+          /* This case has already been handled separately in VASNPRINTF.  */
+          abort ();
+#  endif
+        }
+      else
+# endif
+        {
+# if WIDE_CHAR_VERSION
+          /* ISO C says about %s in fwprintf:
+               "If the precision is not specified or is greater than the size
+                of the converted array, the converted array shall contain a
+                null wide character."
+             So if there is a precision, we must not use strlen.  */
+          /* This case has already been handled separately in VASNPRINTF.  */
+          abort ();
+# else
+          /* ISO C says about %s in fprintf:
+               "If the precision is not specified or greater than the size of
+                the array, the array shall contain a null character."
+             So if there is a precision, we must not use strlen.  */
+          const char *arg = ap->arg[arg_index].a.a_string;
+
+          if (has_precision)
+            tmp_length = local_strnlen (arg, precision);
+          else
+            tmp_length = strlen (arg);
+# endif
+        }
+      break;
+
+    case 'p':
+      tmp_length =
+        (unsigned int) (sizeof (void *) * CHAR_BIT
+                        * 0.25 /* binary -> hexadecimal */
+                       )
+          + 1 /* turn floor into ceil */
+          + 2; /* account for leading 0x */
+      break;
+
+    default:
+      abort ();
+    }
+
+  if (!pad_ourselves)
+    {
+# if ENABLE_UNISTDIO
+      /* Padding considers the number of characters, therefore the number of
+         elements after padding may be
+           > max (tmp_length, width)
+         but is certainly
+           <= tmp_length + width.  */
+      tmp_length = xsum (tmp_length, width);
+# else
+      /* Padding considers the number of elements, says POSIX.  */
+      if (tmp_length < width)
+        tmp_length = width;
+# endif
+    }
+
+  tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+  return tmp_length;
+}
+
+#endif
+
+DCHAR_T *
+VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
+            const FCHAR_T *format, va_list args)
+{
+  DIRECTIVES d;
+  arguments a;
+
+  if (PRINTF_PARSE (format, &d, &a) < 0)
+    /* errno is already set.  */
+    return NULL;
+
+#define CLEANUP() \
+  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)
+    {
+      CLEANUP ();
+      errno = EINVAL;
+      return NULL;
+    }
+
+  {
+    size_t buf_neededlength;
+    TCHAR_T *buf;
+    TCHAR_T *buf_malloced;
+    const FCHAR_T *cp;
+    size_t i;
+    DIRECTIVE *dp;
+    /* Output string accumulator.  */
+    DCHAR_T *result;
+    size_t allocated;
+    size_t length;
+
+    /* Allocate a small buffer that will hold a directive passed to
+       sprintf or snprintf.  */
+    buf_neededlength =
+      xsum4 (7, d.max_width_length, d.max_precision_length, 6);
+#if HAVE_ALLOCA
+    if (buf_neededlength < 4000 / sizeof (TCHAR_T))
+      {
+        buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
+        buf_malloced = NULL;
+      }
+    else
+#endif
+      {
+        size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
+        if (size_overflow_p (buf_memsize))
+          goto out_of_memory_1;
+        buf = (TCHAR_T *) malloc (buf_memsize);
+        if (buf == NULL)
+          goto out_of_memory_1;
+        buf_malloced = buf;
+      }
+
+    if (resultbuf != NULL)
+      {
+        result = resultbuf;
+        allocated = *lengthp;
+      }
+    else
+      {
+        result = NULL;
+        allocated = 0;
+      }
+    length = 0;
+    /* Invariants:
+       result is either == resultbuf or == NULL or malloc-allocated.
+       If length > 0, then result != NULL.  */
+
+    /* Ensures that allocated >= needed.  Aborts through a jump to
+       out_of_memory if needed is SIZE_MAX or otherwise too big.  */
+#define ENSURE_ALLOCATION(needed) \
+    if ((needed) > allocated)                                                \
+      {                                                                      \
+        size_t memory_size;                                                  \
+        DCHAR_T *memory;                                                     \
+                                                                             \
+        allocated = (allocated > 0 ? xtimes (allocated, 2) : 12);            \
+        if ((needed) > allocated)                                            \
+          allocated = (needed);                                              \
+        memory_size = xtimes (allocated, sizeof (DCHAR_T));                  \
+        if (size_overflow_p (memory_size))                                   \
+          goto out_of_memory;                                                \
+        if (result == resultbuf || result == NULL)                           \
+          memory = (DCHAR_T *) malloc (memory_size);                         \
+        else                                                                 \
+          memory = (DCHAR_T *) realloc (result, memory_size);                \
+        if (memory == NULL)                                                  \
+          goto out_of_memory;                                                \
+        if (result == resultbuf && length > 0)                               \
+          DCHAR_CPY (memory, result, length);                                \
+        result = memory;                                                     \
+      }
+
+    for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
+      {
+        if (cp != dp->dir_start)
+          {
+            size_t n = dp->dir_start - cp;
+            size_t augmented_length = xsum (length, n);
+
+            ENSURE_ALLOCATION (augmented_length);
+            /* This copies a piece of FCHAR_T[] into a DCHAR_T[].  Here we
+               need that the format string contains only ASCII characters
+               if FCHAR_T and DCHAR_T are not the same type.  */
+            if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
+              {
+                DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
+                length = augmented_length;
+              }
+            else
+              {
+                do
+                  result[length++] = (unsigned char) *cp++;
+                while (--n > 0);
+              }
+          }
+        if (i == d.count)
+          break;
+
+        /* Execute a single directive.  */
+        if (dp->conversion == '%')
+          {
+            size_t augmented_length;
+
+            if (!(dp->arg_index == ARG_NONE))
+              abort ();
+            augmented_length = xsum (length, 1);
+            ENSURE_ALLOCATION (augmented_length);
+            result[length] = '%';
+            length = augmented_length;
+          }
+        else
+          {
+            if (!(dp->arg_index != ARG_NONE))
+              abort ();
+
+            if (dp->conversion == 'n')
+              {
+                switch (a.arg[dp->arg_index].type)
+                  {
+                  case TYPE_COUNT_SCHAR_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
+                    break;
+                  case TYPE_COUNT_SHORT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_short_pointer = length;
+                    break;
+                  case TYPE_COUNT_INT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_int_pointer = length;
+                    break;
+                  case TYPE_COUNT_LONGINT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
+                    break;
+#if HAVE_LONG_LONG_INT
+                  case TYPE_COUNT_LONGLONGINT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
+                    break;
+#endif
+                  default:
+                    abort ();
+                  }
+              }
+#if ENABLE_UNISTDIO
+            /* The unistdio extensions.  */
+            else if (dp->conversion == 'U')
+              {
+                arg_type type = a.arg[dp->arg_index].type;
+                int flags = dp->flags;
+                int has_width;
+                size_t width;
+                int has_precision;
+                size_t precision;
+
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+
+                has_precision = 0;
+                precision = 0;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+                switch (type)
+                  {
+                  case TYPE_U8_STRING:
+                    {
+                      const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
+                      const uint8_t *arg_end;
+                      size_t characters;
+
+                      if (has_precision)
+                        {
+                          /* Use only PRECISION characters, from the left.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (; precision > 0; precision--)
+                            {
+                              int count = u8_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else if (has_width)
+                        {
+                          /* Use the entire string, and count the number of
+                             characters.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (;;)
+                            {
+                              int count = u8_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else
+                        {
+                          /* Use the entire string.  */
+                          arg_end = arg + u8_strlen (arg);
+                          /* The number of characters doesn't matter.  */
+                          characters = 0;
+                        }
+
+                      if (has_width && width > characters
+                          && !(dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+
+# if DCHAR_IS_UINT8_T
+                      {
+                        size_t n = arg_end - arg;
+                        ENSURE_ALLOCATION (xsum (length, n));
+                        DCHAR_CPY (result + length, arg, n);
+                        length += n;
+                      }
+# else
+                      { /* Convert.  */
+                        DCHAR_T *converted = result + length;
+                        size_t converted_len = allocated - length;
+#  if DCHAR_IS_TCHAR
+                        /* Convert from UTF-8 to locale encoding.  */
+                        converted =
+                          u8_conv_to_encoding (locale_charset (),
+                                               iconveh_question_mark,
+                                               arg, arg_end - arg, NULL,
+                                               converted, &converted_len);
+#  else
+                        /* Convert from UTF-8 to UTF-16/UTF-32.  */
+                        converted =
+                          U8_TO_DCHAR (arg, arg_end - arg,
+                                       converted, &converted_len);
+#  endif
+                        if (converted == NULL)
+                          {
+                            int saved_errno = errno;
+                            if (!(result == resultbuf || result == NULL))
+                              free (result);
+                            if (buf_malloced != NULL)
+                              free (buf_malloced);
+                            CLEANUP ();
+                            errno = saved_errno;
+                            return NULL;
+                          }
+                        if (converted != result + length)
+                          {
+                            ENSURE_ALLOCATION (xsum (length, converted_len));
+                            DCHAR_CPY (result + length, converted, converted_len);
+                            free (converted);
+                          }
+                        length += converted_len;
+                      }
+# endif
+
+                      if (has_width && width > characters
+                          && (dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+                    }
+                    break;
+
+                  case TYPE_U16_STRING:
+                    {
+                      const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
+                      const uint16_t *arg_end;
+                      size_t characters;
+
+                      if (has_precision)
+                        {
+                          /* Use only PRECISION characters, from the left.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (; precision > 0; precision--)
+                            {
+                              int count = u16_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else if (has_width)
+                        {
+                          /* Use the entire string, and count the number of
+                             characters.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (;;)
+                            {
+                              int count = u16_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else
+                        {
+                          /* Use the entire string.  */
+                          arg_end = arg + u16_strlen (arg);
+                          /* The number of characters doesn't matter.  */
+                          characters = 0;
+                        }
+
+                      if (has_width && width > characters
+                          && !(dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+
+# if DCHAR_IS_UINT16_T
+                      {
+                        size_t n = arg_end - arg;
+                        ENSURE_ALLOCATION (xsum (length, n));
+                        DCHAR_CPY (result + length, arg, n);
+                        length += n;
+                      }
+# else
+                      { /* Convert.  */
+                        DCHAR_T *converted = result + length;
+                        size_t converted_len = allocated - length;
+#  if DCHAR_IS_TCHAR
+                        /* Convert from UTF-16 to locale encoding.  */
+                        converted =
+                          u16_conv_to_encoding (locale_charset (),
+                                                iconveh_question_mark,
+                                                arg, arg_end - arg, NULL,
+                                                converted, &converted_len);
+#  else
+                        /* Convert from UTF-16 to UTF-8/UTF-32.  */
+                        converted =
+                          U16_TO_DCHAR (arg, arg_end - arg,
+                                        converted, &converted_len);
+#  endif
+                        if (converted == NULL)
+                          {
+                            int saved_errno = errno;
+                            if (!(result == resultbuf || result == NULL))
+                              free (result);
+                            if (buf_malloced != NULL)
+                              free (buf_malloced);
+                            CLEANUP ();
+                            errno = saved_errno;
+                            return NULL;
+                          }
+                        if (converted != result + length)
+                          {
+                            ENSURE_ALLOCATION (xsum (length, converted_len));
+                            DCHAR_CPY (result + length, converted, converted_len);
+                            free (converted);
+                          }
+                        length += converted_len;
+                      }
+# endif
+
+                      if (has_width && width > characters
+                          && (dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+                    }
+                    break;
+
+                  case TYPE_U32_STRING:
+                    {
+                      const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
+                      const uint32_t *arg_end;
+                      size_t characters;
+
+                      if (has_precision)
+                        {
+                          /* Use only PRECISION characters, from the left.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (; precision > 0; precision--)
+                            {
+                              int count = u32_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else if (has_width)
+                        {
+                          /* Use the entire string, and count the number of
+                             characters.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (;;)
+                            {
+                              int count = u32_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else
+                        {
+                          /* Use the entire string.  */
+                          arg_end = arg + u32_strlen (arg);
+                          /* The number of characters doesn't matter.  */
+                          characters = 0;
+                        }
+
+                      if (has_width && width > characters
+                          && !(dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+
+# if DCHAR_IS_UINT32_T
+                      {
+                        size_t n = arg_end - arg;
+                        ENSURE_ALLOCATION (xsum (length, n));
+                        DCHAR_CPY (result + length, arg, n);
+                        length += n;
+                      }
+# else
+                      { /* Convert.  */
+                        DCHAR_T *converted = result + length;
+                        size_t converted_len = allocated - length;
+#  if DCHAR_IS_TCHAR
+                        /* Convert from UTF-32 to locale encoding.  */
+                        converted =
+                          u32_conv_to_encoding (locale_charset (),
+                                                iconveh_question_mark,
+                                                arg, arg_end - arg, NULL,
+                                                converted, &converted_len);
+#  else
+                        /* Convert from UTF-32 to UTF-8/UTF-16.  */
+                        converted =
+                          U32_TO_DCHAR (arg, arg_end - arg,
+                                        converted, &converted_len);
+#  endif
+                        if (converted == NULL)
+                          {
+                            int saved_errno = errno;
+                            if (!(result == resultbuf || result == NULL))
+                              free (result);
+                            if (buf_malloced != NULL)
+                              free (buf_malloced);
+                            CLEANUP ();
+                            errno = saved_errno;
+                            return NULL;
+                          }
+                        if (converted != result + length)
+                          {
+                            ENSURE_ALLOCATION (xsum (length, converted_len));
+                            DCHAR_CPY (result + length, converted, converted_len);
+                            free (converted);
+                          }
+                        length += converted_len;
+                      }
+# endif
+
+                      if (has_width && width > characters
+                          && (dp->flags & FLAG_LEFT))
+                        {
+                          size_t n = width - characters;
+                          ENSURE_ALLOCATION (xsum (length, n));
+                          DCHAR_SET (result + length, ' ', n);
+                          length += n;
+                        }
+                    }
+                    break;
+
+                  default:
+                    abort ();
+                  }
+              }
+#endif
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+            else if (dp->conversion == 's'
+# if WIDE_CHAR_VERSION
+                     && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
+# else
+                     && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
+# endif
+                    )
+              {
+                /* The normal handling of the 's' directive below requires
+                   allocating a temporary buffer.  The determination of its
+                   length (tmp_length), in the case when a precision is
+                   specified, below requires a conversion between a char[]
+                   string and a wchar_t[] wide string.  It could be done, but
+                   we have no guarantee that the implementation of sprintf will
+                   use the exactly same algorithm.  Without this guarantee, it
+                   is possible to have buffer overrun bugs.  In order to avoid
+                   such bugs, we implement the entire processing of the 's'
+                   directive ourselves.  */
+                int flags = dp->flags;
+                int has_width;
+                size_t width;
+                int has_precision;
+                size_t precision;
+
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+
+                has_precision = 0;
+                precision = 6;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+# if WIDE_CHAR_VERSION
+                /* %s in vasnwprintf.  See the specification of fwprintf.  */
+                {
+                  const char *arg = a.arg[dp->arg_index].a.a_string;
+                  const char *arg_end;
+                  size_t characters;
+
+                  if (has_precision)
+                    {
+                      /* Use only as many bytes as needed to produce PRECISION
+                         wide characters, from the left.  */
+#  if HAVE_MBRTOWC
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      arg_end = arg;
+                      characters = 0;
+                      for (; precision > 0; precision--)
+                        {
+                          int count;
+#  if HAVE_MBRTOWC
+                          count = mbrlen (arg_end, MB_CUR_MAX, &state);
+#  else
+                          count = mblen (arg_end, MB_CUR_MAX);
+#  endif
+                          if (count == 0)
+                            /* Found the terminating NUL.  */
+                            break;
+                          if (count < 0)
+                            {
+                              /* Invalid or incomplete multibyte character.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
+                          arg_end += count;
+                          characters++;
+                        }
+                    }
+                  else if (has_width)
+                    {
+                      /* Use the entire string, and count the number of wide
+                         characters.  */
+#  if HAVE_MBRTOWC
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      arg_end = arg;
+                      characters = 0;
+                      for (;;)
+                        {
+                          int count;
+#  if HAVE_MBRTOWC
+                          count = mbrlen (arg_end, MB_CUR_MAX, &state);
+#  else
+                          count = mblen (arg_end, MB_CUR_MAX);
+#  endif
+                          if (count == 0)
+                            /* Found the terminating NUL.  */
+                            break;
+                          if (count < 0)
+                            {
+                              /* Invalid or incomplete multibyte character.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
+                          arg_end += count;
+                          characters++;
+                        }
+                    }
+                  else
+                    {
+                      /* Use the entire string.  */
+                      arg_end = arg + strlen (arg);
+                      /* The number of characters doesn't matter.  */
+                      characters = 0;
+                    }
+
+                  if (has_width && width > characters
+                      && !(dp->flags & FLAG_LEFT))
+                    {
+                      size_t n = width - characters;
+                      ENSURE_ALLOCATION (xsum (length, n));
+                      DCHAR_SET (result + length, ' ', n);
+                      length += n;
+                    }
+
+                  if (has_precision || has_width)
+                    {
+                      /* We know the number of wide characters in advance.  */
+                      size_t remaining;
+#  if HAVE_MBRTOWC
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      ENSURE_ALLOCATION (xsum (length, characters));
+                      for (remaining = characters; remaining > 0; remaining--)
+                        {
+                          wchar_t wc;
+                          int count;
+#  if HAVE_MBRTOWC
+                          count = mbrtowc (&wc, arg, arg_end - arg, &state);
+#  else
+                          count = mbtowc (&wc, arg, arg_end - arg);
+#  endif
+                          if (count <= 0)
+                            /* mbrtowc not consistent with mbrlen, or mbtowc
+                               not consistent with mblen.  */
+                            abort ();
+                          result[length++] = wc;
+                          arg += count;
+                        }
+                      if (!(arg == arg_end))
+                        abort ();
+                    }
+                  else
+                    {
+#  if HAVE_MBRTOWC
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      while (arg < arg_end)
+                        {
+                          wchar_t wc;
+                          int count;
+#  if HAVE_MBRTOWC
+                          count = mbrtowc (&wc, arg, arg_end - arg, &state);
+#  else
+                          count = mbtowc (&wc, arg, arg_end - arg);
+#  endif
+                          if (count <= 0)
+                            /* mbrtowc not consistent with mbrlen, or mbtowc
+                               not consistent with mblen.  */
+                            abort ();
+                          ENSURE_ALLOCATION (xsum (length, 1));
+                          result[length++] = wc;
+                          arg += count;
+                        }
+                    }
+
+                  if (has_width && width > characters
+                      && (dp->flags & FLAG_LEFT))
+                    {
+                      size_t n = width - characters;
+                      ENSURE_ALLOCATION (xsum (length, n));
+                      DCHAR_SET (result + length, ' ', n);
+                      length += n;
+                    }
+                }
+# else
+                /* %ls in vasnprintf.  See the specification of fprintf.  */
+                {
+                  const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+                  const wchar_t *arg_end;
+                  size_t characters;
+#  if !DCHAR_IS_TCHAR
+                  /* This code assumes that TCHAR_T is 'char'.  */
+                  verify (sizeof (TCHAR_T) == 1);
+                  TCHAR_T *tmpsrc;
+                  DCHAR_T *tmpdst;
+                  size_t tmpdst_len;
+#  endif
+                  size_t w;
+
+                  if (has_precision)
+                    {
+                      /* Use only as many wide characters as needed to produce
+                         at most PRECISION bytes, from the left.  */
+#  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      arg_end = arg;
+                      characters = 0;
+                      while (precision > 0)
+                        {
+                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                          int count;
+
+                          if (*arg_end == 0)
+                            /* Found the terminating null wide character.  */
+                            break;
+#  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                          count = wcrtomb (cbuf, *arg_end, &state);
+#  else
+                          count = wctomb (cbuf, *arg_end);
+#  endif
+                          if (count < 0)
+                            {
+                              /* Cannot convert.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
+                          if (precision < count)
+                            break;
+                          arg_end++;
+                          characters += count;
+                          precision -= count;
+                        }
+                    }
+#  if DCHAR_IS_TCHAR
+                  else if (has_width)
+#  else
+                  else
+#  endif
+                    {
+                      /* Use the entire string, and count the number of
+                         bytes.  */
+#  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+                      arg_end = arg;
+                      characters = 0;
+                      for (;;)
+                        {
+                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                          int count;
+
+                          if (*arg_end == 0)
+                            /* Found the terminating null wide character.  */
+                            break;
+#  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                          count = wcrtomb (cbuf, *arg_end, &state);
+#  else
+                          count = wctomb (cbuf, *arg_end);
+#  endif
+                          if (count < 0)
+                            {
+                              /* Cannot convert.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
+                          arg_end++;
+                          characters += count;
+                        }
+                    }
+#  if DCHAR_IS_TCHAR
+                  else
+                    {
+                      /* Use the entire string.  */
+                      arg_end = arg + local_wcslen (arg);
+                      /* The number of bytes doesn't matter.  */
+                      characters = 0;
+                    }
+#  endif
+
+#  if !DCHAR_IS_TCHAR
+                  /* Convert the string into a piece of temporary memory.  */
+                  tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
+                  if (tmpsrc == NULL)
+                    goto out_of_memory;
+                  {
+                    TCHAR_T *tmpptr = tmpsrc;
+                    size_t remaining;
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                    mbstate_t state;
+                    memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+                    for (remaining = characters; remaining > 0; )
+                      {
+                        char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                        int count;
+
+                        if (*arg == 0)
+                          abort ();
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                        count = wcrtomb (cbuf, *arg, &state);
+#   else
+                        count = wctomb (cbuf, *arg);
+#   endif
+                        if (count <= 0)
+                          /* Inconsistency.  */
+                          abort ();
+                        memcpy (tmpptr, cbuf, count);
+                        tmpptr += count;
+                        arg++;
+                        remaining -= count;
+                      }
+                    if (!(arg == arg_end))
+                      abort ();
+                  }
+
+                  /* Convert from TCHAR_T[] to DCHAR_T[].  */
+                  tmpdst =
+                    DCHAR_CONV_FROM_ENCODING (locale_charset (),
+                                              iconveh_question_mark,
+                                              tmpsrc, characters,
+                                              NULL,
+                                              NULL, &tmpdst_len);
+                  if (tmpdst == NULL)
+                    {
+                      int saved_errno = errno;
+                      free (tmpsrc);
+                      if (!(result == resultbuf || result == NULL))
+                        free (result);
+                      if (buf_malloced != NULL)
+                        free (buf_malloced);
+                      CLEANUP ();
+                      errno = saved_errno;
+                      return NULL;
+                    }
+                  free (tmpsrc);
+#  endif
+
+                  if (has_width)
+                    {
+#  if ENABLE_UNISTDIO
+                      /* Outside POSIX, it's preferrable to compare the width
+                         against the number of _characters_ of the converted
+                         value.  */
+                      w = DCHAR_MBSNLEN (result + length, characters);
+#  else
+                      /* The width is compared against the number of _bytes_
+                         of the converted value, says POSIX.  */
+                      w = characters;
+#  endif
+                    }
+                  else
+                    /* w doesn't matter.  */
+                    w = 0;
+
+                  if (has_width && width > w
+                      && !(dp->flags & FLAG_LEFT))
+                    {
+                      size_t n = width - w;
+                      ENSURE_ALLOCATION (xsum (length, n));
+                      DCHAR_SET (result + length, ' ', n);
+                      length += n;
+                    }
+
+#  if DCHAR_IS_TCHAR
+                  if (has_precision || has_width)
+                    {
+                      /* We know the number of bytes in advance.  */
+                      size_t remaining;
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+                      ENSURE_ALLOCATION (xsum (length, characters));
+                      for (remaining = characters; remaining > 0; )
+                        {
+                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                          int count;
+
+                          if (*arg == 0)
+                            abort ();
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                          count = wcrtomb (cbuf, *arg, &state);
+#   else
+                          count = wctomb (cbuf, *arg);
+#   endif
+                          if (count <= 0)
+                            /* Inconsistency.  */
+                            abort ();
+                          memcpy (result + length, cbuf, count);
+                          length += count;
+                          arg++;
+                          remaining -= count;
+                        }
+                      if (!(arg == arg_end))
+                        abort ();
+                    }
+                  else
+                    {
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                      mbstate_t state;
+                      memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+                      while (arg < arg_end)
+                        {
+                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                          int count;
+
+                          if (*arg == 0)
+                            abort ();
+#   if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
+                          count = wcrtomb (cbuf, *arg, &state);
+#   else
+                          count = wctomb (cbuf, *arg);
+#   endif
+                          if (count <= 0)
+                            {
+                              /* Cannot convert.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
+                          ENSURE_ALLOCATION (xsum (length, count));
+                          memcpy (result + length, cbuf, count);
+                          length += count;
+                          arg++;
+                        }
+                    }
+#  else
+                  ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+                  DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+                  free (tmpdst);
+                  length += tmpdst_len;
+#  endif
+
+                  if (has_width && width > w
+                      && (dp->flags & FLAG_LEFT))
+                    {
+                      size_t n = width - w;
+                      ENSURE_ALLOCATION (xsum (length, n));
+                      DCHAR_SET (result + length, ' ', n);
+                      length += n;
+                    }
+                }
+# endif
+              }
+#endif
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
+            else if ((dp->conversion == 'a' || dp->conversion == 'A')
+# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
+                     && (0
+#  if NEED_PRINTF_DOUBLE
+                         || a.arg[dp->arg_index].type == TYPE_DOUBLE
+#  endif
+#  if NEED_PRINTF_LONG_DOUBLE
+                         || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+#  endif
+                        )
+# endif
+                    )
+              {
+                arg_type type = a.arg[dp->arg_index].type;
+                int flags = dp->flags;
+                int has_width;
+                size_t width;
+                int has_precision;
+                size_t precision;
+                size_t tmp_length;
+                DCHAR_T tmpbuf[700];
+                DCHAR_T *tmp;
+                DCHAR_T *pad_ptr;
+                DCHAR_T *p;
+
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+
+                has_precision = 0;
+                precision = 0;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+                /* Allocate a temporary buffer of sufficient size.  */
+                if (type == TYPE_LONGDOUBLE)
+                  tmp_length =
+                    (unsigned int) ((LDBL_DIG + 1)
+                                    * 0.831 /* decimal -> hexadecimal */
+                                   )
+                    + 1; /* turn floor into ceil */
+                else
+                  tmp_length =
+                    (unsigned int) ((DBL_DIG + 1)
+                                    * 0.831 /* decimal -> hexadecimal */
+                                   )
+                    + 1; /* turn floor into ceil */
+                if (tmp_length < precision)
+                  tmp_length = precision;
+                /* Account for sign, decimal point etc. */
+                tmp_length = xsum (tmp_length, 12);
+
+                if (tmp_length < width)
+                  tmp_length = width;
+
+                tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+                if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+                  tmp = tmpbuf;
+                else
+                  {
+                    size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+                    if (size_overflow_p (tmp_memsize))
+                      /* Overflow, would lead to out of memory.  */
+                      goto out_of_memory;
+                    tmp = (DCHAR_T *) malloc (tmp_memsize);
+                    if (tmp == NULL)
+                      /* Out of memory.  */
+                      goto out_of_memory;
+                  }
+
+                pad_ptr = NULL;
+                p = tmp;
+                if (type == TYPE_LONGDOUBLE)
+                  {
+# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE
+                    long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+                    if (isnanl (arg))
+                      {
+                        if (dp->conversion == 'A')
+                          {
+                            *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+                          }
+                        else
+                          {
+                            *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+                          }
+                      }
+                    else
+                      {
+                        int sign = 0;
+                        DECL_LONG_DOUBLE_ROUNDING
+
+                        BEGIN_LONG_DOUBLE_ROUNDING ();
+
+                        if (signbit (arg)) /* arg < 0.0L or negative zero */
+                          {
+                            sign = -1;
+                            arg = -arg;
+                          }
+
+                        if (sign < 0)
+                          *p++ = '-';
+                        else if (flags & FLAG_SHOWSIGN)
+                          *p++ = '+';
+                        else if (flags & FLAG_SPACE)
+                          *p++ = ' ';
+
+                        if (arg > 0.0L && arg + arg == arg)
+                          {
+                            if (dp->conversion == 'A')
+                              {
+                                *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+                              }
+                            else
+                              {
+                                *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+                              }
+                          }
+                        else
+                          {
+                            int exponent;
+                            long double mantissa;
+
+                            if (arg > 0.0L)
+                              mantissa = printf_frexpl (arg, &exponent);
+                            else
+                              {
+                                exponent = 0;
+                                mantissa = 0.0L;
+                              }
+
+                            if (has_precision
+                                && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
+                              {
+                                /* Round the mantissa.  */
+                                long double tail = mantissa;
+                                size_t q;
+
+                                for (q = precision; ; q--)
+                                  {
+                                    int digit = (int) tail;
+                                    tail -= digit;
+                                    if (q == 0)
+                                      {
+                                        if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
+                                          tail = 1 - tail;
+                                        else
+                                          tail = - tail;
+                                        break;
+                                      }
+                                    tail *= 16.0L;
+                                  }
+                                if (tail != 0.0L)
+                                  for (q = precision; q > 0; q--)
+                                    tail *= 0.0625L;
+                                mantissa += tail;
+                              }
+
+                            *p++ = '0';
+                            *p++ = dp->conversion - 'A' + 'X';
+                            pad_ptr = p;
+                            {
+                              int digit;
+
+                              digit = (int) mantissa;
+                              mantissa -= digit;
+                              *p++ = '0' + digit;
+                              if ((flags & FLAG_ALT)
+                                  || mantissa > 0.0L || precision > 0)
+                                {
+                                  *p++ = decimal_point_char ();
+                                  /* This loop terminates because we assume
+                                     that FLT_RADIX is a power of 2.  */
+                                  while (mantissa > 0.0L)
+                                    {
+                                      mantissa *= 16.0L;
+                                      digit = (int) mantissa;
+                                      mantissa -= digit;
+                                      *p++ = digit
+                                             + (digit < 10
+                                                ? '0'
+                                                : dp->conversion - 10);
+                                      if (precision > 0)
+                                        precision--;
+                                    }
+                                  while (precision > 0)
+                                    {
+                                      *p++ = '0';
+                                      precision--;
+                                    }
+                                }
+                              }
+                              *p++ = dp->conversion - 'A' + 'P';
+#  if WIDE_CHAR_VERSION
+                              {
+                                static const wchar_t decimal_format[] =
+                                  { '%', '+', 'd', '\0' };
+                                SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                              }
+                              while (*p != '\0')
+                                p++;
+#  else
+                              if (sizeof (DCHAR_T) == 1)
+                                {
+                                  sprintf ((char *) p, "%+d", exponent);
+                                  while (*p != '\0')
+                                    p++;
+                                }
+                              else
+                                {
+                                  char expbuf[6 + 1];
+                                  const char *ep;
+                                  sprintf (expbuf, "%+d", exponent);
+                                  for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                    p++;
+                                }
+#  endif
+                          }
+
+                        END_LONG_DOUBLE_ROUNDING ();
+                      }
+# else
+                    abort ();
+# endif
+                  }
+                else
+                  {
+# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
+                    double arg = a.arg[dp->arg_index].a.a_double;
+
+                    if (isnand (arg))
+                      {
+                        if (dp->conversion == 'A')
+                          {
+                            *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+                          }
+                        else
+                          {
+                            *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+                          }
+                      }
+                    else
+                      {
+                        int sign = 0;
+
+                        if (signbit (arg)) /* arg < 0.0 or negative zero */
+                          {
+                            sign = -1;
+                            arg = -arg;
+                          }
+
+                        if (sign < 0)
+                          *p++ = '-';
+                        else if (flags & FLAG_SHOWSIGN)
+                          *p++ = '+';
+                        else if (flags & FLAG_SPACE)
+                          *p++ = ' ';
+
+                        if (arg > 0.0 && arg + arg == arg)
+                          {
+                            if (dp->conversion == 'A')
+                              {
+                                *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+                              }
+                            else
+                              {
+                                *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+                              }
+                          }
+                        else
+                          {
+                            int exponent;
+                            double mantissa;
+
+                            if (arg > 0.0)
+                              mantissa = printf_frexp (arg, &exponent);
+                            else
+                              {
+                                exponent = 0;
+                                mantissa = 0.0;
+                              }
+
+                            if (has_precision
+                                && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
+                              {
+                                /* Round the mantissa.  */
+                                double tail = mantissa;
+                                size_t q;
+
+                                for (q = precision; ; q--)
+                                  {
+                                    int digit = (int) tail;
+                                    tail -= digit;
+                                    if (q == 0)
+                                      {
+                                        if (digit & 1 ? tail >= 0.5 : tail > 0.5)
+                                          tail = 1 - tail;
+                                        else
+                                          tail = - tail;
+                                        break;
+                                      }
+                                    tail *= 16.0;
+                                  }
+                                if (tail != 0.0)
+                                  for (q = precision; q > 0; q--)
+                                    tail *= 0.0625;
+                                mantissa += tail;
+                              }
+
+                            *p++ = '0';
+                            *p++ = dp->conversion - 'A' + 'X';
+                            pad_ptr = p;
+                            {
+                              int digit;
+
+                              digit = (int) mantissa;
+                              mantissa -= digit;
+                              *p++ = '0' + digit;
+                              if ((flags & FLAG_ALT)
+                                  || mantissa > 0.0 || precision > 0)
+                                {
+                                  *p++ = decimal_point_char ();
+                                  /* This loop terminates because we assume
+                                     that FLT_RADIX is a power of 2.  */
+                                  while (mantissa > 0.0)
+                                    {
+                                      mantissa *= 16.0;
+                                      digit = (int) mantissa;
+                                      mantissa -= digit;
+                                      *p++ = digit
+                                             + (digit < 10
+                                                ? '0'
+                                                : dp->conversion - 10);
+                                      if (precision > 0)
+                                        precision--;
+                                    }
+                                  while (precision > 0)
+                                    {
+                                      *p++ = '0';
+                                      precision--;
+                                    }
+                                }
+                              }
+                              *p++ = dp->conversion - 'A' + 'P';
+#  if WIDE_CHAR_VERSION
+                              {
+                                static const wchar_t decimal_format[] =
+                                  { '%', '+', 'd', '\0' };
+                                SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                              }
+                              while (*p != '\0')
+                                p++;
+#  else
+                              if (sizeof (DCHAR_T) == 1)
+                                {
+                                  sprintf ((char *) p, "%+d", exponent);
+                                  while (*p != '\0')
+                                    p++;
+                                }
+                              else
+                                {
+                                  char expbuf[6 + 1];
+                                  const char *ep;
+                                  sprintf (expbuf, "%+d", exponent);
+                                  for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                    p++;
+                                }
+#  endif
+                          }
+                      }
+# else
+                    abort ();
+# endif
+                  }
+                /* The generated string now extends from tmp to p, with the
+                   zero padding insertion point being at pad_ptr.  */
+                if (has_width && p - tmp < width)
+                  {
+                    size_t pad = width - (p - tmp);
+                    DCHAR_T *end = p + pad;
+
+                    if (flags & FLAG_LEFT)
+                      {
+                        /* Pad with spaces on the right.  */
+                        for (; pad > 0; pad--)
+                          *p++ = ' ';
+                      }
+                    else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+                      {
+                        /* Pad with zeroes.  */
+                        DCHAR_T *q = end;
+
+                        while (p > pad_ptr)
+                          *--q = *--p;
+                        for (; pad > 0; pad--)
+                          *p++ = '0';
+                      }
+                    else
+                      {
+                        /* Pad with spaces on the left.  */
+                        DCHAR_T *q = end;
+
+                        while (p > tmp)
+                          *--q = *--p;
+                        for (; pad > 0; pad--)
+                          *p++ = ' ';
+                      }
+
+                    p = end;
+                  }
+
+                {
+                  size_t count = p - tmp;
+
+                  if (count >= tmp_length)
+                    /* tmp_length was incorrectly calculated - fix the
+                       code above!  */
+                    abort ();
+
+                  /* Make room for the result.  */
+                  if (count >= allocated - length)
+                    {
+                      size_t n = xsum (length, count);
+
+                      ENSURE_ALLOCATION (n);
+                    }
+
+                  /* Append the result.  */
+                  memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+                  if (tmp != tmpbuf)
+                    free (tmp);
+                  length += count;
+                }
+              }
+#endif
+#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
+            else if ((dp->conversion == 'f' || dp->conversion == 'F'
+                      || dp->conversion == 'e' || dp->conversion == 'E'
+                      || dp->conversion == 'g' || dp->conversion == 'G'
+                      || dp->conversion == 'a' || dp->conversion == 'A')
+                     && (0
+# if NEED_PRINTF_DOUBLE
+                         || a.arg[dp->arg_index].type == TYPE_DOUBLE
+# elif NEED_PRINTF_INFINITE_DOUBLE
+                         || (a.arg[dp->arg_index].type == TYPE_DOUBLE
+                             /* The systems (mingw) which produce wrong output
+                                for Inf, -Inf, and NaN also do so for -0.0.
+                                Therefore we treat this case here as well.  */
+                             && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
+# endif
+# if NEED_PRINTF_LONG_DOUBLE
+                         || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+# elif NEED_PRINTF_INFINITE_LONG_DOUBLE
+                         || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
+                             /* Some systems produce wrong output for Inf,
+                                -Inf, and NaN.  Some systems in this category
+                                (IRIX 5.3) also do so for -0.0.  Therefore we
+                                treat this case here as well.  */
+                             && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
+# endif
+                        ))
+              {
+# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE)
+                arg_type type = a.arg[dp->arg_index].type;
+# endif
+                int flags = dp->flags;
+                int has_width;
+                size_t width;
+                int has_precision;
+                size_t precision;
+                size_t tmp_length;
+                DCHAR_T tmpbuf[700];
+                DCHAR_T *tmp;
+                DCHAR_T *pad_ptr;
+                DCHAR_T *p;
+
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+
+                has_precision = 0;
+                precision = 0;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+                /* POSIX specifies the default precision to be 6 for %f, %F,
+                   %e, %E, but not for %g, %G.  Implementations appear to use
+                   the same default precision also for %g, %G.  But for %a, %A,
+                   the default precision is 0.  */
+                if (!has_precision)
+                  if (!(dp->conversion == 'a' || dp->conversion == 'A'))
+                    precision = 6;
+
+                /* Allocate a temporary buffer of sufficient size.  */
+# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
+                tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
+# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
+                tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
+# elif NEED_PRINTF_LONG_DOUBLE
+                tmp_length = LDBL_DIG + 1;
+# elif NEED_PRINTF_DOUBLE
+                tmp_length = DBL_DIG + 1;
+# else
+                tmp_length = 0;
+# endif
+                if (tmp_length < precision)
+                  tmp_length = precision;
+# if NEED_PRINTF_LONG_DOUBLE
+#  if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+                if (type == TYPE_LONGDOUBLE)
+#  endif
+                  if (dp->conversion == 'f' || dp->conversion == 'F')
+                    {
+                      long double arg = a.arg[dp->arg_index].a.a_longdouble;
+                      if (!(isnanl (arg) || arg + arg == arg))
+                        {
+                          /* arg is finite and nonzero.  */
+                          int exponent = floorlog10l (arg < 0 ? -arg : arg);
+                          if (exponent >= 0 && tmp_length < exponent + precision)
+                            tmp_length = exponent + precision;
+                        }
+                    }
+# endif
+# if NEED_PRINTF_DOUBLE
+#  if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
+                if (type == TYPE_DOUBLE)
+#  endif
+                  if (dp->conversion == 'f' || dp->conversion == 'F')
+                    {
+                      double arg = a.arg[dp->arg_index].a.a_double;
+                      if (!(isnand (arg) || arg + arg == arg))
+                        {
+                          /* arg is finite and nonzero.  */
+                          int exponent = floorlog10 (arg < 0 ? -arg : arg);
+                          if (exponent >= 0 && tmp_length < exponent + precision)
+                            tmp_length = exponent + precision;
+                        }
+                    }
+# endif
+                /* Account for sign, decimal point etc. */
+                tmp_length = xsum (tmp_length, 12);
+
+                if (tmp_length < width)
+                  tmp_length = width;
+
+                tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+                if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
+                  tmp = tmpbuf;
+                else
+                  {
+                    size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
+
+                    if (size_overflow_p (tmp_memsize))
+                      /* Overflow, would lead to out of memory.  */
+                      goto out_of_memory;
+                    tmp = (DCHAR_T *) malloc (tmp_memsize);
+                    if (tmp == NULL)
+                      /* Out of memory.  */
+                      goto out_of_memory;
+                  }
+
+                pad_ptr = NULL;
+                p = tmp;
+
+# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
+#  if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+                if (type == TYPE_LONGDOUBLE)
+#  endif
+                  {
+                    long double arg = a.arg[dp->arg_index].a.a_longdouble;
+
+                    if (isnanl (arg))
+                      {
+                        if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+                          {
+                            *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+                          }
+                        else
+                          {
+                            *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+                          }
+                      }
+                    else
+                      {
+                        int sign = 0;
+                        DECL_LONG_DOUBLE_ROUNDING
+
+                        BEGIN_LONG_DOUBLE_ROUNDING ();
+
+                        if (signbit (arg)) /* arg < 0.0L or negative zero */
+                          {
+                            sign = -1;
+                            arg = -arg;
+                          }
+
+                        if (sign < 0)
+                          *p++ = '-';
+                        else if (flags & FLAG_SHOWSIGN)
+                          *p++ = '+';
+                        else if (flags & FLAG_SPACE)
+                          *p++ = ' ';
+
+                        if (arg > 0.0L && arg + arg == arg)
+                          {
+                            if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+                              {
+                                *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+                              }
+                            else
+                              {
+                                *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+                              }
+                          }
+                        else
+                          {
+#  if NEED_PRINTF_LONG_DOUBLE
+                            pad_ptr = p;
+
+                            if (dp->conversion == 'f' || dp->conversion == 'F')
+                              {
+                                char *digits;
+                                size_t ndigits;
+
+                                digits =
+                                  scale10_round_decimal_long_double (arg, precision);
+                                if (digits == NULL)
+                                  {
+                                    END_LONG_DOUBLE_ROUNDING ();
+                                    goto out_of_memory;
+                                  }
+                                ndigits = strlen (digits);
+
+                                if (ndigits > precision)
+                                  do
+                                    {
+                                      --ndigits;
+                                      *p++ = digits[ndigits];
+                                    }
+                                  while (ndigits > precision);
+                                else
+                                  *p++ = '0';
+                                /* Here ndigits <= precision.  */
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > ndigits; precision--)
+                                      *p++ = '0';
+                                    while (ndigits > 0)
+                                      {
+                                        --ndigits;
+                                        *p++ = digits[ndigits];
+                                      }
+                                  }
+
+                                free (digits);
+                              }
+                            else if (dp->conversion == 'e' || dp->conversion == 'E')
+                              {
+                                int exponent;
+
+                                if (arg == 0.0L)
+                                  {
+                                    exponent = 0;
+                                    *p++ = '0';
+                                    if ((flags & FLAG_ALT) || precision > 0)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        for (; precision > 0; precision--)
+                                          *p++ = '0';
+                                      }
+                                  }
+                                else
+                                  {
+                                    /* arg > 0.0L.  */
+                                    int adjusted;
+                                    char *digits;
+                                    size_t ndigits;
+
+                                    exponent = floorlog10l (arg);
+                                    adjusted = 0;
+                                    for (;;)
+                                      {
+                                        digits =
+                                          scale10_round_decimal_long_double (arg,
+                                                                             (int)precision - exponent);
+                                        if (digits == NULL)
+                                          {
+                                            END_LONG_DOUBLE_ROUNDING ();
+                                            goto out_of_memory;
+                                          }
+                                        ndigits = strlen (digits);
+
+                                        if (ndigits == precision + 1)
+                                          break;
+                                        if (ndigits < precision
+                                            || ndigits > precision + 2)
+                                          /* The exponent was not guessed
+                                             precisely enough.  */
+                                          abort ();
+                                        if (adjusted)
+                                          /* None of two values of exponent is
+                                             the right one.  Prevent an endless
+                                             loop.  */
+                                          abort ();
+                                        free (digits);
+                                        if (ndigits == precision)
+                                          exponent -= 1;
+                                        else
+                                          exponent += 1;
+                                        adjusted = 1;
+                                      }
+                                    /* Here ndigits = precision+1.  */
+                                    if (is_borderline (digits, precision))
+                                      {
+                                        /* Maybe the exponent guess was too high
+                                           and a smaller exponent can be reached
+                                           by turning a 10...0 into 9...9x.  */
+                                        char *digits2 =
+                                          scale10_round_decimal_long_double (arg,
+                                                                             (int)precision - exponent + 1);
+                                        if (digits2 == NULL)
+                                          {
+                                            free (digits);
+                                            END_LONG_DOUBLE_ROUNDING ();
+                                            goto out_of_memory;
+                                          }
+                                        if (strlen (digits2) == precision + 1)
+                                          {
+                                            free (digits);
+                                            digits = digits2;
+                                            exponent -= 1;
+                                          }
+                                        else
+                                          free (digits2);
+                                      }
+                                    /* Here ndigits = precision+1.  */
+
+                                    *p++ = digits[--ndigits];
+                                    if ((flags & FLAG_ALT) || precision > 0)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        while (ndigits > 0)
+                                          {
+                                            --ndigits;
+                                            *p++ = digits[ndigits];
+                                          }
+                                      }
+
+                                    free (digits);
+                                  }
+
+                                *p++ = dp->conversion; /* 'e' or 'E' */
+#   if WIDE_CHAR_VERSION
+                                {
+                                  static const wchar_t decimal_format[] =
+                                    { '%', '+', '.', '2', 'd', '\0' };
+                                  SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                                }
+                                while (*p != '\0')
+                                  p++;
+#   else
+                                if (sizeof (DCHAR_T) == 1)
+                                  {
+                                    sprintf ((char *) p, "%+.2d", exponent);
+                                    while (*p != '\0')
+                                      p++;
+                                  }
+                                else
+                                  {
+                                    char expbuf[6 + 1];
+                                    const char *ep;
+                                    sprintf (expbuf, "%+.2d", exponent);
+                                    for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                      p++;
+                                  }
+#   endif
+                              }
+                            else if (dp->conversion == 'g' || dp->conversion == 'G')
+                              {
+                                if (precision == 0)
+                                  precision = 1;
+                                /* precision >= 1.  */
+
+                                if (arg == 0.0L)
+                                  /* The exponent is 0, >= -4, < precision.
+                                     Use fixed-point notation.  */
+                                  {
+                                    size_t ndigits = precision;
+                                    /* Number of trailing zeroes that have to be
+                                       dropped.  */
+                                    size_t nzeroes =
+                                      (flags & FLAG_ALT ? 0 : precision - 1);
+
+                                    --ndigits;
+                                    *p++ = '0';
+                                    if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        while (ndigits > nzeroes)
+                                          {
+                                            --ndigits;
+                                            *p++ = '0';
+                                          }
+                                      }
+                                  }
+                                else
+                                  {
+                                    /* arg > 0.0L.  */
+                                    int exponent;
+                                    int adjusted;
+                                    char *digits;
+                                    size_t ndigits;
+                                    size_t nzeroes;
+
+                                    exponent = floorlog10l (arg);
+                                    adjusted = 0;
+                                    for (;;)
+                                      {
+                                        digits =
+                                          scale10_round_decimal_long_double (arg,
+                                                                             (int)(precision - 1) - exponent);
+                                        if (digits == NULL)
+                                          {
+                                            END_LONG_DOUBLE_ROUNDING ();
+                                            goto out_of_memory;
+                                          }
+                                        ndigits = strlen (digits);
+
+                                        if (ndigits == precision)
+                                          break;
+                                        if (ndigits < precision - 1
+                                            || ndigits > precision + 1)
+                                          /* The exponent was not guessed
+                                             precisely enough.  */
+                                          abort ();
+                                        if (adjusted)
+                                          /* None of two values of exponent is
+                                             the right one.  Prevent an endless
+                                             loop.  */
+                                          abort ();
+                                        free (digits);
+                                        if (ndigits < precision)
+                                          exponent -= 1;
+                                        else
+                                          exponent += 1;
+                                        adjusted = 1;
+                                      }
+                                    /* Here ndigits = precision.  */
+                                    if (is_borderline (digits, precision - 1))
+                                      {
+                                        /* Maybe the exponent guess was too high
+                                           and a smaller exponent can be reached
+                                           by turning a 10...0 into 9...9x.  */
+                                        char *digits2 =
+                                          scale10_round_decimal_long_double (arg,
+                                                                             (int)(precision - 1) - exponent + 1);
+                                        if (digits2 == NULL)
+                                          {
+                                            free (digits);
+                                            END_LONG_DOUBLE_ROUNDING ();
+                                            goto out_of_memory;
+                                          }
+                                        if (strlen (digits2) == precision)
+                                          {
+                                            free (digits);
+                                            digits = digits2;
+                                            exponent -= 1;
+                                          }
+                                        else
+                                          free (digits2);
+                                      }
+                                    /* Here ndigits = precision.  */
+
+                                    /* Determine the number of trailing zeroes
+                                       that have to be dropped.  */
+                                    nzeroes = 0;
+                                    if ((flags & FLAG_ALT) == 0)
+                                      while (nzeroes < ndigits
+                                             && digits[nzeroes] == '0')
+                                        nzeroes++;
+
+                                    /* The exponent is now determined.  */
+                                    if (exponent >= -4
+                                        && exponent < (long)precision)
+                                      {
+                                        /* Fixed-point notation:
+                                           max(exponent,0)+1 digits, then the
+                                           decimal point, then the remaining
+                                           digits without trailing zeroes.  */
+                                        if (exponent >= 0)
+                                          {
+                                            size_t count = exponent + 1;
+                                            /* Note: count <= precision = ndigits.  */
+                                            for (; count > 0; count--)
+                                              *p++ = digits[--ndigits];
+                                            if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                              {
+                                                *p++ = decimal_point_char ();
+                                                while (ndigits > nzeroes)
+                                                  {
+                                                    --ndigits;
+                                                    *p++ = digits[ndigits];
+                                                  }
+                                              }
+                                          }
+                                        else
+                                          {
+                                            size_t count = -exponent - 1;
+                                            *p++ = '0';
+                                            *p++ = decimal_point_char ();
+                                            for (; count > 0; count--)
+                                              *p++ = '0';
+                                            while (ndigits > nzeroes)
+                                              {
+                                                --ndigits;
+                                                *p++ = digits[ndigits];
+                                              }
+                                          }
+                                      }
+                                    else
+                                      {
+                                        /* Exponential notation.  */
+                                        *p++ = digits[--ndigits];
+                                        if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                          {
+                                            *p++ = decimal_point_char ();
+                                            while (ndigits > nzeroes)
+                                              {
+                                                --ndigits;
+                                                *p++ = digits[ndigits];
+                                              }
+                                          }
+                                        *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+#   if WIDE_CHAR_VERSION
+                                        {
+                                          static const wchar_t decimal_format[] =
+                                            { '%', '+', '.', '2', 'd', '\0' };
+                                          SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                                        }
+                                        while (*p != '\0')
+                                          p++;
+#   else
+                                        if (sizeof (DCHAR_T) == 1)
+                                          {
+                                            sprintf ((char *) p, "%+.2d", exponent);
+                                            while (*p != '\0')
+                                              p++;
+                                          }
+                                        else
+                                          {
+                                            char expbuf[6 + 1];
+                                            const char *ep;
+                                            sprintf (expbuf, "%+.2d", exponent);
+                                            for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                              p++;
+                                          }
+#   endif
+                                      }
+
+                                    free (digits);
+                                  }
+                              }
+                            else
+                              abort ();
+#  else
+                            /* arg is finite.  */
+                            if (!(arg == 0.0L))
+                              abort ();
+
+                            pad_ptr = p;
+
+                            if (dp->conversion == 'f' || dp->conversion == 'F')
+                              {
+                                *p++ = '0';
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > 0; precision--)
+                                      *p++ = '0';
+                                  }
+                              }
+                            else if (dp->conversion == 'e' || dp->conversion == 'E')
+                              {
+                                *p++ = '0';
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > 0; precision--)
+                                      *p++ = '0';
+                                  }
+                                *p++ = dp->conversion; /* 'e' or 'E' */
+                                *p++ = '+';
+                                *p++ = '0';
+                                *p++ = '0';
+                              }
+                            else if (dp->conversion == 'g' || dp->conversion == 'G')
+                              {
+                                *p++ = '0';
+                                if (flags & FLAG_ALT)
+                                  {
+                                    size_t ndigits =
+                                      (precision > 0 ? precision - 1 : 0);
+                                    *p++ = decimal_point_char ();
+                                    for (; ndigits > 0; --ndigits)
+                                      *p++ = '0';
+                                  }
+                              }
+                            else if (dp->conversion == 'a' || dp->conversion == 'A')
+                              {
+                                *p++ = '0';
+                                *p++ = dp->conversion - 'A' + 'X';
+                                pad_ptr = p;
+                                *p++ = '0';
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > 0; precision--)
+                                      *p++ = '0';
+                                  }
+                                *p++ = dp->conversion - 'A' + 'P';
+                                *p++ = '+';
+                                *p++ = '0';
+                              }
+                            else
+                              abort ();
+#  endif
+                          }
+
+                        END_LONG_DOUBLE_ROUNDING ();
+                      }
+                  }
+#  if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+                else
+#  endif
+# endif
+# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
+                  {
+                    double arg = a.arg[dp->arg_index].a.a_double;
+
+                    if (isnand (arg))
+                      {
+                        if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+                          {
+                            *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
+                          }
+                        else
+                          {
+                            *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
+                          }
+                      }
+                    else
+                      {
+                        int sign = 0;
+
+                        if (signbit (arg)) /* arg < 0.0 or negative zero */
+                          {
+                            sign = -1;
+                            arg = -arg;
+                          }
+
+                        if (sign < 0)
+                          *p++ = '-';
+                        else if (flags & FLAG_SHOWSIGN)
+                          *p++ = '+';
+                        else if (flags & FLAG_SPACE)
+                          *p++ = ' ';
+
+                        if (arg > 0.0 && arg + arg == arg)
+                          {
+                            if (dp->conversion >= 'A' && dp->conversion <= 'Z')
+                              {
+                                *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
+                              }
+                            else
+                              {
+                                *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
+                              }
+                          }
+                        else
+                          {
+#  if NEED_PRINTF_DOUBLE
+                            pad_ptr = p;
+
+                            if (dp->conversion == 'f' || dp->conversion == 'F')
+                              {
+                                char *digits;
+                                size_t ndigits;
+
+                                digits =
+                                  scale10_round_decimal_double (arg, precision);
+                                if (digits == NULL)
+                                  goto out_of_memory;
+                                ndigits = strlen (digits);
+
+                                if (ndigits > precision)
+                                  do
+                                    {
+                                      --ndigits;
+                                      *p++ = digits[ndigits];
+                                    }
+                                  while (ndigits > precision);
+                                else
+                                  *p++ = '0';
+                                /* Here ndigits <= precision.  */
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > ndigits; precision--)
+                                      *p++ = '0';
+                                    while (ndigits > 0)
+                                      {
+                                        --ndigits;
+                                        *p++ = digits[ndigits];
+                                      }
+                                  }
+
+                                free (digits);
+                              }
+                            else if (dp->conversion == 'e' || dp->conversion == 'E')
+                              {
+                                int exponent;
+
+                                if (arg == 0.0)
+                                  {
+                                    exponent = 0;
+                                    *p++ = '0';
+                                    if ((flags & FLAG_ALT) || precision > 0)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        for (; precision > 0; precision--)
+                                          *p++ = '0';
+                                      }
+                                  }
+                                else
+                                  {
+                                    /* arg > 0.0.  */
+                                    int adjusted;
+                                    char *digits;
+                                    size_t ndigits;
+
+                                    exponent = floorlog10 (arg);
+                                    adjusted = 0;
+                                    for (;;)
+                                      {
+                                        digits =
+                                          scale10_round_decimal_double (arg,
+                                                                        (int)precision - exponent);
+                                        if (digits == NULL)
+                                          goto out_of_memory;
+                                        ndigits = strlen (digits);
+
+                                        if (ndigits == precision + 1)
+                                          break;
+                                        if (ndigits < precision
+                                            || ndigits > precision + 2)
+                                          /* The exponent was not guessed
+                                             precisely enough.  */
+                                          abort ();
+                                        if (adjusted)
+                                          /* None of two values of exponent is
+                                             the right one.  Prevent an endless
+                                             loop.  */
+                                          abort ();
+                                        free (digits);
+                                        if (ndigits == precision)
+                                          exponent -= 1;
+                                        else
+                                          exponent += 1;
+                                        adjusted = 1;
+                                      }
+                                    /* Here ndigits = precision+1.  */
+                                    if (is_borderline (digits, precision))
+                                      {
+                                        /* Maybe the exponent guess was too high
+                                           and a smaller exponent can be reached
+                                           by turning a 10...0 into 9...9x.  */
+                                        char *digits2 =
+                                          scale10_round_decimal_double (arg,
+                                                                        (int)precision - exponent + 1);
+                                        if (digits2 == NULL)
+                                          {
+                                            free (digits);
+                                            goto out_of_memory;
+                                          }
+                                        if (strlen (digits2) == precision + 1)
+                                          {
+                                            free (digits);
+                                            digits = digits2;
+                                            exponent -= 1;
+                                          }
+                                        else
+                                          free (digits2);
+                                      }
+                                    /* Here ndigits = precision+1.  */
+
+                                    *p++ = digits[--ndigits];
+                                    if ((flags & FLAG_ALT) || precision > 0)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        while (ndigits > 0)
+                                          {
+                                            --ndigits;
+                                            *p++ = digits[ndigits];
+                                          }
+                                      }
+
+                                    free (digits);
+                                  }
+
+                                *p++ = dp->conversion; /* 'e' or 'E' */
+#   if WIDE_CHAR_VERSION
+                                {
+                                  static const wchar_t decimal_format[] =
+                                    /* Produce the same number of exponent digits
+                                       as the native printf implementation.  */
+#    if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                                    { '%', '+', '.', '3', 'd', '\0' };
+#    else
+                                    { '%', '+', '.', '2', 'd', '\0' };
+#    endif
+                                  SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                                }
+                                while (*p != '\0')
+                                  p++;
+#   else
+                                {
+                                  static const char decimal_format[] =
+                                    /* Produce the same number of exponent digits
+                                       as the native printf implementation.  */
+#    if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                                    "%+.3d";
+#    else
+                                    "%+.2d";
+#    endif
+                                  if (sizeof (DCHAR_T) == 1)
+                                    {
+                                      sprintf ((char *) p, decimal_format, exponent);
+                                      while (*p != '\0')
+                                        p++;
+                                    }
+                                  else
+                                    {
+                                      char expbuf[6 + 1];
+                                      const char *ep;
+                                      sprintf (expbuf, decimal_format, exponent);
+                                      for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                        p++;
+                                    }
+                                }
+#   endif
+                              }
+                            else if (dp->conversion == 'g' || dp->conversion == 'G')
+                              {
+                                if (precision == 0)
+                                  precision = 1;
+                                /* precision >= 1.  */
+
+                                if (arg == 0.0)
+                                  /* The exponent is 0, >= -4, < precision.
+                                     Use fixed-point notation.  */
+                                  {
+                                    size_t ndigits = precision;
+                                    /* Number of trailing zeroes that have to be
+                                       dropped.  */
+                                    size_t nzeroes =
+                                      (flags & FLAG_ALT ? 0 : precision - 1);
+
+                                    --ndigits;
+                                    *p++ = '0';
+                                    if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                      {
+                                        *p++ = decimal_point_char ();
+                                        while (ndigits > nzeroes)
+                                          {
+                                            --ndigits;
+                                            *p++ = '0';
+                                          }
+                                      }
+                                  }
+                                else
+                                  {
+                                    /* arg > 0.0.  */
+                                    int exponent;
+                                    int adjusted;
+                                    char *digits;
+                                    size_t ndigits;
+                                    size_t nzeroes;
+
+                                    exponent = floorlog10 (arg);
+                                    adjusted = 0;
+                                    for (;;)
+                                      {
+                                        digits =
+                                          scale10_round_decimal_double (arg,
+                                                                        (int)(precision - 1) - exponent);
+                                        if (digits == NULL)
+                                          goto out_of_memory;
+                                        ndigits = strlen (digits);
+
+                                        if (ndigits == precision)
+                                          break;
+                                        if (ndigits < precision - 1
+                                            || ndigits > precision + 1)
+                                          /* The exponent was not guessed
+                                             precisely enough.  */
+                                          abort ();
+                                        if (adjusted)
+                                          /* None of two values of exponent is
+                                             the right one.  Prevent an endless
+                                             loop.  */
+                                          abort ();
+                                        free (digits);
+                                        if (ndigits < precision)
+                                          exponent -= 1;
+                                        else
+                                          exponent += 1;
+                                        adjusted = 1;
+                                      }
+                                    /* Here ndigits = precision.  */
+                                    if (is_borderline (digits, precision - 1))
+                                      {
+                                        /* Maybe the exponent guess was too high
+                                           and a smaller exponent can be reached
+                                           by turning a 10...0 into 9...9x.  */
+                                        char *digits2 =
+                                          scale10_round_decimal_double (arg,
+                                                                        (int)(precision - 1) - exponent + 1);
+                                        if (digits2 == NULL)
+                                          {
+                                            free (digits);
+                                            goto out_of_memory;
+                                          }
+                                        if (strlen (digits2) == precision)
+                                          {
+                                            free (digits);
+                                            digits = digits2;
+                                            exponent -= 1;
+                                          }
+                                        else
+                                          free (digits2);
+                                      }
+                                    /* Here ndigits = precision.  */
+
+                                    /* Determine the number of trailing zeroes
+                                       that have to be dropped.  */
+                                    nzeroes = 0;
+                                    if ((flags & FLAG_ALT) == 0)
+                                      while (nzeroes < ndigits
+                                             && digits[nzeroes] == '0')
+                                        nzeroes++;
+
+                                    /* The exponent is now determined.  */
+                                    if (exponent >= -4
+                                        && exponent < (long)precision)
+                                      {
+                                        /* Fixed-point notation:
+                                           max(exponent,0)+1 digits, then the
+                                           decimal point, then the remaining
+                                           digits without trailing zeroes.  */
+                                        if (exponent >= 0)
+                                          {
+                                            size_t count = exponent + 1;
+                                            /* Note: count <= precision = ndigits.  */
+                                            for (; count > 0; count--)
+                                              *p++ = digits[--ndigits];
+                                            if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                              {
+                                                *p++ = decimal_point_char ();
+                                                while (ndigits > nzeroes)
+                                                  {
+                                                    --ndigits;
+                                                    *p++ = digits[ndigits];
+                                                  }
+                                              }
+                                          }
+                                        else
+                                          {
+                                            size_t count = -exponent - 1;
+                                            *p++ = '0';
+                                            *p++ = decimal_point_char ();
+                                            for (; count > 0; count--)
+                                              *p++ = '0';
+                                            while (ndigits > nzeroes)
+                                              {
+                                                --ndigits;
+                                                *p++ = digits[ndigits];
+                                              }
+                                          }
+                                      }
+                                    else
+                                      {
+                                        /* Exponential notation.  */
+                                        *p++ = digits[--ndigits];
+                                        if ((flags & FLAG_ALT) || ndigits > nzeroes)
+                                          {
+                                            *p++ = decimal_point_char ();
+                                            while (ndigits > nzeroes)
+                                              {
+                                                --ndigits;
+                                                *p++ = digits[ndigits];
+                                              }
+                                          }
+                                        *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
+#   if WIDE_CHAR_VERSION
+                                        {
+                                          static const wchar_t decimal_format[] =
+                                            /* Produce the same number of exponent digits
+                                               as the native printf implementation.  */
+#    if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                                            { '%', '+', '.', '3', 'd', '\0' };
+#    else
+                                            { '%', '+', '.', '2', 'd', '\0' };
+#    endif
+                                          SNPRINTF (p, 6 + 1, decimal_format, exponent);
+                                        }
+                                        while (*p != '\0')
+                                          p++;
+#   else
+                                        {
+                                          static const char decimal_format[] =
+                                            /* Produce the same number of exponent digits
+                                               as the native printf implementation.  */
+#    if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                                            "%+.3d";
+#    else
+                                            "%+.2d";
+#    endif
+                                          if (sizeof (DCHAR_T) == 1)
+                                            {
+                                              sprintf ((char *) p, decimal_format, exponent);
+                                              while (*p != '\0')
+                                                p++;
+                                            }
+                                          else
+                                            {
+                                              char expbuf[6 + 1];
+                                              const char *ep;
+                                              sprintf (expbuf, decimal_format, exponent);
+                                              for (ep = expbuf; (*p = *ep) != '\0'; ep++)
+                                                p++;
+                                            }
+                                        }
+#   endif
+                                      }
+
+                                    free (digits);
+                                  }
+                              }
+                            else
+                              abort ();
+#  else
+                            /* arg is finite.  */
+                            if (!(arg == 0.0))
+                              abort ();
+
+                            pad_ptr = p;
+
+                            if (dp->conversion == 'f' || dp->conversion == 'F')
+                              {
+                                *p++ = '0';
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > 0; precision--)
+                                      *p++ = '0';
+                                  }
+                              }
+                            else if (dp->conversion == 'e' || dp->conversion == 'E')
+                              {
+                                *p++ = '0';
+                                if ((flags & FLAG_ALT) || precision > 0)
+                                  {
+                                    *p++ = decimal_point_char ();
+                                    for (; precision > 0; precision--)
+                                      *p++ = '0';
+                                  }
+                                *p++ = dp->conversion; /* 'e' or 'E' */
+                                *p++ = '+';
+                                /* Produce the same number of exponent digits as
+                                   the native printf implementation.  */
+#   if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                                *p++ = '0';
+#   endif
+                                *p++ = '0';
+                                *p++ = '0';
+                              }
+                            else if (dp->conversion == 'g' || dp->conversion == 'G')
+                              {
+                                *p++ = '0';
+                                if (flags & FLAG_ALT)
+                                  {
+                                    size_t ndigits =
+                                      (precision > 0 ? precision - 1 : 0);
+                                    *p++ = decimal_point_char ();
+                                    for (; ndigits > 0; --ndigits)
+                                      *p++ = '0';
+                                  }
+                              }
+                            else
+                              abort ();
+#  endif
+                          }
+                      }
+                  }
+# endif
+
+                /* The generated string now extends from tmp to p, with the
+                   zero padding insertion point being at pad_ptr.  */
+                if (has_width && p - tmp < width)
+                  {
+                    size_t pad = width - (p - tmp);
+                    DCHAR_T *end = p + pad;
+
+                    if (flags & FLAG_LEFT)
+                      {
+                        /* Pad with spaces on the right.  */
+                        for (; pad > 0; pad--)
+                          *p++ = ' ';
+                      }
+                    else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+                      {
+                        /* Pad with zeroes.  */
+                        DCHAR_T *q = end;
+
+                        while (p > pad_ptr)
+                          *--q = *--p;
+                        for (; pad > 0; pad--)
+                          *p++ = '0';
+                      }
+                    else
+                      {
+                        /* Pad with spaces on the left.  */
+                        DCHAR_T *q = end;
+
+                        while (p > tmp)
+                          *--q = *--p;
+                        for (; pad > 0; pad--)
+                          *p++ = ' ';
+                      }
+
+                    p = end;
+                  }
+
+                {
+                  size_t count = p - tmp;
+
+                  if (count >= tmp_length)
+                    /* tmp_length was incorrectly calculated - fix the
+                       code above!  */
+                    abort ();
+
+                  /* Make room for the result.  */
+                  if (count >= allocated - length)
+                    {
+                      size_t n = xsum (length, count);
+
+                      ENSURE_ALLOCATION (n);
+                    }
+
+                  /* Append the result.  */
+                  memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+                  if (tmp != tmpbuf)
+                    free (tmp);
+                  length += count;
+                }
+              }
+#endif
+            else
+              {
+                arg_type type = a.arg[dp->arg_index].type;
+                int flags = dp->flags;
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+                int has_width;
+                size_t width;
+#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
+                int has_precision;
+                size_t precision;
+#endif
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+                int prec_ourselves;
+#else
+#               define prec_ourselves 0
+#endif
+#if NEED_PRINTF_FLAG_LEFTADJUST
+#               define pad_ourselves 1
+#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+                int pad_ourselves;
+#else
+#               define pad_ourselves 0
+#endif
+                TCHAR_T *fbp;
+                unsigned int prefix_count;
+                int prefixes[2] IF_LINT (= { 0 });
+                int orig_errno;
+#if !USE_SNPRINTF
+                size_t tmp_length;
+                TCHAR_T tmpbuf[700];
+                TCHAR_T *tmp;
+#endif
+
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+#endif
+
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
+                has_precision = 0;
+                precision = 6;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+#endif
+
+                /* Decide whether to handle the precision ourselves.  */
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+                switch (dp->conversion)
+                  {
+                  case 'd': case 'i': case 'u':
+                  case 'o':
+                  case 'x': case 'X': case 'p':
+                    prec_ourselves = has_precision && (precision > 0);
+                    break;
+                  default:
+                    prec_ourselves = 0;
+                    break;
+                  }
+#endif
+
+                /* Decide whether to perform the padding ourselves.  */
+#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
+                switch (dp->conversion)
+                  {
+# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
+                  /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
+                     to perform the padding after this conversion.  Functions
+                     with unistdio extensions perform the padding based on
+                     character count rather than element count.  */
+                  case 'c': case 's':
+# endif
+# if NEED_PRINTF_FLAG_ZERO
+                  case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+                  case 'a': case 'A':
+# endif
+                    pad_ourselves = 1;
+                    break;
+                  default:
+                    pad_ourselves = prec_ourselves;
+                    break;
+                  }
+#endif
+
+#if !USE_SNPRINTF
+                /* Allocate a temporary buffer of sufficient size for calling
+                   sprintf.  */
+                tmp_length =
+                  MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type,
+                                   flags, width, has_precision, precision,
+                                   pad_ourselves);
+
+                if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
+                  tmp = tmpbuf;
+                else
+                  {
+                    size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
+
+                    if (size_overflow_p (tmp_memsize))
+                      /* Overflow, would lead to out of memory.  */
+                      goto out_of_memory;
+                    tmp = (TCHAR_T *) malloc (tmp_memsize);
+                    if (tmp == NULL)
+                      /* Out of memory.  */
+                      goto out_of_memory;
+                  }
+#endif
+
+                /* Construct the format string for calling snprintf or
+                   sprintf.  */
+                fbp = buf;
+                *fbp++ = '%';
+#if NEED_PRINTF_FLAG_GROUPING
+                /* The underlying implementation doesn't support the ' flag.
+                   Produce no grouping characters in this case; this is
+                   acceptable because the grouping is locale dependent.  */
+#else
+                if (flags & FLAG_GROUP)
+                  *fbp++ = '\'';
+#endif
+                if (flags & FLAG_LEFT)
+                  *fbp++ = '-';
+                if (flags & FLAG_SHOWSIGN)
+                  *fbp++ = '+';
+                if (flags & FLAG_SPACE)
+                  *fbp++ = ' ';
+                if (flags & FLAG_ALT)
+                  *fbp++ = '#';
+#if __GLIBC__ >= 2 && !defined __UCLIBC__
+                if (flags & FLAG_LOCALIZED)
+                  *fbp++ = 'I';
+#endif
+                if (!pad_ourselves)
+                  {
+                    if (flags & FLAG_ZERO)
+                      *fbp++ = '0';
+                    if (dp->width_start != dp->width_end)
+                      {
+                        size_t n = dp->width_end - dp->width_start;
+                        /* The width specification is known to consist only
+                           of standard ASCII characters.  */
+                        if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+                          {
+                            memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
+                            fbp += n;
+                          }
+                        else
+                          {
+                            const FCHAR_T *mp = dp->width_start;
+                            do
+                              *fbp++ = (unsigned char) *mp++;
+                            while (--n > 0);
+                          }
+                      }
+                  }
+                if (!prec_ourselves)
+                  {
+                    if (dp->precision_start != dp->precision_end)
+                      {
+                        size_t n = dp->precision_end - dp->precision_start;
+                        /* The precision specification is known to consist only
+                           of standard ASCII characters.  */
+                        if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
+                          {
+                            memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
+                            fbp += n;
+                          }
+                        else
+                          {
+                            const FCHAR_T *mp = dp->precision_start;
+                            do
+                              *fbp++ = (unsigned char) *mp++;
+                            while (--n > 0);
+                          }
+                      }
+                  }
+
+                switch (type)
+                  {
+#if HAVE_LONG_LONG_INT
+                  case TYPE_LONGLONGINT:
+                  case TYPE_ULONGLONGINT:
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+                    *fbp++ = 'I';
+                    *fbp++ = '6';
+                    *fbp++ = '4';
+                    break;
+# else
+                    *fbp++ = 'l';
+                    /*FALLTHROUGH*/
+# endif
+#endif
+                  case TYPE_LONGINT:
+                  case TYPE_ULONGINT:
+#if HAVE_WINT_T
+                  case TYPE_WIDE_CHAR:
+#endif
+#if HAVE_WCHAR_T
+                  case TYPE_WIDE_STRING:
+#endif
+                    *fbp++ = 'l';
+                    break;
+                  case TYPE_LONGDOUBLE:
+                    *fbp++ = 'L';
+                    break;
+                  default:
+                    break;
+                  }
+#if NEED_PRINTF_DIRECTIVE_F
+                if (dp->conversion == 'F')
+                  *fbp = 'f';
+                else
+#endif
+                  *fbp = dp->conversion;
+#if USE_SNPRINTF
+# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+                fbp[1] = '%';
+                fbp[2] = 'n';
+                fbp[3] = '\0';
+# else
+                /* On glibc2 systems from glibc >= 2.3 - probably also older
+                   ones - we know that snprintf's return value conforms to
+                   ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
+                   gl_SNPRINTF_TRUNCATION_C99 pass.
+                   Therefore we can avoid using %n in this situation.
+                   On glibc2 systems from 2004-10-18 or newer, the use of %n
+                   in format strings in writable memory may crash the program
+                   (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
+                   in this situation.  */
+                /* On native Win32 systems (such as mingw), we can avoid using
+                   %n because:
+                     - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
+                       snprintf does not write more than the specified number
+                       of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
+                       '4', '5', '6' into buf, not '4', '5', '\0'.)
+                     - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
+                       allows us to recognize the case of an insufficient
+                       buffer size: it returns -1 in this case.
+                   On native Win32 systems (such as mingw) where the OS is
+                   Windows Vista, the use of %n in format strings by default
+                   crashes the program. See
+                     <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+                     <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+                   So we should avoid %n in this situation.  */
+                fbp[1] = '\0';
+# endif
+#else
+                fbp[1] = '\0';
+#endif
+
+                /* Construct the arguments for calling snprintf or sprintf.  */
+                prefix_count = 0;
+                if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
+                  {
+                    if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                      abort ();
+                    prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
+                  }
+                if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
+                  {
+                    if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                      abort ();
+                    prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
+                  }
+
+#if USE_SNPRINTF
+                /* The SNPRINTF result is appended after result[0..length].
+                   The latter is an array of DCHAR_T; SNPRINTF appends an
+                   array of TCHAR_T to it.  This is possible because
+                   sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
+                   alignof (TCHAR_T) <= alignof (DCHAR_T).  */
+# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
+                /* Ensure that maxlen below will be >= 2.  Needed on BeOS,
+                   where an snprintf() with maxlen==1 acts like sprintf().  */
+                ENSURE_ALLOCATION (xsum (length,
+                                         (2 + TCHARS_PER_DCHAR - 1)
+                                         / TCHARS_PER_DCHAR));
+                /* Prepare checking whether snprintf returns the count
+                   via %n.  */
+                *(TCHAR_T *) (result + length) = '\0';
+#endif
+
+                orig_errno = errno;
+
+                for (;;)
+                  {
+                    int count = -1;
+
+#if USE_SNPRINTF
+                    int retcount = 0;
+                    size_t maxlen = allocated - length;
+                    /* SNPRINTF can fail if its second argument is
+                       > INT_MAX.  */
+                    if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
+                      maxlen = INT_MAX / TCHARS_PER_DCHAR;
+                    maxlen = maxlen * TCHARS_PER_DCHAR;
+# define SNPRINTF_BUF(arg) \
+                    switch (prefix_count)                                   \
+                      {                                                     \
+                      case 0:                                               \
+                        retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+                                             maxlen, buf,                   \
+                                             arg, &count);                  \
+                        break;                                              \
+                      case 1:                                               \
+                        retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+                                             maxlen, buf,                   \
+                                             prefixes[0], arg, &count);     \
+                        break;                                              \
+                      case 2:                                               \
+                        retcount = SNPRINTF ((TCHAR_T *) (result + length), \
+                                             maxlen, buf,                   \
+                                             prefixes[0], prefixes[1], arg, \
+                                             &count);                       \
+                        break;                                              \
+                      default:                                              \
+                        abort ();                                           \
+                      }
+#else
+# define SNPRINTF_BUF(arg) \
+                    switch (prefix_count)                                   \
+                      {                                                     \
+                      case 0:                                               \
+                        count = sprintf (tmp, buf, arg);                    \
+                        break;                                              \
+                      case 1:                                               \
+                        count = sprintf (tmp, buf, prefixes[0], arg);       \
+                        break;                                              \
+                      case 2:                                               \
+                        count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
+                                         arg);                              \
+                        break;                                              \
+                      default:                                              \
+                        abort ();                                           \
+                      }
+#endif
+
+                    errno = 0;
+                    switch (type)
+                      {
+                      case TYPE_SCHAR:
+                        {
+                          int arg = a.arg[dp->arg_index].a.a_schar;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_UCHAR:
+                        {
+                          unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_SHORT:
+                        {
+                          int arg = a.arg[dp->arg_index].a.a_short;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_USHORT:
+                        {
+                          unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_INT:
+                        {
+                          int arg = a.arg[dp->arg_index].a.a_int;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_UINT:
+                        {
+                          unsigned int arg = a.arg[dp->arg_index].a.a_uint;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_LONGINT:
+                        {
+                          long int arg = a.arg[dp->arg_index].a.a_longint;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_ULONGINT:
+                        {
+                          unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#if HAVE_LONG_LONG_INT
+                      case TYPE_LONGLONGINT:
+                        {
+                          long long int arg = a.arg[dp->arg_index].a.a_longlongint;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_ULONGLONGINT:
+                        {
+                          unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#endif
+                      case TYPE_DOUBLE:
+                        {
+                          double arg = a.arg[dp->arg_index].a.a_double;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_LONGDOUBLE:
+                        {
+                          long double arg = a.arg[dp->arg_index].a.a_longdouble;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      case TYPE_CHAR:
+                        {
+                          int arg = a.arg[dp->arg_index].a.a_char;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#if HAVE_WINT_T
+                      case TYPE_WIDE_CHAR:
+                        {
+                          wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#endif
+                      case TYPE_STRING:
+                        {
+                          const char *arg = a.arg[dp->arg_index].a.a_string;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#if HAVE_WCHAR_T
+                      case TYPE_WIDE_STRING:
+                        {
+                          const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+#endif
+                      case TYPE_POINTER:
+                        {
+                          void *arg = a.arg[dp->arg_index].a.a_pointer;
+                          SNPRINTF_BUF (arg);
+                        }
+                        break;
+                      default:
+                        abort ();
+                      }
+
+#if USE_SNPRINTF
+                    /* Portability: Not all implementations of snprintf()
+                       are ISO C 99 compliant.  Determine the number of
+                       bytes that snprintf() has produced or would have
+                       produced.  */
+                    if (count >= 0)
+                      {
+                        /* Verify that snprintf() has NUL-terminated its
+                           result.  */
+                        if (count < maxlen
+                            && ((TCHAR_T *) (result + length)) [count] != '\0')
+                          abort ();
+                        /* Portability hack.  */
+                        if (retcount > count)
+                          count = retcount;
+                      }
+                    else
+                      {
+                        /* snprintf() doesn't understand the '%n'
+                           directive.  */
+                        if (fbp[1] != '\0')
+                          {
+                            /* Don't use the '%n' directive; instead, look
+                               at the snprintf() return value.  */
+                            fbp[1] = '\0';
+                            continue;
+                          }
+                        else
+                          {
+                            /* Look at the snprintf() return value.  */
+                            if (retcount < 0)
+                              {
+# if !HAVE_SNPRINTF_RETVAL_C99
+                                /* HP-UX 10.20 snprintf() is doubly deficient:
+                                   It doesn't understand the '%n' directive,
+                                   *and* it returns -1 (rather than the length
+                                   that would have been required) when the
+                                   buffer is too small.
+                                   But a failure at this point can also come
+                                   from other reasons than a too small buffer,
+                                   such as an invalid wide string argument to
+                                   the %ls directive, or possibly an invalid
+                                   floating-point argument.  */
+                                size_t tmp_length =
+                                  MAX_ROOM_NEEDED (&a, dp->arg_index,
+                                                   dp->conversion, type, flags,
+                                                   width, has_precision,
+                                                   precision, pad_ourselves);
+
+                                if (maxlen < tmp_length)
+                                  {
+                                    /* Make more room.  But try to do through
+                                       this reallocation only once.  */
+                                    size_t bigger_need =
+                                      xsum (length,
+                                            xsum (tmp_length,
+                                                  TCHARS_PER_DCHAR - 1)
+                                            / TCHARS_PER_DCHAR);
+                                    /* And always grow proportionally.
+                                       (There may be several arguments, each
+                                       needing a little more room than the
+                                       previous one.)  */
+                                    size_t bigger_need2 =
+                                      xsum (xtimes (allocated, 2), 12);
+                                    if (bigger_need < bigger_need2)
+                                      bigger_need = bigger_need2;
+                                    ENSURE_ALLOCATION (bigger_need);
+                                    continue;
+                                  }
+# endif
+                              }
+                            else
+                              count = retcount;
+                          }
+                      }
+#endif
+
+                    /* Attempt to handle failure.  */
+                    if (count < 0)
+                      {
+                        /* SNPRINTF or sprintf failed.  Save and use the errno
+                           that it has set, if any.  */
+                        int saved_errno = errno;
+
+                        if (!(result == resultbuf || result == NULL))
+                          free (result);
+                        if (buf_malloced != NULL)
+                          free (buf_malloced);
+                        CLEANUP ();
+                        errno =
+                          (saved_errno != 0
+                           ? saved_errno
+                           : (dp->conversion == 'c' || dp->conversion == 's'
+                              ? EILSEQ
+                              : EINVAL));
+                        return NULL;
+                      }
+
+#if USE_SNPRINTF
+                    /* Handle overflow of the allocated buffer.
+                       If such an overflow occurs, a C99 compliant snprintf()
+                       returns a count >= maxlen.  However, a non-compliant
+                       snprintf() function returns only count = maxlen - 1.  To
+                       cover both cases, test whether count >= maxlen - 1.  */
+                    if ((unsigned int) count + 1 >= maxlen)
+                      {
+                        /* If maxlen already has attained its allowed maximum,
+                           allocating more memory will not increase maxlen.
+                           Instead of looping, bail out.  */
+                        if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
+                          goto overflow;
+                        else
+                          {
+                            /* Need at least (count + 1) * sizeof (TCHAR_T)
+                               bytes.  (The +1 is for the trailing NUL.)
+                               But ask for (count + 2) * sizeof (TCHAR_T)
+                               bytes, so that in the next round, we likely get
+                                 maxlen > (unsigned int) count + 1
+                               and so we don't get here again.
+                               And allocate proportionally, to avoid looping
+                               eternally if snprintf() reports a too small
+                               count.  */
+                            size_t n =
+                              xmax (xsum (length,
+                                          ((unsigned int) count + 2
+                                           + TCHARS_PER_DCHAR - 1)
+                                          / TCHARS_PER_DCHAR),
+                                    xtimes (allocated, 2));
+
+                            ENSURE_ALLOCATION (n);
+                            continue;
+                          }
+                      }
+#endif
+
+#if NEED_PRINTF_UNBOUNDED_PRECISION
+                    if (prec_ourselves)
+                      {
+                        /* Handle the precision.  */
+                        TCHAR_T *prec_ptr =
+# if USE_SNPRINTF
+                          (TCHAR_T *) (result + length);
+# else
+                          tmp;
+# endif
+                        size_t prefix_count;
+                        size_t move;
+
+                        prefix_count = 0;
+                        /* Put the additional zeroes after the sign.  */
+                        if (count >= 1
+                            && (*prec_ptr == '-' || *prec_ptr == '+'
+                                || *prec_ptr == ' '))
+                          prefix_count = 1;
+                        /* Put the additional zeroes after the 0x prefix if
+                           (flags & FLAG_ALT) || (dp->conversion == 'p').  */
+                        else if (count >= 2
+                                 && prec_ptr[0] == '0'
+                                 && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
+                          prefix_count = 2;
+
+                        move = count - prefix_count;
+                        if (precision > move)
+                          {
+                            /* Insert zeroes.  */
+                            size_t insert = precision - move;
+                            TCHAR_T *prec_end;
+
+# if USE_SNPRINTF
+                            size_t n =
+                              xsum (length,
+                                    (count + insert + TCHARS_PER_DCHAR - 1)
+                                    / TCHARS_PER_DCHAR);
+                            length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+                            ENSURE_ALLOCATION (n);
+                            length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
+                            prec_ptr = (TCHAR_T *) (result + length);
+# endif
+
+                            prec_end = prec_ptr + count;
+                            prec_ptr += prefix_count;
+
+                            while (prec_end > prec_ptr)
+                              {
+                                prec_end--;
+                                prec_end[insert] = prec_end[0];
+                              }
+
+                            prec_end += insert;
+                            do
+                              *--prec_end = '0';
+                            while (prec_end > prec_ptr);
+
+                            count += insert;
+                          }
+                      }
+#endif
+
+#if !USE_SNPRINTF
+                    if (count >= tmp_length)
+                      /* tmp_length was incorrectly calculated - fix the
+                         code above!  */
+                      abort ();
+#endif
+
+#if !DCHAR_IS_TCHAR
+                    /* Convert from TCHAR_T[] to DCHAR_T[].  */
+                    if (dp->conversion == 'c' || dp->conversion == 's')
+                      {
+                        /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
+                           TYPE_WIDE_STRING.
+                           The result string is not certainly ASCII.  */
+                        const TCHAR_T *tmpsrc;
+                        DCHAR_T *tmpdst;
+                        size_t tmpdst_len;
+                        /* This code assumes that TCHAR_T is 'char'.  */
+                        verify (sizeof (TCHAR_T) == 1);
+# if USE_SNPRINTF
+                        tmpsrc = (TCHAR_T *) (result + length);
+# else
+                        tmpsrc = tmp;
+# endif
+                        tmpdst =
+                          DCHAR_CONV_FROM_ENCODING (locale_charset (),
+                                                    iconveh_question_mark,
+                                                    tmpsrc, count,
+                                                    NULL,
+                                                    NULL, &tmpdst_len);
+                        if (tmpdst == NULL)
+                          {
+                            int saved_errno = errno;
+                            if (!(result == resultbuf || result == NULL))
+                              free (result);
+                            if (buf_malloced != NULL)
+                              free (buf_malloced);
+                            CLEANUP ();
+                            errno = saved_errno;
+                            return NULL;
+                          }
+                        ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+                        DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+                        free (tmpdst);
+                        count = tmpdst_len;
+                      }
+                    else
+                      {
+                        /* The result string is ASCII.
+                           Simple 1:1 conversion.  */
+# if USE_SNPRINTF
+                        /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
+                           no-op conversion, in-place on the array starting
+                           at (result + length).  */
+                        if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
+# endif
+                          {
+                            const TCHAR_T *tmpsrc;
+                            DCHAR_T *tmpdst;
+                            size_t n;
+
+# if USE_SNPRINTF
+                            if (result == resultbuf)
+                              {
+                                tmpsrc = (TCHAR_T *) (result + length);
+                                /* ENSURE_ALLOCATION will not move tmpsrc
+                                   (because it's part of resultbuf).  */
+                                ENSURE_ALLOCATION (xsum (length, count));
+                              }
+                            else
+                              {
+                                /* ENSURE_ALLOCATION will move the array
+                                   (because it uses realloc().  */
+                                ENSURE_ALLOCATION (xsum (length, count));
+                                tmpsrc = (TCHAR_T *) (result + length);
+                              }
+# else
+                            tmpsrc = tmp;
+                            ENSURE_ALLOCATION (xsum (length, count));
+# endif
+                            tmpdst = result + length;
+                            /* Copy backwards, because of overlapping.  */
+                            tmpsrc += count;
+                            tmpdst += count;
+                            for (n = count; n > 0; n--)
+                              *--tmpdst = (unsigned char) *--tmpsrc;
+                          }
+                      }
+#endif
+
+#if DCHAR_IS_TCHAR && !USE_SNPRINTF
+                    /* Make room for the result.  */
+                    if (count > allocated - length)
+                      {
+                        /* Need at least count elements.  But allocate
+                           proportionally.  */
+                        size_t n =
+                          xmax (xsum (length, count), xtimes (allocated, 2));
+
+                        ENSURE_ALLOCATION (n);
+                      }
+#endif
+
+                    /* Here count <= allocated - length.  */
+
+                    /* Perform padding.  */
+#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+                    if (pad_ourselves && has_width)
+                      {
+                        size_t w;
+# if ENABLE_UNISTDIO
+                        /* Outside POSIX, it's preferrable to compare the width
+                           against the number of _characters_ of the converted
+                           value.  */
+                        w = DCHAR_MBSNLEN (result + length, count);
+# else
+                        /* The width is compared against the number of _bytes_
+                           of the converted value, says POSIX.  */
+                        w = count;
+# endif
+                        if (w < width)
+                          {
+                            size_t pad = width - w;
+
+                            /* Make room for the result.  */
+                            if (xsum (count, pad) > allocated - length)
+                              {
+                                /* Need at least count + pad elements.  But
+                                   allocate proportionally.  */
+                                size_t n =
+                                  xmax (xsum3 (length, count, pad),
+                                        xtimes (allocated, 2));
+
+# if USE_SNPRINTF
+                                length += count;
+                                ENSURE_ALLOCATION (n);
+                                length -= count;
+# else
+                                ENSURE_ALLOCATION (n);
+# endif
+                              }
+                            /* Here count + pad <= allocated - length.  */
+
+                            {
+# if !DCHAR_IS_TCHAR || USE_SNPRINTF
+                              DCHAR_T * const rp = result + length;
+# else
+                              DCHAR_T * const rp = tmp;
+# endif
+                              DCHAR_T *p = rp + count;
+                              DCHAR_T *end = p + pad;
+                              DCHAR_T *pad_ptr;
+# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
+                              if (dp->conversion == 'c'
+                                  || dp->conversion == 's')
+                                /* No zero-padding for string directives.  */
+                                pad_ptr = NULL;
+                              else
+# endif
+                                {
+                                  pad_ptr = (*rp == '-' ? rp + 1 : rp);
+                                  /* No zero-padding of "inf" and "nan".  */
+                                  if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
+                                      || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
+                                    pad_ptr = NULL;
+                                }
+                              /* The generated string now extends from rp to p,
+                                 with the zero padding insertion point being at
+                                 pad_ptr.  */
+
+                              count = count + pad; /* = end - rp */
+
+                              if (flags & FLAG_LEFT)
+                                {
+                                  /* Pad with spaces on the right.  */
+                                  for (; pad > 0; pad--)
+                                    *p++ = ' ';
+                                }
+                              else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
+                                {
+                                  /* Pad with zeroes.  */
+                                  DCHAR_T *q = end;
+
+                                  while (p > pad_ptr)
+                                    *--q = *--p;
+                                  for (; pad > 0; pad--)
+                                    *p++ = '0';
+                                }
+                              else
+                                {
+                                  /* Pad with spaces on the left.  */
+                                  DCHAR_T *q = end;
+
+                                  while (p > rp)
+                                    *--q = *--p;
+                                  for (; pad > 0; pad--)
+                                    *p++ = ' ';
+                                }
+                            }
+                          }
+                      }
+#endif
+
+                    /* Here still count <= allocated - length.  */
+
+#if !DCHAR_IS_TCHAR || USE_SNPRINTF
+                    /* The snprintf() result did fit.  */
+#else
+                    /* Append the sprintf() result.  */
+                    memcpy (result + length, tmp, count * sizeof (DCHAR_T));
+#endif
+#if !USE_SNPRINTF
+                    if (tmp != tmpbuf)
+                      free (tmp);
+#endif
+
+#if NEED_PRINTF_DIRECTIVE_F
+                    if (dp->conversion == 'F')
+                      {
+                        /* Convert the %f result to upper case for %F.  */
+                        DCHAR_T *rp = result + length;
+                        size_t rc;
+                        for (rc = count; rc > 0; rc--, rp++)
+                          if (*rp >= 'a' && *rp <= 'z')
+                            *rp = *rp - 'a' + 'A';
+                      }
+#endif
+
+                    length += count;
+                    break;
+                  }
+                errno = orig_errno;
+#undef pad_ourselves
+#undef prec_ourselves
+              }
+          }
+      }
+
+    /* Add the final NUL.  */
+    ENSURE_ALLOCATION (xsum (length, 1));
+    result[length] = '\0';
+
+    if (result != resultbuf && length + 1 < allocated)
+      {
+        /* Shrink the allocated memory if possible.  */
+        DCHAR_T *memory;
+
+        memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
+        if (memory != NULL)
+          result = memory;
+      }
+
+    if (buf_malloced != NULL)
+      free (buf_malloced);
+    CLEANUP ();
+    *lengthp = length;
+    /* Note that we can produce a big string of a length > INT_MAX.  POSIX
+       says that snprintf() fails with errno = EOVERFLOW in this case, but
+       that's only because snprintf() returns an 'int'.  This function does
+       not have this limitation.  */
+    return result;
+
+#if USE_SNPRINTF
+  overflow:
+    if (!(result == resultbuf || result == NULL))
+      free (result);
+    if (buf_malloced != NULL)
+      free (buf_malloced);
+    CLEANUP ();
+    errno = EOVERFLOW;
+    return NULL;
+#endif
+
+  out_of_memory:
+    if (!(result == resultbuf || result == NULL))
+      free (result);
+    if (buf_malloced != NULL)
+      free (buf_malloced);
+  out_of_memory_1:
+    CLEANUP ();
+    errno = ENOMEM;
+    return NULL;
+  }
+}
+
+#undef MAX_ROOM_NEEDED
+#undef TCHARS_PER_DCHAR
+#undef SNPRINTF
+#undef USE_SNPRINTF
+#undef DCHAR_SET
+#undef DCHAR_CPY
+#undef PRINTF_PARSE
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef DCHAR_IS_TCHAR
+#undef TCHAR_T
+#undef DCHAR_T
+#undef FCHAR_T
+#undef VASNPRINTF
diff --git a/gnulib/lib/vasnprintf.h b/gnulib/lib/vasnprintf.h
new file mode 100644 (file)
index 0000000..740f7e9
--- /dev/null
@@ -0,0 +1,80 @@
+/* vsprintf with automatic memory allocation.
+   Copyright (C) 2002-2004, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _VASNPRINTF_H
+#define _VASNPRINTF_H
+
+/* Get va_list.  */
+#include <stdarg.h>
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* 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 _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 _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Write formatted output to a string dynamically allocated with malloc().
+   You can pass a preallocated buffer for the result in RESULTBUF and its
+   size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
+   If successful, return the address of the string (this may be = RESULTBUF
+   if no dynamic memory allocation was necessary) and set *LENGTHP to the
+   number of resulting bytes, excluding the trailing NUL.  Upon error, set
+   errno and return NULL.
+
+   When dynamic memory allocation occurs, the preallocated buffer is left
+   alone (with possibly modified contents).  This makes it possible to use
+   a statically allocated or stack-allocated buffer, like this:
+
+          char buf[100];
+          size_t len = sizeof (buf);
+          char *output = vasnprintf (buf, &len, format, args);
+          if (output == NULL)
+            ... error handling ...;
+          else
+            {
+              ... use the output string ...;
+              if (output != buf)
+                free (output);
+            }
+  */
+#if REPLACE_VASNPRINTF
+# define asnprintf rpl_asnprintf
+# define vasnprintf rpl_vasnprintf
+#endif
+extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
+extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VASNPRINTF_H */
diff --git a/gnulib/lib/vasprintf.c b/gnulib/lib/vasprintf.c
new file mode 100644 (file)
index 0000000..86d0328
--- /dev/null
@@ -0,0 +1,51 @@
+/* Formatted output to strings.
+   Copyright (C) 1999, 2002, 2006-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#ifdef IN_LIBASPRINTF
+# include "vasprintf.h"
+#else
+# include <stdio.h>
+#endif
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#include "vasnprintf.h"
+
+int
+vasprintf (char **resultp, const char *format, va_list args)
+{
+  size_t length;
+  char *result = vasnprintf (NULL, &length, format, args);
+  if (result == NULL)
+    return -1;
+
+  if (length > INT_MAX)
+    {
+      free (result);
+      errno = EOVERFLOW;
+      return -1;
+    }
+
+  *resultp = result;
+  /* Return the number of resulting bytes, excluding the trailing NUL.  */
+  return length;
+}
diff --git a/gnulib/lib/verify.h b/gnulib/lib/verify.h
new file mode 100644 (file)
index 0000000..d51ba68
--- /dev/null
@@ -0,0 +1,163 @@
+/* Compile-time assert-like macros.
+
+   Copyright (C) 2005-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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
+
+#ifndef VERIFY_H
+# define VERIFY_H 1
+
+/* Each of these macros verifies that its argument R is nonzero.  To
+   be portable, R should be an integer constant expression.  Unlike
+   assert (R), there is no run-time overhead.
+
+   There are two macros, since no single macro can be used in all
+   contexts in C.  verify_true (R) is for scalar contexts, including
+   integer constant expression contexts.  verify (R) is for declaration
+   contexts, e.g., the top level.
+
+   Symbols ending in "__" are private to this header.
+
+   The code below uses several ideas.
+
+   * The first step is ((R) ? 1 : -1).  Given an expression R, of
+     integral or boolean or floating-point type, this yields an
+     expression of integral type, whose value is later verified to be
+     constant and nonnegative.
+
+   * Next this expression W is wrapped in a type
+     struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+     If W is negative, this yields a compile-time error.  No compiler can
+     deal with a bit-field of negative size.
+
+     One might think that an array size check would have the same
+     effect, that is, that the type struct { unsigned int dummy[W]; }
+     would work as well.  However, inside a function, some compilers
+     (such as C++ compilers and GNU C) allow local parameters and
+     variables inside array size expressions.  With these compilers,
+     an array size check would not properly diagnose this misuse of
+     the verify macro:
+
+       void function (int n) { verify (n < 0); }
+
+   * For the verify macro, the struct verify_type__ will need to
+     somehow be embedded into a declaration.  To be portable, this
+     declaration must declare an object, a constant, a function, or a
+     typedef name.  If the declared entity uses the type directly,
+     such as in
+
+       struct dummy {...};
+       typedef struct {...} dummy;
+       extern struct {...} *dummy;
+       extern void dummy (struct {...} *);
+       extern struct {...} *dummy (void);
+
+     two uses of the verify macro would yield colliding declarations
+     if the entity names are not disambiguated.  A workaround is to
+     attach the current line number to the entity name:
+
+       #define _GL_CONCAT0(x, y) x##y
+       #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+       extern struct {...} * _GL_CONCAT (dummy, __LINE__);
+
+     But this has the problem that two invocations of verify from
+     within the same macro would collide, since the __LINE__ value
+     would be the same for both invocations.  (The GCC __COUNTER__
+     macro solves this problem, but is not portable.)
+
+     A solution is to use the sizeof operator.  It yields a number,
+     getting rid of the identity of the type.  Declarations like
+
+       extern int dummy [sizeof (struct {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+     can be repeated.
+
+   * Should the implementation use a named struct or an unnamed struct?
+     Which of the following alternatives can be used?
+
+       extern int dummy [sizeof (struct {...})];
+       extern int dummy [sizeof (struct verify_type__ {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern void dummy (int [sizeof (struct verify_type__ {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+       extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+
+     In the second and sixth case, the struct type is exported to the
+     outer scope; two such declarations therefore collide.  GCC warns
+     about the first, third, and fourth cases.  So the only remaining
+     possibility is the fifth case:
+
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+   * GCC warns about duplicate declarations of the dummy function if
+     -Wredundant_decls is used.  GCC 4.3 and later have a builtin
+     __COUNTER__ macro that can let us generate unique identifiers for
+     each dummy function, to suppress this warning.
+
+   * This implementation exploits the fact that GCC does not warn about
+     the last declaration mentioned above.  If a future version of GCC
+     introduces a warning for this, the problem could be worked around
+     by using code specialized to GCC, just as __COUNTER__ is already
+     being used if available.
+
+       #if 4 <= __GNUC__
+       # define verify(R) [another version to keep GCC happy]
+       #endif
+
+   * In C++, any struct definition inside sizeof is invalid.
+     Use a template type to work around the problem.  */
+
+/* Concatenate two preprocessor tokens.  */
+# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+# define _GL_CONCAT0(x, y) x##y
+
+/* _GL_COUNTER is an integer, preferably one that changes each time we
+   use it.  Use __COUNTER__ if it works, falling back on __LINE__
+   otherwise.  __LINE__ isn't perfect, but it's better than a
+   constant.  */
+# if defined __COUNTER__ && __COUNTER__ != __COUNTER__
+#  define _GL_COUNTER __COUNTER__
+# else
+#  define _GL_COUNTER __LINE__
+# endif
+
+/* Generate a symbol with the given prefix, making it unique if
+   possible.  */
+# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+   Return 1.  */
+
+# ifdef __cplusplus
+template <int w>
+  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+#  define verify_true(R) \
+     (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# else
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+   trailing ';'.  */
+
+# define verify(R) \
+    extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
+
+#endif
diff --git a/gnulib/lib/wchar.in.h b/gnulib/lib/wchar.in.h
new file mode 100644 (file)
index 0000000..5bc137c
--- /dev/null
@@ -0,0 +1,922 @@
+/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
+
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake.  */
+
+/*
+ * ISO C 99 <wchar.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/wchar.h.html>
+ *
+ * For now, this just ensures proper prerequisite inclusion order and
+ * the declaration of wcwidth().
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
+/* Special invocation convention:
+   - Inside glibc and uClibc header files.
+   - On HP-UX 11.00 we have a sequence of nested includes
+     <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
+     once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
+     and once directly.  In both situations 'wint_t' is not yet defined,
+     therefore we cannot provide the function overrides; instead include only
+     the system's <wchar.h>.
+   - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
+     the latter includes <wchar.h>.  But here, we have no way to detect whether
+     <wctype.h> is completely included or is still being included.  */
+
+#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _GL_WCHAR_H
+
+#define _GL_ALREADY_INCLUDING_WCHAR_H
+
+#if @HAVE_FEATURES_H@
+# include <features.h> /* for __GLIBC__ */
+#endif
+
+/* 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>.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+#endif
+
+/* Include the original <wchar.h> if it exists.
+   Some builds of uClibc lack it.  */
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_WCHAR_H@
+# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
+#endif
+
+#undef _GL_ALREADY_INCLUDING_WCHAR_H
+
+#ifndef _GL_WCHAR_H
+#define _GL_WCHAR_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+/* Define wint_t and WEOF.  (Also done in wctype.in.h.)  */
+#if !@HAVE_WINT_T@ && !defined wint_t
+# define wint_t int
+# ifndef WEOF
+#  define WEOF -1
+# endif
+#else
+# ifndef WEOF
+#  define WEOF ((wint_t) -1)
+# endif
+#endif
+
+
+/* Override mbstate_t if it is too small.
+   On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
+   implementing mbrtowc for encodings like UTF-8.  */
+#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
+# 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
+# endif
+#endif
+
+
+/* Convert a single-byte character to a wide character.  */
+#if @GNULIB_BTOWC@
+# if @REPLACE_BTOWC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef btowc
+#   define btowc rpl_btowc
+#  endif
+_GL_FUNCDECL_RPL (btowc, wint_t, (int c));
+_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
+# else
+#  if !@HAVE_BTOWC@
+_GL_FUNCDECL_SYS (btowc, wint_t, (int c));
+#  endif
+_GL_CXXALIAS_SYS (btowc, wint_t, (int c));
+# endif
+_GL_CXXALIASWARN (btowc);
+#elif defined GNULIB_POSIXCHECK
+# undef btowc
+# if HAVE_RAW_DECL_BTOWC
+_GL_WARN_ON_USE (btowc, "btowc is unportable - "
+                 "use gnulib module btowc for portability");
+# endif
+#endif
+
+
+/* Convert a wide character to a single-byte character.  */
+#if @GNULIB_WCTOB@
+# if @REPLACE_WCTOB@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wctob
+#   define wctob rpl_wctob
+#  endif
+_GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
+_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
+# else
+#  if !defined wctob && !@HAVE_DECL_WCTOB@
+/* wctob is provided by gnulib, or wctob exists but is not declared.  */
+_GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
+#  endif
+_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
+# endif
+_GL_CXXALIASWARN (wctob);
+#elif defined GNULIB_POSIXCHECK
+# undef wctob
+# if HAVE_RAW_DECL_WCTOB
+_GL_WARN_ON_USE (wctob, "wctob is unportable - "
+                 "use gnulib module wctob for portability");
+# endif
+#endif
+
+
+/* Test whether *PS is in the initial state.  */
+#if @GNULIB_MBSINIT@
+# if @REPLACE_MBSINIT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsinit
+#   define mbsinit rpl_mbsinit
+#  endif
+_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
+# else
+#  if !@HAVE_MBSINIT@
+_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsinit);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsinit
+# if HAVE_RAW_DECL_MBSINIT
+_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
+                 "use gnulib module mbsinit for portability");
+# endif
+#endif
+
+
+/* Convert a multibyte character to a wide character.  */
+#if @GNULIB_MBRTOWC@
+# if @REPLACE_MBRTOWC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrtowc
+#   define mbrtowc rpl_mbrtowc
+#  endif
+_GL_FUNCDECL_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# else
+#  if !@HAVE_MBRTOWC@
+_GL_FUNCDECL_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrtowc, size_t,
+                  (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbrtowc);
+#elif defined GNULIB_POSIXCHECK
+# undef mbrtowc
+# if HAVE_RAW_DECL_MBRTOWC
+_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
+                 "use gnulib module mbrtowc for portability");
+# endif
+#endif
+
+
+/* Recognize a multibyte character.  */
+#if @GNULIB_MBRLEN@
+# if @REPLACE_MBRLEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbrlen
+#   define mbrlen rpl_mbrlen
+#  endif
+_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# else
+#  if !@HAVE_MBRLEN@
+_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbrlen);
+#elif defined GNULIB_POSIXCHECK
+# undef mbrlen
+# if HAVE_RAW_DECL_MBRLEN
+_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
+                 "use gnulib module mbrlen for portability");
+# endif
+#endif
+
+
+/* Convert a string to a wide string.  */
+#if @GNULIB_MBSRTOWCS@
+# if @REPLACE_MBSRTOWCS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsrtowcs
+#   define mbsrtowcs rpl_mbsrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if !@HAVE_MBSRTOWCS@
+_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t len,
+                   mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsrtowcs);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsrtowcs
+# if HAVE_RAW_DECL_MBSRTOWCS
+_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
+                 "use gnulib module mbsrtowcs for portability");
+# endif
+#endif
+
+
+/* Convert a string to a wide string.  */
+#if @GNULIB_MBSNRTOWCS@
+# if @REPLACE_MBSNRTOWCS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbsnrtowcs
+#   define mbsnrtowcs rpl_mbsnrtowcs
+#  endif
+_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if !@HAVE_MBSNRTOWCS@
+_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
+                  (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (mbsnrtowcs);
+#elif defined GNULIB_POSIXCHECK
+# undef mbsnrtowcs
+# if HAVE_RAW_DECL_MBSNRTOWCS
+_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
+                 "use gnulib module mbsnrtowcs for portability");
+# endif
+#endif
+
+
+/* Convert a wide character to a multibyte character.  */
+#if @GNULIB_WCRTOMB@
+# if @REPLACE_WCRTOMB@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcrtomb
+#   define wcrtomb rpl_wcrtomb
+#  endif
+_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# else
+#  if !@HAVE_WCRTOMB@
+_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+#  endif
+_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcrtomb);
+#elif defined GNULIB_POSIXCHECK
+# undef wcrtomb
+# if HAVE_RAW_DECL_WCRTOMB
+_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
+                 "use gnulib module wcrtomb for portability");
+# endif
+#endif
+
+
+/* Convert a wide string to a string.  */
+#if @GNULIB_WCSRTOMBS@
+# if @REPLACE_WCSRTOMBS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsrtombs
+#   define wcsrtombs rpl_wcsrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
+# else
+#  if !@HAVE_WCSRTOMBS@
+_GL_FUNCDECL_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t len,
+                   mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcsrtombs);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsrtombs
+# if HAVE_RAW_DECL_WCSRTOMBS
+_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
+                 "use gnulib module wcsrtombs for portability");
+# endif
+#endif
+
+
+/* Convert a wide string to a string.  */
+#if @GNULIB_WCSNRTOMBS@
+# if @REPLACE_WCSNRTOMBS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcsnrtombs
+#   define wcsnrtombs rpl_wcsnrtombs
+#  endif
+_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# else
+#  if !@HAVE_WCSNRTOMBS@
+_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
+                  (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
+                   mbstate_t *ps));
+# endif
+_GL_CXXALIASWARN (wcsnrtombs);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsnrtombs
+# if HAVE_RAW_DECL_WCSNRTOMBS
+_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
+                 "use gnulib module wcsnrtombs for portability");
+# endif
+#endif
+
+
+/* Return the number of screen columns needed for WC.  */
+#if @GNULIB_WCWIDTH@
+# if @REPLACE_WCWIDTH@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcwidth
+#   define wcwidth rpl_wcwidth
+#  endif
+_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
+_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
+# else
+#  if !@HAVE_DECL_WCWIDTH@
+/* wcwidth exists but is not declared.  */
+_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
+#  endif
+_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
+# endif
+_GL_CXXALIASWARN (wcwidth);
+#elif defined GNULIB_POSIXCHECK
+# undef wcwidth
+# if HAVE_RAW_DECL_WCWIDTH
+_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
+                 "use gnulib module wcwidth for portability");
+# endif
+#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
diff --git a/gnulib/lib/wcrtomb.c b/gnulib/lib/wcrtomb.c
new file mode 100644 (file)
index 0000000..00e7b85
--- /dev/null
@@ -0,0 +1,53 @@
+/* Convert wide character to multibyte character.
+   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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <errno.h>
+#include <stdlib.h>
+
+
+size_t
+wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+{
+  /* This implementation of wcrtomb on top of wctomb() supports only
+     stateless encodings.  ps must be in the initial state.  */
+  if (ps != NULL && !mbsinit (ps))
+    {
+      errno = EINVAL;
+      return (size_t)(-1);
+    }
+
+  if (s == NULL)
+    /* We know the NUL wide character corresponds to the NUL character.  */
+    return 1;
+  else
+    {
+      int ret = wctomb (s, wc);
+
+      if (ret >= 0)
+        return ret;
+      else
+        {
+          errno = EILSEQ;
+          return (size_t)(-1);
+        }
+    }
+}
diff --git a/gnulib/lib/wctype.in.h b/gnulib/lib/wctype.in.h
new file mode 100644 (file)
index 0000000..18a5dd7
--- /dev/null
@@ -0,0 +1,470 @@
+/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
+
+   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible and Paul Eggert.  */
+
+/*
+ * ISO C 99 <wctype.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/wctype.h.html>
+ *
+ * iswctype, towctrans, towlower, towupper, wctrans, wctype,
+ * wctrans_t, and wctype_t are not yet implemented.
+ */
+
+#ifndef _GL_WCTYPE_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if @HAVE_WINT_T@
+/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
+   Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+# include <wchar.h>
+#endif
+
+/* Include the original <wctype.h> if it exists.
+   BeOS 5 has the functions but no <wctype.h>.  */
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_WCTYPE_H@
+# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
+#endif
+
+#ifndef _GL_WCTYPE_H
+#define _GL_WCTYPE_H
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Define wint_t and WEOF.  (Also done in wchar.in.h.)  */
+#if !@HAVE_WINT_T@ && !defined wint_t
+# define wint_t int
+# ifndef WEOF
+#  define WEOF -1
+# endif
+#else
+# ifndef WEOF
+#  define WEOF ((wint_t) -1)
+# endif
+#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@
+
+/* 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
+
+/* 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
+#   endif
+#  endif
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswalnum
+#  else
+iswalnum
+#  endif
+         (wint_t wc)
+{
+  return ((wc >= '0' && wc <= '9')
+          || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswalpha
+#  else
+iswalpha
+#  endif
+         (wint_t wc)
+{
+  return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswblank
+#  else
+iswblank
+#  endif
+         (wint_t wc)
+{
+  return wc == ' ' || wc == '\t';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswcntrl
+#  else
+iswcntrl
+#  endif
+        (wint_t wc)
+{
+  return (wc & ~0x1f) == 0 || wc == 0x7f;
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswdigit
+#  else
+iswdigit
+#  endif
+         (wint_t wc)
+{
+  return wc >= '0' && wc <= '9';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswgraph
+#  else
+iswgraph
+#  endif
+         (wint_t wc)
+{
+  return wc >= '!' && wc <= '~';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswlower
+#  else
+iswlower
+#  endif
+         (wint_t wc)
+{
+  return wc >= 'a' && wc <= 'z';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswprint
+#  else
+iswprint
+#  endif
+         (wint_t wc)
+{
+  return wc >= ' ' && wc <= '~';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswpunct
+#  else
+iswpunct
+#  endif
+         (wint_t wc)
+{
+  return (wc >= '!' && wc <= '~'
+          && !((wc >= '0' && wc <= '9')
+               || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswspace
+#  else
+iswspace
+#  endif
+         (wint_t wc)
+{
+  return (wc == ' ' || wc == '\t'
+          || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswupper
+#  else
+iswupper
+#  endif
+         (wint_t wc)
+{
+  return wc >= 'A' && wc <= 'Z';
+}
+
+static inline int
+#  if @REPLACE_ISWCNTRL@
+rpl_iswxdigit
+#  else
+iswxdigit
+#  endif
+          (wint_t wc)
+{
+  return ((wc >= '0' && wc <= '9')
+          || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
+}
+
+static inline wint_t
+#  if @REPLACE_ISWCNTRL@
+rpl_towlower
+#  else
+towlower
+#  endif
+         (wint_t wc)
+{
+  return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
+}
+
+static inline wint_t
+#  if @REPLACE_ISWCNTRL@
+rpl_towupper
+#  else
+towupper
+#  endif
+         (wint_t wc)
+{
+  return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
+}
+
+# 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
+#   endif
+_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
+#  else
+_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
+#  endif
+
+# endif
+
+# 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
+   to take a wchar_t argument and return a wchar_t result.  mingw declares
+   these functions to take a wint_t argument and return a wint_t result.
+   This means that:
+   1. When the user passes an argument outside the range 0x0000..0xFFFF, the
+      function will look only at the lower 16 bits.  This is allowed according
+      to POSIX.
+   2. The return value is returned in the lower 16 bits of the result register.
+      The upper 16 bits are random: whatever happened to be in that part of the
+      result register.  We need to fix this by adding a zero-extend from
+      wchar_t to wint_t after the call.  */
+
+static inline wint_t
+rpl_towlower (wint_t wc)
+{
+  return (wint_t) (wchar_t) towlower (wc);
+}
+#  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
+
+# 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 (iswcntrl, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
+_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
+#else
+_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
+_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
+#endif
+_GL_CXXALIASWARN (iswalnum);
+_GL_CXXALIASWARN (iswalpha);
+_GL_CXXALIASWARN (iswcntrl);
+_GL_CXXALIASWARN (iswdigit);
+_GL_CXXALIASWARN (iswgraph);
+_GL_CXXALIASWARN (iswlower);
+_GL_CXXALIASWARN (iswprint);
+_GL_CXXALIASWARN (iswpunct);
+_GL_CXXALIASWARN (iswspace);
+_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));
+#else
+_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
+_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
+#endif
+_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 */
diff --git a/gnulib/lib/xsize.h b/gnulib/lib/xsize.h
new file mode 100644 (file)
index 0000000..5816dcf
--- /dev/null
@@ -0,0 +1,108 @@
+/* xsize.h -- Checked size_t computations.
+
+   Copyright (C) 2003, 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 Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _XSIZE_H
+#define _XSIZE_H
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* Get SIZE_MAX.  */
+#include <limits.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+/* The size of memory objects is often computed through expressions of
+   type size_t. Example:
+      void* p = malloc (header_size + n * element_size).
+   These computations can lead to overflow.  When this happens, malloc()
+   returns a piece of memory that is way too small, and the program then
+   crashes while attempting to fill the memory.
+   To avoid this, the functions and macros in this file check for overflow.
+   The convention is that SIZE_MAX represents overflow.
+   malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
+   implementation that uses mmap --, it's recommended to use size_overflow_p()
+   or size_in_bounds_p() before invoking malloc().
+   The example thus becomes:
+      size_t size = xsum (header_size, xtimes (n, element_size));
+      void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
+*/
+
+/* Convert an arbitrary value >= 0 to type size_t.  */
+#define xcast_size_t(N) \
+  ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
+
+/* Sum of two sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum (size_t size1, size_t size2)
+{
+  size_t sum = size1 + size2;
+  return (sum >= size1 ? sum : SIZE_MAX);
+}
+
+/* Sum of three sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum3 (size_t size1, size_t size2, size_t size3)
+{
+  return xsum (xsum (size1, size2), size3);
+}
+
+/* Sum of four sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
+{
+  return xsum (xsum (xsum (size1, size2), size3), size4);
+}
+
+/* Maximum of two sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xmax (size_t size1, size_t size2)
+{
+  /* No explicit check is needed here, because for any n:
+     max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */
+  return (size1 >= size2 ? size1 : size2);
+}
+
+/* Multiplication of a count with an element size, with overflow check.
+   The count must be >= 0 and the element size must be > 0.
+   This is a macro, not an inline function, so that it works correctly even
+   when N is of a wider type and N > SIZE_MAX.  */
+#define xtimes(N, ELSIZE) \
+  ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
+
+/* Check for overflow.  */
+#define size_overflow_p(SIZE) \
+  ((SIZE) == SIZE_MAX)
+/* Check against overflow.  */
+#define size_in_bounds_p(SIZE) \
+  ((SIZE) != SIZE_MAX)
+
+#endif /* _XSIZE_H */
diff --git a/gnulib/m4/00gnulib.m4 b/gnulib/m4/00gnulib.m4
new file mode 100644 (file)
index 0000000..7feed46
--- /dev/null
@@ -0,0 +1,30 @@
+# 00gnulib.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This file must be named something that sorts before all other
+dnl gnulib-provided .m4 files.  It is needed until such time as we can
+dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics.
+
+# AC_DEFUN_ONCE([NAME], VALUE)
+# ----------------------------
+# Define NAME to expand to VALUE on the first use (whether by direct
+# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses.
+# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier.  This
+# definition is slower than the version in Autoconf 2.64, because it
+# can only use interfaces that existed since 2.59; but it achieves the
+# same effect.  Quoting is necessary to avoid confusing Automake.
+m4_version_prereq([2.63.263], [],
+[m4_define([AC][_DEFUN_ONCE],
+  [AC][_DEFUN([$1],
+    [AC_REQUIRE([_gl_DEFUN_ONCE([$1])],
+      [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl
+[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])])
+
+# gl_00GNULIB
+# -----------
+# Witness macro that this file has been included.  Needed to force
+# Automake to include this file prior to all other gnulib .m4 files.
+AC_DEFUN([gl_00GNULIB])
diff --git a/gnulib/m4/alloca.m4 b/gnulib/m4/alloca.m4
new file mode 100644 (file)
index 0000000..e2e8a05
--- /dev/null
@@ -0,0 +1,43 @@
+# alloca.m4 serial 10
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl 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_ALLOCA],
+[
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  if test $ac_cv_func_alloca_works = no; then
+    gl_PREREQ_ALLOCA
+  fi
+
+  # Define an additional variable used in the Makefile substitution.
+  if test $ac_cv_working_alloca_h = yes; then
+    AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
+      AC_EGREP_CPP([Need own alloca], [
+#if defined __GNUC__ || defined _AIX || defined _MSC_VER
+        Need own alloca
+#endif
+        ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
+    ])
+    if test $gl_cv_rpl_alloca = yes; then
+      dnl OK, alloca can be implemented through a compiler built-in.
+      AC_DEFINE([HAVE_ALLOCA], [1],
+        [Define to 1 if you have 'alloca' after including <alloca.h>,
+         a header that may be supplied by this distribution.])
+      ALLOCA_H=alloca.h
+    else
+      dnl alloca exists as a library function, i.e. it is slow and probably
+      dnl a memory leak. Don't define HAVE_ALLOCA in this case.
+      ALLOCA_H=
+    fi
+  else
+    ALLOCA_H=alloca.h
+  fi
+  AC_SUBST([ALLOCA_H])
+])
+
+# Prerequisites of lib/alloca.c.
+# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
+AC_DEFUN([gl_PREREQ_ALLOCA], [:])
diff --git a/gnulib/m4/argz.m4 b/gnulib/m4/argz.m4
new file mode 100644 (file)
index 0000000..f4fa3a0
--- /dev/null
@@ -0,0 +1,80 @@
+# Portability macros for glibc argz.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004-2011 Free Software Foundation, Inc.
+#   Written by Gary V. Vaughan <gary@gnu.org>
+#
+# 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.
+
+# serial 8 argz.m4
+
+AC_DEFUN([gl_FUNC_ARGZ],
+[gl_PREREQ_ARGZ
+
+AC_REQUIRE([AC_C_RESTRICT])
+
+AC_CHECK_HEADERS([argz.h], [], [], [AC_INCLUDES_DEFAULT])
+
+AC_CHECK_TYPES([error_t],
+  [],
+  [AC_DEFINE([error_t], [int],
+   [Define to a type to use for `error_t' if it is not otherwise available.])
+   AC_DEFINE([__error_t_defined], [1], [Define so that glibc/gnulib argp.h
+    does not typedef error_t.])],
+  [#if defined(HAVE_ARGZ_H)
+#  include <argz.h>
+#endif])
+
+ARGZ_H=
+AC_CHECK_FUNC([argz_replace], [], [ARGZ_H=argz.h; AC_LIBOBJ([argz])])
+
+dnl if have system argz functions, allow forced use of
+dnl libltdl-supplied implementation (and default to do so
+dnl on "known bad" systems). Could use a runtime check, but
+dnl (a) detecting malloc issues is notoriously unreliable
+dnl (b) only known system that declares argz functions,
+dnl     provides them, yet they are broken, is cygwin
+dnl     releases prior to 5-May-2007 (1.5.24 and earlier)
+dnl So, it's more straightforward simply to special case
+dnl this for known bad systems.
+AS_IF([test -z "$ARGZ_H"],
+    [AC_CACHE_CHECK(
+        [if argz actually works],
+        [lt_cv_sys_argz_works],
+        [[case $host_os in #(
+         *cygwin*)
+           lt_cv_sys_argz_works=no
+           if test "$cross_compiling" != no; then
+             lt_cv_sys_argz_works="guessing no"
+           else
+             lt_sed_extract_leading_digits='s/^\([0-9\.]*\).*/\1/'
+             save_IFS=$IFS
+             IFS=-.
+             set x `uname -r | sed -e "$lt_sed_extract_leading_digits"`
+             IFS=$save_IFS
+             lt_os_major=${2-0}
+             lt_os_minor=${3-0}
+             lt_os_micro=${4-0}
+             if test "$lt_os_major" -gt 1 \
+                || { test "$lt_os_major" -eq 1 \
+                  && { test "$lt_os_minor" -gt 5 \
+                    || { test "$lt_os_minor" -eq 5 \
+                      && test "$lt_os_micro" -gt 24; }; }; }; then
+               lt_cv_sys_argz_works=yes
+             fi
+           fi
+           ;; #(
+         *) lt_cv_sys_argz_works=yes ;;
+         esac]])
+     AS_IF([test "$lt_cv_sys_argz_works" = yes],
+        [AC_DEFINE([HAVE_WORKING_ARGZ], [1],
+                   [This value is set to 1 to indicate that the system argz facility works])],
+        [ARGZ_H=argz.h
+        AC_LIBOBJ([argz])])])
+
+AC_SUBST([ARGZ_H])
+])
+
+# Prerequisites of lib/argz.c.
+AC_DEFUN([gl_PREREQ_ARGZ], [:])
diff --git a/gnulib/m4/btowc.m4 b/gnulib/m4/btowc.m4
new file mode 100644 (file)
index 0000000..603298f
--- /dev/null
@@ -0,0 +1,121 @@
+# btowc.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_BTOWC],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
+  dnl program below may lead to an endless loop. See
+  dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
+  AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
+
+  AC_CHECK_FUNCS_ONCE([btowc])
+  if test $ac_cv_func_btowc = no; then
+    HAVE_BTOWC=0
+  else
+
+    AC_REQUIRE([AC_PROG_CC])
+    AC_REQUIRE([gt_LOCALE_FR])
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+    dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
+    AC_CACHE_CHECK([whether btowc(0) is correct],
+      [gl_cv_func_btowc_nul],
+      [
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (btowc ('\0') != 0)
+    return 1;
+  return 0;
+}]])],
+          [gl_cv_func_btowc_nul=yes],
+          [gl_cv_func_btowc_nul=no],
+          [
+changequote(,)dnl
+           case "$host_os" in
+                      # Guess no on Cygwin.
+             cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
+                      # Guess yes otherwise.
+             *)       gl_cv_func_btowc_nul="guessing yes" ;;
+           esac
+changequote([,])dnl
+          ])
+      ])
+
+    dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
+    AC_CACHE_CHECK([whether btowc(EOF) is correct],
+      [gl_cv_func_btowc_eof],
+      [
+        dnl Initial guess, used when cross-compiling or when no suitable locale
+        dnl is present.
+changequote(,)dnl
+        case "$host_os" in
+                 # Guess no on IRIX.
+          irix*) gl_cv_func_btowc_eof="guessing no" ;;
+                 # Guess yes otherwise.
+          *)     gl_cv_func_btowc_eof="guessing yes" ;;
+        esac
+changequote([,])dnl
+        if test $LOCALE_FR != none; then
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (btowc (EOF) != WEOF)
+        return 1;
+    }
+  return 0;
+}]])],
+            [gl_cv_func_btowc_eof=yes],
+            [gl_cv_func_btowc_eof=no],
+            [:])
+        fi
+      ])
+
+    case "$gl_cv_func_btowc_nul" in
+      *yes) ;;
+      *) REPLACE_BTOWC=1 ;;
+    esac
+    case "$gl_cv_func_btowc_eof" in
+      *yes) ;;
+      *) REPLACE_BTOWC=1 ;;
+    esac
+  fi
+  if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([btowc])
+    gl_PREREQ_BTOWC
+  fi
+])
+
+# Prerequisites of lib/btowc.c.
+AC_DEFUN([gl_PREREQ_BTOWC], [
+  :
+])
diff --git a/gnulib/m4/canonicalize.m4 b/gnulib/m4/canonicalize.m4
new file mode 100644 (file)
index 0000000..dcc6039
--- /dev/null
@@ -0,0 +1,94 @@
+# canonicalize.m4 serial 17
+
+dnl Copyright (C) 2003-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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Provides canonicalize_file_name and canonicalize_filename_mode, but does
+# not provide or fix realpath.
+AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE],
+[
+  AC_LIBOBJ([canonicalize])
+
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+  AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
+  AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
+  if test $ac_cv_func_canonicalize_file_name = no; then
+    HAVE_CANONICALIZE_FILE_NAME=0
+  elif test "$gl_cv_func_realpath_works" != yes; then
+    REPLACE_CANONICALIZE_FILE_NAME=1
+  fi
+])
+
+# Provides canonicalize_file_name and realpath.
+AC_DEFUN([gl_CANONICALIZE_LGPL],
+[
+  AC_REQUIRE([gl_CANONICALIZE_LGPL_SEPARATE])
+  if test $ac_cv_func_canonicalize_file_name = no; then
+    HAVE_CANONICALIZE_FILE_NAME=0
+    AC_LIBOBJ([canonicalize-lgpl])
+    if test $ac_cv_func_realpath = no; then
+      HAVE_REALPATH=0
+    elif test "$gl_cv_func_realpath_works" != yes; then
+      REPLACE_REALPATH=1
+    fi
+  elif test "$gl_cv_func_realpath_works" != yes; then
+    AC_LIBOBJ([canonicalize-lgpl])
+    REPLACE_REALPATH=1
+    REPLACE_CANONICALIZE_FILE_NAME=1
+  fi
+])
+
+# Like gl_CANONICALIZE_LGPL, except prepare for separate compilation
+# (no AC_LIBOBJ).
+AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
+[
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name getcwd readlink])
+  AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
+  AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
+])
+
+# Check whether realpath works.  Assume that if a platform has both
+# realpath and canonicalize_file_name, but the former is broken, then
+# so is the latter.
+AC_DEFUN([gl_FUNC_REALPATH_WORKS],
+[
+  AC_CHECK_FUNCS_ONCE([realpath])
+  AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [
+    touch conftest.a
+    AC_RUN_IFELSE([
+      AC_LANG_PROGRAM([[
+        #include <stdlib.h>
+      ]], [[
+        int result = 0;
+        {
+          char *name = realpath ("conftest.a", NULL);
+          if (!(name && *name == '/'))
+            result |= 1;
+        }
+        {
+          char *name = realpath ("conftest.b/../conftest.a", NULL);
+          if (name != NULL)
+            result |= 2;
+        }
+        {
+          char *name = realpath ("conftest.a/", NULL);
+          if (name != NULL)
+            result |= 4;
+        }
+        return result;
+      ]])
+    ], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no],
+       [gl_cv_func_realpath_works="guessing no"])
+  ])
+  if test "$gl_cv_func_realpath_works" = yes; then
+    AC_DEFINE([FUNC_REALPATH_WORKS], [1], [Define to 1 if realpath()
+      can malloc memory, always gives an absolute path, and handles
+      trailing slash correctly.])
+  fi
+])
diff --git a/gnulib/m4/codeset.m4 b/gnulib/m4/codeset.m4
new file mode 100644 (file)
index 0000000..da73552
--- /dev/null
@@ -0,0 +1,23 @@
+# codeset.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 2000-2002, 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <langinfo.h>]],
+          [[char* cs = nl_langinfo(CODESET); return !cs;]])],
+       [am_cv_langinfo_codeset=yes],
+       [am_cv_langinfo_codeset=no])
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])
diff --git a/gnulib/m4/configmake.m4 b/gnulib/m4/configmake.m4
new file mode 100644 (file)
index 0000000..a029823
--- /dev/null
@@ -0,0 +1,50 @@
+# configmake.m4 serial 1
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_CONFIGMAKE_PREP
+# ------------------
+# Guarantee all of the standard directory variables, even when used with
+# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
+# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
+AC_DEFUN([gl_CONFIGMAKE_PREP],
+[
+  dnl Technically, datadir should default to datarootdir.  But if
+  dnl autoconf is too old to provide datarootdir, then reversing the
+  dnl definition is a reasonable compromise.  Only AC_SUBST a variable
+  dnl if it was not already defined earlier by autoconf.
+  if test "x$datarootdir" = x; then
+    AC_SUBST([datarootdir], ['${datadir}'])
+  fi
+  dnl Copy the approach used in autoconf 2.60.
+  if test "x$docdir" = x; then
+    AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
+      ['${datarootdir}/doc/${PACKAGE_TARNAME}'],
+      ['${datarootdir}/doc/${PACKAGE}'])])
+  fi
+  dnl The remaining variables missing from autoconf 2.59 are easier.
+  if test "x$htmldir" = x; then
+    AC_SUBST([htmldir], ['${docdir}'])
+  fi
+  if test "x$dvidir" = x; then
+    AC_SUBST([dvidir], ['${docdir}'])
+  fi
+  if test "x$pdfdir" = x; then
+    AC_SUBST([pdfdir], ['${docdir}'])
+  fi
+  if test "x$psdir" = x; then
+    AC_SUBST([psdir], ['${docdir}'])
+  fi
+  if test "x$lispdir" = x; then
+    AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
+  fi
+  if test "x$localedir" = x; then
+    AC_SUBST([localedir], ['${datarootdir}/locale'])
+  fi
+
+  dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
+  dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
+  AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
+])
diff --git a/gnulib/m4/ctype.m4 b/gnulib/m4/ctype.m4
new file mode 100644 (file)
index 0000000..4a86ba9
--- /dev/null
@@ -0,0 +1,32 @@
+# ctype_h.m4 serial 6
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_CTYPE_H],
+[
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+  dnl <ctype.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_NEXT_HEADERS([ctype.h])
+
+  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([[#include <ctype.h>
+    ]], [isblank])
+])
+
+AC_DEFUN([gl_CTYPE_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+])
+
+AC_DEFUN([gl_CTYPE_H_DEFAULTS],
+[
+  GNULIB_ISBLANK=0; AC_SUBST([GNULIB_ISBLANK])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_ISBLANK=1;   AC_SUBST([HAVE_ISBLANK])
+])
diff --git a/gnulib/m4/double-slash-root.m4 b/gnulib/m4/double-slash-root.m4
new file mode 100644 (file)
index 0000000..16a4e3e
--- /dev/null
@@ -0,0 +1,38 @@
+# double-slash-root.m4 serial 4   -*- Autoconf -*-
+dnl Copyright (C) 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
+    [ if test x"$cross_compiling" = xyes ; then
+        # When cross-compiling, there is no way to tell whether // is special
+        # short of a list of hosts.  However, the only known hosts to date
+        # that have a distinct // are Apollo DomainOS (too old to port to),
+        # Cygwin, and z/OS.  If anyone knows of another system for which // has
+        # special semantics and is distinct from /, please report it to
+        # <bug-gnulib@gnu.org>.
+        case $host in
+          *-cygwin | i370-ibm-openedition)
+            gl_cv_double_slash_root=yes ;;
+          *)
+            # Be optimistic and assume that / and // are the same when we
+            # don't know.
+            gl_cv_double_slash_root='unknown, assuming no' ;;
+        esac
+      else
+        set x `ls -di / // 2>/dev/null`
+        if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
+          gl_cv_double_slash_root=no
+        else
+          gl_cv_double_slash_root=yes
+        fi
+      fi])
+  if test "$gl_cv_double_slash_root" = yes; then
+    AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
+      [Define to 1 if // is a file system root distinct from /.])
+  fi
+])
diff --git a/gnulib/m4/dup2.m4 b/gnulib/m4/dup2.m4
new file mode 100644 (file)
index 0000000..def263b
--- /dev/null
@@ -0,0 +1,70 @@
+#serial 12
+dnl Copyright (C) 2002, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_DUP2],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_CHECK_FUNCS_ONCE([dup2 fcntl])
+  if test $ac_cv_func_dup2 = no; then
+    HAVE_DUP2=0
+    AC_LIBOBJ([dup2])
+  else
+    AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
+      [AC_RUN_IFELSE([
+         AC_LANG_PROGRAM([[#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>]],
+           [int result = 0;
+#if HAVE_FCNTL
+            if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
+              result |= 1;
+#endif HAVE_FCNTL
+            if (dup2 (1, 1) == 0)
+              result |= 2;
+#if HAVE_FCNTL
+            if (fcntl (1, F_GETFD) != FD_CLOEXEC)
+              result |= 4;
+#endif
+            close (0);
+            if (dup2 (0, 0) != -1)
+              result |= 8;
+            /* Many gnulib modules require POSIX conformance of EBADF.  */
+            if (dup2 (2, 1000000) == -1 && errno != EBADF)
+              result |= 16;
+            return result;
+           ])
+        ],
+        [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
+        [case "$host_os" in
+           mingw*) # on this platform, dup2 always returns 0 for success
+             gl_cv_func_dup2_works=no;;
+           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+             gl_cv_func_dup2_works=no;;
+           linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
+                   # closed fd may yield -EBADF instead of -1 / errno=EBADF.
+             gl_cv_func_dup2_works=no;;
+           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
+             gl_cv_func_dup2_works=no;;
+           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
+             gl_cv_func_dup2_works=no;;
+           *) gl_cv_func_dup2_works=yes;;
+         esac])
+      ])
+    if test "$gl_cv_func_dup2_works" = no; then
+      gl_REPLACE_DUP2
+    fi
+  fi
+])
+
+AC_DEFUN([gl_REPLACE_DUP2],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  if test $ac_cv_func_dup2 = yes; then
+    REPLACE_DUP2=1
+  fi
+  AC_LIBOBJ([dup2])
+])
diff --git a/gnulib/m4/eealloc.m4 b/gnulib/m4/eealloc.m4
new file mode 100644 (file)
index 0000000..3006c48
--- /dev/null
@@ -0,0 +1,32 @@
+# eealloc.m4 serial 2
+dnl Copyright (C) 2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_EEALLOC],
+[
+  AC_REQUIRE([gl_EEMALLOC])
+  AC_REQUIRE([gl_EEREALLOC])
+  AC_REQUIRE([AC_C_INLINE])
+])
+
+AC_DEFUN([gl_EEMALLOC],
+[
+  _AC_FUNC_MALLOC_IF(
+    [gl_cv_func_malloc_0_nonnull=1],
+    [gl_cv_func_malloc_0_nonnull=0])
+  AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
+    [If malloc(0) is != NULL, define this to 1.  Otherwise define this
+     to 0.])
+])
+
+AC_DEFUN([gl_EEREALLOC],
+[
+  _AC_FUNC_REALLOC_IF(
+    [gl_cv_func_realloc_0_nonnull=1],
+    [gl_cv_func_realloc_0_nonnull=0])
+  AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
+    [If realloc(NULL,0) is != NULL, define this to 1.  Otherwise define this
+     to 0.])
+])
diff --git a/gnulib/m4/environ.m4 b/gnulib/m4/environ.m4
new file mode 100644 (file)
index 0000000..7457ad1
--- /dev/null
@@ -0,0 +1,38 @@
+# environ.m4 serial 5
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_ENVIRON],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  dnl Persuade glibc <unistd.h> to declare environ.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
+  if test $gt_cv_var_environ_declaration != yes; then
+    HAVE_DECL_ENVIRON=0
+  fi
+])
+
+# Check if a variable is properly declared.
+# gt_CHECK_VAR_DECL(includes,variable)
+AC_DEFUN([gt_CHECK_VAR_DECL],
+[
+  define([gt_cv_var], [gt_cv_var_]$2[_declaration])
+  AC_MSG_CHECKING([if $2 is properly declared])
+  AC_CACHE_VAL([gt_cv_var], [
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[$1
+           extern struct { int foo; } $2;]],
+         [[$2.foo = 1;]])],
+      [gt_cv_var=no],
+      [gt_cv_var=yes])])
+  AC_MSG_RESULT([$gt_cv_var])
+  if test $gt_cv_var = yes; then
+    AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
+              [Define if you have the declaration of $2.])
+  fi
+  undefine([gt_cv_var])
+])
diff --git a/gnulib/m4/errno_h.m4 b/gnulib/m4/errno_h.m4
new file mode 100644 (file)
index 0000000..687baff
--- /dev/null
@@ -0,0 +1,118 @@
+# errno_h.m4 serial 8
+dnl Copyright (C) 2004, 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
+    AC_EGREP_CPP([booboo],[
+#include <errno.h>
+#if !defined ENOMSG
+booboo
+#endif
+#if !defined EIDRM
+booboo
+#endif
+#if !defined ENOLINK
+booboo
+#endif
+#if !defined EPROTO
+booboo
+#endif
+#if !defined EMULTIHOP
+booboo
+#endif
+#if !defined EBADMSG
+booboo
+#endif
+#if !defined EOVERFLOW
+booboo
+#endif
+#if !defined ENOTSUP
+booboo
+#endif
+#if !defined ESTALE
+booboo
+#endif
+#if !defined EDQUOT
+booboo
+#endif
+#if !defined ECANCELED
+booboo
+#endif
+      ],
+      [gl_cv_header_errno_h_complete=no],
+      [gl_cv_header_errno_h_complete=yes])
+  ])
+  if test $gl_cv_header_errno_h_complete = yes; then
+    ERRNO_H=''
+  else
+    gl_NEXT_HEADERS([errno.h])
+    ERRNO_H='errno.h'
+  fi
+  AC_SUBST([ERRNO_H])
+  gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
+  gl_REPLACE_ERRNO_VALUE([ENOLINK])
+  gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
+])
+
+# Assuming $1 = EOVERFLOW.
+# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
+# POSIX.  But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
+# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
+# Check for the value of EOVERFLOW.
+# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
+AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
+[
+  if test -n "$ERRNO_H"; then
+    AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
+      AC_EGREP_CPP([yes],[
+#include <errno.h>
+#ifdef ]$1[
+yes
+#endif
+      ],
+      [gl_cv_header_errno_h_]$1[=yes],
+      [gl_cv_header_errno_h_]$1[=no])
+      if test $gl_cv_header_errno_h_]$1[ = no; then
+        AC_EGREP_CPP([yes],[
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef ]$1[
+yes
+#endif
+          ], [gl_cv_header_errno_h_]$1[=hidden])
+        if test $gl_cv_header_errno_h_]$1[ = hidden; then
+          dnl The macro exists but is hidden.
+          dnl Define it to the same value.
+          AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+])
+        fi
+      fi
+    ])
+    case $gl_cv_header_errno_h_]$1[ in
+      yes | no)
+        ]$1[_HIDDEN=0; ]$1[_VALUE=
+        ;;
+      *)
+        ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
+        ;;
+    esac
+    AC_SUBST($1[_HIDDEN])
+    AC_SUBST($1[_VALUE])
+  fi
+])
+
+dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
+dnl Remove this when we can assume autoconf >= 2.61.
+m4_ifdef([AC_COMPUTE_INT], [], [
+  AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
+])
diff --git a/gnulib/m4/extensions.m4 b/gnulib/m4/extensions.m4
new file mode 100644 (file)
index 0000000..1330503
--- /dev/null
@@ -0,0 +1,118 @@
+# serial 9  -*- Autoconf -*-
+# Enable extensions on systems that normally disable them.
+
+# Copyright (C) 2003, 2006-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.
+
+# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
+# Autoconf.  Perhaps we can remove this once we can assume Autoconf
+# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
+# enough in this area it's likely we'll need to redefine
+# AC_USE_SYSTEM_EXTENSIONS for quite some time.
+
+# If autoconf reports a warning
+#     warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# or  warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# the fix is
+#   1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
+#      but always AC_REQUIREd,
+#   2) to ensure that for each occurrence of
+#        AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+#      or
+#        AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+#      the corresponding gnulib module description has 'extensions' among
+#      its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
+#      invocation occurs in gl_EARLY, not in gl_INIT.
+
+# AC_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+# Remember that #undef in AH_VERBATIM gets replaced with #define by
+# AC_DEFINE.  The goal here is to define all known feature-enabling
+# macros, then, if reports of conflicts are made, disable macros that
+# cause problems on some platforms (such as __EXTENSIONS__).
+AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
+[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
+AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
+
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
+  if test "$MINIX" = yes; then
+    AC_DEFINE([_POSIX_SOURCE], [1],
+      [Define to 1 if you need to in order for `stat' and other
+       things to work.])
+    AC_DEFINE([_POSIX_1_SOURCE], [2],
+      [Define to 2 if the system does not provide POSIX.1 features
+       except with this defined.])
+    AC_DEFINE([_MINIX], [1],
+      [Define to 1 if on MINIX.])
+  fi
+
+  dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
+  dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
+  dnl provided.
+  case "$host_os" in
+    hpux*)
+      AC_DEFINE([_XOPEN_SOURCE], [500],
+        [Define to 500 only on HP-UX.])
+      ;;
+  esac
+
+  AH_VERBATIM([__EXTENSIONS__],
+[/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+])
+  AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
+    [ac_cv_safe_to_define___extensions__],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[
+#         define __EXTENSIONS__ 1
+          ]AC_INCLUDES_DEFAULT])],
+       [ac_cv_safe_to_define___extensions__=yes],
+       [ac_cv_safe_to_define___extensions__=no])])
+  test $ac_cv_safe_to_define___extensions__ = yes &&
+    AC_DEFINE([__EXTENSIONS__])
+  AC_DEFINE([_ALL_SOURCE])
+  AC_DEFINE([_GNU_SOURCE])
+  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
+  AC_DEFINE([_TANDEM_SOURCE])
+])# AC_USE_SYSTEM_EXTENSIONS
+
+# gl_USE_SYSTEM_EXTENSIONS
+# ------------------------
+# Enable extensions on systems that normally disable them,
+# typically due to standards-conformance issues.
+AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
+[
+  dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
+  dnl gnulib does not need it. But if it gets required by third-party macros
+  dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
+  dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
+  dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
+  dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
+  AC_REQUIRE([AC_GNU_SOURCE])
+
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+])
diff --git a/gnulib/m4/fcntl-o.m4 b/gnulib/m4/fcntl-o.m4
new file mode 100644 (file)
index 0000000..88db07e
--- /dev/null
@@ -0,0 +1,112 @@
+# fcntl-o.m4 serial 3
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
+# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
+# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
+AC_DEFUN([gl_FCNTL_O_FLAGS],
+[
+  dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
+  dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
+  dnl AC_GNU_SOURCE.
+  m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
+    [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
+    [AC_REQUIRE([AC_GNU_SOURCE])])
+  AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+           #include <sys/stat.h>
+           #include <unistd.h>
+           #include <fcntl.h>
+           #ifndef O_NOATIME
+            #define O_NOATIME 0
+           #endif
+           #ifndef O_NOFOLLOW
+            #define O_NOFOLLOW 0
+           #endif
+           static int const constants[] =
+            {
+              O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+              O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+            };
+          ]],
+          [[
+            int result = !constants;
+            {
+              static char const sym[] = "conftest.sym";
+              if (symlink (".", sym) != 0)
+                result |= 2;
+              else
+                {
+                  int fd = open (sym, O_RDONLY | O_NOFOLLOW);
+                  if (fd >= 0)
+                    {
+                      close (fd);
+                      result |= 4;
+                    }
+                }
+              unlink (sym);
+            }
+            {
+              static char const file[] = "confdefs.h";
+              int fd = open (file, O_RDONLY | O_NOATIME);
+              if (fd < 0)
+                result |= 8;
+              else
+                {
+                  struct stat st0;
+                  if (fstat (fd, &st0) != 0)
+                    result |= 16;
+                  else
+                    {
+                      char c;
+                      sleep (1);
+                      if (read (fd, &c, 1) != 1)
+                        result |= 24;
+                      else
+                        {
+                          if (close (fd) != 0)
+                            result |= 32;
+                          else
+                            {
+                              struct stat st1;
+                              if (stat (file, &st1) != 0)
+                                result |= 40;
+                              else
+                                if (st0.st_atime != st1.st_atime)
+                                  result |= 64;
+                            }
+                        }
+                    }
+                }
+            }
+            return result;]])],
+       [gl_cv_header_working_fcntl_h=yes],
+       [case $? in #(
+        4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+        64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
+        68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+         *) gl_cv_header_working_fcntl_h='no';;
+        esac],
+       [gl_cv_header_working_fcntl_h=cross-compiling])])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
+    [Define to 1 if O_NOATIME works.])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
+    [Define to 1 if O_NOFOLLOW works.])
+])
diff --git a/gnulib/m4/fcntl_h.m4 b/gnulib/m4/fcntl_h.m4
new file mode 100644 (file)
index 0000000..1ef4f45
--- /dev/null
@@ -0,0 +1,43 @@
+# serial 13
+# Configure fcntl.h.
+dnl Copyright (C) 2006-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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl_FCNTL_H],
+[
+  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+  AC_REQUIRE([gl_FCNTL_O_FLAGS])
+  gl_NEXT_HEADERS([fcntl.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use, if it is not common
+  dnl enough to be declared everywhere.
+  gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
+    ]], [fcntl openat])
+])
+
+AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_FCNTL_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_FCNTL_H_DEFAULTS],
+[
+  GNULIB_FCNTL=0;   AC_SUBST([GNULIB_FCNTL])
+  GNULIB_OPEN=0;    AC_SUBST([GNULIB_OPEN])
+  GNULIB_OPENAT=0;  AC_SUBST([GNULIB_OPENAT])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_FCNTL=1;     AC_SUBST([HAVE_FCNTL])
+  HAVE_OPENAT=1;    AC_SUBST([HAVE_OPENAT])
+  REPLACE_FCNTL=0;  AC_SUBST([REPLACE_FCNTL])
+  REPLACE_OPEN=0;   AC_SUBST([REPLACE_OPEN])
+  REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
+])
diff --git a/gnulib/m4/float_h.m4 b/gnulib/m4/float_h.m4
new file mode 100644 (file)
index 0000000..265a4c1
--- /dev/null
@@ -0,0 +1,19 @@
+# float_h.m4 serial 5
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FLOAT_H],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  FLOAT_H=
+  case "$host_os" in
+    beos* | openbsd* | mirbsd*)
+      FLOAT_H=float.h
+      gl_NEXT_HEADERS([float.h])
+      ;;
+  esac
+  AC_SUBST([FLOAT_H])
+])
diff --git a/gnulib/m4/fnmatch.m4 b/gnulib/m4/fnmatch.m4
new file mode 100644 (file)
index 0000000..9b537a7
--- /dev/null
@@ -0,0 +1,150 @@
+# Check for fnmatch - serial 5.
+
+# Copyright (C) 2000-2007, 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.
+
+# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
+# New applications should use the macros below instead.
+
+# Request a POSIX compliant fnmatch function.
+AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
+[
+  m4_divert_text([DEFAULTS], [gl_fnmatch_required=POSIX])
+
+  dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
+  dnl This is only needed if gl_fnmatch_required = GNU. It would be possible
+  dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting
+  dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  FNMATCH_H=
+  gl_fnmatch_required_lowercase=`
+    echo $gl_fnmatch_required | tr '[[A-Z]]' '[[a-z]]'
+  `
+  gl_fnmatch_cache_var="gl_cv_func_fnmatch_${gl_fnmatch_required_lowercase}"
+  AC_CACHE_CHECK([for working $gl_fnmatch_required fnmatch],
+    [$gl_fnmatch_cache_var],
+    [dnl Some versions of Solaris, SCO, and the GNU C Library
+     dnl have a broken or incompatible fnmatch.
+     dnl So we run a test program.  If we are cross-compiling, take no chance.
+     dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this
+     dnl test.
+     if test $gl_fnmatch_required = GNU; then
+       gl_fnmatch_gnu_start=
+       gl_fnmatch_gnu_end=
+     else
+       gl_fnmatch_gnu_start='#if 0'
+       gl_fnmatch_gnu_end='#endif'
+     fi
+     AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <fnmatch.h>
+            static int
+            y (char const *pattern, char const *string, int flags)
+            {
+              return fnmatch (pattern, string, flags) == 0;
+            }
+            static int
+            n (char const *pattern, char const *string, int flags)
+            {
+              return fnmatch (pattern, string, flags) == FNM_NOMATCH;
+            }
+          ]],
+          [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]";
+            char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]";
+            static char const A_1[] = { 'A' - 1, 0 };
+            static char const A01[] = { 'A' + 1, 0 };
+            static char const a_1[] = { 'a' - 1, 0 };
+            static char const a01[] = { 'a' + 1, 0 };
+            static char const bs_1[] = { '\\\\' - 1, 0 };
+            static char const bs01[] = { '\\\\' + 1, 0 };
+            int result = 0;
+            if (!n ("a*", "", 0))
+              return 1;
+            if (!y ("a*", "abc", 0))
+              return 1;
+            if (!n ("d*/*1", "d/s/1", FNM_PATHNAME))
+              return 2;
+            if (!y ("a\\\\bc", "abc", 0))
+              return 3;
+            if (!n ("a\\\\bc", "abc", FNM_NOESCAPE))
+              return 3;
+            if (!y ("*x", ".x", 0))
+              return 4;
+            if (!n ("*x", ".x", FNM_PERIOD))
+              return 4;
+            if (!y (Apat, "\\\\", 0))
+              return 5;
+            if (!y (Apat, "A", 0))
+              return 5;
+            if (!y (apat, "\\\\", 0))
+              return 5;
+            if (!y (apat, "a", 0))
+              return 5;
+            if (!(n (Apat, A_1, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(n (apat, a_1, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(y (Apat, A01, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(y (apat, a01, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(y (Apat, bs_1, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(y (apat, bs_1, 0) == ('a' < '\\\\')))
+              return 5;
+            if (!(n (Apat, bs01, 0) == ('A' < '\\\\')))
+              return 5;
+            if (!(n (apat, bs01, 0) == ('a' < '\\\\')))
+              return 5;
+            $gl_fnmatch_gnu_start
+            if (!y ("xxXX", "xXxX", FNM_CASEFOLD))
+              result |= 8;
+            if (!y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH))
+              result |= 16;
+            if (!n ("d*/*1", "d/s/1", FNM_FILE_NAME))
+              result |= 32;
+            if (!y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            if (!y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            if (!y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR))
+              result |= 64;
+            $gl_fnmatch_gnu_end
+            return result;
+          ]])],
+       [eval "$gl_fnmatch_cache_var=yes"],
+       [eval "$gl_fnmatch_cache_var=no"],
+       [eval "$gl_fnmatch_cache_var=\"guessing no\""])
+    ])
+  eval "gl_fnmatch_result=\"\$$gl_fnmatch_cache_var\""
+  if test "$gl_fnmatch_result" = yes; then
+    dnl Not strictly necessary. Only to avoid spurious leftover files if people
+    dnl don't do "make distclean".
+    rm -f "$gl_source_base/fnmatch.h"
+  else
+    FNMATCH_H=fnmatch.h
+    AC_LIBOBJ([fnmatch])
+    dnl We must choose a different name for our function, since on ELF systems
+    dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
+    dnl compiled into a shared library.
+    AC_DEFINE_UNQUOTED([fnmatch], [${gl_fnmatch_required_lowercase}_fnmatch],
+      [Define to a replacement function name for fnmatch().])
+    dnl Prerequisites of lib/fnmatch.c.
+    AC_REQUIRE([AC_TYPE_MBSTATE_T])
+    AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
+    AC_CHECK_FUNCS_ONCE([btowc isblank iswctype mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
+    AC_CHECK_HEADERS_ONCE([wctype.h])
+  fi
+  AC_SUBST([FNMATCH_H])
+])
+
+# Request a POSIX compliant fnmatch function with GNU extensions.
+AC_DEFUN([gl_FUNC_FNMATCH_GNU],
+[
+  m4_divert_text([INIT_PREPARE], [gl_fnmatch_required=GNU])
+
+  AC_REQUIRE([gl_FUNC_FNMATCH_POSIX])
+])
diff --git a/gnulib/m4/getdelim.m4 b/gnulib/m4/getdelim.m4
new file mode 100644 (file)
index 0000000..ef12736
--- /dev/null
@@ -0,0 +1,90 @@
+# getdelim.m4 serial 8
+
+dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
+dnl
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_PREREQ([2.59])
+
+AC_DEFUN([gl_FUNC_GETDELIM],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+
+  dnl Persuade glibc <stdio.h> to declare getdelim().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_DECLS_ONCE([getdelim])
+
+  AC_CHECK_FUNCS_ONCE([getdelim])
+  if test $ac_cv_func_getdelim = yes; then
+    dnl Found it in some library.  Verify that it works.
+    AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim],
+    [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+    int main ()
+    {
+      FILE *in = fopen ("./conftest.data", "r");
+      if (!in)
+        return 1;
+      {
+        /* Test result for a NULL buffer and a zero size.
+           Based on a test program from Karl Heuer.  */
+        char *line = NULL;
+        size_t siz = 0;
+        int len = getdelim (&line, &siz, '\n', in);
+        if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+          return 2;
+      }
+      {
+        /* Test result for a NULL buffer and a non-zero size.
+           This crashes on FreeBSD 8.0.  */
+        char *line = NULL;
+        size_t siz = (size_t)(~0) / 4;
+        if (getdelim (&line, &siz, '\n', in) == -1)
+          return 3;
+      }
+      return 0;
+    }
+    ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works.
+    , [gl_cv_func_working_getdelim=no] dnl The library version does NOT work.
+    , dnl We're cross compiling. Assume it works on glibc2 systems.
+      [AC_EGREP_CPP([Lucky GNU user],
+         [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2) && !defined __UCLIBC__
+  Lucky GNU user
+ #endif
+#endif
+         ],
+         [gl_cv_func_working_getdelim=yes],
+         [gl_cv_func_working_getdelim=no])]
+    )])
+  else
+    gl_cv_func_working_getdelim=no
+  fi
+
+  if test $ac_cv_have_decl_getdelim = no; then
+    HAVE_DECL_GETDELIM=0
+  fi
+
+  if test $gl_cv_func_working_getdelim = no; then
+    if test $ac_cv_func_getdelim = yes; then
+      REPLACE_GETDELIM=1
+    fi
+    AC_LIBOBJ([getdelim])
+    gl_PREREQ_GETDELIM
+  fi
+])
+
+# Prerequisites of lib/getdelim.c.
+AC_DEFUN([gl_PREREQ_GETDELIM],
+[
+  AC_CHECK_FUNCS([flockfile funlockfile])
+  AC_CHECK_DECLS([getc_unlocked])
+])
diff --git a/gnulib/m4/getline.m4 b/gnulib/m4/getline.m4
new file mode 100644 (file)
index 0000000..ec001b9
--- /dev/null
@@ -0,0 +1,97 @@
+# getline.m4 serial 23
+
+dnl Copyright (C) 1998-2003, 2005-2007, 2009-2011 Free Software Foundation,
+dnl Inc.
+dnl
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_PREREQ([2.59])
+
+dnl See if there's a working, system-supplied version of the getline function.
+dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
+dnl have a function by that name in -linet that doesn't have anything
+dnl to do with the function we need.
+AC_DEFUN([gl_FUNC_GETLINE],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+
+  dnl Persuade glibc <stdio.h> to declare getline().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_DECLS_ONCE([getline])
+
+  gl_getline_needs_run_time_check=no
+  AC_CHECK_FUNC([getline],
+                [dnl Found it in some library.  Verify that it works.
+                 gl_getline_needs_run_time_check=yes],
+                [am_cv_func_working_getline=no])
+  if test $gl_getline_needs_run_time_check = yes; then
+    AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline],
+    [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#    include <stdio.h>
+#    include <stdlib.h>
+#    include <string.h>
+    int main ()
+    {
+      FILE *in = fopen ("./conftest.data", "r");
+      if (!in)
+        return 1;
+      {
+        /* Test result for a NULL buffer and a zero size.
+           Based on a test program from Karl Heuer.  */
+        char *line = NULL;
+        size_t siz = 0;
+        int len = getline (&line, &siz, in);
+        if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+          return 2;
+      }
+      {
+        /* Test result for a NULL buffer and a non-zero size.
+           This crashes on FreeBSD 8.0.  */
+        char *line = NULL;
+        size_t siz = (size_t)(~0) / 4;
+        if (getline (&line, &siz, in) == -1)
+          return 3;
+      }
+      return 0;
+    }
+    ]])], [am_cv_func_working_getline=yes] dnl The library version works.
+    , [am_cv_func_working_getline=no] dnl The library version does NOT work.
+    , dnl We're cross compiling. Assume it works on glibc2 systems.
+      [AC_EGREP_CPP([Lucky GNU user],
+         [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2) && !defined __UCLIBC__
+  Lucky GNU user
+ #endif
+#endif
+         ],
+         [am_cv_func_working_getline=yes],
+         [am_cv_func_working_getline=no])]
+    )])
+  fi
+
+  if test $ac_cv_have_decl_getline = no; then
+    HAVE_DECL_GETLINE=0
+  fi
+
+  if test $am_cv_func_working_getline = no; then
+    dnl Set REPLACE_GETLINE always: Even if we have not found the broken
+    dnl getline function among $LIBS, it may exist in libinet and the
+    dnl executable may be linked with -linet.
+    REPLACE_GETLINE=1
+    AC_LIBOBJ([getline])
+
+    gl_PREREQ_GETLINE
+  fi
+])
+
+# Prerequisites of lib/getline.c.
+AC_DEFUN([gl_PREREQ_GETLINE],
+[
+  gl_FUNC_GETDELIM
+])
diff --git a/gnulib/m4/getopt.m4 b/gnulib/m4/getopt.m4
new file mode 100644 (file)
index 0000000..035a530
--- /dev/null
@@ -0,0 +1,321 @@
+# getopt.m4 serial 34
+dnl Copyright (C) 2002-2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Request a POSIX compliant getopt function.
+AC_DEFUN([gl_FUNC_GETOPT_POSIX],
+[
+  m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  gl_GETOPT_IFELSE([
+    gl_REPLACE_GETOPT
+  ],
+  [])
+])
+
+# Request a POSIX compliant getopt function with GNU extensions (such as
+# options with optional arguments) and the functions getopt_long,
+# getopt_long_only.
+AC_DEFUN([gl_FUNC_GETOPT_GNU],
+[
+  m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
+
+  AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
+])
+
+# Request the gnulib implementation of the getopt functions unconditionally.
+# argp.m4 uses this.
+AC_DEFUN([gl_REPLACE_GETOPT],
+[
+  dnl Arrange for getopt.h to be created.
+  gl_GETOPT_SUBSTITUTE_HEADER
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_UNISTD_H_GETOPT=1
+  dnl Arrange to compile the getopt implementation.
+  AC_LIBOBJ([getopt])
+  AC_LIBOBJ([getopt1])
+  gl_PREREQ_GETOPT
+])
+
+# emacs' configure.in uses this.
+AC_DEFUN([gl_GETOPT_IFELSE],
+[
+  AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
+  AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
+])
+
+# Determine whether to replace the entire getopt facility.
+AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON
+
+  dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  gl_CHECK_NEXT_HEADERS([getopt.h])
+  if test $ac_cv_header_getopt_h = yes; then
+    HAVE_GETOPT_H=1
+  else
+    HAVE_GETOPT_H=0
+  fi
+  AC_SUBST([HAVE_GETOPT_H])
+
+  gl_replace_getopt=
+
+  dnl Test whether <getopt.h> is available.
+  if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
+  fi
+
+  dnl Test whether the function getopt_long is available.
+  if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
+  fi
+
+  dnl mingw's getopt (in libmingwex.a) does weird things when the options
+  dnl strings starts with '+' and it's not the first call.  Some internal state
+  dnl is left over from earlier calls, and neither setting optind = 0 nor
+  dnl setting optreset = 1 get rid of this internal state.
+  dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
+  dnl POSIX 2008 does not specify leading '+' behavior, but see
+  dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
+  dnl the next version of POSIX.  For now, we only guarantee leading '+'
+  dnl behavior with getopt-gnu.
+  if test -z "$gl_replace_getopt"; then
+    AC_CACHE_CHECK([whether getopt is POSIX compatible],
+      [gl_cv_func_getopt_posix],
+      [
+        dnl BSD getopt_long uses an incompatible method to reset
+        dnl option processing.  Existence of the variable, in and of
+        dnl itself, is not a reason to replace getopt, but knowledge
+        dnl of the variable is needed to determine how to reset and
+        dnl whether a reset reparses the environment.  Solaris
+        dnl supports neither optreset nor optind=0, but keeps no state
+        dnl that needs a reset beyond setting optind=1; detect Solaris
+        dnl by getopt_clip.
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[#include <unistd.h>]],
+             [[int *p = &optreset; return optreset;]])],
+          [gl_optind_min=1],
+          [AC_COMPILE_IFELSE(
+             [AC_LANG_PROGRAM(
+                [[#include <getopt.h>]],
+                [[return !getopt_clip;]])],
+             [gl_optind_min=1],
+             [gl_optind_min=0])])
+
+        dnl This test fails on mingw and succeeds on many other platforms.
+        gl_save_CPPFLAGS=$CPPFLAGS
+        CPPFLAGS="$CPPFLAGS -DOPTIND_MIN=$gl_optind_min"
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+  {
+    int argc = 0;
+    char *argv[10];
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-a";
+    argv[argc++] = "foo";
+    argv[argc++] = "bar";
+    argv[argc] = NULL;
+    optind = OPTIND_MIN;
+    opterr = 0;
+
+    c = getopt (argc, argv, "ab");
+    if (!(c == 'a'))
+      return 1;
+    c = getopt (argc, argv, "ab");
+    if (!(c == -1))
+      return 2;
+    if (!(optind == 2))
+      return 3;
+  }
+  /* Some internal state exists at this point.  */
+  {
+    int argc = 0;
+    char *argv[10];
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "donald";
+    argv[argc++] = "-p";
+    argv[argc++] = "billy";
+    argv[argc++] = "duck";
+    argv[argc++] = "-a";
+    argv[argc++] = "bar";
+    argv[argc] = NULL;
+    optind = OPTIND_MIN;
+    opterr = 0;
+
+    c = getopt (argc, argv, "+abp:q:");
+    if (!(c == -1))
+      return 4;
+    if (!(strcmp (argv[0], "program") == 0))
+      return 5;
+    if (!(strcmp (argv[1], "donald") == 0))
+      return 6;
+    if (!(strcmp (argv[2], "-p") == 0))
+      return 7;
+    if (!(strcmp (argv[3], "billy") == 0))
+      return 8;
+    if (!(strcmp (argv[4], "duck") == 0))
+      return 9;
+    if (!(strcmp (argv[5], "-a") == 0))
+      return 10;
+    if (!(strcmp (argv[6], "bar") == 0))
+      return 11;
+    if (!(optind == 1))
+      return 12;
+  }
+  /* Detect MacOS 10.5, AIX 7.1 bug.  */
+  {
+    char *argv[3] = { "program", "-ab", NULL };
+    optind = OPTIND_MIN;
+    opterr = 0;
+    if (getopt (2, argv, "ab:") != 'a')
+      return 13;
+    if (getopt (2, argv, "ab:") != '?')
+      return 14;
+    if (optopt != 'b')
+      return 15;
+    if (optind != 2)
+      return 16;
+  }
+
+  return 0;
+}
+]])],
+          [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no],
+          [case "$host_os" in
+             mingw*)         gl_cv_func_getopt_posix="guessing no";;
+             darwin* | aix*) gl_cv_func_getopt_posix="guessing no";;
+             *)              gl_cv_func_getopt_posix="guessing yes";;
+           esac
+          ])
+        CPPFLAGS=$gl_save_CPPFLAGS
+      ])
+    case "$gl_cv_func_getopt_posix" in
+      *no) gl_replace_getopt=yes ;;
+    esac
+  fi
+
+  if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
+    AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
+      [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
+       # optstring is necessary for programs like m4 that have POSIX-mandated
+       # semantics for supporting options interspersed with files.
+       # Also, since getopt_long is a GNU extension, we require optind=0.
+       # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
+       # so take care to revert to the correct (non-)export state.
+dnl GNU Coding Standards currently allow awk but not env; besides, env
+dnl is ambiguous with environment values that contain newlines.
+       gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
+       case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
+         xx) gl_had_POSIXLY_CORRECT=exported ;;
+         x)  gl_had_POSIXLY_CORRECT=yes      ;;
+         *)  gl_had_POSIXLY_CORRECT=         ;;
+       esac
+       POSIXLY_CORRECT=1
+       export POSIXLY_CORRECT
+       AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM([[#include <getopt.h>
+                           #include <stddef.h>
+                           #include <string.h>
+           ]], [[
+             int result = 0;
+             /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
+                and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
+                OSF/1 5.1, Solaris 10.  */
+             {
+               char *myargv[3];
+               myargv[0] = "conftest";
+               myargv[1] = "-+";
+               myargv[2] = 0;
+               opterr = 0;
+               if (getopt (2, myargv, "+a") != '?')
+                 result |= 1;
+             }
+             /* This code succeeds on glibc 2.8, mingw,
+                and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
+                IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x.  */
+             {
+               char *argv[] = { "program", "-p", "foo", "bar", NULL };
+
+               optind = 1;
+               if (getopt (4, argv, "p::") != 'p')
+                 result |= 2;
+               else if (optarg != NULL)
+                 result |= 4;
+               else if (getopt (4, argv, "p::") != -1)
+                 result |= 6;
+               else if (optind != 2)
+                 result |= 8;
+             }
+             /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0.  */
+             {
+               char *argv[] = { "program", "foo", "-p", NULL };
+               optind = 0;
+               if (getopt (3, argv, "-p") != 1)
+                 result |= 16;
+               else if (getopt (3, argv, "-p") != 'p')
+                 result |= 32;
+             }
+             /* This code fails on glibc 2.11.  */
+             {
+               char *argv[] = { "program", "-b", "-a", NULL };
+               optind = opterr = 0;
+               if (getopt (3, argv, "+:a:b") != 'b')
+                 result |= 64;
+               else if (getopt (3, argv, "+:a:b") != ':')
+                 result |= 64;
+             }
+             return result;
+           ]])],
+        [gl_cv_func_getopt_gnu=yes],
+        [gl_cv_func_getopt_gnu=no],
+        [dnl Cross compiling. Guess based on host and declarations.
+         case $host_os:$ac_cv_have_decl_optreset in
+           *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
+           *:yes)               gl_cv_func_getopt_gnu=no;;
+           *)                   gl_cv_func_getopt_gnu=yes;;
+         esac
+        ])
+       case $gl_had_POSIXLY_CORRECT in
+         exported) ;;
+         yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
+         *) AS_UNSET([POSIXLY_CORRECT]) ;;
+       esac
+      ])
+    if test "$gl_cv_func_getopt_gnu" = "no"; then
+      gl_replace_getopt=yes
+    fi
+  fi
+])
+
+# emacs' configure.in uses this.
+AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
+[
+  GETOPT_H=getopt.h
+  AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
+    [Define to rpl_ if the getopt replacement functions and variables
+     should be used.])
+  AC_SUBST([GETOPT_H])
+])
+
+# Prerequisites of lib/getopt*.
+# emacs' configure.in uses this.
+AC_DEFUN([gl_PREREQ_GETOPT],
+[
+  AC_CHECK_DECLS_ONCE([getenv])
+])
diff --git a/gnulib/m4/getpagesize.m4 b/gnulib/m4/getpagesize.m4
new file mode 100644 (file)
index 0000000..79dfbbe
--- /dev/null
@@ -0,0 +1,33 @@
+# getpagesize.m4 serial 8
+dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2011 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_GETPAGESIZE],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_CHECK_FUNCS([getpagesize])
+  if test $ac_cv_func_getpagesize = no; then
+    HAVE_GETPAGESIZE=0
+    AC_CHECK_HEADERS([OS.h])
+    if test $ac_cv_header_OS_h = yes; then
+      HAVE_OS_H=1
+    fi
+    AC_CHECK_HEADERS([sys/param.h])
+    if test $ac_cv_header_sys_param_h = yes; then
+      HAVE_SYS_PARAM_H=1
+    fi
+  fi
+  case "$host_os" in
+    mingw*)
+      REPLACE_GETPAGESIZE=1
+      AC_LIBOBJ([getpagesize])
+      ;;
+  esac
+  dnl Also check whether it's declared.
+  dnl mingw has getpagesize() in libgcc.a but doesn't declare it.
+  AC_CHECK_DECL([getpagesize], , [HAVE_DECL_GETPAGESIZE=0])
+])
diff --git a/gnulib/m4/glibc21.m4 b/gnulib/m4/glibc21.m4
new file mode 100644 (file)
index 0000000..bc81c11
--- /dev/null
@@ -0,0 +1,34 @@
+# glibc21.m4 serial 5
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2011 Free Software Foundation,
+dnl 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.
+
+# Test for the GNU C Library, version 2.1 or newer, or uClibc.
+# From Bruno Haible.
+
+AC_DEFUN([gl_GLIBC21],
+  [
+    AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
+      [ac_cv_gnu_library_2_1],
+      [AC_EGREP_CPP([Lucky],
+        [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
+  Lucky GNU user
+ #endif
+#endif
+#ifdef __UCLIBC__
+ Lucky user
+#endif
+        ],
+        [ac_cv_gnu_library_2_1=yes],
+        [ac_cv_gnu_library_2_1=no])
+      ]
+    )
+    AC_SUBST([GLIBC21])
+    GLIBC21="$ac_cv_gnu_library_2_1"
+  ]
+)
diff --git a/gnulib/m4/gnulib-common.m4 b/gnulib/m4/gnulib-common.m4
new file mode 100644 (file)
index 0000000..ecbf336
--- /dev/null
@@ -0,0 +1,234 @@
+# gnulib-common.m4 serial 23
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_COMMON
+# is expanded unconditionally through gnulib-tool magic.
+AC_DEFUN([gl_COMMON], [
+  dnl Use AC_REQUIRE here, so that the code is expanded once only.
+  AC_REQUIRE([gl_00GNULIB])
+  AC_REQUIRE([gl_COMMON_BODY])
+])
+AC_DEFUN([gl_COMMON_BODY], [
+  AH_VERBATIM([isoc99_inline],
+[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
+   the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
+   earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
+   __APPLE__ && __MACH__ test for MacOS X.
+   __APPLE_CC__ tests for the Apple compiler and its version.
+   __STDC_VERSION__ tests for the C99 mode.  */
+#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
+# define __GNUC_STDC_INLINE__ 1
+#endif])
+  AH_VERBATIM([unused_parameter],
+[/* Define as a marker that can be attached to declarations that might not
+    be used.  This helps to reduce warnings, such as from
+    GCC -Wunused-parameter.  */
+#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_UNUSED __attribute__ ((__unused__))
+#else
+# define _GL_UNUSED
+#endif
+/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
+   is a misnomer outside of parameter lists.  */
+#define _UNUSED_PARAMETER_ _GL_UNUSED
+])
+  dnl Preparation for running test programs:
+  dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
+  dnl to /dev/tty, so they can be redirected to log files.  Such diagnostics
+  dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
+  LIBC_FATAL_STDERR_=1
+  export LIBC_FATAL_STDERR_
+])
+
+# gl_MODULE_INDICATOR_CONDITION
+# expands to a C preprocessor expression that evaluates to 1 or 0, depending
+# whether a gnulib module that has been requested shall be considered present
+# or not.
+AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1])
+
+# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
+# sets the shell variable that indicates the presence of the given module to
+# a C preprocessor expression that will evaluate to 1.
+AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
+[
+  GNULIB_[]m4_translit([[$1]],
+    [abcdefghijklmnopqrstuvwxyz./-],
+    [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION
+])
+
+# gl_MODULE_INDICATOR([modulename])
+# defines a C macro indicating the presence of the given module
+# in a location where it can be used.
+#                                             |  Value  |   Value   |
+#                                             | in lib/ | in tests/ |
+# --------------------------------------------+---------+-----------+
+# Module present among main modules:          |    1    |     1     |
+# --------------------------------------------+---------+-----------+
+# Module present among tests-related modules: |    0    |     1     |
+# --------------------------------------------+---------+-----------+
+# Module not present at all:                  |    0    |     0     |
+# --------------------------------------------+---------+-----------+
+AC_DEFUN([gl_MODULE_INDICATOR],
+[
+  AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
+      [abcdefghijklmnopqrstuvwxyz./-],
+      [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
+    [gl_MODULE_INDICATOR_CONDITION],
+    [Define to a C preprocessor expression that evaluates to 1 or 0,
+     depending whether the gnulib module $1 shall be considered present.])
+])
+
+# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
+# defines a C macro indicating the presence of the given module
+# in lib or tests. This is useful to determine whether the module
+# should be tested.
+#                                             |  Value  |   Value   |
+#                                             | in lib/ | in tests/ |
+# --------------------------------------------+---------+-----------+
+# Module present among main modules:          |    1    |     1     |
+# --------------------------------------------+---------+-----------+
+# Module present among tests-related modules: |    1    |     1     |
+# --------------------------------------------+---------+-----------+
+# Module not present at all:                  |    0    |     0     |
+# --------------------------------------------+---------+-----------+
+AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
+[
+  AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
+      [abcdefghijklmnopqrstuvwxyz./-],
+      [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
+    [Define to 1 when the gnulib module $1 should be tested.])
+])
+
+# gl_ASSERT_NO_GNULIB_POSIXCHECK
+# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
+# and thereby enables an optimization of configure and config.h.
+# Used by Emacs.
+AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
+[
+  dnl Override gl_WARN_ON_USE_PREPARE.
+  AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
+])
+
+# gl_ASSERT_NO_GNULIB_TESTS
+# asserts that there will be no gnulib tests in the scope of the configure.ac
+# and thereby enables an optimization of config.h.
+# Used by Emacs.
+AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
+[
+  dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
+  AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
+])
+
+# Test whether <features.h> exists.
+# Set HAVE_FEATURES_H.
+AC_DEFUN([gl_FEATURES_H],
+[
+  AC_CHECK_HEADERS_ONCE([features.h])
+  if test $ac_cv_header_features_h = yes; then
+    HAVE_FEATURES_H=1
+  else
+    HAVE_FEATURES_H=0
+  fi
+  AC_SUBST([HAVE_FEATURES_H])
+])
+
+# m4_foreach_w
+# is a backport of autoconf-2.59c's m4_foreach_w.
+# Remove this macro when we can assume autoconf >= 2.60.
+m4_ifndef([m4_foreach_w],
+  [m4_define([m4_foreach_w],
+    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
+
+# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
+# ----------------------------------------------------
+# Backport of autoconf-2.63b's macro.
+# Remove this macro when we can assume autoconf >= 2.64.
+m4_ifndef([AS_VAR_IF],
+[m4_define([AS_VAR_IF],
+[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
+
+# AC_PROG_MKDIR_P
+# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
+# for interoperability with automake-1.9.6 from autoconf-2.62.
+# Remove this macro when we can assume autoconf >= 2.62 or
+# autoconf >= 2.60 && automake >= 1.10.
+m4_ifdef([AC_PROG_MKDIR_P], [
+  dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
+  m4_define([AC_PROG_MKDIR_P],
+    m4_defn([AC_PROG_MKDIR_P])[
+    AC_SUBST([MKDIR_P])])], [
+  dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
+  AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
+    [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
+     MKDIR_P='$(mkdir_p)'
+     AC_SUBST([MKDIR_P])])])
+
+# AC_C_RESTRICT
+# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
+# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
+# works.
+# This definition can be removed once autoconf >= 2.62 can be assumed.
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
+AC_DEFUN([AC_C_RESTRICT],
+[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
+  [ac_cv_c_restrict=no
+   # The order here caters to the fact that C++ does not require restrict.
+   for ac_kw in __restrict __restrict__ _Restrict restrict; do
+     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+      [[typedef int * int_ptr;
+        int foo (int_ptr $ac_kw ip) {
+        return ip[0];
+       }]],
+      [[int s[1];
+        int * $ac_kw t = s;
+        t[0] = 0;
+        return foo(t)]])],
+      [ac_cv_c_restrict=$ac_kw])
+     test "$ac_cv_c_restrict" != no && break
+   done
+  ])
+ AH_VERBATIM([restrict],
+[/* Define to the equivalent of the C99 'restrict' keyword, or to
+   nothing if this is not supported.  Do not define if restrict is
+   supported directly.  */
+#undef restrict
+/* Work around a bug in Sun C++: it does not support _Restrict, even
+   though the corresponding Sun C compiler does, which causes
+   "#define restrict _Restrict" in the previous line.  Perhaps some future
+   version of Sun C++ will work with _Restrict; if so, it'll probably
+   define __RESTRICT, just as Sun C does.  */
+#if defined __SUNPRO_CC && !defined __RESTRICT
+# define _Restrict
+#endif])
+ case $ac_cv_c_restrict in
+   restrict) ;;
+   no) AC_DEFINE([restrict], []) ;;
+   *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
+ esac
+])
+])
+
+# gl_BIGENDIAN
+# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
+# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
+# macros invoke AC_C_BIGENDIAN with arguments.
+AC_DEFUN([gl_BIGENDIAN],
+[
+  AC_C_BIGENDIAN
+])
+
+# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
+# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
+# output a spurious "(cached)" mark in the midst of other configure output.
+# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
+# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
+AC_DEFUN([gl_CACHE_VAL_SILENT],
+[
+  saved_as_echo_n="$as_echo_n"
+  as_echo_n=':'
+  AC_CACHE_VAL([$1], [$2])
+  as_echo_n="$saved_as_echo_n"
+])
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
new file mode 100644 (file)
index 0000000..e42948b
--- /dev/null
@@ -0,0 +1,913 @@
+# DO NOT EDIT! GENERATED AUTOMATICALLY!
+# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+#
+# This file is free software, distributed under the terms of the GNU
+# General Public License.  As a special exception to the GNU General
+# Public License, this file may be distributed as part of a program
+# that contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+#
+# This file represents the compiled summary of the specification in
+# gnulib-cache.m4. It lists the computed macro invocations that need
+# to be invoked from configure.ac.
+# In projects that use version control, this file can be treated like
+# other built files.
+
+
+# This macro should be invoked from ./configure.ac, in the section
+# "Checks for programs", right after AC_PROG_CC, and certainly before
+# any checks for libraries, header files, types and library functions.
+AC_DEFUN([gl_EARLY],
+[
+  m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
+  m4_pattern_allow([^gl_ES$])dnl a valid locale name
+  m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
+  m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
+  AC_REQUIRE([AC_PROG_RANLIB])
+  # Code from module alloca:
+  # Code from module alloca-opt:
+  # Code from module alloca-opt-tests:
+  # Code from module arg-nonnull:
+  # Code from module argz:
+  # Code from module binary-io:
+  # Code from module binary-io-tests:
+  # Code from module btowc:
+  # Code from module btowc-tests:
+  # Code from module c++defs:
+  # Code from module c-ctype:
+  # Code from module c-ctype-tests:
+  # Code from module c-strcase:
+  # Code from module c-strcase-tests:
+  # Code from module canonicalize-lgpl:
+  # Code from module canonicalize-lgpl-tests:
+  # Code from module configmake:
+  # Code from module ctype:
+  # Code from module ctype-tests:
+  # Code from module dosname:
+  # Code from module dup2:
+  # Code from module dup2-tests:
+  # Code from module environ:
+  # Code from module environ-tests:
+  # Code from module errno:
+  # Code from module errno-tests:
+  # Code from module extensions:
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  # Code from module fcntl-h:
+  # Code from module fcntl-h-tests:
+  # Code from module float:
+  # Code from module fnmatch:
+  # Code from module fnmatch-tests:
+  # Code from module getdelim:
+  # Code from module getdelim-tests:
+  # Code from module getline:
+  # Code from module getline-tests:
+  # Code from module getopt-gnu:
+  # Code from module getopt-posix:
+  # Code from module getopt-posix-tests:
+  # Code from module getpagesize:
+  # Code from module gettext-h:
+  # Code from module gitlog-to-changelog:
+  # Code from module havelib:
+  # Code from module ignore-value:
+  # Code from module ignore-value-tests:
+  # Code from module include_next:
+  # Code from module intprops:
+  # Code from module isblank:
+  # Code from module isblank-tests:
+  # Code from module langinfo:
+  # Code from module langinfo-tests:
+  # Code from module localcharset:
+  # Code from module locale:
+  # Code from module locale-tests:
+  # Code from module localename:
+  # Code from module localename-tests:
+  # Code from module lock:
+  # Code from module lock-tests:
+  # Code from module lstat:
+  # Code from module lstat-tests:
+  # Code from module malloc-gnu:
+  # Code from module malloc-gnu-tests:
+  # Code from module malloc-posix:
+  # Code from module malloca:
+  # Code from module malloca-tests:
+  # Code from module mbrtowc:
+  # Code from module mbrtowc-tests:
+  # Code from module mbsinit:
+  # Code from module mbsinit-tests:
+  # Code from module mbsrtowcs:
+  # Code from module mbsrtowcs-tests:
+  # Code from module mbtowc:
+  # Code from module memchr:
+  # Code from module memchr-tests:
+  # Code from module mempcpy:
+  # Code from module multiarch:
+  # Code from module nl_langinfo:
+  # Code from module nl_langinfo-tests:
+  # Code from module open:
+  # Code from module open-tests:
+  # Code from module pathmax:
+  # Code from module putenv:
+  # Code from module readlink:
+  # Code from module readlink-tests:
+  # Code from module realloc-posix:
+  # Code from module regex:
+  # Code from module safe-alloc:
+  # Code from module safe-alloc-tests:
+  # Code from module same-inode:
+  # Code from module selinux-h:
+  # Code from module setenv:
+  # Code from module setenv-tests:
+  # Code from module setlocale:
+  # Code from module setlocale-tests:
+  # Code from module size_max:
+  # Code from module ssize_t:
+  # Code from module stat:
+  # Code from module stat-tests:
+  # Code from module stdbool:
+  # Code from module stdbool-tests:
+  # Code from module stddef:
+  # Code from module stddef-tests:
+  # Code from module stdint:
+  # Code from module stdint-tests:
+  # Code from module stdio:
+  # Code from module stdio-tests:
+  # Code from module stdlib:
+  # Code from module stdlib-tests:
+  # Code from module stpcpy:
+  # Code from module stpncpy:
+  # Code from module streq:
+  # Code from module string:
+  # Code from module string-tests:
+  # Code from module strndup:
+  # Code from module strnlen:
+  # Code from module strnlen-tests:
+  # Code from module strnlen1:
+  # Code from module strstr:
+  # Code from module strstr-simple:
+  # Code from module strstr-tests:
+  # Code from module symlink:
+  # Code from module symlink-tests:
+  # Code from module sys_stat:
+  # Code from module sys_stat-tests:
+  # Code from module sys_wait:
+  # Code from module sys_wait-tests:
+  # Code from module thread:
+  # Code from module threadlib:
+  gl_THREADLIB_EARLY
+  # Code from module time:
+  # Code from module time-tests:
+  # Code from module unistd:
+  # Code from module unistd-tests:
+  # Code from module unsetenv:
+  # Code from module unsetenv-tests:
+  # Code from module unused-parameter:
+  # Code from module vasnprintf:
+  # Code from module vasnprintf-tests:
+  # Code from module vasprintf:
+  # Code from module vasprintf-tests:
+  # Code from module verify:
+  # Code from module verify-tests:
+  # Code from module warn-on-use:
+  # Code from module wchar:
+  # Code from module wchar-tests:
+  # Code from module wcrtomb:
+  # Code from module wcrtomb-tests:
+  # Code from module wctob:
+  # Code from module wctomb:
+  # Code from module wctype-h:
+  # Code from module wctype-h-tests:
+  # Code from module xsize:
+  # Code from module yield:
+])
+
+# This macro should be invoked from ./configure.ac, in the section
+# "Check for header files, types and library functions".
+AC_DEFUN([gl_INIT],
+[
+  AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
+  gl_cond_libtool=true
+  gl_m4_base='gnulib/m4'
+  m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
+  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
+  m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
+  m4_pushdef([gl_LIBSOURCES_LIST], [])
+  m4_pushdef([gl_LIBSOURCES_DIR], [])
+  gl_COMMON
+  gl_source_base='gnulib/lib'
+  # Code from module alloca:
+changequote(,)dnl
+LTALLOCA=`echo "$ALLOCA" | sed -e 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
+changequote([, ])dnl
+AC_SUBST([LTALLOCA])
+  # Code from module alloca-opt:
+  gl_FUNC_ALLOCA
+  # Code from module arg-nonnull:
+  # Code from module argz:
+  gl_FUNC_ARGZ
+  # Code from module btowc:
+  gl_FUNC_BTOWC
+  gl_WCHAR_MODULE_INDICATOR([btowc])
+  # Code from module c++defs:
+  # Code from module canonicalize-lgpl:
+  gl_CANONICALIZE_LGPL
+  gl_MODULE_INDICATOR([canonicalize-lgpl])
+  gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
+  gl_STDLIB_MODULE_INDICATOR([realpath])
+  # Code from module configmake:
+  gl_CONFIGMAKE_PREP
+  # Code from module ctype:
+  gl_CTYPE_H
+  # Code from module dosname:
+  # Code from module errno:
+  gl_HEADER_ERRNO_H
+  # Code from module extensions:
+  # Code from module float:
+  gl_FLOAT_H
+  # Code from module fnmatch:
+  gl_FUNC_FNMATCH_POSIX
+  # Code from module getdelim:
+  gl_FUNC_GETDELIM
+  gl_STDIO_MODULE_INDICATOR([getdelim])
+  # Code from module getline:
+  gl_FUNC_GETLINE
+  gl_STDIO_MODULE_INDICATOR([getline])
+  # Code from module getopt-gnu:
+  gl_FUNC_GETOPT_GNU
+  gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
+  # Code from module getopt-posix:
+  gl_FUNC_GETOPT_POSIX
+  # Code from module gettext-h:
+  AC_SUBST([LIBINTL])
+  AC_SUBST([LTLIBINTL])
+  # Code from module gitlog-to-changelog:
+  # Code from module include_next:
+  # Code from module isblank:
+  gl_FUNC_ISBLANK
+  gl_CTYPE_MODULE_INDICATOR([isblank])
+  # Code from module langinfo:
+  gl_LANGINFO_H
+  # Code from module localcharset:
+  gl_LOCALCHARSET
+  LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
+  AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
+  # Code from module locale:
+  gl_LOCALE_H
+  # Code from module lstat:
+  gl_FUNC_LSTAT
+  gl_SYS_STAT_MODULE_INDICATOR([lstat])
+  # Code from module malloc-gnu:
+  gl_FUNC_MALLOC_GNU
+  gl_MODULE_INDICATOR([malloc-gnu])
+  # Code from module malloc-posix:
+  gl_FUNC_MALLOC_POSIX
+  gl_STDLIB_MODULE_INDICATOR([malloc-posix])
+  # Code from module malloca:
+  gl_MALLOCA
+  # Code from module mbrtowc:
+  gl_FUNC_MBRTOWC
+  gl_WCHAR_MODULE_INDICATOR([mbrtowc])
+  # Code from module mbsinit:
+  gl_FUNC_MBSINIT
+  gl_WCHAR_MODULE_INDICATOR([mbsinit])
+  # Code from module mbsrtowcs:
+  gl_FUNC_MBSRTOWCS
+  gl_WCHAR_MODULE_INDICATOR([mbsrtowcs])
+  # Code from module mbtowc:
+  gl_FUNC_MBTOWC
+  gl_STDLIB_MODULE_INDICATOR([mbtowc])
+  # Code from module memchr:
+  gl_FUNC_MEMCHR
+  gl_STRING_MODULE_INDICATOR([memchr])
+  # Code from module mempcpy:
+  gl_FUNC_MEMPCPY
+  gl_STRING_MODULE_INDICATOR([mempcpy])
+  # Code from module multiarch:
+  gl_MULTIARCH
+  # Code from module nl_langinfo:
+  gl_FUNC_NL_LANGINFO
+  gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
+  # Code from module pathmax:
+  gl_PATHMAX
+  # Code from module readlink:
+  gl_FUNC_READLINK
+  gl_UNISTD_MODULE_INDICATOR([readlink])
+  # Code from module realloc-posix:
+  gl_FUNC_REALLOC_POSIX
+  gl_STDLIB_MODULE_INDICATOR([realloc-posix])
+  # Code from module regex:
+  gl_REGEX
+  # Code from module safe-alloc:
+  gl_SAFE_ALLOC
+  # Code from module selinux-h:
+  gl_HEADERS_SELINUX_SELINUX_H
+  gl_HEADERS_SELINUX_CONTEXT_H
+  AC_REQUIRE([AC_C_INLINE])
+  # Code from module size_max:
+  gl_SIZE_MAX
+  # Code from module ssize_t:
+  gt_TYPE_SSIZE_T
+  # Code from module stat:
+  gl_FUNC_STAT
+  gl_SYS_STAT_MODULE_INDICATOR([stat])
+  # Code from module stdbool:
+  AM_STDBOOL_H
+  # Code from module stddef:
+  gl_STDDEF_H
+  # Code from module stdint:
+  gl_STDINT_H
+  # Code from module stdio:
+  gl_STDIO_H
+  # Code from module stdlib:
+  gl_STDLIB_H
+  # Code from module stpcpy:
+  gl_FUNC_STPCPY
+  gl_STRING_MODULE_INDICATOR([stpcpy])
+  # Code from module stpncpy:
+  gl_FUNC_STPNCPY
+  gl_STRING_MODULE_INDICATOR([stpncpy])
+  # Code from module streq:
+  # Code from module string:
+  gl_HEADER_STRING_H
+  # Code from module strndup:
+  gl_FUNC_STRNDUP
+  gl_STRING_MODULE_INDICATOR([strndup])
+  # Code from module strnlen:
+  gl_FUNC_STRNLEN
+  gl_STRING_MODULE_INDICATOR([strnlen])
+  # Code from module strnlen1:
+  # Code from module strstr:
+  gl_FUNC_STRSTR
+  # Code from module strstr-simple:
+  gl_FUNC_STRSTR_SIMPLE
+  gl_STRING_MODULE_INDICATOR([strstr])
+  # Code from module sys_stat:
+  gl_HEADER_SYS_STAT_H
+  AC_PROG_MKDIR_P
+  # Code from module sys_wait:
+  gl_SYS_WAIT_H
+  AC_PROG_MKDIR_P
+  # Code from module time:
+  gl_HEADER_TIME_H
+  # Code from module unistd:
+  gl_UNISTD_H
+  # Code from module unused-parameter:
+  # Code from module vasnprintf:
+  gl_FUNC_VASNPRINTF
+  # Code from module vasprintf:
+  gl_FUNC_VASPRINTF
+  gl_STDIO_MODULE_INDICATOR([vasprintf])
+  m4_ifdef([AM_XGETTEXT_OPTION],
+    [AM_][XGETTEXT_OPTION([--flag=asprintf:2:c-format])
+     AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
+  # Code from module verify:
+  # Code from module warn-on-use:
+  # Code from module wchar:
+  gl_WCHAR_H
+  # Code from module wcrtomb:
+  gl_FUNC_WCRTOMB
+  gl_WCHAR_MODULE_INDICATOR([wcrtomb])
+  # Code from module wctype-h:
+  gl_WCTYPE_H
+  # Code from module xsize:
+  gl_XSIZE
+  # End of code from modules
+  m4_ifval(gl_LIBSOURCES_LIST, [
+    m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
+      for gl_file in ]gl_LIBSOURCES_LIST[ ; do
+        if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then
+          echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2
+          exit 1
+        fi
+      done])dnl
+      m4_if(m4_sysval, [0], [],
+        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
+  ])
+  m4_popdef([gl_LIBSOURCES_DIR])
+  m4_popdef([gl_LIBSOURCES_LIST])
+  m4_popdef([AC_LIBSOURCES])
+  m4_popdef([AC_REPLACE_FUNCS])
+  m4_popdef([AC_LIBOBJ])
+  AC_CONFIG_COMMANDS_PRE([
+    gl_libobjs=
+    gl_ltlibobjs=
+    if test -n "$gl_LIBOBJS"; then
+      # Remove the extension.
+      sed_drop_objext='s/\.o$//;s/\.obj$//'
+      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
+        gl_libobjs="$gl_libobjs $i.$ac_objext"
+        gl_ltlibobjs="$gl_ltlibobjs $i.lo"
+      done
+    fi
+    AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
+    AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
+  ])
+  gltests_libdeps=
+  gltests_ltlibdeps=
+  m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
+  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
+  m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
+  m4_pushdef([gltests_LIBSOURCES_LIST], [])
+  m4_pushdef([gltests_LIBSOURCES_DIR], [])
+  gl_COMMON
+  gl_source_base='gnulib/tests'
+changequote(,)dnl
+  gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
+changequote([, ])dnl
+  AC_SUBST([gltests_WITNESS])
+  gl_module_indicator_condition=$gltests_WITNESS
+  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_FR
+  gt_LOCALE_TR_UTF8
+  gl_FUNC_DUP2
+  gl_UNISTD_MODULE_INDICATOR([dup2])
+  gl_ENVIRON
+  gl_UNISTD_MODULE_INDICATOR([environ])
+  gl_FCNTL_H
+  gl_FUNC_GETPAGESIZE
+  gl_UNISTD_MODULE_INDICATOR([getpagesize])
+  AC_REQUIRE([AC_C_INLINE])
+  AC_CHECK_FUNCS_ONCE([newlocale])
+  gl_LOCALENAME
+  AC_CHECK_FUNCS_ONCE([newlocale])
+  gl_LOCK
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  dnl Check for prerequisites for memory fence checks.
+  gl_FUNC_MMAP_ANON
+  AC_CHECK_HEADERS_ONCE([sys/mman.h])
+  AC_CHECK_FUNCS_ONCE([mprotect])
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gl_FUNC_OPEN
+  gl_FCNTL_MODULE_INDICATOR([open])
+  gl_FUNC_PUTENV
+  gl_STDLIB_MODULE_INDICATOR([putenv])
+  gl_FUNC_SETENV
+  gl_STDLIB_MODULE_INDICATOR([setenv])
+  gl_FUNC_SETLOCALE
+  gl_LOCALE_MODULE_INDICATOR([setlocale])
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  gt_TYPE_WCHAR_T
+  gt_TYPE_WINT_T
+  dnl Check for prerequisites for memory fence checks.
+  gl_FUNC_MMAP_ANON
+  AC_CHECK_HEADERS_ONCE([sys/mman.h])
+  AC_CHECK_FUNCS_ONCE([mprotect])
+  AC_CHECK_DECLS_ONCE([alarm])
+  gl_FUNC_MMAP_ANON
+  AC_CHECK_HEADERS_ONCE([sys/mman.h])
+  AC_CHECK_FUNCS_ONCE([mprotect])
+  gl_FUNC_SYMLINK
+  gl_UNISTD_MODULE_INDICATOR([symlink])
+  gl_THREAD
+  gl_THREADLIB
+  gl_FUNC_UNSETENV
+  gl_STDLIB_MODULE_INDICATOR([unsetenv])
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  gl_FUNC_WCTOB
+  gl_WCHAR_MODULE_INDICATOR([wctob])
+  gl_FUNC_WCTOMB
+  gl_STDLIB_MODULE_INDICATOR([wctomb])
+  gl_YIELD
+  m4_popdef([gl_MODULE_INDICATOR_CONDITION])
+  m4_ifval(gltests_LIBSOURCES_LIST, [
+    m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
+      for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
+        if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then
+          echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2
+          exit 1
+        fi
+      done])dnl
+      m4_if(m4_sysval, [0], [],
+        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
+  ])
+  m4_popdef([gltests_LIBSOURCES_DIR])
+  m4_popdef([gltests_LIBSOURCES_LIST])
+  m4_popdef([AC_LIBSOURCES])
+  m4_popdef([AC_REPLACE_FUNCS])
+  m4_popdef([AC_LIBOBJ])
+  AC_CONFIG_COMMANDS_PRE([
+    gltests_libobjs=
+    gltests_ltlibobjs=
+    if test -n "$gltests_LIBOBJS"; then
+      # Remove the extension.
+      sed_drop_objext='s/\.o$//;s/\.obj$//'
+      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
+        gltests_libobjs="$gltests_libobjs $i.$ac_objext"
+        gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
+      done
+    fi
+    AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
+    AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
+  ])
+  LIBTESTS_LIBDEPS="$gltests_libdeps"
+  AC_SUBST([LIBTESTS_LIBDEPS])
+])
+
+# Like AC_LIBOBJ, except that the module name goes
+# into gl_LIBOBJS instead of into LIBOBJS.
+AC_DEFUN([gl_LIBOBJ], [
+  AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl
+  gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
+])
+
+# Like AC_REPLACE_FUNCS, except that the module name goes
+# into gl_LIBOBJS instead of into LIBOBJS.
+AC_DEFUN([gl_REPLACE_FUNCS], [
+  m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
+  AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)])
+])
+
+# Like AC_LIBSOURCES, except the directory where the source file is
+# expected is derived from the gnulib-tool parameterization,
+# and alloca is special cased (for the alloca-opt module).
+# We could also entirely rely on EXTRA_lib..._SOURCES.
+AC_DEFUN([gl_LIBSOURCES], [
+  m4_foreach([_gl_NAME], [$1], [
+    m4_if(_gl_NAME, [alloca.c], [], [
+      m4_define([gl_LIBSOURCES_DIR], [gnulib/lib])
+      m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
+    ])
+  ])
+])
+
+# Like AC_LIBOBJ, except that the module name goes
+# into gltests_LIBOBJS instead of into LIBOBJS.
+AC_DEFUN([gltests_LIBOBJ], [
+  AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl
+  gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
+])
+
+# Like AC_REPLACE_FUNCS, except that the module name goes
+# into gltests_LIBOBJS instead of into LIBOBJS.
+AC_DEFUN([gltests_REPLACE_FUNCS], [
+  m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
+  AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)])
+])
+
+# Like AC_LIBSOURCES, except the directory where the source file is
+# expected is derived from the gnulib-tool parameterization,
+# and alloca is special cased (for the alloca-opt module).
+# We could also entirely rely on EXTRA_lib..._SOURCES.
+AC_DEFUN([gltests_LIBSOURCES], [
+  m4_foreach([_gl_NAME], [$1], [
+    m4_if(_gl_NAME, [alloca.c], [], [
+      m4_define([gltests_LIBSOURCES_DIR], [gnulib/tests])
+      m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
+    ])
+  ])
+])
+
+# This macro records the list of files which have been installed by
+# gnulib-tool and may be removed by future gnulib-tool invocations.
+AC_DEFUN([gl_FILE_LIST], [
+  build-aux/arg-nonnull.h
+  build-aux/c++defs.h
+  build-aux/config.rpath
+  build-aux/gitlog-to-changelog
+  build-aux/unused-parameter.h
+  build-aux/warn-on-use.h
+  lib/alloca.c
+  lib/alloca.in.h
+  lib/argz.c
+  lib/argz.in.h
+  lib/asnprintf.c
+  lib/asprintf.c
+  lib/btowc.c
+  lib/canonicalize-lgpl.c
+  lib/config.charset
+  lib/ctype.in.h
+  lib/dosname.h
+  lib/errno.in.h
+  lib/float+.h
+  lib/float.in.h
+  lib/fnmatch.c
+  lib/fnmatch.in.h
+  lib/fnmatch_loop.c
+  lib/getdelim.c
+  lib/getfilecon.c
+  lib/getline.c
+  lib/getopt.c
+  lib/getopt.in.h
+  lib/getopt1.c
+  lib/getopt_int.h
+  lib/gettext.h
+  lib/isblank.c
+  lib/langinfo.in.h
+  lib/localcharset.c
+  lib/localcharset.h
+  lib/locale.in.h
+  lib/lstat.c
+  lib/malloc.c
+  lib/malloca.c
+  lib/malloca.h
+  lib/malloca.valgrind
+  lib/mbrtowc.c
+  lib/mbsinit.c
+  lib/mbsrtowcs-impl.h
+  lib/mbsrtowcs-state.c
+  lib/mbsrtowcs.c
+  lib/mbtowc-impl.h
+  lib/mbtowc.c
+  lib/memchr.c
+  lib/memchr.valgrind
+  lib/mempcpy.c
+  lib/nl_langinfo.c
+  lib/pathmax.h
+  lib/printf-args.c
+  lib/printf-args.h
+  lib/printf-parse.c
+  lib/printf-parse.h
+  lib/readlink.c
+  lib/realloc.c
+  lib/ref-add.sin
+  lib/ref-del.sin
+  lib/regcomp.c
+  lib/regex.c
+  lib/regex.h
+  lib/regex_internal.c
+  lib/regex_internal.h
+  lib/regexec.c
+  lib/safe-alloc.c
+  lib/safe-alloc.h
+  lib/se-context.in.h
+  lib/se-selinux.in.h
+  lib/size_max.h
+  lib/stat.c
+  lib/stdbool.in.h
+  lib/stddef.in.h
+  lib/stdint.in.h
+  lib/stdio.in.h
+  lib/stdlib.in.h
+  lib/stpcpy.c
+  lib/stpncpy.c
+  lib/str-two-way.h
+  lib/streq.h
+  lib/string.in.h
+  lib/strndup.c
+  lib/strnlen.c
+  lib/strnlen1.c
+  lib/strnlen1.h
+  lib/strstr.c
+  lib/sys_stat.in.h
+  lib/sys_wait.in.h
+  lib/time.in.h
+  lib/unistd.in.h
+  lib/vasnprintf.c
+  lib/vasnprintf.h
+  lib/vasprintf.c
+  lib/verify.h
+  lib/wchar.in.h
+  lib/wcrtomb.c
+  lib/wctype.in.h
+  lib/xsize.h
+  m4/00gnulib.m4
+  m4/alloca.m4
+  m4/argz.m4
+  m4/btowc.m4
+  m4/canonicalize.m4
+  m4/codeset.m4
+  m4/configmake.m4
+  m4/ctype.m4
+  m4/double-slash-root.m4
+  m4/dup2.m4
+  m4/eealloc.m4
+  m4/environ.m4
+  m4/errno_h.m4
+  m4/extensions.m4
+  m4/fcntl-o.m4
+  m4/fcntl_h.m4
+  m4/float_h.m4
+  m4/fnmatch.m4
+  m4/getdelim.m4
+  m4/getline.m4
+  m4/getopt.m4
+  m4/getpagesize.m4
+  m4/glibc21.m4
+  m4/gnulib-common.m4
+  m4/include_next.m4
+  m4/intlmacosx.m4
+  m4/intmax_t.m4
+  m4/inttypes_h.m4
+  m4/isblank.m4
+  m4/langinfo_h.m4
+  m4/lcmessage.m4
+  m4/lib-ld.m4
+  m4/lib-link.m4
+  m4/lib-prefix.m4
+  m4/localcharset.m4
+  m4/locale-fr.m4
+  m4/locale-ja.m4
+  m4/locale-tr.m4
+  m4/locale-zh.m4
+  m4/locale_h.m4
+  m4/localename.m4
+  m4/lock.m4
+  m4/longlong.m4
+  m4/lstat.m4
+  m4/malloc.m4
+  m4/malloca.m4
+  m4/mbrtowc.m4
+  m4/mbsinit.m4
+  m4/mbsrtowcs.m4
+  m4/mbstate_t.m4
+  m4/mbtowc.m4
+  m4/memchr.m4
+  m4/mempcpy.m4
+  m4/mmap-anon.m4
+  m4/mode_t.m4
+  m4/multiarch.m4
+  m4/nl_langinfo.m4
+  m4/onceonly.m4
+  m4/open.m4
+  m4/pathmax.m4
+  m4/printf.m4
+  m4/putenv.m4
+  m4/readlink.m4
+  m4/realloc.m4
+  m4/regex.m4
+  m4/safe-alloc.m4
+  m4/selinux-context-h.m4
+  m4/selinux-selinux-h.m4
+  m4/setenv.m4
+  m4/setlocale.m4
+  m4/size_max.m4
+  m4/ssize_t.m4
+  m4/stat.m4
+  m4/stdbool.m4
+  m4/stddef_h.m4
+  m4/stdint.m4
+  m4/stdint_h.m4
+  m4/stdio_h.m4
+  m4/stdlib_h.m4
+  m4/stpcpy.m4
+  m4/stpncpy.m4
+  m4/string_h.m4
+  m4/strndup.m4
+  m4/strnlen.m4
+  m4/strstr.m4
+  m4/symlink.m4
+  m4/sys_stat_h.m4
+  m4/sys_wait_h.m4
+  m4/thread.m4
+  m4/threadlib.m4
+  m4/time_h.m4
+  m4/unistd_h.m4
+  m4/vasnprintf.m4
+  m4/vasprintf.m4
+  m4/warn-on-use.m4
+  m4/wchar_h.m4
+  m4/wchar_t.m4
+  m4/wcrtomb.m4
+  m4/wctob.m4
+  m4/wctomb.m4
+  m4/wctype_h.m4
+  m4/wint_t.m4
+  m4/xsize.m4
+  m4/yield.m4
+  tests/init.sh
+  tests/macros.h
+  tests/signature.h
+  tests/test-alloca-opt.c
+  tests/test-binary-io.c
+  tests/test-binary-io.sh
+  tests/test-btowc.c
+  tests/test-btowc1.sh
+  tests/test-btowc2.sh
+  tests/test-c-ctype.c
+  tests/test-c-strcase.sh
+  tests/test-c-strcasecmp.c
+  tests/test-c-strncasecmp.c
+  tests/test-canonicalize-lgpl.c
+  tests/test-ctype.c
+  tests/test-dup2.c
+  tests/test-environ.c
+  tests/test-errno.c
+  tests/test-fcntl-h.c
+  tests/test-fnmatch.c
+  tests/test-getdelim.c
+  tests/test-getline.c
+  tests/test-getopt.c
+  tests/test-getopt.h
+  tests/test-getopt_long.h
+  tests/test-ignore-value.c
+  tests/test-isblank.c
+  tests/test-langinfo.c
+  tests/test-locale.c
+  tests/test-localename.c
+  tests/test-lock.c
+  tests/test-lstat.c
+  tests/test-lstat.h
+  tests/test-malloc-gnu.c
+  tests/test-malloca.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/test-mbrtowc.c
+  tests/test-mbrtowc1.sh
+  tests/test-mbrtowc2.sh
+  tests/test-mbrtowc3.sh
+  tests/test-mbrtowc4.sh
+  tests/test-mbsinit.c
+  tests/test-mbsinit.sh
+  tests/test-mbsrtowcs.c
+  tests/test-mbsrtowcs1.sh
+  tests/test-mbsrtowcs2.sh
+  tests/test-mbsrtowcs3.sh
+  tests/test-mbsrtowcs4.sh
+  tests/test-memchr.c
+  tests/test-nl_langinfo.c
+  tests/test-nl_langinfo.sh
+  tests/test-open.c
+  tests/test-open.h
+  tests/test-readlink.c
+  tests/test-readlink.h
+  tests/test-safe-alloc.c
+  tests/test-setenv.c
+  tests/test-setlocale1.c
+  tests/test-setlocale1.sh
+  tests/test-setlocale2.c
+  tests/test-setlocale2.sh
+  tests/test-stat.c
+  tests/test-stat.h
+  tests/test-stdbool.c
+  tests/test-stddef.c
+  tests/test-stdint.c
+  tests/test-stdio.c
+  tests/test-stdlib.c
+  tests/test-string.c
+  tests/test-strnlen.c
+  tests/test-strstr.c
+  tests/test-symlink.c
+  tests/test-symlink.h
+  tests/test-sys_stat.c
+  tests/test-sys_wait.c
+  tests/test-sys_wait.h
+  tests/test-time.c
+  tests/test-unistd.c
+  tests/test-unsetenv.c
+  tests/test-vasnprintf.c
+  tests/test-vasprintf.c
+  tests/test-verify.c
+  tests/test-verify.sh
+  tests/test-wchar.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/test-wcrtomb.c
+  tests/test-wcrtomb.sh
+  tests/test-wctype-h.c
+  tests/zerosize-ptr.h
+  tests=lib/binary-io.h
+  tests=lib/c-ctype.c
+  tests=lib/c-ctype.h
+  tests=lib/c-strcase.h
+  tests=lib/c-strcasecmp.c
+  tests=lib/c-strncasecmp.c
+  tests=lib/dup2.c
+  tests=lib/fcntl.in.h
+  tests=lib/getpagesize.c
+  tests=lib/glthread/lock.c
+  tests=lib/glthread/lock.h
+  tests=lib/glthread/thread.c
+  tests=lib/glthread/thread.h
+  tests=lib/glthread/threadlib.c
+  tests=lib/glthread/yield.h
+  tests=lib/ignore-value.h
+  tests=lib/intprops.h
+  tests=lib/localename.c
+  tests=lib/localename.h
+  tests=lib/open.c
+  tests=lib/putenv.c
+  tests=lib/same-inode.h
+  tests=lib/setenv.c
+  tests=lib/setlocale.c
+  tests=lib/symlink.c
+  tests=lib/unsetenv.c
+  tests=lib/wctob.c
+  tests=lib/wctomb-impl.h
+  tests=lib/wctomb.c
+])
diff --git a/gnulib/m4/include_next.m4 b/gnulib/m4/include_next.m4
new file mode 100644 (file)
index 0000000..b3c7849
--- /dev/null
@@ -0,0 +1,244 @@
+# include_next.m4 serial 18
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert and Derek Price.
+
+dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
+dnl
+dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
+dnl 'include' otherwise.
+dnl
+dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
+dnl supports it in the special case that it is the first include directive in
+dnl the given file, or to 'include' otherwise.
+dnl
+dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
+dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
+dnl '#pragma GCC system_header' has the same effect as if the file was found
+dnl through the include search path specified with '-isystem' options (as
+dnl opposed to the search path specified with '-I' options). Namely, gcc
+dnl does not warn about some things, and on some systems (Solaris and Interix)
+dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
+dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
+dnl of plain '__STDC__'.
+dnl
+dnl PRAGMA_COLUMNS can be used in files that override system header files, so
+dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
+dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
+dnl has the effect of truncating the lines of that file and all files that it
+dnl includes to 80 columns) and the gnulib file has lines longer than 80
+dnl columns.
+
+AC_DEFUN([gl_INCLUDE_NEXT],
+[
+  AC_LANG_PREPROC_REQUIRE()
+  AC_CACHE_CHECK([whether the preprocessor supports include_next],
+    [gl_cv_have_include_next],
+    [rm -rf conftestd1a conftestd1b conftestd2
+     mkdir conftestd1a conftestd1b conftestd2
+     dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
+     dnl AIX 6.1 support include_next when used as first preprocessor directive
+     dnl in a file, but not when preceded by another include directive. Check
+     dnl for this bug by including <stdio.h>.
+     dnl Additionally, with this same compiler, include_next is a no-op when
+     dnl used in a header file that was included by specifying its absolute
+     dnl file name. Despite these two bugs, include_next is used in the
+     dnl compiler's <math.h>. By virtue of the second bug, we need to use
+     dnl include_next as well in this case.
+     cat <<EOF > conftestd1a/conftest.h
+#define DEFINED_IN_CONFTESTD1
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd1b/conftest.h
+#define DEFINED_IN_CONFTESTD1
+#include <stdio.h>
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd2/conftest.h
+#ifndef DEFINED_IN_CONFTESTD1
+#error "include_next test doesn't work"
+#endif
+#define DEFINED_IN_CONFTESTD2
+EOF
+     gl_save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
+dnl We intentionally avoid using AC_LANG_SOURCE here.
+     AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
+       [gl_cv_have_include_next=yes],
+       [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
+        AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
+          [gl_cv_have_include_next=buggy],
+          [gl_cv_have_include_next=no])
+       ])
+     CPPFLAGS="$gl_save_CPPFLAGS"
+     rm -rf conftestd1a conftestd1b conftestd2
+    ])
+  PRAGMA_SYSTEM_HEADER=
+  if test $gl_cv_have_include_next = yes; then
+    INCLUDE_NEXT=include_next
+    INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    if test -n "$GCC"; then
+      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
+    fi
+  else
+    if test $gl_cv_have_include_next = buggy; then
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    else
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
+    fi
+  fi
+  AC_SUBST([INCLUDE_NEXT])
+  AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
+  AC_SUBST([PRAGMA_SYSTEM_HEADER])
+  AC_CACHE_CHECK([whether system header files limit the line length],
+    [gl_cv_pragma_columns],
+    [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
+     AC_EGREP_CPP([choke me],
+       [
+#ifdef __TANDEM
+choke me
+#endif
+       ],
+       [gl_cv_pragma_columns=yes],
+       [gl_cv_pragma_columns=no])
+    ])
+  if test $gl_cv_pragma_columns = yes; then
+    PRAGMA_COLUMNS="#pragma COLUMNS 10000"
+  else
+    PRAGMA_COLUMNS=
+  fi
+  AC_SUBST([PRAGMA_COLUMNS])
+])
+
+# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
+# ------------------------------------------
+# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
+# '<foo.h>'; otherwise define it to be
+# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
+# Also, if #include_next works as first preprocessing directive in a file,
+# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
+# be
+# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
+# That way, a header file with the following line:
+#       #@INCLUDE_NEXT@ @NEXT_FOO_H@
+# or
+#       #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
+# behaves (after sed substitution) as if it contained
+#       #include_next <foo.h>
+# even if the compiler does not support include_next.
+# The three "///" are to pacify Sun C 5.8, which otherwise would say
+# "warning: #include of /usr/include/... may be non-portable".
+# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
+# Note: This macro assumes that the header file is not empty after
+# preprocessing, i.e. it does not only define preprocessor macros but also
+# provides some type/enum definitions or function/variable declarations.
+#
+# This macro also checks whether each header exists, by invoking
+# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
+AC_DEFUN([gl_CHECK_NEXT_HEADERS],
+[
+  gl_NEXT_HEADERS_INTERNAL([$1], [check])
+])
+
+# gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
+# ------------------------------------
+# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
+# This is suitable for headers like <stddef.h> that are standardized by C89
+# and therefore can be assumed to exist.
+AC_DEFUN([gl_NEXT_HEADERS],
+[
+  gl_NEXT_HEADERS_INTERNAL([$1], [assume])
+])
+
+# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
+AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
+[
+  AC_REQUIRE([gl_INCLUDE_NEXT])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  m4_if([$2], [check],
+    [AC_CHECK_HEADERS_ONCE([$1])
+    ])
+
+  m4_foreach_w([gl_HEADER_NAME], [$1],
+    [AS_VAR_PUSHDEF([gl_next_header],
+                    [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
+     if test $gl_cv_have_include_next = yes; then
+       AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+     else
+       AC_CACHE_CHECK(
+         [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
+         m4_defn([gl_next_header]),
+         [m4_if([$2], [check],
+            [AS_VAR_PUSHDEF([gl_header_exists],
+                            [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
+             if test AS_VAR_GET(gl_header_exists) = yes; then
+             AS_VAR_POPDEF([gl_header_exists])
+            ])
+               AC_LANG_CONFTEST(
+                 [AC_LANG_SOURCE(
+                    [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
+                  )])
+               dnl AIX "xlc -E" and "cc -E" omit #line directives for header
+               dnl files that contain only a #include of other header files and
+               dnl no non-comment tokens of their own. This leads to a failure
+               dnl to detect the absolute name of <dirent.h>, <signal.h>,
+               dnl <poll.h> and others. The workaround is to force preservation
+               dnl of comments through option -C. This ensures all necessary
+               dnl #line directives are present. GCC supports option -C as well.
+               case "$host_os" in
+                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
+                 *)    gl_absname_cpp="$ac_cpp" ;;
+               esac
+               dnl eval is necessary to expand gl_absname_cpp.
+               dnl Ultrix and Pyramid sh refuse to redirect output of eval,
+               dnl so use subshell.
+               AS_VAR_SET([gl_next_header],
+                 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+                  sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
+                    s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
+                    s#^/[^/]#//&#
+                    p
+                    q
+                  }'`'"'])
+          m4_if([$2], [check],
+            [else
+               AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+             fi
+            ])
+         ])
+     fi
+     AC_SUBST(
+       AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
+       [AS_VAR_GET([gl_next_header])])
+     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+       gl_next_as_first_directive='<'gl_HEADER_NAME'>'
+     else
+       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+       gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
+     fi
+     AC_SUBST(
+       AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
+       [$gl_next_as_first_directive])
+     AS_VAR_POPDEF([gl_next_header])])
+])
+
+# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
+# this fallback is safe for all earlier autoconf versions.
+m4_define_default([AC_LANG_DEFINES_PROVIDED])
diff --git a/gnulib/m4/intlmacosx.m4 b/gnulib/m4/intlmacosx.m4
new file mode 100644 (file)
index 0000000..51f8547
--- /dev/null
@@ -0,0 +1,56 @@
+# intlmacosx.m4 serial 4 (gettext-0.18.2)
+dnl Copyright (C) 2004-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.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Checks for special options needed on MacOS X.
+dnl Defines INTL_MACOSX_LIBS.
+AC_DEFUN([gt_INTL_MACOSX],
+[
+  dnl Check for API introduced in MacOS X 10.2.
+  AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
+    [gt_cv_func_CFPreferencesCopyAppValue],
+    [gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <CoreFoundation/CFPreferences.h>]],
+          [[CFPreferencesCopyAppValue(NULL, NULL)]])],
+       [gt_cv_func_CFPreferencesCopyAppValue=yes],
+       [gt_cv_func_CFPreferencesCopyAppValue=no])
+     LIBS="$gt_save_LIBS"])
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
+    AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
+      [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
+  fi
+  dnl Check for API introduced in MacOS X 10.3.
+  AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
+    [gt_save_LIBS="$LIBS"
+     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
+     AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <CoreFoundation/CFLocale.h>]],
+          [[CFLocaleCopyCurrent();]])],
+       [gt_cv_func_CFLocaleCopyCurrent=yes],
+       [gt_cv_func_CFLocaleCopyCurrent=no])
+     LIBS="$gt_save_LIBS"])
+  if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+    AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
+      [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
+  fi
+  INTL_MACOSX_LIBS=
+  if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
+    INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
+  fi
+  AC_SUBST([INTL_MACOSX_LIBS])
+])
diff --git a/gnulib/m4/intmax_t.m4 b/gnulib/m4/intmax_t.m4
new file mode 100644 (file)
index 0000000..7341054
--- /dev/null
@@ -0,0 +1,67 @@
+# intmax_t.m4 serial 8
+dnl Copyright (C) 1997-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert.
+
+AC_PREREQ([2.53])
+
+# Define intmax_t to 'long' or 'long long'
+# if it is not already defined in <stdint.h> or <inttypes.h>.
+
+AC_DEFUN([gl_AC_TYPE_INTMAX_T],
+[
+  dnl For simplicity, we assume that a header file defines 'intmax_t' if and
+  dnl only if it defines 'uintmax_t'.
+  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+  if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
+    AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+    test $ac_cv_type_long_long_int = yes \
+      && ac_type='long long' \
+      || ac_type='long'
+    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
+     [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
+  else
+    AC_DEFINE([HAVE_INTMAX_T], [1],
+      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
+  fi
+])
+
+dnl An alternative would be to explicitly test for 'intmax_t'.
+
+AC_DEFUN([gt_AC_TYPE_INTMAX_T],
+[
+  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+  AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[
+#include <stddef.h>
+#include <stdlib.h>
+#if HAVE_STDINT_H_WITH_UINTMAX
+#include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H_WITH_UINTMAX
+#include <inttypes.h>
+#endif
+          ]],
+          [[intmax_t x = -1; return !x;]])],
+       [gt_cv_c_intmax_t=yes],
+       [gt_cv_c_intmax_t=no])])
+  if test $gt_cv_c_intmax_t = yes; then
+    AC_DEFINE([HAVE_INTMAX_T], [1],
+      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
+  else
+    AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+    test $ac_cv_type_long_long_int = yes \
+      && ac_type='long long' \
+      || ac_type='long'
+    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
+     [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
+  fi
+])
diff --git a/gnulib/m4/inttypes_h.m4 b/gnulib/m4/inttypes_h.m4
new file mode 100644 (file)
index 0000000..f10fd54
--- /dev/null
@@ -0,0 +1,29 @@
+# inttypes_h.m4 serial 10
+dnl Copyright (C) 1997-2004, 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert.
+
+# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+
+AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
+[
+  AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[
+#include <sys/types.h>
+#include <inttypes.h>
+          ]],
+          [[uintmax_t i = (uintmax_t) -1; return !i;]])],
+       [gl_cv_header_inttypes_h=yes],
+       [gl_cv_header_inttypes_h=no])])
+  if test $gl_cv_header_inttypes_h = yes; then
+    AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1],
+      [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
+       and declares uintmax_t. ])
+  fi
+])
diff --git a/gnulib/m4/isblank.m4 b/gnulib/m4/isblank.m4
new file mode 100644 (file)
index 0000000..771deef
--- /dev/null
@@ -0,0 +1,18 @@
+# isblank.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_ISBLANK],
+[
+  dnl Persuade glibc <ctype.h> to declare isblank().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([isblank])
+  if test $ac_cv_func_isblank = no; then
+    HAVE_ISBLANK=0
+    AC_LIBOBJ([isblank])
+  fi
+])
diff --git a/gnulib/m4/langinfo_h.m4 b/gnulib/m4/langinfo_h.m4
new file mode 100644 (file)
index 0000000..4cced8a
--- /dev/null
@@ -0,0 +1,105 @@
+# langinfo_h.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LANGINFO_H],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+
+  dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  dnl <langinfo.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_CHECK_NEXT_HEADERS([langinfo.h])
+
+  dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
+  HAVE_LANGINFO_CODESET=0
+  HAVE_LANGINFO_T_FMT_AMPM=0
+  HAVE_LANGINFO_ERA=0
+  HAVE_LANGINFO_YESEXPR=0
+  AC_CHECK_HEADERS_ONCE([langinfo.h])
+  if test $ac_cv_header_langinfo_h = yes; then
+    HAVE_LANGINFO_H=1
+    dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
+    dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
+    AC_CACHE_CHECK([whether langinfo.h defines CODESET],
+      [gl_cv_header_langinfo_codeset],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = CODESET;
+]])],
+         [gl_cv_header_langinfo_codeset=yes],
+         [gl_cv_header_langinfo_codeset=no])
+      ])
+    if test $gl_cv_header_langinfo_codeset = yes; then
+      HAVE_LANGINFO_CODESET=1
+    fi
+    AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
+      [gl_cv_header_langinfo_t_fmt_ampm],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = T_FMT_AMPM;
+]])],
+         [gl_cv_header_langinfo_t_fmt_ampm=yes],
+         [gl_cv_header_langinfo_t_fmt_ampm=no])
+      ])
+    if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
+      HAVE_LANGINFO_T_FMT_AMPM=1
+    fi
+    AC_CACHE_CHECK([whether langinfo.h defines ERA],
+      [gl_cv_header_langinfo_era],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = ERA;
+]])],
+         [gl_cv_header_langinfo_era=yes],
+         [gl_cv_header_langinfo_era=no])
+      ])
+    if test $gl_cv_header_langinfo_era = yes; then
+      HAVE_LANGINFO_ERA=1
+    fi
+    AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
+      [gl_cv_header_langinfo_yesexpr],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = YESEXPR;
+]])],
+         [gl_cv_header_langinfo_yesexpr=yes],
+         [gl_cv_header_langinfo_yesexpr=no])
+      ])
+    if test $gl_cv_header_langinfo_yesexpr = yes; then
+      HAVE_LANGINFO_YESEXPR=1
+    fi
+  else
+    HAVE_LANGINFO_H=0
+  fi
+  AC_SUBST([HAVE_LANGINFO_H])
+  AC_SUBST([HAVE_LANGINFO_CODESET])
+  AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
+  AC_SUBST([HAVE_LANGINFO_ERA])
+  AC_SUBST([HAVE_LANGINFO_YESEXPR])
+
+  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([[#include <langinfo.h>
+    ]], [nl_langinfo])
+])
+
+AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  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_LANGINFO_H_DEFAULTS],
+[
+  GNULIB_NL_LANGINFO=0;  AC_SUBST([GNULIB_NL_LANGINFO])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_NL_LANGINFO=1;    AC_SUBST([HAVE_NL_LANGINFO])
+  REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
+])
diff --git a/gnulib/m4/lcmessage.m4 b/gnulib/m4/lcmessage.m4
new file mode 100644 (file)
index 0000000..baf41c5
--- /dev/null
@@ -0,0 +1,35 @@
+# lcmessage.m4 serial 7 (gettext-0.18.2)
+dnl Copyright (C) 1995-2002, 2004-2005, 2008-2011 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
+
+# Check whether LC_MESSAGES is available in <locale.h>.
+
+AC_DEFUN([gt_LC_MESSAGES],
+[
+  AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <locale.h>]],
+          [[return LC_MESSAGES]])],
+       [gt_cv_val_LC_MESSAGES=yes],
+       [gt_cv_val_LC_MESSAGES=no])])
+  if test $gt_cv_val_LC_MESSAGES = yes; then
+    AC_DEFINE([HAVE_LC_MESSAGES], [1],
+      [Define if your <locale.h> file defines LC_MESSAGES.])
+  fi
+])
diff --git a/gnulib/m4/lib-ld.m4 b/gnulib/m4/lib-ld.m4
new file mode 100644 (file)
index 0000000..ae003f7
--- /dev/null
@@ -0,0 +1,109 @@
+# lib-ld.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 1996-2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Subroutines of libtool.m4,
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
+
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
+AC_DEFUN([AC_LIB_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  acl_cv_prog_gnu_ld=yes ;;
+*)
+  acl_cv_prog_gnu_ld=no ;;
+esac])
+with_gnu_ld=$acl_cv_prog_gnu_ld
+])
+
+dnl From libtool-1.4. Sets the variable LD.
+AC_DEFUN([AC_LIB_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
+  # contains only /bin. Note that ksh looks also at the FPATH variable,
+  # so we have to set that as well for the test.
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+           || PATH_SEPARATOR=';'
+       }
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]* | [A-Za-z]:[\\/]*)]
+      [re_direlt='/[^/][^/]*/\.\./']
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL([acl_cv_path_LD],
+[if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+      *GNU* | *'with BFD'*)
+        test "$with_gnu_ld" != no && break ;;
+      *)
+        test "$with_gnu_ld" != yes && break ;;
+      esac
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT([$LD])
+else
+  AC_MSG_RESULT([no])
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_LIB_PROG_LD_GNU
+])
diff --git a/gnulib/m4/lib-link.m4 b/gnulib/m4/lib-link.m4
new file mode 100644 (file)
index 0000000..e7c9ba9
--- /dev/null
@@ -0,0 +1,777 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_PREREQ([2.54])
+
+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
+dnl augments the CPPFLAGS variable.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  pushdef([Name],[m4_translit([$1],[./+-], [____])])
+  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
+                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
+    AC_LIB_LINKFLAGS_BODY([$1], [$2])
+    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
+    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
+    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
+    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
+  ])
+  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
+  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
+  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
+  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  AC_SUBST([LIB]NAME[_PREFIX])
+  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
+  dnl results of this search when this library appears as a dependency.
+  HAVE_LIB[]NAME=yes
+  popdef([NAME])
+  popdef([Name])
+])
+
+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
+dnl searches for libname and the libraries corresponding to explicit and
+dnl implicit dependencies, together with the specified include files and
+dnl the ability to compile and link the specified testcode. The missing-message
+dnl defaults to 'no' and may contain additional hints for the user.
+dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
+dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  pushdef([Name],[m4_translit([$1],[./+-], [____])])
+  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
+                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+
+  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
+  dnl accordingly.
+  AC_LIB_LINKFLAGS_BODY([$1], [$2])
+
+  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
+  dnl because if the user has installed lib[]Name and not disabled its use
+  dnl via --without-lib[]Name-prefix, he wants to use it.
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+
+  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
+    ac_save_LIBS="$LIBS"
+    dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
+    dnl because these -l options might require -L options that are present in
+    dnl LIBS. -l options benefit only from the -L options listed before it.
+    dnl Otherwise, add it to the front of LIBS, because it may be a static
+    dnl library that depends on another static library that is present in LIBS.
+    dnl Static libraries benefit only from the static libraries listed after
+    dnl it.
+    case " $LIB[]NAME" in
+      *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
+      *)       LIBS="$LIB[]NAME $LIBS" ;;
+    esac
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([[$3]], [[$4]])],
+      [ac_cv_lib[]Name=yes],
+      [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
+    LIBS="$ac_save_LIBS"
+  ])
+  if test "$ac_cv_lib[]Name" = yes; then
+    HAVE_LIB[]NAME=yes
+    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
+    AC_MSG_CHECKING([how to link with lib[]$1])
+    AC_MSG_RESULT([$LIB[]NAME])
+  else
+    HAVE_LIB[]NAME=no
+    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
+    dnl $INC[]NAME either.
+    CPPFLAGS="$ac_save_CPPFLAGS"
+    LIB[]NAME=
+    LTLIB[]NAME=
+    LIB[]NAME[]_PREFIX=
+  fi
+  AC_SUBST([HAVE_LIB]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  AC_SUBST([LIB]NAME[_PREFIX])
+  popdef([NAME])
+  popdef([Name])
+])
+
+dnl Determine the platform dependent parameters needed to use rpath:
+dnl   acl_libext,
+dnl   acl_shlibext,
+dnl   acl_libname_spec,
+dnl   acl_library_names_spec,
+dnl   acl_hardcode_libdir_flag_spec,
+dnl   acl_hardcode_libdir_separator,
+dnl   acl_hardcode_direct,
+dnl   acl_hardcode_minus_L.
+AC_DEFUN([AC_LIB_RPATH],
+[
+  dnl Tell automake >= 1.10 to complain if config.rpath is missing.
+  m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
+  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
+  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
+  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
+  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+  ])
+  wl="$acl_cv_wl"
+  acl_libext="$acl_cv_libext"
+  acl_shlibext="$acl_cv_shlibext"
+  acl_libname_spec="$acl_cv_libname_spec"
+  acl_library_names_spec="$acl_cv_library_names_spec"
+  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  acl_hardcode_direct="$acl_cv_hardcode_direct"
+  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
+  dnl Determine whether the user wants rpath handling at all.
+  AC_ARG_ENABLE([rpath],
+    [  --disable-rpath         do not hardcode runtime library paths],
+    :, enable_rpath=yes)
+])
+
+dnl AC_LIB_FROMPACKAGE(name, package)
+dnl declares that libname comes from the given package. The configure file
+dnl will then not have a --with-libname-prefix option but a
+dnl --with-package-prefix option. Several libraries can come from the same
+dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
+dnl macro call that searches for libname.
+AC_DEFUN([AC_LIB_FROMPACKAGE],
+[
+  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
+                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  define([acl_frompackage_]NAME, [$2])
+  popdef([NAME])
+  pushdef([PACK],[$2])
+  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
+                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  define([acl_libsinpackage_]PACKUP,
+    m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
+  popdef([PACKUP])
+  popdef([PACK])
+])
+
+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
+dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
+dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
+                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
+  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
+                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
+  dnl Autoconf >= 2.61 supports dots in --with options.
+  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_ARG_WITH(P_A_C_K[-prefix],
+[[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
+  --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/$acl_libdirstem"
+        if test "$acl_libdirstem2" != "$acl_libdirstem" \
+           && ! test -d "$withval/$acl_libdirstem"; then
+          additional_libdir="$withval/$acl_libdirstem2"
+        fi
+      fi
+    fi
+])
+  dnl Search the library and its dependencies in $additional_libdir and
+  dnl $LDFLAGS. Using breadth-first-seach.
+  LIB[]NAME=
+  LTLIB[]NAME=
+  INC[]NAME=
+  LIB[]NAME[]_PREFIX=
+  dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
+  dnl computed. So it has to be reset here.
+  HAVE_LIB[]NAME=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='$1 $2'
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
+        dnl or AC_LIB_HAVE_LINKFLAGS call.
+        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
+          else
+            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
+            dnl that this library doesn't exist. So just drop it.
+            :
+          fi
+        else
+          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
+          dnl and the already constructed $LIBNAME/$LTLIBNAME.
+          found_dir=
+          found_la=
+          found_so=
+          found_a=
+          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
+          if test -n "$acl_shlibext"; then
+            shrext=".$acl_shlibext"             # typically: shrext=.so
+          else
+            shrext=
+          fi
+          if test $use_additional = yes; then
+            dir="$additional_libdir"
+            dnl The same code as in the loop below:
+            dnl First look for a shared library.
+            if test -n "$acl_shlibext"; then
+              if test -f "$dir/$libname$shrext"; then
+                found_dir="$dir"
+                found_so="$dir/$libname$shrext"
+              else
+                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                  ver=`(cd "$dir" && \
+                        for f in "$libname$shrext".*; do echo "$f"; done \
+                        | sed -e "s,^$libname$shrext\\\\.,," \
+                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                        | sed 1q ) 2>/dev/null`
+                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                    found_dir="$dir"
+                    found_so="$dir/$libname$shrext.$ver"
+                  fi
+                else
+                  eval library_names=\"$acl_library_names_spec\"
+                  for f in $library_names; do
+                    if test -f "$dir/$f"; then
+                      found_dir="$dir"
+                      found_so="$dir/$f"
+                      break
+                    fi
+                  done
+                fi
+              fi
+            fi
+            dnl Then look for a static library.
+            if test "X$found_dir" = "X"; then
+              if test -f "$dir/$libname.$acl_libext"; then
+                found_dir="$dir"
+                found_a="$dir/$libname.$acl_libext"
+              fi
+            fi
+            if test "X$found_dir" != "X"; then
+              if test -f "$dir/$libname.la"; then
+                found_la="$dir/$libname.la"
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIB[]NAME; do
+              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  dnl First look for a shared library.
+                  if test -n "$acl_shlibext"; then
+                    if test -f "$dir/$libname$shrext"; then
+                      found_dir="$dir"
+                      found_so="$dir/$libname$shrext"
+                    else
+                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                        ver=`(cd "$dir" && \
+                              for f in "$libname$shrext".*; do echo "$f"; done \
+                              | sed -e "s,^$libname$shrext\\\\.,," \
+                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                              | sed 1q ) 2>/dev/null`
+                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                          found_dir="$dir"
+                          found_so="$dir/$libname$shrext.$ver"
+                        fi
+                      else
+                        eval library_names=\"$acl_library_names_spec\"
+                        for f in $library_names; do
+                          if test -f "$dir/$f"; then
+                            found_dir="$dir"
+                            found_so="$dir/$f"
+                            break
+                          fi
+                        done
+                      fi
+                    fi
+                  fi
+                  dnl Then look for a static library.
+                  if test "X$found_dir" = "X"; then
+                    if test -f "$dir/$libname.$acl_libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/$libname.$acl_libext"
+                    fi
+                  fi
+                  if test "X$found_dir" != "X"; then
+                    if test -f "$dir/$libname.la"; then
+                      found_la="$dir/$libname.la"
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+            dnl Found the library.
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+              dnl Linking with a shared library. We attempt to hardcode its
+              dnl directory into the executable's runpath, unless it's the
+              dnl standard /usr/lib.
+              if test "$enable_rpath" = no \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
+                dnl No hardcoding is needed.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+              else
+                dnl Use an explicit option to hardcode DIR into the resulting
+                dnl binary.
+                dnl Potentially add DIR to ltrpathdirs.
+                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                dnl The hardcoding into $LIBNAME is system dependent.
+                if test "$acl_hardcode_direct" = yes; then
+                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
+                  dnl resulting binary.
+                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                else
+                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
+                    dnl Use an explicit option to hardcode DIR into the resulting
+                    dnl binary.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    dnl Potentially add DIR to rpathdirs.
+                    dnl The rpathdirs will be appended to $LIBNAME at the end.
+                    haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                    dnl Rely on "-L$found_dir".
+                    dnl But don't add it if it's already contained in the LDFLAGS
+                    dnl or the already constructed $LIBNAME
+                    haveit=
+                    for x in $LDFLAGS $LIB[]NAME; do
+                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
+                    fi
+                    if test "$acl_hardcode_minus_L" != no; then
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    else
+                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
+                      dnl here, because this doesn't fit in flags passed to the
+                      dnl compiler. So give up. No hardcoding. This affects only
+                      dnl very old systems.
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                dnl Linking with a static library.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
+              else
+                dnl We shouldn't come here, but anyway it's good to have a
+                dnl fallback.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
+              fi
+            fi
+            dnl Assume the include files are nearby.
+            additional_includedir=
+            case "$found_dir" in
+              */$acl_libdirstem | */$acl_libdirstem/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+              */$acl_libdirstem2 | */$acl_libdirstem2/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+              dnl Potentially add $additional_includedir to $INCNAME.
+              dnl But don't add it
+              dnl   1. if it's the standard /usr/include,
+              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
+              dnl   3. if it's already present in $CPPFLAGS or the already
+              dnl      constructed $INCNAME,
+              dnl   4. if it doesn't exist as a directory.
+              if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INC[]NAME; do
+                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                      dnl Really add $additional_includedir to $INCNAME.
+                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+            dnl Look for dependencies.
+            if test -n "$found_la"; then
+              dnl Read the .la file. It defines the variables
+              dnl dlname, library_names, old_library, dependency_libs, current,
+              dnl age, revision, installed, dlopen, dlpreopen, libdir.
+              save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+              dnl We use only dependency_libs.
+              for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
+                    dnl But don't add it
+                    dnl   1. if it's the standard /usr/lib,
+                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
+                    dnl   3. if it's already present in $LDFLAGS or the already
+                    dnl      constructed $LIBNAME,
+                    dnl   4. if it doesn't exist as a directory.
+                    if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
+                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
+                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LIBNAME.
+                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LTLIBNAME.
+                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                      dnl Potentially add DIR to rpathdirs.
+                      dnl The rpathdirs will be appended to $LIBNAME at the end.
+                      haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                      dnl Potentially add DIR to ltrpathdirs.
+                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                      haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                    dnl Handle this in the next round.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                    dnl Handle this in the next round. Throw away the .la's
+                    dnl directory; it is already contained in a preceding -L
+                    dnl option.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                    dnl Most likely an immediate library name.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
+                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+            dnl Didn't find the library; assume it is in the system directories
+            dnl known to the linker and runtime loader. (All the system
+            dnl directories known to the linker should also be known to the
+            dnl runtime loader, otherwise the system is severely misconfigured.)
+            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$acl_hardcode_libdir_separator"; then
+      dnl Weird platform: only the last -rpath option counts, the user must
+      dnl pass all path elements in one option. We can arrange that for a
+      dnl single library, but not when more than one $LIBNAMEs are used.
+      alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
+      done
+      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
+      acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$acl_hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+    else
+      dnl The -rpath options are cumulative.
+      for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$acl_hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+    dnl When using libtool, the option that works for both libraries and
+    dnl executables is -R. The -R options are cumulative.
+    for found_dir in $ltrpathdirs; do
+      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
+    done
+  fi
+  popdef([P_A_C_K])
+  popdef([PACKLIBS])
+  popdef([PACKUP])
+  popdef([PACK])
+  popdef([NAME])
+])
+
+dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
+dnl unless already present in VAR.
+dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
+dnl contains two or three consecutive elements that belong together.
+AC_DEFUN([AC_LIB_APPENDTOVAR],
+[
+  for element in [$2]; do
+    haveit=
+    for x in $[$1]; do
+      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      [$1]="${[$1]}${[$1]:+ }$element"
+    fi
+  done
+])
+
+dnl For those cases where a variable contains several -L and -l options
+dnl referring to unknown libraries and directories, this macro determines the
+dnl necessary additional linker options for the runtime path.
+dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
+dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
+dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
+dnl otherwise linking without libtool is assumed.
+AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
+[
+  AC_REQUIRE([AC_LIB_RPATH])
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  $1=
+  if test "$enable_rpath" != no; then
+    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
+      dnl Use an explicit option to hardcode directories into the resulting
+      dnl binary.
+      rpathdirs=
+      next=
+      for opt in $2; do
+        if test -n "$next"; then
+          dir="$next"
+          dnl No need to hardcode the standard /usr/lib.
+          if test "X$dir" != "X/usr/$acl_libdirstem" \
+             && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+            rpathdirs="$rpathdirs $dir"
+          fi
+          next=
+        else
+          case $opt in
+            -L) next=yes ;;
+            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
+                 dnl No need to hardcode the standard /usr/lib.
+                 if test "X$dir" != "X/usr/$acl_libdirstem" \
+                    && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+                   rpathdirs="$rpathdirs $dir"
+                 fi
+                 next= ;;
+            *) next= ;;
+          esac
+        fi
+      done
+      if test "X$rpathdirs" != "X"; then
+        if test -n ""$3""; then
+          dnl libtool is used for linking. Use -R options.
+          for dir in $rpathdirs; do
+            $1="${$1}${$1:+ }-R$dir"
+          done
+        else
+          dnl The linker is used for linking directly.
+          if test -n "$acl_hardcode_libdir_separator"; then
+            dnl Weird platform: only the last -rpath option counts, the user
+            dnl must pass all path elements in one option.
+            alldirs=
+            for dir in $rpathdirs; do
+              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
+            done
+            acl_save_libdir="$libdir"
+            libdir="$alldirs"
+            eval flag=\"$acl_hardcode_libdir_flag_spec\"
+            libdir="$acl_save_libdir"
+            $1="$flag"
+          else
+            dnl The -rpath options are cumulative.
+            for dir in $rpathdirs; do
+              acl_save_libdir="$libdir"
+              libdir="$dir"
+              eval flag=\"$acl_hardcode_libdir_flag_spec\"
+              libdir="$acl_save_libdir"
+              $1="${$1}${$1:+ }$flag"
+            done
+          fi
+        fi
+      fi
+    fi
+  fi
+  AC_SUBST([$1])
+])
diff --git a/gnulib/m4/lib-prefix.m4 b/gnulib/m4/lib-prefix.m4
new file mode 100644 (file)
index 0000000..7e5f0bd
--- /dev/null
@@ -0,0 +1,224 @@
+# lib-prefix.m4 serial 7 (gettext-0.18)
+dnl Copyright (C) 2001-2005, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
+dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
+dnl require excessive bracketing.
+ifdef([AC_HELP_STRING],
+[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
+[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
+
+dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
+dnl to access previously installed libraries. The basic assumption is that
+dnl a user will want packages to use other packages he previously installed
+dnl with the same --prefix option.
+dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
+dnl libraries, but is otherwise very convenient.
+AC_DEFUN([AC_LIB_PREFIX],
+[
+  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_LIB_ARG_WITH([lib-prefix],
+[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
+  --without-lib-prefix    don't search for libraries in includedir and libdir],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/$acl_libdirstem"
+      fi
+    fi
+])
+  if test $use_additional = yes; then
+    dnl Potentially add $additional_includedir to $CPPFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/include,
+    dnl   2. if it's already present in $CPPFLAGS,
+    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_includedir" != "X/usr/include"; then
+      haveit=
+      for x in $CPPFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-I$additional_includedir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_includedir" = "X/usr/local/include"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_includedir"; then
+            dnl Really add $additional_includedir to $CPPFLAGS.
+            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
+          fi
+        fi
+      fi
+    fi
+    dnl Potentially add $additional_libdir to $LDFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/lib,
+    dnl   2. if it's already present in $LDFLAGS,
+    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
+      haveit=
+      for x in $LDFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-L$additional_libdir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux*) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_libdir"; then
+            dnl Really add $additional_libdir to $LDFLAGS.
+            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
+          fi
+        fi
+      fi
+    fi
+  fi
+])
+
+dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
+dnl acl_final_exec_prefix, containing the values to which $prefix and
+dnl $exec_prefix will expand at the end of the configure script.
+AC_DEFUN([AC_LIB_PREPARE_PREFIX],
+[
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+])
+
+dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
+dnl variables prefix and exec_prefix bound to the values they will have
+dnl at the end of the configure script.
+AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
+[
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  $1
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+])
+
+dnl AC_LIB_PREPARE_MULTILIB creates
+dnl - a variable acl_libdirstem, containing the basename of the libdir, either
+dnl   "lib" or "lib64" or "lib/64",
+dnl - a variable acl_libdirstem2, as a secondary possible value for
+dnl   acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
+dnl   "lib/amd64".
+AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
+[
+  dnl There is no formal standard regarding lib and lib64.
+  dnl On glibc systems, the current practice is that on a system supporting
+  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
+  dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
+  dnl the compiler's default mode by looking at the compiler's library search
+  dnl path. If at least one of its elements ends in /lib64 or points to a
+  dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
+  dnl Otherwise we use the default, namely "lib".
+  dnl On Solaris systems, the current practice is that on a system supporting
+  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
+  dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
+  dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  acl_libdirstem=lib
+  acl_libdirstem2=
+  case "$host_os" in
+    solaris*)
+      dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
+      dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
+      dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
+      dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
+      dnl symlink is missing, so we set acl_libdirstem2 too.
+      AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
+        [AC_EGREP_CPP([sixtyfour bits], [
+#ifdef _LP64
+sixtyfour bits
+#endif
+           ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
+        ])
+      if test $gl_cv_solaris_64bit = yes; then
+        acl_libdirstem=lib/64
+        case "$host_cpu" in
+          sparc*)        acl_libdirstem2=lib/sparcv9 ;;
+          i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+        esac
+      fi
+      ;;
+    *)
+      searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+      if test -n "$searchpath"; then
+        acl_save_IFS="${IFS=   }"; IFS=":"
+        for searchdir in $searchpath; do
+          if test -d "$searchdir"; then
+            case "$searchdir" in
+              */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
+              */../ | */.. )
+                # Better ignore directories of this form. They are misleading.
+                ;;
+              *) searchdir=`cd "$searchdir" && pwd`
+                 case "$searchdir" in
+                   */lib64 ) acl_libdirstem=lib64 ;;
+                 esac ;;
+            esac
+          fi
+        done
+        IFS="$acl_save_IFS"
+      fi
+      ;;
+  esac
+  test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
+])
diff --git a/gnulib/m4/libtool.m4 b/gnulib/m4/libtool.m4
new file mode 100644 (file)
index 0000000..8c99a62
--- /dev/null
@@ -0,0 +1,7441 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
+#                 Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
+#                 Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool 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 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 57 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+       [m4_default([$3],
+                  [m4_fatal([Libtool version $1 or higher is required],
+                            63)])],
+       [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+  *\ * | *\    *)
+    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    _LT_PATH_MAGIC
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME.  Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+       [m4_ifval([$1], [$1], [$2])])
+    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+    m4_ifval([$4],
+       [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+    lt_dict_add_subkey([lt_decl_dict], [$2],
+       [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+  [0], [m4_fatal([$0: too few arguments: $#])],
+  [1], [m4_fatal([$0: too few arguments: $#: $1])],
+  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_if([$2], [],
+          m4_quote(lt_decl_varnames),
+       m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+                       lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'.  VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly.  In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+#    # Some comment about what VAR is for.
+#    visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+                                          [description])))[]dnl
+m4_pushdef([_libtool_name],
+    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+    [0], [_libtool_name=[$]$1],
+    [1], [_libtool_name=$lt_[]$1],
+    [2], [_libtool_name=$lt_[]$1],
+    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'.  Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+       dnl If the libtool generation code has been placed in $CONFIG_LT,
+       dnl instead of duplicating it all over again into config.status,
+       dnl then we will have config.status run $CONFIG_LT later, so it
+       dnl needs to know what name is stored there:
+        [AC_CONFIG_COMMANDS([libtool],
+            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+    dnl If the libtool generation code is destined for config.status,
+    dnl expand the accumulated commands and init code now:
+    [AC_CONFIG_COMMANDS([libtool],
+        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable.  If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins.  After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script.  The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $lt_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+  echo
+  AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2010 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+  case $[1] in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
+
+    -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+    *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+  esac
+  shift
+done
+
+if $lt_cl_silent; then
+  exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+  lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars.  Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+  m4_if(_LT_TAG, [C], [
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+  _LT_PROG_LTMAIN
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  _LT_PROG_XSI_SHELLFNS
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+  [C],                 [_LT_LANG(C)],
+  [C++],               [_LT_LANG(CXX)],
+  [Java],              [_LT_LANG(GCJ)],
+  [Fortran 77],                [_LT_LANG(F77)],
+  [Fortran],           [_LT_LANG(FC)],
+  [Windows Resource],  [_LT_LANG(RC)],
+  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+    [_LT_LANG($1)],
+    [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+  [LT_SUPPORTED_TAG([$1])dnl
+  m4_append([_LT_TAGS], [$1 ])dnl
+  m4_define([_LT_LANG_]$1[_enabled], [])dnl
+  _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [LT_LANG(CXX)],
+  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+  [LT_LANG(F77)],
+  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+  [LT_LANG(GCJ)],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+    [LT_LANG(GCJ)],
+    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+      [LT_LANG(GCJ)],
+      [m4_ifdef([AC_PROG_GCJ],
+       [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([A][M_PROG_GCJ],
+       [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([LT_PROG_GCJ],
+       [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+  [LT_LANG(RC)],
+  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+    AC_CHECK_TOOL([LIPO], [lipo], [:])
+    AC_CHECK_TOOL([OTOOL], [otool], [:])
+    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+    _LT_DECL([], [DSYMUTIL], [1],
+      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+    _LT_DECL([], [NMEDIT], [1],
+      [Tool to change global to local symbols on Mac OS X])
+    _LT_DECL([], [LIPO], [1],
+      [Tool to manipulate fat objects and archives on Mac OS X])
+    _LT_DECL([], [OTOOL], [1],
+      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+    _LT_DECL([], [OTOOL64], [1],
+      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+       # By default we will add the -single_module flag. You can override
+       # by either setting the environment variable LT_MULTI_MODULE
+       # non-empty at configure time, or by adding -multi_module to the
+       # link flags.
+       rm -rf libconftest.dylib*
+       echo "int foo(void){return 1;}" > conftest.c
+       echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+       $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+         -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+       if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+         lt_cv_apple_cc_single_mod=yes
+       else
+         cat conftest.err >&AS_MESSAGE_LOG_FD
+       fi
+       rm -rf libconftest.dylib*
+       rm -f conftest.*
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+       [lt_cv_ld_exported_symbols_list=yes],
+       [lt_cv_ld_exported_symbols_list=no])
+       LDFLAGS="$save_LDFLAGS"
+    ])
+    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+      [lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
+       lt_cv_ld_force_load=yes
+      else
+       cat conftest.err >&AS_MESSAGE_LOG_FD
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[012]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+       10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+       10.[[012]]*)
+         _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+       10.*)
+         _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_automatic, $1)=yes
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  else
+    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  fi
+  _LT_TAGVAR(link_all_deplibs, $1)=yes
+  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    m4_if([$1], [CXX],
+[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+],[])
+  else
+  _LT_TAGVAR(ld_shlibs, $1)=no
+  fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX
+# -----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+       /^0/ {
+           s/^0  *\(.*\)$/\1/
+           p
+       }
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
+
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script which will find a shell with a builtin
+# printf (which we can use as an echo command).
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`print -r -- -n 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*" 
+}
+
+case "$ECHO" in
+  printf*) AC_MSG_RESULT([printf]) ;;
+  print*) AC_MSG_RESULT([print -r]) ;;
+  *) AC_MSG_RESULT([cat]) ;;
+esac
+
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test "X`printf %s $ECHO`" = "X$ECHO" \
+      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
+
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+  [AS_HELP_STRING([--disable-libtool-lock],
+    [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+       HPUX_IA64_MODE="32"
+       ;;
+      *ELF-64*)
+       HPUX_IA64_MODE="64"
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -melf32bsmip"
+         ;;
+       *N32*)
+         LD="${LD-ld} -melf32bmipn32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -melf64bmip"
+       ;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+       *32-bit*)
+         LD="${LD-ld} -32"
+         ;;
+       *N32*)
+         LD="${LD-ld} -n32"
+         ;;
+       *64-bit*)
+         LD="${LD-ld} -64"
+         ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_i386_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_i386"
+           ;;
+         ppc64-*linux*|powerpc64-*linux*)
+           LD="${LD-ld} -m elf32ppclinux"
+           ;;
+         s390x-*linux*)
+           LD="${LD-ld} -m elf_s390"
+           ;;
+         sparc64-*linux*)
+           LD="${LD-ld} -m elf32_sparc"
+           ;;
+       esac
+       ;;
+      *64-bit*)
+       case $host in
+         x86_64-*kfreebsd*-gnu)
+           LD="${LD-ld} -m elf_x86_64_fbsd"
+           ;;
+         x86_64-*linux*)
+           LD="${LD-ld} -m elf_x86_64"
+           ;;
+         ppc*-*linux*|powerpc*-*linux*)
+           LD="${LD-ld} -m elf64ppc"
+           ;;
+         s390*-*linux*|s390*-*tpf*)
+           LD="${LD-ld} -m elf64_s390"
+           ;;
+         sparc*-*linux*)
+           LD="${LD-ld} -m elf64_sparc"
+           ;;
+       esac
+       ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+       if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+         LD="${LD-ld} -64"
+       fi
+       ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+    [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+    [Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+    [Whether to use a lock for old archive extraction])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#              [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$5], , :, [$5])
+else
+    m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                  [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$4], , :, [$4])
+else
+    m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[        ]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
+                = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+             test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+    [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+[#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+void fnord () __attribute__((visibility("default")));
+#endif
+
+void fnord () { int i=42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+         if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+       }
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}]
+_LT_EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+    ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+         [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+           [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+       [AC_CHECK_FUNC([dlopen],
+             [lt_cv_dlopen="dlopen"],
+         [AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+           [AC_CHECK_LIB([svld], [dlopen],
+                 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+             [AC_CHECK_LIB([dld], [dld_link],
+                   [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+             ])
+           ])
+         ])
+       ])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+         lt_cv_dlopen_self, [dnl
+         _LT_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+           lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+         lt_cv_dlopen_self_static, [dnl
+         _LT_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+           lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+        [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+        [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+        [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+       [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+         [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+    [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+    fi
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+       [], [
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+       lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+
+  # Some binutils ld are patched to set DT_RUNPATH
+  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+    [lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+        LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+        [lt_cv_shlibpath_overrides_runpath=yes])])
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
+    ])
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Add ABI-specific directories to the system library path.
+  sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[  ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+       ;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+    [Variables whose values should be saved in libtool wrapper scripts and
+    restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+    [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+    [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+    [[List of archive names.  First name is the real one, the rest are links.
+    The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+    [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+    [Permission mode override for installation of shared libraries])
+_LT_DECL([], [postinstall_cmds], [2],
+    [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+    [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+    [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+    [[As "finish_cmds", except a single script fragment to be evaled but
+    not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+    [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+    [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+    [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="m4_if([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+        [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
+
+AC_ARG_WITH([gnu-ld],
+    [AS_HELP_STRING([--with-gnu-ld],
+       [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_TAGDECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+    [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+    [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       # Tru64's nm complains that /dev/null is an invalid object file
+       case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+       */dev/null* | *'Invalid file or object type'*)
+         lt_cv_path_NM="$tmp_nm -B"
+         break
+         ;;
+       *)
+         case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+         */dev/null*)
+           lt_cv_path_NM="$tmp_nm -p"
+           break
+           ;;
+         *)
+           lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+           continue # so that we can try to find one that supports BSD flags
+           ;;
+         esac
+         ;;
+       esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
+  AC_SUBST([DUMPBIN])
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+  [lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
+  cat conftest.out >&AS_MESSAGE_LOG_FD
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
+  esac
+
+  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+       [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK ['"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx]"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[    ]]\($symcode$symcode*\)[[       ]][[    ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+       if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+         cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+         cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+         if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+    [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+    [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+    [lt_cv_sys_global_symbol_to_c_name_address], [1],
+    [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+    [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+       # All AIX code is PIC.
+       if test "$host_cpu" = ia64; then
+         # AIX 5 now supports IA64 processor
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+       else
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+       fi
+       ;;
+      chorus*)
+       case $cc_basename in
+       cxch68*)
+         # Green Hills C++ Compiler
+         # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+         ;;
+       esac
+       ;;
+      dgux*)
+       case $cc_basename in
+         ec++*)
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         ghcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      freebsd* | dragonfly*)
+       # FreeBSD uses GNU C++
+       ;;
+      hpux9* | hpux10* | hpux11*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+           if test "$host_cpu" != ia64; then
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+           fi
+           ;;
+         aCC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+           case $host_cpu in
+           hppa*64*|ia64*)
+             # +Z the default
+             ;;
+           *)
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+             ;;
+           esac
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      interix*)
+       # This is c89, which is MS Visual C++ (no shared libs)
+       # Anyone wants to do a port?
+       ;;
+      irix5* | irix6* | nonstopux*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           # CC pic flag -KPIC is the default.
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+       case $cc_basename in
+         KCC*)
+           # KAI C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         ecpc* )
+           # old Intel C++ for x86_64 which still supported -KPIC.
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         icpc* )
+           # Intel C++, used to be incompatible with GCC.
+           # ICC 10 doesn't accept -KPIC any more.
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         pgCC* | pgcpp*)
+           # Portland Group C++ compiler
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         cxx*)
+           # Compaq C++
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
+           # IBM XL 8.0, 9.0 on PPC and BlueGene
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+             _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+             _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+      lynxos*)
+       ;;
+      m88k*)
+       ;;
+      mvs*)
+       case $cc_basename in
+         cxx*)
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      netbsd*)
+       ;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+       case $cc_basename in
+         KCC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           ;;
+         RCC*)
+           # Rational C++ 2.4.1
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         cxx*)
+           # Digital/Compaq C++
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      psos*)
+       ;;
+      solaris*)
+       case $cc_basename in
+         CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+           ;;
+         gcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sunos4*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.x
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         lcc*)
+           # Lucid
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+       case $cc_basename in
+         CC*)
+           _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+       esac
+       ;;
+      tandem*)
+       case $cc_basename in
+         NCC*)
+           # NonStop-UX NCC 3.20
+           _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      vxworks*)
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+       ;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)=
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      m4_if([$1], [GCJ], [],
+       [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+       ;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+       # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+       ;;
+      *)
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ F* | *Sun*Fortran*)
+         # Sun Fortran 8.3 passes all unrecognized flags to the linker
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+         ;;
+       *Sun\ C*)
+         # Sun C 5.9
+         _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+         _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+         _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+       esac
+       ;;
+      esac
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+       [How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+       [Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+       [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    # Also, AIX nm treats weak defined symbols like other global defined
+    # symbols, whereas GNU nm marks them as "W".
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw* | cegcc*)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+  runpath_var=
+  _LT_TAGVAR(allow_undefined_flag, $1)=
+  _LT_TAGVAR(always_export_symbols, $1)=no
+  _LT_TAGVAR(archive_cmds, $1)=
+  _LT_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_TAGVAR(compiler_needs_object, $1)=no
+  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  _LT_TAGVAR(hardcode_automatic, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(inherit_rpath, $1)=no
+  _LT_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_TAGVAR(module_cmds, $1)=
+  _LT_TAGVAR(module_expsym_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_TAGVAR(ld_shlibs, $1)=yes
+
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
+    case $host_os in
+      aix*)
+       # The AIX port of GNU ld has always aspired to compatibility
+       # with the native linker.  However, as the warning in the GNU ld
+       # block says, versions before 2.19.5* couldn't really create working
+       # shared libraries, regardless of the interface used.
+       case `$LD -v 2>&1` in
+         *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+         *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
+         *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
+         *)
+           lt_use_gnu_ld_interface=yes
+           ;;
+       esac
+       ;;
+      *)
+       lt_use_gnu_ld_interface=yes
+       ;;
+    esac
+  fi
+
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=no
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    haiku*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    interix[[3-9]]*)
+      _LT_TAGVAR(hardcode_direct, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+       case $cc_basename in
+         diet\ *) tmp_diet=yes;;       # linux-dietlibc with static linking (!diet-dyn)
+       esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+        && test "$tmp_diet" = no
+      then
+       tmp_addflag=
+       tmp_sharedflag='-shared'
+       case $cc_basename,$host_cpu in
+        pgcc*)                         # Portland Group C compiler
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95* | pgfortran*)
+                                       # Portland Group f77 and f90 compilers
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)        # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       lf95*)                          # Lahey Fortran 8.1
+         _LT_TAGVAR(whole_archive_flag_spec, $1)=
+         tmp_sharedflag='--shared' ;;
+       xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+         tmp_sharedflag='-qmkshrobj'
+         tmp_addflag= ;;
+       nvcc*)  # Cuda Compiler Driver 2.2
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         _LT_TAGVAR(compiler_needs_object, $1)=yes
+         ;;
+       esac
+       case `$CC -V 2>&1 | sed 5q` in
+       *Sun\ C*)                       # Sun C 5.9
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+         _LT_TAGVAR(compiler_needs_object, $1)=yes
+         tmp_sharedflag='-G' ;;
+       *Sun\ F*)                       # Sun Fortran 8.3
+         tmp_sharedflag='-G' ;;
+       esac
+       _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+           cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+           echo "local: *; };" >> $output_objdir/$libname.ver~
+           $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+       case $cc_basename in
+       xlf* | bgf* | bgxlf* | mpixlf*)
+         # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+         _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+         _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+         if test "x$supports_anon_versioning" = xyes; then
+           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+             cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+             echo "local: *; };" >> $output_objdir/$libname.ver~
+             $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+         fi
+         ;;
+       esac
+      else
+        _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+       ;;
+       *)
+         # For security reasons, it is highly recommended that you always
+         # use absolute paths for naming shared libraries, and exclude the
+         # DT_RUNPATH tag from executables and libraries.  But doing so
+         # requires that you compile everything twice, which is a pain.
+         if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         else
+           _LT_TAGVAR(ld_shlibs, $1)=no
+         fi
+       ;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       _LT_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       # Also, AIX nm treats weak defined symbols like other global
+       # defined symbols, whereas GNU nm marks them as "W".
+       if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+         _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       else
+         _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+         ;;
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_TAGVAR(archive_cmds, $1)=''
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[[012]]|aix4.[[012]].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+          strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         :
+         else
+         # We have old collect2
+         _LT_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+         ;;
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+         fi
+       fi
+      fi
+
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+       if test "$host_cpu" = ia64; then
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+         _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+         _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+         if test "$with_gnu_ld" = yes; then
+           # We only use this code for GNU lds that support --whole-archive.
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+         else
+           # Exported symbols can be pulled into shared objects from archives
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+         fi
+         _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[[45]]*)
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      _LT_DARWIN_LINKER_FEATURES($1)
+      ;;
+
+    dgux*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_TAGVAR(hardcode_direct, $1)=yes
+       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       # hardcode_minus_L: Not really in the search PATH,
+       # but as the default location of the library.
+       _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       ia64*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+       m4_if($1, [], [
+         # Older versions of the 11.00 compiler do not understand -b yet
+         # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+         _LT_LINKER_OPTION([if $CC understands -b],
+           _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
+           [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+           [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
+         [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_TAGVAR(hardcode_direct, $1)=no
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+         ;;
+       *)
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+         _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       # Try to use the -exported_symbol ld option, if it does not
+       # work, assume that -exports_file does not work either and
+       # implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        AC_LINK_IFELSE(int foo(void) {},
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+        )
+        LDFLAGS="$save_LDFLAGS"
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(inherit_rpath, $1)=yes
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+       _LT_TAGVAR(hardcode_direct, $1)=yes
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+       if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+         _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       else
+         case $host_os in
+          openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+            _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+            ;;
+          *)
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+            ;;
+         esac
+       fi
+      else
+       _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+       _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+       $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+       case `$CC -V 2>&1` in
+       *"Compilers 5.0"*)
+         wlarc=''
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+         ;;
+       *)
+         wlarc='${wl}'
+         _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+         $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+         ;;
+       esac
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+       # The compiler driver will combine and reorder linker options,
+       # but understands `-z linker_flag'.  GCC discards it without `$wl',
+       # but is careful enough not to reorder.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       if test "$GCC" = yes; then
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+       else
+         _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+       fi
+       ;;
+      esac
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+         _LT_TAGVAR(hardcode_direct, $1)=no
+        ;;
+       motorola)
+         _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       _LT_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+       ;;
+      esac
+    fi
+  fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+    [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_CACHE_CHECK([whether -lc should be explicitly linked in],
+       [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
+       [$RM conftest*
+       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+       if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+         soname=conftest
+         lib=conftest
+         libobjs=conftest.$ac_objext
+         deplibs=
+         wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+         pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+         compiler_flags=-v
+         linker_flags=-v
+         verstring=
+         output_objdir=.
+         libname=conftest
+         lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+         _LT_TAGVAR(allow_undefined_flag, $1)=
+         if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+         then
+           lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+         else
+           lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+         fi
+         _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+       else
+         cat conftest.err 1>&5
+       fi
+       $RM conftest*
+       ])
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+    [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+    [enable_shared_with_static_runtimes], [0],
+    [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+    [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+    [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+    [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+    [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+    [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+    [Commands used to build a loadable module if different from building
+    a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+    [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+    [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+    [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+    [Flag to hardcode $libdir into a binary during linking.
+    This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
+    [[If ld is used when linking, flag to hardcode $libdir into a binary
+    during linking.  This must work even if $libdir does not exist]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+    [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary and the resulting library dependency is
+    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+    [Set to "yes" if building a shared library automatically hardcodes DIR
+    into the library and all subsequent libraries and executables linked
+    against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+    [Set to yes if linker adds runtime paths of dependent libraries
+    to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+    [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+    [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+    [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+    [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+    [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+    [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+    [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+    [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl    [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_SYS_DYNAMIC_LINKER($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+  LT_SYS_DLOPEN_SELF
+  _LT_CMD_STRIPLIB
+
+  # Report which library types will actually be built
+  AC_MSG_CHECKING([if libtool supports shared libraries])
+  AC_MSG_RESULT([$can_build_shared])
+
+  AC_MSG_CHECKING([whether to build shared libraries])
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[[4-9]]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  AC_MSG_RESULT([$enable_shared])
+
+  AC_MSG_CHECKING([whether to build static libraries])
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  AC_MSG_RESULT([$enable_static])
+
+  _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+else
+  _lt_caught_CXX_error=yes
+fi
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+    else
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+      LT_PATH_LD
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+         $GREP 'no-whole-archive' > /dev/null; then
+          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+    _LT_TAGVAR(ld_shlibs, $1)=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+      aix[[4-9]]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+           for ld_flag in $LDFLAGS; do
+             case $ld_flag in
+             *-brtl*)
+               aix_use_runtimelinking=yes
+               break
+               ;;
+             esac
+           done
+           ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        _LT_TAGVAR(archive_cmds, $1)=''
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[[012]]|aix4.[[012]].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" &&
+            strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+         then
+           # We have reworked collect2
+           :
+         else
+           # We have old collect2
+           _LT_TAGVAR(hardcode_direct, $1)=unsupported
+           # It fails to find uninstalled libraries when the uninstalled
+           # path is not listed in the libpath.  Setting hardcode_minus_L
+           # to unsupported forces relinking
+           _LT_TAGVAR(hardcode_minus_L, $1)=yes
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+          esac
+          shared_flag='-shared'
+         if test "$aix_use_runtimelinking" = yes; then
+           shared_flag="$shared_flag "'${wl}-G'
+         fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+         # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+         # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+          else
+           if test "$aix_use_runtimelinking" = yes; then
+             shared_flag='${wl}-G'
+           else
+             shared_flag='${wl}-bM:SRE'
+           fi
+          fi
+        fi
+
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+       # export.
+        _LT_TAGVAR(always_export_symbols, $1)=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          _LT_SYS_MODULE_PATH_AIX
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+           _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+           # Determine the default libpath from the value encoded in an
+           # empty executable.
+           _LT_SYS_MODULE_PATH_AIX
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+           # Warning - without using the other run time loading flags,
+           # -berok will link without error, but may produce a broken library.
+           _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+           _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+           if test "$with_gnu_ld" = yes; then
+             # We only use this code for GNU lds that support --whole-archive.
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           else
+             # Exported symbols can be pulled into shared objects from archives
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+           fi
+           _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+           # This is similar to how AIX traditionally builds its shared
+           # libraries.
+           _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+         _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+         # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+         # support --undefined.  This deserves some investigation.  FIXME
+         _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       else
+         _LT_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+         # FIXME: insert proper C++ library support
+         _LT_TAGVAR(ld_shlibs, $1)=no
+         ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32* | cegcc*)
+        # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+        # as there is no search path for DLLs.
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+        _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+        _LT_TAGVAR(always_export_symbols, $1)=no
+        _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+          # If the export-symbols file already is a .def file (1st line
+          # is EXPORTS), use it as is; otherwise, prepend...
+          _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+           cp $export_symbols $output_objdir/$soname.def;
+          else
+           echo EXPORTS > $output_objdir/$soname.def;
+           cat $export_symbols >> $output_objdir/$soname.def;
+          fi~
+          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        else
+          _LT_TAGVAR(ld_shlibs, $1)=no
+        fi
+        ;;
+      darwin* | rhapsody*)
+        _LT_DARWIN_LINKER_FEATURES($1)
+       ;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          ghcx*)
+           # Green Hills C++ Compiler
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      freebsd[[12]]*)
+        # C++ shared libraries reported to be fairly broken before
+       # switch to ELF
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      freebsd-elf*)
+        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      haiku*)
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        ;;
+
+      hpux9*)
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                            # but as the default
+                                            # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            _LT_TAGVAR(ld_shlibs, $1)=no
+            ;;
+          aCC*)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              _LT_TAGVAR(ld_shlibs, $1)=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+             _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            _LT_TAGVAR(hardcode_direct, $1)=no
+            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+            ;;
+          *)
+            _LT_TAGVAR(hardcode_direct, $1)=yes
+            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                                # but as the default
+                                                # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          aCC*)
+           case $host_cpu in
+             hppa*64*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             ia64*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+             *)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+               ;;
+           esac
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test $with_gnu_ld = no; then
+               case $host_cpu in
+                 hppa*64*)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 ia64*)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+                 *)
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+                   ;;
+               esac
+             fi
+           else
+             # FIXME: insert proper C++ library support
+             _LT_TAGVAR(ld_shlibs, $1)=no
+           fi
+           ;;
+        esac
+        ;;
+
+      interix[[3-9]]*)
+       _LT_TAGVAR(hardcode_direct, $1)=no
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+       # Instead, shared libraries are loaded at an image base (0x10000000 by
+       # default) and relocated if they conflict, which is a slow very memory
+       # consuming and fragmenting process.  To avoid this, we pick a random,
+       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+       ;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+           # SGI C++
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+           # Archives containing C++ object files must be created using
+           # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+           ;;
+          *)
+           if test "$GXX" = yes; then
+             if test "$with_gnu_ld" = no; then
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+             else
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+             fi
+           fi
+           _LT_TAGVAR(link_all_deplibs, $1)=yes
+           ;;
+        esac
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(inherit_rpath, $1)=yes
+        ;;
+
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+           # Archives containing C++ object files must be created using
+           # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+           ;;
+         icpc* | ecpc* )
+           # Intel C++
+           with_gnu_ld=yes
+           # version 8.0 and above of icpc choke on multiply defined symbols
+           # if we add $predep_objects and $postdep_objects, however 7.1 and
+           # earlier do not add the objects themselves.
+           case `$CC -V 2>&1` in
+             *"Version 7."*)
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+             *)  # Version 8.0 or newer
+               tmp_idyn=
+               case $host_cpu in
+                 ia64*) tmp_idyn=' -i_dynamic';;
+               esac
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+               ;;
+           esac
+           _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+           ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+           case `$CC -V` in
+           *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
+             _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+             _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+               $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+               $RANLIB $oldlib'
+             _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+               $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           *) # Version 6 and above use weak symbols
+             _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+             ;;
+           esac
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+         cxx*)
+           # Compaq C++
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+           runpath_var=LD_RUN_PATH
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+           ;;
+         xl* | mpixl* | bgxl*)
+           # IBM XL 8.0 on PPC, with GNU ld
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+           if test "x$supports_anon_versioning" = xyes; then
+             _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+               cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+               echo "local: *; };" >> $output_objdir/$libname.ver~
+               $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+           fi
+           ;;
+         *)
+           case `$CC -V 2>&1 | sed 5q` in
+           *Sun\ C*)
+             # Sun C++ 5.9
+             _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+             _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+             _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+             _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+             _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+             # Not sure whether something based on
+             # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+             # would be better.
+             output_verbose_link_cmd='func_echo_all'
+
+             # Archives containing C++ object files must be created using
+             # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+             # necessary to make sure instantiated templates are included
+             # in the archive.
+             _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+             ;;
+           esac
+           ;;
+       esac
+       ;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+         *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+       esac
+       ;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+         _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+         wlarc=
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       fi
+       # Workaround some broken pre-1.5 toolchains
+       output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+       ;;
+
+      *nto* | *qnx*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+       ;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+       _LT_TAGVAR(ld_shlibs, $1)=no
+       ;;
+
+      openbsd*)
+       if test -f /usr/libexec/ld.so; then
+         _LT_TAGVAR(hardcode_direct, $1)=yes
+         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+         _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+         if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+           _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+           _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+         fi
+         output_verbose_link_cmd=func_echo_all
+       else
+         _LT_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+           # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+           # KCC will only create a shared library if the output file
+           # ends with ".so" (or ".sl" for HP-UX), so rename the library
+           # to its proper name (with version) after linking.
+           _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Archives containing C++ object files must be created using
+           # the KAI C++ compiler.
+           case $host in
+             osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+             *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+           esac
+           ;;
+          RCC*)
+           # Rational C++ 2.4.1
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          cxx*)
+           case $host in
+             osf3*)
+               _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+               ;;
+             *)
+               _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+                 echo "-hidden">> $lib.exp~
+                 $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+                 $RM $lib.exp'
+               _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+               ;;
+           esac
+
+           _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           #
+           # There doesn't appear to be a way to prevent this compiler from
+           # explicitly linking system object files so we need to strip them
+           # from the output so that they don't get included in the library
+           # dependencies.
+           output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+           ;;
+         *)
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+             case $host in
+               osf3*)
+                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+               *)
+                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+                 ;;
+             esac
+
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+             _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+             # Commands to make compiler produce verbose output that lists
+             # what "hidden" libraries, object files and flags are used when
+             # linking a shared library.
+             output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+           else
+             # FIXME: insert proper C++ library support
+             _LT_TAGVAR(ld_shlibs, $1)=no
+           fi
+           ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+           # Sun C++ 4.x
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          lcc*)
+           # Lucid
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC* | sunCC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+           _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+           _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+             $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+           _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+           _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+           case $host_os in
+             solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+             *)
+               # The compiler driver will combine and reorder linker options,
+               # but understands `-z linker_flag'.
+               # Supported since Solaris 2.6 (maybe 2.5.1?)
+               _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+               ;;
+           esac
+           _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+           output_verbose_link_cmd='func_echo_all'
+
+           # Archives containing C++ object files must be created using
+           # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+           # necessary to make sure instantiated templates are included
+           # in the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+           ;;
+          gcx*)
+           # Green Hills C++ Compiler
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+           # The C++ compiler must be used to create the archive.
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+           ;;
+          *)
+           # GNU C++ compiler with Solaris linker
+           if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+             _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+             if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             else
+               # g++ 2.7 appears to require `-G' NOT `-shared' on this
+               # platform.
+               _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+               _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+                 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+               # Commands to make compiler produce verbose output that lists
+               # what "hidden" libraries, object files and flags are used when
+               # linking a shared library.
+               output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+             fi
+
+             _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+             case $host_os in
+               solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+               *)
+                 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+                 ;;
+             esac
+           fi
+           ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+       # Note: We can NOT use -z defs as we might desire, because we do not
+       # link with -lc, and that would cause any symbols used from libc to
+       # always be unresolved, which means just about no library would
+       # ever link correctly.  If we're not using GNU ld we use -z text
+       # though, which does catch some bad symbols but isn't as heavy-handed
+       # as -z defs.
+       _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+       _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+       _LT_TAGVAR(link_all_deplibs, $1)=yes
+       _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+       runpath_var='LD_RUN_PATH'
+
+       case $cc_basename in
+          CC*)
+           _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+             '"$_LT_TAGVAR(old_archive_cmds, $1)"
+           _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+             '"$_LT_TAGVAR(reload_cmds, $1)"
+           ;;
+         *)
+           _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+           ;;
+       esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+           # NonStop-UX NCC 3.20
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+          *)
+           # FIXME: insert proper C++ library support
+           _LT_TAGVAR(ld_shlibs, $1)=no
+           ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+    esac
+
+    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+_LT_EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+        prev=$p
+        continue
+       else
+        prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        case $p in
+        -L* | -R*)
+          # Internal compiler library paths should come after those
+          # provided the user.  The postdeps already come after the
+          # user supplied libs so there is no need to process them.
+          if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+            _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+          else
+            _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+          fi
+          ;;
+        # The "-l" case would never come before the object being
+        # linked, so don't bother handling this case.
+        esac
+       else
+        if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+          _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+        else
+          _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+        fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+        pre_test_object_deps_done=yes
+        continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+          _LT_TAGVAR(predep_objects, $1)="$p"
+        else
+          _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+        fi
+       else
+        if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+          _LT_TAGVAR(postdep_objects, $1)="$p"
+        else
+          _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+        fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_TAGVAR(predep_objects,$1)=
+  _LT_TAGVAR(postdep_objects,$1)=
+  _LT_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC* | sunCC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+    [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+    [Dependencies to place before and after the objects being linked to
+    create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+    [The library search path used internally by the compiler when linking
+    a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${F77-"f77"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+  GCC=$G77
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+       if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+         test "$enable_shared" = yes && enable_static=no
+       fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$G77"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_LANG_PUSH(Fortran)
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${FC-"f95"}
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
+
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+       if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+         test "$enable_shared" = yes && enable_static=no
+       fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+  :
+  _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+    [AC_CHECK_TOOL(GCJ, gcj,)
+      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "${1}" | $SED 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]+=\$[2]"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+    ;;
+  esac
+])
diff --git a/gnulib/m4/localcharset.m4 b/gnulib/m4/localcharset.m4
new file mode 100644 (file)
index 0000000..6801ca9
--- /dev/null
@@ -0,0 +1,17 @@
+# localcharset.m4 serial 7
+dnl Copyright (C) 2002, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LOCALCHARSET],
+[
+  dnl Prerequisites of lib/localcharset.c.
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_REQUIRE([gl_FCNTL_O_FLAGS])
+  AC_CHECK_DECLS_ONCE([getc_unlocked])
+
+  dnl Prerequisites of the lib/Makefile.am snippet.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([gl_GLIBC21])
+])
diff --git a/gnulib/m4/locale-fr.m4 b/gnulib/m4/locale-fr.m4
new file mode 100644 (file)
index 0000000..3f4f954
--- /dev/null
@@ -0,0 +1,246 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a french locale with traditional encoding.
+AC_DEFUN([gt_LOCALE_FR],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      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
+            # 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 AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+              if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr_FR.ISO8859-1
+              else
+                # Test for the HP-UX locale name.
+                if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_fr=fr_FR.iso88591
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_fr=fr
+                  else
+                    # None found.
+                    gt_cv_locale_fr=none
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_FR=$gt_cv_locale_fr
+  AC_SUBST([LOCALE_FR])
+])
+
+dnl Determine the name of a french locale with UTF-8 encoding.
+AC_DEFUN([gt_LOCALE_FR_UTF8],
+[
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+# if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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*
+  ])
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+  AC_SUBST([LOCALE_FR_UTF8])
+])
diff --git a/gnulib/m4/locale-ja.m4 b/gnulib/m4/locale-ja.m4
new file mode 100644 (file)
index 0000000..d44c2c8
--- /dev/null
@@ -0,0 +1,135 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a japanese locale with EUC-JP encoding.
+AC_DEFUN([gt_LOCALE_JA],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      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 locale name with explicit encoding suffix.
+            if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC-JP
+            else
+              # Test for the HP-UX, OSF/1, NetBSD locale name.
+              if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja_JP.eucJP
+              else
+                # Test for the IRIX, FreeBSD locale name.
+                if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                  gt_cv_locale_ja=ja_JP.EUC
+                else
+                  # Test for the Solaris 7 locale name.
+                  if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                    gt_cv_locale_ja=ja
+                  else
+                    # Special test for NetBSD 1.6.
+                    if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                      gt_cv_locale_ja=ja_JP.eucJP
+                    else
+                      # None found.
+                      gt_cv_locale_ja=none
+                    fi
+                  fi
+                fi
+              fi
+            fi
+          fi
+          ;;
+      esac
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_JA=$gt_cv_locale_ja
+  AC_SUBST([LOCALE_JA])
+])
diff --git a/gnulib/m4/locale-tr.m4 b/gnulib/m4/locale-tr.m4
new file mode 100644 (file)
index 0000000..19ded1b
--- /dev/null
@@ -0,0 +1,127 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a turkish locale with UTF-8 encoding.
+AC_DEFUN([gt_LOCALE_TR_UTF8],
+[
+  AC_REQUIRE([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([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  But BeOS does not
+     implement the Turkish upper-/lowercase mappings.  Therefore, let this
+     program return 1 on BeOS.  */
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the eighth month, the second
+     character (should be U+011F: LATIN SMALL LETTER G WITH BREVE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1992 - 1900; t.tm_mon = 8 - 1; t.tm_mday = 19;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc4 || buf[2] != (char) 0x9f)
+    return 1;
+  /* Check whether the upper-/lowercase mappings are as expected for
+     Turkish.  */
+  if (towupper ('i') != 0x0130 || towlower (0x0130) != 'i'
+      || towupper(0x0131) != 'I' || towlower ('I') != 0x0131)
+    return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      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
+          ;;
+        *)
+          # 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
+    rm -fr conftest*
+  ])
+  LOCALE_TR_UTF8=$gt_cv_locale_tr_utf8
+  AC_SUBST([LOCALE_TR_UTF8])
+])
diff --git a/gnulib/m4/locale-zh.m4 b/gnulib/m4/locale-zh.m4
new file mode 100644 (file)
index 0000000..e03f91f
--- /dev/null
@@ -0,0 +1,124 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a chinese locale with GB18030 encoding.
+AC_DEFUN([gt_LOCALE_ZH_CN],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+#if (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.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.
+     On MirBSD 10, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "UTF-8".  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
+        || strcmp (cs, "UTF-8") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding (except on MirBSD).  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      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.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+  AC_SUBST([LOCALE_ZH_CN])
+])
diff --git a/gnulib/m4/locale_h.m4 b/gnulib/m4/locale_h.m4
new file mode 100644 (file)
index 0000000..4d0f894
--- /dev/null
@@ -0,0 +1,101 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LOCALE_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
+
+  dnl Persuade glibc <locale.h> to define locale_t.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
+  AC_REQUIRE([gl_STDDEF_H])
+
+  AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
+    [gl_cv_header_locale_h_posix2001],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <locale.h>
+            int x = LC_MESSAGES;]],
+          [[]])],
+       [gl_cv_header_locale_h_posix2001=yes],
+       [gl_cv_header_locale_h_posix2001=no])])
+
+  dnl Check for <xlocale.h>.
+  AC_CHECK_HEADERS_ONCE([xlocale.h])
+  if test $ac_cv_header_xlocale_h = yes; then
+    HAVE_XLOCALE_H=1
+    dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
+    dnl e.g. on MacOS X 10.5. If <locale.h> does not define locale_t by
+    dnl itself, we assume that <xlocale.h> will do so.
+    AC_CACHE_CHECK([whether locale.h defines locale_t],
+      [gl_cv_header_locale_has_locale_t],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <locale.h>
+              locale_t x;]],
+            [[]])],
+         [gl_cv_header_locale_has_locale_t=yes],
+         [gl_cv_header_locale_has_locale_t=no])
+      ])
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      gl_cv_header_locale_h_needs_xlocale_h=no
+    else
+      gl_cv_header_locale_h_needs_xlocale_h=yes
+    fi
+  else
+    HAVE_XLOCALE_H=0
+    gl_cv_header_locale_h_needs_xlocale_h=no
+  fi
+  AC_SUBST([HAVE_XLOCALE_H])
+
+  dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_NEXT_HEADERS([locale.h])
+
+  if test -n "$STDDEF_H" \
+     || test $gl_cv_header_locale_h_posix2001 = no \
+     || test $gl_cv_header_locale_h_needs_xlocale_h = yes; then
+    gl_REPLACE_LOCALE_H
+  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([[#include <locale.h>
+/* Some systems provide declarations in a non-standard header.  */
+#if HAVE_XLOCALE_H
+# include <xlocale.h>
+#endif
+    ]],
+    [setlocale duplocale])
+])
+
+dnl Unconditionally enables the replacement of <locale.h>.
+AC_DEFUN([gl_REPLACE_LOCALE_H],
+[
+  dnl This is a no-op, because <locale.h> is always overridden.
+  :
+])
+
+AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_LOCALE_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_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])
+])
diff --git a/gnulib/m4/localename.m4 b/gnulib/m4/localename.m4
new file mode 100644 (file)
index 0000000..926ada6
--- /dev/null
@@ -0,0 +1,12 @@
+# localename.m4 serial 2
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LOCALENAME],
+[
+  AC_REQUIRE([gt_LC_MESSAGES])
+  AC_REQUIRE([gt_INTL_MACOSX])
+  AC_CHECK_FUNCS([setlocale uselocale])
+])
diff --git a/gnulib/m4/lock.m4 b/gnulib/m4/lock.m4
new file mode 100644 (file)
index 0000000..9686945
--- /dev/null
@@ -0,0 +1,41 @@
+# lock.m4 serial 11 (gettext-0.18.2)
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_LOCK],
+[
+  AC_REQUIRE([gl_THREADLIB])
+  if test "$gl_threads_api" = posix; then
+    # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
+    # pthread_rwlock_* functions.
+    AC_CHECK_TYPE([pthread_rwlock_t],
+      [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
+         [Define if the POSIX multithreading library has read/write locks.])],
+      [],
+      [#include <pthread.h>])
+    # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM(
+        [[#include <pthread.h>]],
+        [[
+#if __FreeBSD__ == 4
+error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
+#else
+int x = (int)PTHREAD_MUTEX_RECURSIVE;
+return !x;
+#endif
+        ]])],
+      [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
+         [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
+  fi
+  gl_PREREQ_LOCK
+])
+
+# Prerequisites of lib/lock.c.
+AC_DEFUN([gl_PREREQ_LOCK], [
+  AC_REQUIRE([AC_C_INLINE])
+])
diff --git a/gnulib/m4/longlong.m4 b/gnulib/m4/longlong.m4
new file mode 100644 (file)
index 0000000..aed816c
--- /dev/null
@@ -0,0 +1,113 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert.
+
+# Define HAVE_LONG_LONG_INT if 'long long int' works.
+# 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
+# defined. In this case you can treat 'long long int' like 'long int'.
+
+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_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'.])
+  fi
+])
+
+# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
+# 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
+# will not be defined. In this case you can treat 'unsigned long long int'
+# like 'unsigned long int'.
+
+AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
+[
+  AC_CACHE_CHECK([for unsigned long long int],
+    [ac_cv_type_unsigned_long_long_int],
+    [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'.])
+  fi
+])
+
+# Expands to a C program that can be used to test for simultaneous support
+# of 'long long' and 'unsigned long long'. We don't want to say that
+# 'long long' is available if 'unsigned long long' is not, or vice versa,
+# because too many programs rely on the symmetry between signed and unsigned
+# integer types (excluding 'bool').
+AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
+[
+  AC_LANG_PROGRAM(
+    [[/* For now, do not test the preprocessor; as of 2007 there are too many
+         implementations with broken preprocessors.  Perhaps this can
+         be revisited in 2012.  In the meantime, code should not expect
+         #if to work with literals wider than 32 bits.  */
+      /* Test literals.  */
+      long long int ll = 9223372036854775807ll;
+      long long int nll = -9223372036854775807LL;
+      unsigned long long int ull = 18446744073709551615ULL;
+      /* Test constant expressions.   */
+      typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
+                     ? 1 : -1)];
+      typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
+                     ? 1 : -1)];
+      int i = 63;]],
+    [[/* Test availability of runtime routines for shift and division.  */
+      long long int llmax = 9223372036854775807ll;
+      unsigned long long int ullmax = 18446744073709551615ull;
+      return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
+              | (llmax / ll) | (llmax % ll)
+              | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
+              | (ullmax / ull) | (ullmax % ull));]])
+])
diff --git a/gnulib/m4/lstat.m4 b/gnulib/m4/lstat.m4
new file mode 100644 (file)
index 0000000..b9b22a6
--- /dev/null
@@ -0,0 +1,69 @@
+# serial 21
+
+# Copyright (C) 1997-2001, 2003-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.
+
+dnl From Jim Meyering.
+
+AC_DEFUN([gl_FUNC_LSTAT],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  dnl If lstat does not exist, the replacement <sys/stat.h> does
+  dnl "#define lstat stat", and lstat.c is a no-op.
+  AC_CHECK_FUNCS_ONCE([lstat])
+  if test $ac_cv_func_lstat = yes; then
+    AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
+    if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
+      dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ([lstat]).
+      REPLACE_LSTAT=1
+    fi
+    # Prerequisites of lib/lstat.c.
+    AC_REQUIRE([AC_C_INLINE])
+  else
+    HAVE_LSTAT=0
+  fi
+])
+
+# Redefine AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, because it is no longer
+# maintained in Autoconf.
+AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
+[
+  AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
+    [ac_cv_func_lstat_dereferences_slashed_symlink],
+    [rm -f conftest.sym conftest.file
+     echo >conftest.file
+     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+            [AC_INCLUDES_DEFAULT],
+            [[struct stat sbuf;
+              /* Linux will dereference the symlink and fail, as required by
+                 POSIX.  That is better in the sense that it means we will not
+                 have to compile and use the lstat wrapper.  */
+              return lstat ("conftest.sym/", &sbuf) == 0;
+            ]])],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
+         [ac_cv_func_lstat_dereferences_slashed_symlink=no],
+         [# When cross-compiling, be pessimistic so we will end up using the
+          # replacement version of lstat that checks for trailing slashes and
+          # calls lstat a second time when necessary.
+          ac_cv_func_lstat_dereferences_slashed_symlink=no
+         ])
+     else
+       # If the 'ln -s' command failed, then we probably don't even
+       # have an lstat function.
+       ac_cv_func_lstat_dereferences_slashed_symlink=no
+     fi
+     rm -f conftest.sym conftest.file
+    ])
+  test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
+    AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
+      [Define to 1 if `lstat' dereferences a symlink specified
+       with a trailing slash.])
+  if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
+    AC_LIBOBJ([lstat])
+  fi
+])
diff --git a/gnulib/m4/ltoptions.m4 b/gnulib/m4/ltoptions.m4
new file mode 100644 (file)
index 0000000..17cfd51
--- /dev/null
@@ -0,0 +1,369 @@
+# Helper functions for option handling.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
+#   Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# 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.
+
+# serial 7 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+        _LT_MANGLE_DEFUN([$1], [$2]),
+    [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+           [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+                     [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME.  If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+    [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+  dnl
+  dnl Simply set some default values (i.e off) if boolean options were not
+  dnl specified:
+  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+  ])
+  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+  ])
+  dnl
+  dnl If no reference was made to various pairs of opposing options, then
+  dnl we run the default mode handler for the pair.  For example, if neither
+  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl archives by default:
+  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+                  [_LT_ENABLE_FAST_INSTALL])
+  ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS],      [1], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+       [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+    _LT_DECL([build_libtool_libs], [enable_shared], [0],
+       [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+       [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+    _LT_DECL([build_old_libs], [enable_static], [0],
+       [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+        [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+    [AS_HELP_STRING([--with-pic],
+       [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+                [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+                [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+                [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+                [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+                [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/gnulib/m4/ltsugar.m4 b/gnulib/m4/ltsugar.m4
new file mode 100644 (file)
index 0000000..9000a05
--- /dev/null
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# 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.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+       [$#], [2], [[$2]],
+       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+       [$#], 1, [],
+       [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+          m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+            [m4_foreach([_Lt_suffix],
+               ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+       [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+         [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+                [lt_append([$1], [$2], [$3])$4],
+                [$5])],
+         [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+       m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+       [$5],
+    [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+  [lt_join(m4_quote(m4_default([$4], [[, ]])),
+           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+                     [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/gnulib/m4/ltversion.m4 b/gnulib/m4/ltversion.m4
new file mode 100644 (file)
index 0000000..93fc771
--- /dev/null
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers                      -*- Autoconf -*-
+#
+#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004
+#
+# 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.
+
+# Generated from ltversion.in.
+
+# serial 3175 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.10])
+m4_define([LT_PACKAGE_REVISION], [1.3175])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.10'
+macro_revision='1.3175'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/gnulib/m4/lt~obsolete.m4 b/gnulib/m4/lt~obsolete.m4
new file mode 100644 (file)
index 0000000..c573da9
--- /dev/null
@@ -0,0 +1,98 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
+#
+# 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.
+
+# serial 5 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],  [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],             [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],        [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],         [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],    [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],           [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],             [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],    [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],           [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],       [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],               [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],        [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],    [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],    [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],         [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],            [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],  [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],             [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],            [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],    [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],   [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],          [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],            [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],           [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],  [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],    [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],          [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],          [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],                [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],     [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],          [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],   [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],           [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],           [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],           [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],  [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],      [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],    [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],    [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],        [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],    [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],     [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],         [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],       [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],        [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP],                [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],        [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH],   [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77],              [AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC],               [AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX],              [AC_DEFUN([_LT_PROG_CXX])])
diff --git a/gnulib/m4/malloc.m4 b/gnulib/m4/malloc.m4
new file mode 100644 (file)
index 0000000..8094444
--- /dev/null
@@ -0,0 +1,66 @@
+# malloc.m4 serial 12
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_FUNC_MALLOC_GNU
+# ------------------
+# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if
+# it is not.
+AC_DEFUN([gl_FUNC_MALLOC_GNU],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  dnl _AC_FUNC_MALLOC_IF is defined in Autoconf.
+  _AC_FUNC_MALLOC_IF(
+    [AC_DEFINE([HAVE_MALLOC_GNU], [1],
+               [Define to 1 if your system has a GNU libc compatible 'malloc'
+                function, and to 0 otherwise.])],
+    [AC_DEFINE([HAVE_MALLOC_GNU], [0])
+     gl_REPLACE_MALLOC
+    ])
+])
+
+# gl_FUNC_MALLOC_POSIX
+# --------------------
+# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
+# fails), and replace malloc if it is not.
+AC_DEFUN([gl_FUNC_MALLOC_POSIX],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+  if test $gl_cv_func_malloc_posix = yes; then
+    AC_DEFINE([HAVE_MALLOC_POSIX], [1],
+      [Define if the 'malloc' function is POSIX compliant.])
+  else
+    gl_REPLACE_MALLOC
+  fi
+])
+
+# Test whether malloc, realloc, calloc are POSIX compliant,
+# Set gl_cv_func_malloc_posix to yes or no accordingly.
+AC_DEFUN([gl_CHECK_MALLOC_POSIX],
+[
+  AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant],
+    [gl_cv_func_malloc_posix],
+    [
+      dnl It is too dangerous to try to allocate a large amount of memory:
+      dnl some systems go to their knees when you do that. So assume that
+      dnl all Unix implementations of the function are POSIX compliant.
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[]],
+           [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+             choke me
+             #endif
+            ]])],
+        [gl_cv_func_malloc_posix=yes],
+        [gl_cv_func_malloc_posix=no])
+    ])
+])
+
+AC_DEFUN([gl_REPLACE_MALLOC],
+[
+  AC_LIBOBJ([malloc])
+  REPLACE_MALLOC=1
+])
diff --git a/gnulib/m4/malloca.m4 b/gnulib/m4/malloca.m4
new file mode 100644 (file)
index 0000000..aec43f5
--- /dev/null
@@ -0,0 +1,15 @@
+# malloca.m4 serial 1
+dnl Copyright (C) 2003-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl 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_MALLOCA],
+[
+  dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables
+  dnl @ALLOCA@ and @LTALLOCA@.
+  dnl gl_FUNC_ALLOCA   dnl Already brought in by the module dependencies.
+  AC_REQUIRE([gl_EEMALLOC])
+  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+])
diff --git a/gnulib/m4/mbrtowc.m4 b/gnulib/m4/mbrtowc.m4
new file mode 100644 (file)
index 0000000..c353862
--- /dev/null
@@ -0,0 +1,564 @@
+# 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
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBRTOWC],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+
+  AC_CHECK_FUNCS_ONCE([mbrtowc])
+  if test $ac_cv_func_mbrtowc = no; then
+    HAVE_MBRTOWC=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_MBRTOWC=1
+    else
+      gl_MBRTOWC_NULL_ARG1
+      gl_MBRTOWC_NULL_ARG2
+      gl_MBRTOWC_RETVAL
+      gl_MBRTOWC_NUL_RETVAL
+      case "$gl_cv_func_mbrtowc_null_arg1" in
+        *yes) ;;
+        *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
+             [Define if the mbrtowc function has the NULL pwc argument bug.])
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_null_arg2" in
+        *yes) ;;
+        *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
+             [Define if the mbrtowc function has the NULL string argument bug.])
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_retval" in
+        *yes) ;;
+        *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
+             [Define if the mbrtowc function returns a wrong return value.])
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+      case "$gl_cv_func_mbrtowc_nul_retval" in
+        *yes) ;;
+        *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
+             [Define if the mbrtowc function does not return 0 for a NUL character.])
+           REPLACE_MBRTOWC=1
+           ;;
+      esac
+    fi
+  fi
+  if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([mbrtowc])
+    gl_PREREQ_MBRTOWC
+  fi
+])
+
+dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
+dnl redefines the semantics of the given mbstate_t type.
+dnl Result is REPLACE_MBSTATE_T.
+dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
+dnl avoid inconsistencies.
+
+AC_DEFUN([gl_MBSTATE_T_BROKEN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  AC_CHECK_FUNCS_ONCE([mbsinit])
+  AC_CHECK_FUNCS_ONCE([mbrtowc])
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+    gl_MBRTOWC_INCOMPLETE_STATE
+    gl_MBRTOWC_SANITYCHECK
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+    gl_REPLACE_WCHAR_H
+  fi
+])
+
+dnl Test whether mbrtowc puts the state into non-initial state when parsing an
+dnl incomplete multibyte character.
+dnl Result is gl_cv_func_mbrtowc_incomplete_state.
+
+AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_JA])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
+    [gl_cv_func_mbrtowc_incomplete_state],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                     # Guess no on AIX and OSF/1.
+        aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+                     # Guess yes otherwise.
+        *)           gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_JA != none; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}]])],
+          [gl_cv_func_mbrtowc_incomplete_state=yes],
+          [gl_cv_func_mbrtowc_incomplete_state=no],
+          [:])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc works not worse than mbtowc.
+dnl Result is gl_cv_func_mbrtowc_sanitycheck.
+
+AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_ZH_CN])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
+    [gl_cv_func_mbrtowc_sanitycheck],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_ZH_CN != none; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}]])],
+          [gl_cv_func_mbrtowc_sanitycheck=yes],
+          [gl_cv_func_mbrtowc_sanitycheck=no],
+          [:])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc supports a NULL pwc argument correctly.
+dnl Result is gl_cv_func_mbrtowc_null_arg1.
+
+AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR_UTF8])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
+    [gl_cv_func_mbrtowc_null_arg1],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                  # Guess no on Solaris.
+        solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
+                  # Guess yes otherwise.
+        *)        gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_FR_UTF8 != none; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      char input[] = "\303\237er";
+      mbstate_t state;
+      wchar_t wc;
+      size_t ret;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      wc = (wchar_t) 0xBADFACE;
+      ret = mbrtowc (&wc, input, 5, &state);
+      if (ret != 2)
+        result |= 1;
+      if (!mbsinit (&state))
+        result |= 2;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      ret = mbrtowc (NULL, input, 5, &state);
+      if (ret != 2) /* Solaris 7 fails here: ret is -1.  */
+        result |= 4;
+      if (!mbsinit (&state))
+        result |= 8;
+    }
+  return result;
+}]])],
+          [gl_cv_func_mbrtowc_null_arg1=yes],
+          [gl_cv_func_mbrtowc_null_arg1=no],
+          [:])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc supports a NULL string argument correctly.
+dnl Result is gl_cv_func_mbrtowc_null_arg2.
+
+AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR_UTF8])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
+    [gl_cv_func_mbrtowc_null_arg2],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+              # Guess no on OSF/1.
+        osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
+              # Guess yes otherwise.
+        *)    gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_FR_UTF8 != none; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+      int ret;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      wc = (wchar_t) 0xBADFACE;
+      mbrtowc (&wc, NULL, 5, &state);
+      /* Check that wc was not modified.  */
+      if (wc != (wchar_t) 0xBADFACE)
+        return 1;
+    }
+  return 0;
+}]])],
+          [gl_cv_func_mbrtowc_null_arg2=yes],
+          [gl_cv_func_mbrtowc_null_arg2=no],
+          [:])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc, when parsing the end of a multibyte character,
+dnl correctly returns the number of bytes that were needed to complete the
+dnl character (not the total number of bytes of the multibyte character).
+dnl Result is gl_cv_func_mbrtowc_retval.
+
+AC_DEFUN([gl_MBRTOWC_RETVAL],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR_UTF8])
+  AC_REQUIRE([gt_LOCALE_JA])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_CACHE_CHECK([whether mbrtowc has a correct return value],
+    [gl_cv_func_mbrtowc_retval],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                                   # Guess no on HP-UX, 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 \
+         || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+  int found_some_locale = 0;
+  /* This fails on Solaris.  */
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      char input[] = "B\303\274\303\237er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 1)
+            result |= 1;
+        }
+      found_some_locale = 1;
+    }
+  /* This fails on HP-UX 11.11.  */
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 2)
+            result |= 2;
+        }
+      found_some_locale = 1;
+    }
+  /* 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],
+          [if test $? != 77; then
+             gl_cv_func_mbrtowc_retval=no
+           fi
+          ],
+          [:])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
+dnl Result is gl_cv_func_mbrtowc_nul_retval.
+
+AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_ZH_CN])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
+    [gl_cv_func_mbrtowc_nul_retval],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                       # Guess no on Solaris 8 and 9.
+        solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
+                       # Guess yes otherwise.
+        *)             gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_ZH_CN != none; then
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8 and 9.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, "", 1, &state) != 0)
+        return 1;
+    }
+  return 0;
+}]])],
+          [gl_cv_func_mbrtowc_nul_retval=yes],
+          [gl_cv_func_mbrtowc_nul_retval=no],
+          [:])
+      fi
+    ])
+])
+
+# Prerequisites of lib/mbrtowc.c.
+AC_DEFUN([gl_PREREQ_MBRTOWC], [
+  :
+])
+
+
+dnl From Paul Eggert
+
+dnl This is an override of an autoconf macro.
+
+AC_DEFUN([AC_FUNC_MBRTOWC],
+[
+  dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
+  AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
+    gl_cv_func_mbrtowc,
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+            [[/* 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>]],
+            [[wchar_t wc;
+              char const s[] = "";
+              size_t n = 1;
+              mbstate_t state;
+              return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
+       gl_cv_func_mbrtowc=yes,
+       gl_cv_func_mbrtowc=no)])
+  if test $gl_cv_func_mbrtowc = yes; then
+    AC_DEFINE([HAVE_MBRTOWC], [1],
+      [Define to 1 if mbrtowc and mbstate_t are properly declared.])
+  fi
+])
diff --git a/gnulib/m4/mbsinit.m4 b/gnulib/m4/mbsinit.m4
new file mode 100644 (file)
index 0000000..47e2d14
--- /dev/null
@@ -0,0 +1,40 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBSINIT],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+
+  AC_CHECK_FUNCS_ONCE([mbsinit])
+  if test $ac_cv_func_mbsinit = no; then
+    HAVE_MBSINIT=0
+  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
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([mbsinit])
+    gl_PREREQ_MBSINIT
+  fi
+])
+
+# Prerequisites of lib/mbsinit.c.
+AC_DEFUN([gl_PREREQ_MBSINIT], [
+  :
+])
diff --git a/gnulib/m4/mbsrtowcs.m4 b/gnulib/m4/mbsrtowcs.m4
new file mode 100644 (file)
index 0000000..1fe8dcf
--- /dev/null
@@ -0,0 +1,145 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBSRTOWCS],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+
+  AC_CHECK_FUNCS_ONCE([mbsrtowcs])
+  if test $ac_cv_func_mbsrtowcs = no; then
+    HAVE_MBSRTOWCS=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_MBSRTOWCS=1
+    else
+      gl_MBSRTOWCS_WORKS
+      case "$gl_cv_func_mbsrtowcs_works" in
+        *yes) ;;
+        *) REPLACE_MBSRTOWCS=1 ;;
+      esac
+    fi
+  fi
+  if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([mbsrtowcs])
+    AC_LIBOBJ([mbsrtowcs-state])
+    gl_PREREQ_MBSRTOWCS
+  fi
+])
+
+dnl Test whether mbsrtowcs works.
+dnl Result is gl_cv_func_mbsrtowcs_works.
+
+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])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbsrtowcs works],
+    [gl_cv_func_mbsrtowcs_works],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                                   # Guess no on 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 != 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>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+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)
+    {
+      const char input[] = "B\303\274\303\237er";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 2;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 4)
+              result |= 2;
+          }
+    }
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "<\306\374\313\334\270\354>";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 4;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 3)
+              result |= 4;
+          }
+    }
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      const char input[] = "B\250\271\201\060\211\070er";
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2))
+        if (!mbsinit (&state))
+          {
+            const char *src = input + 2;
+            if (mbsrtowcs (NULL, &src, 10, &state) != 4)
+              result |= 8;
+          }
+    }
+  return result;
+}]])],
+          [gl_cv_func_mbsrtowcs_works=yes],
+          [gl_cv_func_mbsrtowcs_works=no],
+          [:])
+      fi
+    ])
+])
+
+# Prerequisites of lib/mbsrtowcs.c.
+AC_DEFUN([gl_PREREQ_MBSRTOWCS], [
+  :
+])
diff --git a/gnulib/m4/mbstate_t.m4 b/gnulib/m4/mbstate_t.m4
new file mode 100644 (file)
index 0000000..f7c46b8
--- /dev/null
@@ -0,0 +1,41 @@
+# mbstate_t.m4 serial 13
+dnl Copyright (C) 2000-2002, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# From Paul Eggert.
+
+# BeOS 5 has <wchar.h> but does not define mbstate_t,
+# so you can't declare an object of that type.
+# Check for this incompatibility with Standard C.
+
+# AC_TYPE_MBSTATE_T
+# -----------------
+AC_DEFUN([AC_TYPE_MBSTATE_T],
+[
+   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
+
+   AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
+     [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [AC_INCLUDES_DEFAULT[
+/* 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>]],
+           [[mbstate_t x; return sizeof x;]])],
+        [ac_cv_type_mbstate_t=yes],
+        [ac_cv_type_mbstate_t=no])])
+   if test $ac_cv_type_mbstate_t = yes; then
+     AC_DEFINE([HAVE_MBSTATE_T], [1],
+               [Define to 1 if <wchar.h> declares mbstate_t.])
+   else
+     AC_DEFINE([mbstate_t], [int],
+               [Define to a type if <wchar.h> does not define.])
+   fi
+])
diff --git a/gnulib/m4/mbtowc.m4 b/gnulib/m4/mbtowc.m4
new file mode 100644 (file)
index 0000000..9215892
--- /dev/null
@@ -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], [
+  :
+])
diff --git a/gnulib/m4/memchr.m4 b/gnulib/m4/memchr.m4
new file mode 100644 (file)
index 0000000..3c2b313
--- /dev/null
@@ -0,0 +1,88 @@
+# memchr.m4 serial 10
+dnl Copyright (C) 2002-2004, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
+[
+  dnl Check for prerequisites for memory fence checks.
+  gl_FUNC_MMAP_ANON
+  AC_CHECK_HEADERS_ONCE([sys/mman.h])
+  AC_CHECK_FUNCS_ONCE([mprotect])
+
+  dnl These days, we assume memchr is present.  But just in case...
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([memchr])
+  if test $ac_cv_func_memchr = yes; then
+    # Detect platform-specific bugs in some versions of glibc:
+    # memchr should not dereference anything with length 0
+    #   http://bugzilla.redhat.com/499689
+    # memchr should not dereference overestimated length after a match
+    #   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
+    #   http://sourceware.org/bugzilla/show_bug.cgi?id=10162
+    # Assume that memchr works on platforms that lack mprotect.
+    AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <string.h>
+#if HAVE_SYS_MMAN_H
+# include <fcntl.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/mman.h>
+# ifndef MAP_FILE
+#  define MAP_FILE 0
+# endif
+#endif
+]], [[
+  int result = 0;
+  char *fence = NULL;
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+# if HAVE_MAP_ANONYMOUS
+  const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+  const int fd = -1;
+# else /* !HAVE_MAP_ANONYMOUS */
+  const int flags = MAP_FILE | MAP_PRIVATE;
+  int fd = open ("/dev/zero", O_RDONLY, 0666);
+  if (fd >= 0)
+# endif
+    {
+      int pagesize = getpagesize ();
+      char *two_pages =
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
+      if (two_pages != (char *)(-1)
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        fence = two_pages + pagesize;
+    }
+#endif
+  if (fence)
+    {
+      if (memchr (fence, 0, 0))
+        result |= 1;
+      strcpy (fence - 9, "12345678");
+      if (memchr (fence - 9, 0, 79) != fence - 1)
+        result |= 2;
+      if (memchr (fence - 1, 0, 3) != fence - 1)
+        result |= 4;
+    }
+  return result;
+]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
+      [dnl Be pessimistic for now.
+       gl_cv_func_memchr_works="guessing no"])])
+    if test "$gl_cv_func_memchr_works" != yes; then
+      REPLACE_MEMCHR=1
+    fi
+  else
+    HAVE_MEMCHR=0
+  fi
+  if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+    AC_LIBOBJ([memchr])
+    gl_PREREQ_MEMCHR
+  fi
+])
+
+# Prerequisites of lib/memchr.c.
+AC_DEFUN([gl_PREREQ_MEMCHR], [
+  AC_CHECK_HEADERS([bp-sym.h])
+])
diff --git a/gnulib/m4/mempcpy.m4 b/gnulib/m4/mempcpy.m4
new file mode 100644 (file)
index 0000000..cc36900
--- /dev/null
@@ -0,0 +1,27 @@
+# mempcpy.m4 serial 10
+dnl Copyright (C) 2003-2004, 2006-2007, 2009-2011 Free Software Foundation,
+dnl 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_MEMPCPY],
+[
+  dnl Persuade glibc <string.h> to declare mempcpy().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'.
+  AC_REQUIRE([AC_C_RESTRICT])
+
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REPLACE_FUNCS([mempcpy])
+  if test $ac_cv_func_mempcpy = no; then
+    HAVE_MEMPCPY=0
+    gl_PREREQ_MEMPCPY
+  fi
+])
+
+# Prerequisites of lib/mempcpy.c.
+AC_DEFUN([gl_PREREQ_MEMPCPY], [
+  :
+])
diff --git a/gnulib/m4/mmap-anon.m4 b/gnulib/m4/mmap-anon.m4
new file mode 100644 (file)
index 0000000..7ba7fd2
--- /dev/null
@@ -0,0 +1,55 @@
+# mmap-anon.m4 serial 9
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Detect how mmap can be used to create anonymous (not file-backed) memory
+# mappings.
+# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
+#   and MAP_ANON exist and have the same value.
+# - On HP-UX, only MAP_ANONYMOUS exists.
+# - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists.
+# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
+#   used.
+
+AC_DEFUN([gl_FUNC_MMAP_ANON],
+[
+  dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
+  # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
+  # irrelevant for anonymous mappings.
+  AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no])
+
+  # Try to allow MAP_ANONYMOUS.
+  gl_have_mmap_anonymous=no
+  if test $gl_have_mmap = yes; then
+    AC_MSG_CHECKING([for MAP_ANONYMOUS])
+    AC_EGREP_CPP([I cant identify this map.], [
+#include <sys/mman.h>
+#ifdef MAP_ANONYMOUS
+    I cant identify this map.
+#endif
+],
+      [gl_have_mmap_anonymous=yes])
+    if test $gl_have_mmap_anonymous != yes; then
+      AC_EGREP_CPP([I cant identify this map.], [
+#include <sys/mman.h>
+#ifdef MAP_ANON
+    I cant identify this map.
+#endif
+],
+        [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
+          [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.])
+         gl_have_mmap_anonymous=yes])
+    fi
+    AC_MSG_RESULT([$gl_have_mmap_anonymous])
+    if test $gl_have_mmap_anonymous = yes; then
+      AC_DEFINE([HAVE_MAP_ANONYMOUS], [1],
+        [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including
+         config.h and <sys/mman.h>.])
+    fi
+  fi
+])
diff --git a/gnulib/m4/mode_t.m4 b/gnulib/m4/mode_t.m4
new file mode 100644 (file)
index 0000000..f9cf704
--- /dev/null
@@ -0,0 +1,26 @@
+# mode_t.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
+# include <sys/types.h>.
+
+# Define PROMOTED_MODE_T to the type that is the result of "default argument
+# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
+AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
+[
+  AC_REQUIRE([AC_TYPE_MODE_T])
+  AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
+    dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
+    dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
+    dnl standard, but we don't know of any real-world counterexamples.
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
+      [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
+      [gl_cv_promoted_mode_t='int'],
+      [gl_cv_promoted_mode_t='mode_t'])
+  ])
+  AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
+    [Define to the type that is the result of default argument promotions of type mode_t.])
+])
diff --git a/gnulib/m4/multiarch.m4 b/gnulib/m4/multiarch.m4
new file mode 100644 (file)
index 0000000..691d892
--- /dev/null
@@ -0,0 +1,62 @@
+# multiarch.m4 serial 6
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Determine whether the compiler is or may be producing universal binaries.
+#
+# On MacOS X 10.5 and later systems, the user can create libraries and
+# executables that work on multiple system types--known as "fat" or
+# "universal" binaries--by specifying multiple '-arch' options to the
+# compiler but only a single '-arch' option to the preprocessor.  Like
+# this:
+#
+#     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+#                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+#                 CPP="gcc -E" CXXCPP="g++ -E"
+#
+# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
+
+AC_DEFUN_ONCE([gl_MULTIARCH],
+[
+  dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
+  gl_cv_c_multiarch=no
+  AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE(
+      [[#ifndef __APPLE_CC__
+         not a universal capable compiler
+        #endif
+        typedef int dummy;
+      ]])],
+    [
+     dnl Check for potential -arch flags.  It is not universal unless
+     dnl there are at least two -arch flags with different values.
+     arch=
+     prev=
+     for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
+       if test -n "$prev"; then
+         case $word in
+           i?86 | x86_64 | ppc | ppc64)
+             if test -z "$arch" || test "$arch" = "$word"; then
+               arch="$word"
+             else
+               gl_cv_c_multiarch=yes
+             fi
+             ;;
+         esac
+         prev=
+       else
+         if test "x$word" = "x-arch"; then
+           prev=arch
+         fi
+       fi
+     done
+    ])
+  if test $gl_cv_c_multiarch = yes; then
+    APPLE_UNIVERSAL_BUILD=1
+  else
+    APPLE_UNIVERSAL_BUILD=0
+  fi
+  AC_SUBST([APPLE_UNIVERSAL_BUILD])
+])
diff --git a/gnulib/m4/nl_langinfo.m4 b/gnulib/m4/nl_langinfo.m4
new file mode 100644 (file)
index 0000000..ca9d28d
--- /dev/null
@@ -0,0 +1,52 @@
+# nl_langinfo.m4 serial 4
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NL_LANGINFO],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  AC_REQUIRE([gl_LANGINFO_H])
+  AC_CHECK_FUNCS_ONCE([nl_langinfo])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  if test $ac_cv_func_nl_langinfo = yes; then
+    # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
+    AC_CACHE_CHECK([whether YESEXPR works],
+      [gl_cv_func_nl_langinfo_yesexpr_works],
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+]], [[return !*nl_langinfo(YESEXPR);
+]])],
+         [gl_cv_func_nl_langinfo_yesexpr_works=yes],
+         [gl_cv_func_nl_langinfo_yesexpr_works=no],
+         [
+         case "$host_os" in
+                   # Guess no on irix systems.
+           irix*)  gl_cv_func_nl_langinfo_yesexpr_works="guessing no";;
+                   # Guess yes elsewhere.
+           *)      gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";;
+         esac
+         ])
+      ])
+    case $gl_cv_func_nl_langinfo_yesexpr_works in
+      *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;;
+      *)    FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;;
+    esac
+    AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
+      [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
+      [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
+    if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \
+        && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then
+      :
+    else
+      REPLACE_NL_LANGINFO=1
+      AC_DEFINE([REPLACE_NL_LANGINFO], [1],
+        [Define if nl_langinfo exists but is overridden by gnulib.])
+      AC_LIBOBJ([nl_langinfo])
+    fi
+  else
+    HAVE_NL_LANGINFO=0
+    AC_LIBOBJ([nl_langinfo])
+  fi
+])
diff --git a/gnulib/m4/onceonly.m4 b/gnulib/m4/onceonly.m4
new file mode 100644 (file)
index 0000000..223071a
--- /dev/null
@@ -0,0 +1,91 @@
+# onceonly.m4 serial 7
+dnl Copyright (C) 2002-2003, 2005-2006, 2008-2011 Free Software Foundation,
+dnl Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl This file defines some "once only" variants of standard autoconf macros.
+dnl   AC_CHECK_HEADERS_ONCE          like  AC_CHECK_HEADERS
+dnl   AC_CHECK_FUNCS_ONCE            like  AC_CHECK_FUNCS
+dnl   AC_CHECK_DECLS_ONCE            like  AC_CHECK_DECLS
+dnl   AC_REQUIRE([AC_FUNC_STRCOLL])  like  AC_FUNC_STRCOLL
+dnl The advantage is that the check for each of the headers/functions/decls
+dnl will be put only once into the 'configure' file. It keeps the size of
+dnl the 'configure' file down, and avoids redundant output when 'configure'
+dnl is run.
+dnl The drawback is that the checks cannot be conditionalized. If you write
+dnl   if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
+dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
+dnl empty, and the check will be inserted before the body of the AC_DEFUNed
+dnl function.
+
+dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
+dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
+dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
+dnl headers at once, thus reducing the size of 'configure'. It is known to work
+dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
+
+dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
+dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
+dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
+dnl argument!
+AC_PREREQ([2.59])
+
+# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
+# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
+AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
+  :
+  m4_foreach_w([gl_HEADER_NAME], [$1], [
+    AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
+                                                    [./-], [___])), [
+      m4_divert_text([INIT_PREPARE],
+        [gl_header_list="$gl_header_list gl_HEADER_NAME"])
+      gl_HEADERS_EXPANSION
+      AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
+        [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
+    ])
+    AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
+                                                      [./-], [___])))
+  ])
+])
+m4_define([gl_HEADERS_EXPANSION], [
+  m4_divert_text([DEFAULTS], [gl_header_list=])
+  AC_CHECK_HEADERS([$gl_header_list])
+  m4_define([gl_HEADERS_EXPANSION], [])
+])
+
+# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
+# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
+AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
+  :
+  m4_foreach_w([gl_FUNC_NAME], [$1], [
+    AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
+      m4_divert_text([INIT_PREPARE],
+        [gl_func_list="$gl_func_list gl_FUNC_NAME"])
+      gl_FUNCS_EXPANSION
+      AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
+        [Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.])
+    ])
+    AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
+  ])
+])
+m4_define([gl_FUNCS_EXPANSION], [
+  m4_divert_text([DEFAULTS], [gl_func_list=])
+  AC_CHECK_FUNCS([$gl_func_list])
+  m4_define([gl_FUNCS_EXPANSION], [])
+])
+
+# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
+# AC_CHECK_DECLS(DECL1, DECL2, ...).
+AC_DEFUN([AC_CHECK_DECLS_ONCE], [
+  :
+  m4_foreach_w([gl_DECL_NAME], [$1], [
+    AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
+      AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
+    ])
+    AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
+  ])
+])
diff --git a/gnulib/m4/open.m4 b/gnulib/m4/open.m4
new file mode 100644 (file)
index 0000000..bfebdab
--- /dev/null
@@ -0,0 +1,81 @@
+# open.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_OPEN],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  case "$host_os" in
+    mingw* | pw*)
+      gl_REPLACE_OPEN
+      ;;
+    *)
+      dnl open("foo/") should not create a file when the file name has a
+      dnl trailing slash.  FreeBSD only has the problem on symlinks.
+      AC_CHECK_FUNCS_ONCE([lstat])
+      AC_CACHE_CHECK([whether open recognizes a trailing slash],
+        [gl_cv_func_open_slash],
+        [# Assume that if we have lstat, we can also check symlinks.
+          if test $ac_cv_func_lstat = yes; then
+            touch conftest.tmp
+            ln -s conftest.tmp conftest.lnk
+          fi
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+int main ()
+{
+  int result = 0;
+#if HAVE_LSTAT
+  if (open ("conftest.lnk/", O_RDONLY) != -1)
+    result |= 1;
+#endif
+  if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
+    result |= 2;
+  return result;
+}]])],
+            [gl_cv_func_open_slash=yes],
+            [gl_cv_func_open_slash=no],
+            [
+changequote(,)dnl
+             case "$host_os" in
+               freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
+                 gl_cv_func_open_slash="guessing no" ;;
+               *)
+                 gl_cv_func_open_slash="guessing yes" ;;
+             esac
+changequote([,])dnl
+            ])
+          rm -f conftest.sl conftest.tmp conftest.lnk
+        ])
+      case "$gl_cv_func_open_slash" in
+        *no)
+          AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
+            [Define to 1 if open() fails to recognize a trailing slash.])
+          gl_REPLACE_OPEN
+          ;;
+      esac
+      ;;
+  esac
+])
+
+AC_DEFUN([gl_REPLACE_OPEN],
+[
+  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+  REPLACE_OPEN=1
+  AC_LIBOBJ([open])
+  gl_PREREQ_OPEN
+])
+
+# Prerequisites of lib/open.c.
+AC_DEFUN([gl_PREREQ_OPEN],
+[
+  AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
+  :
+])
diff --git a/gnulib/m4/pathmax.m4 b/gnulib/m4/pathmax.m4
new file mode 100644 (file)
index 0000000..17b3d64
--- /dev/null
@@ -0,0 +1,13 @@
+# pathmax.m4 serial 8
+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2011 Free Software Foundation,
+dnl 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_PATHMAX],
+[
+  dnl Prerequisites of lib/pathmax.h.
+  AC_CHECK_FUNCS_ONCE([pathconf])
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
+])
diff --git a/gnulib/m4/printf.m4 b/gnulib/m4/printf.m4
new file mode 100644 (file)
index 0000000..9c2ed1e
--- /dev/null
@@ -0,0 +1,1481 @@
+# printf.m4 serial 42
+dnl Copyright (C) 2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
+dnl 'L' size specifiers. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_sizes_c99.
+
+AC_DEFUN([gl_PRINTF_SIZES_C99],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
+    [gl_cv_func_printf_sizes_c99],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#if HAVE_STDINT_H_WITH_UINTMAX
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H_WITH_UINTMAX
+# include <inttypes.h>
+#endif
+static char buf[100];
+int main ()
+{
+  int result = 0;
+#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
+  buf[0] = '\0';
+  if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
+      || strcmp (buf, "12345671 33") != 0)
+    result |= 1;
+#endif
+  buf[0] = '\0';
+  if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
+      || strcmp (buf, "12345672 33") != 0)
+    result |= 2;
+  buf[0] = '\0';
+  if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
+      || strcmp (buf, "12345673 33") != 0)
+    result |= 4;
+  buf[0] = '\0';
+  if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
+      || strcmp (buf, "1.5 33") != 0)
+    result |= 8;
+  return result;
+}]])],
+        [gl_cv_func_printf_sizes_c99=yes],
+        [gl_cv_func_printf_sizes_c99=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_printf_sizes_c99="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_printf_sizes_c99="guessing no";;
+           darwin*)              gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # Guess yes on OpenBSD >= 3.9.
+           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
+                                 gl_cv_func_printf_sizes_c99="guessing no";;
+           openbsd*)             gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # Guess yes on Solaris >= 2.10.
+           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
+           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_printf_sizes_c99="guessing no";;
+           netbsd*)              gl_cv_func_printf_sizes_c99="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_printf_sizes_c99="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports 'long double'
+dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_long_double.
+
+AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports 'long double' arguments],
+    [gl_cv_func_printf_long_double],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[10000];
+int main ()
+{
+  int result = 0;
+  buf[0] = '\0';
+  if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
+      || strcmp (buf, "1.750000 33") != 0)
+    result |= 1;
+  buf[0] = '\0';
+  if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
+      || strcmp (buf, "1.750000e+00 33") != 0)
+    result |= 2;
+  buf[0] = '\0';
+  if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
+      || strcmp (buf, "1.75 33") != 0)
+    result |= 4;
+  return result;
+}]])],
+        [gl_cv_func_printf_long_double=yes],
+        [gl_cv_func_printf_long_double=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           beos*)        gl_cv_func_printf_long_double="guessing no";;
+           mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
+           *)            gl_cv_func_printf_long_double="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports infinite and NaN
+dnl 'double' arguments and negative zero arguments in the %f, %e, %g
+dnl directives. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_infinite.
+
+AC_DEFUN([gl_PRINTF_INFINITE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
+    [gl_cv_func_printf_infinite],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static int
+strisnan (const char *string, size_t start_index, size_t end_index)
+{
+  if (start_index < end_index)
+    {
+      if (string[start_index] == '-')
+        start_index++;
+      if (start_index + 3 <= end_index
+          && memcmp (string + start_index, "nan", 3) == 0)
+        {
+          start_index += 3;
+          if (start_index == end_index
+              || (string[start_index] == '(' && string[end_index - 1] == ')'))
+            return 1;
+        }
+    }
+  return 0;
+}
+static int
+have_minus_zero ()
+{
+  static double plus_zero = 0.0;
+  double minus_zero = - plus_zero;
+  return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0;
+}
+static char buf[10000];
+static double zero = 0.0;
+int main ()
+{
+  int result = 0;
+  if (sprintf (buf, "%f", 1.0 / 0.0) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%f", -1.0 / 0.0) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%f", zero / zero) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 2;
+  if (sprintf (buf, "%e", 1.0 / 0.0) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 4;
+  if (sprintf (buf, "%e", -1.0 / 0.0) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 4;
+  if (sprintf (buf, "%e", zero / zero) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 8;
+  if (sprintf (buf, "%g", 1.0 / 0.0) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 16;
+  if (sprintf (buf, "%g", -1.0 / 0.0) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 16;
+  if (sprintf (buf, "%g", zero / zero) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 32;
+  /* This test fails on HP-UX 10.20.  */
+  if (have_minus_zero ())
+    if (sprintf (buf, "%g", - zero) < 0
+        || strcmp (buf, "-0") != 0)
+    result |= 64;
+  return result;
+}]])],
+        [gl_cv_func_printf_infinite=yes],
+        [gl_cv_func_printf_infinite=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess yes on FreeBSD >= 6.
+           freebsd[1-5]*)        gl_cv_func_printf_infinite="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_printf_infinite="guessing no";;
+           darwin*)              gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess yes on HP-UX >= 11.
+           hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
+           hpux*)                gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_printf_infinite="guessing no";;
+           netbsd*)              gl_cv_func_printf_infinite="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_printf_infinite="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_printf_infinite="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports infinite and NaN
+dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_infinite_long_double.
+
+AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
+[
+  AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_BIGENDIAN])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  dnl The user can set or unset the variable gl_printf_safe to indicate
+  dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
+  if test -n "$gl_printf_safe"; then
+    AC_DEFINE([CHECK_PRINTF_SAFE], [1],
+      [Define if you wish *printf() functions that have a safe handling of
+       non-IEEE-754 'long double' values.])
+  fi
+  case "$gl_cv_func_printf_long_double" in
+    *yes)
+      AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
+        [gl_cv_func_printf_infinite_long_double],
+        [
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+]GL_NOCRASH[
+#include <float.h>
+#include <stdio.h>
+#include <string.h>
+static int
+strisnan (const char *string, size_t start_index, size_t end_index)
+{
+  if (start_index < end_index)
+    {
+      if (string[start_index] == '-')
+        start_index++;
+      if (start_index + 3 <= end_index
+          && memcmp (string + start_index, "nan", 3) == 0)
+        {
+          start_index += 3;
+          if (start_index == end_index
+              || (string[start_index] == '(' && string[end_index - 1] == ')'))
+            return 1;
+        }
+    }
+  return 0;
+}
+static char buf[10000];
+static long double zeroL = 0.0L;
+int main ()
+{
+  int result = 0;
+  nocrash_init();
+  if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 1;
+  if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Le", zeroL / zeroL) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 1;
+  if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
+      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
+      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
+    result |= 1;
+  if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
+      || !strisnan (buf, 0, strlen (buf)))
+    result |= 1;
+#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
+/* Representation of an 80-bit 'long double' as an initializer for a sequence
+   of 'unsigned int' words.  */
+# ifdef WORDS_BIGENDIAN
+#  define LDBL80_WORDS(exponent,manthi,mantlo) \
+     { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
+       ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16),    \
+       (unsigned int) (mantlo) << 16                                        \
+     }
+# else
+#  define LDBL80_WORDS(exponent,manthi,mantlo) \
+     { mantlo, manthi, exponent }
+# endif
+  { /* Quiet NaN.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+  }
+  {
+    /* Signalling NaN.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 2;
+  }
+  { /* Pseudo-NaN.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 4;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 4;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 4;
+  }
+  { /* Pseudo-Infinity.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 8;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 8;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 8;
+  }
+  { /* Pseudo-Zero.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 16;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 16;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 16;
+  }
+  { /* Unnormalized number.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 32;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 32;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 32;
+  }
+  { /* Pseudo-Denormal.  */
+    static union { unsigned int word[4]; long double value; } x =
+      { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
+    if (sprintf (buf, "%Lf", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 64;
+    if (sprintf (buf, "%Le", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 64;
+    if (sprintf (buf, "%Lg", x.value) < 0
+        || !strisnan (buf, 0, strlen (buf)))
+      result |= 64;
+  }
+#endif
+  return result;
+}]])],
+            [gl_cv_func_printf_infinite_long_double=yes],
+            [gl_cv_func_printf_infinite_long_double=no],
+            [
+changequote(,)dnl
+             case "$host_cpu" in
+                                     # Guess no on ia64, x86_64, i386.
+               ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
+               *)
+                 case "$host_os" in
+                                         # Guess yes on glibc systems.
+                   *-gnu*)               gl_cv_func_printf_infinite_long_double="guessing yes";;
+                                         # Guess yes on FreeBSD >= 6.
+                   freebsd[1-5]*)        gl_cv_func_printf_infinite_long_double="guessing no";;
+                   freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
+                                         # Guess yes on HP-UX >= 11.
+                   hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
+                   hpux*)                gl_cv_func_printf_infinite_long_double="guessing yes";;
+                                         # If we don't know, assume the worst.
+                   *)                    gl_cv_func_printf_infinite_long_double="guessing no";;
+                 esac
+                 ;;
+             esac
+changequote([,])dnl
+            ])
+        ])
+      ;;
+    *)
+      gl_cv_func_printf_infinite_long_double="irrelevant"
+      ;;
+  esac
+])
+
+dnl Test whether the *printf family of functions supports the 'a' and 'A'
+dnl conversion specifier for hexadecimal output of floating-point numbers.
+dnl (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_directive_a.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
+    [gl_cv_func_printf_directive_a],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  int result = 0;
+  if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
+      || (strcmp (buf, "0x1.922p+1 33") != 0
+          && strcmp (buf, "0x3.244p+0 33") != 0
+          && strcmp (buf, "0x6.488p-1 33") != 0
+          && strcmp (buf, "0xc.91p-2 33") != 0))
+    result |= 1;
+  if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
+      || (strcmp (buf, "-0X1.922P+1 33") != 0
+          && strcmp (buf, "-0X3.244P+0 33") != 0
+          && strcmp (buf, "-0X6.488P-1 33") != 0
+          && strcmp (buf, "-0XC.91P-2 33") != 0))
+    result |= 2;
+  /* This catches a FreeBSD 6.1 bug: it doesn't round.  */
+  if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
+      || (strcmp (buf, "0x1.83p+0 33") != 0
+          && strcmp (buf, "0x3.05p-1 33") != 0
+          && strcmp (buf, "0x6.0ap-2 33") != 0
+          && strcmp (buf, "0xc.14p-3 33") != 0))
+    result |= 4;
+  /* This catches a FreeBSD 6.1 bug.  See
+     <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
+  if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
+      || buf[0] == '0')
+    result |= 8;
+  /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug.  */
+  if (sprintf (buf, "%.1a", 1.999) < 0
+      || (strcmp (buf, "0x1.0p+1") != 0
+          && strcmp (buf, "0x2.0p+0") != 0
+          && strcmp (buf, "0x4.0p-1") != 0
+          && strcmp (buf, "0x8.0p-2") != 0))
+    result |= 16;
+  /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
+     glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>.  */
+  if (sprintf (buf, "%.1La", 1.999L) < 0
+      || (strcmp (buf, "0x1.0p+1") != 0
+          && strcmp (buf, "0x2.0p+0") != 0
+          && strcmp (buf, "0x4.0p-1") != 0
+          && strcmp (buf, "0x8.0p-2") != 0))
+    result |= 32;
+  return result;
+}]])],
+        [gl_cv_func_printf_directive_a=yes],
+        [gl_cv_func_printf_directive_a=no],
+        [
+         case "$host_os" in
+                                 # Guess yes on glibc >= 2.5 systems.
+           *-gnu*)
+             AC_EGREP_CPP([BZ2908], [
+               #include <features.h>
+               #ifdef __GNU_LIBRARY__
+                #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__
+                 BZ2908
+                #endif
+               #endif
+               ],
+               [gl_cv_func_printf_directive_a="guessing yes"],
+               [gl_cv_func_printf_directive_a="guessing no"])
+             ;;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_printf_directive_a="guessing no";;
+         esac
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports the %F format
+dnl directive. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_directive_f.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'F' directive],
+    [gl_cv_func_printf_directive_f],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  int result = 0;
+  if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
+      || strcmp (buf, "1234567.000000 33") != 0)
+    result |= 1;
+  if (sprintf (buf, "%F", 1.0 / 0.0) < 0
+      || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
+    result |= 2;
+  /* This catches a Cygwin 1.5.x bug.  */
+  if (sprintf (buf, "%.F", 1234.0) < 0
+      || strcmp (buf, "1234") != 0)
+    result |= 4;
+  return result;
+}]])],
+        [gl_cv_func_printf_directive_f=yes],
+        [gl_cv_func_printf_directive_f=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_printf_directive_f="guessing yes";;
+                                 # Guess yes on FreeBSD >= 6.
+           freebsd[1-5]*)        gl_cv_func_printf_directive_f="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_printf_directive_f="guessing no";;
+           darwin*)              gl_cv_func_printf_directive_f="guessing yes";;
+                                 # Guess yes on Solaris >= 2.10.
+           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
+           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_printf_directive_f="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports the %n format
+dnl directive. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_printf_directive_n.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'n' directive],
+    [gl_cv_func_printf_directive_n],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char fmtstring[10];
+static char buf[100];
+int main ()
+{
+  int count = -1;
+  /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
+     support %n in format strings in read-only memory but not in writable
+     memory.  */
+  strcpy (fmtstring, "%d %n");
+  if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
+      || strcmp (buf, "123 ") != 0
+      || count != 4)
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_printf_directive_n=yes],
+        [gl_cv_func_printf_directive_n=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           *)     gl_cv_func_printf_directive_n="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports the %ls format
+dnl directive and in particular, when a precision is specified, whether
+dnl the functions stop converting the wide string argument when the number
+dnl of bytes that have been produced by this conversion equals or exceeds
+dnl the precision.
+dnl Result is gl_cv_func_printf_directive_ls.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'ls' directive],
+    [gl_cv_func_printf_directive_ls],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+#include <string.h>
+int main ()
+{
+  int result = 0;
+  char buf[100];
+  /* Test whether %ls works at all.
+     This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
+     Cygwin 1.5.  */
+  {
+    static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%ls", wstring) < 0
+        || strcmp (buf, "abc") != 0)
+      result |= 1;
+  }
+  /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
+     assertion failure inside libc), but not on OpenBSD 4.0.  */
+  {
+    static const wchar_t wstring[] = { 'a', 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%ls", wstring) < 0
+        || strcmp (buf, "a") != 0)
+      result |= 2;
+  }
+  /* Test whether precisions in %ls are supported as specified in ISO C 99
+     section 7.19.6.1:
+       "If a precision is specified, no more than that many bytes are written
+        (including shift sequences, if any), and the array shall contain a
+        null wide character if, to equal the multibyte character sequence
+        length given by the precision, the function would need to access a
+        wide character one past the end of the array."
+     This test fails on Solaris 10.  */
+  {
+    static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%.2ls", wstring) < 0
+        || strcmp (buf, "ab") != 0)
+      result |= 8;
+  }
+  return result;
+}]])],
+        [gl_cv_func_printf_directive_ls=yes],
+        [gl_cv_func_printf_directive_ls=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           openbsd*)        gl_cv_func_printf_directive_ls="guessing no";;
+           irix*)           gl_cv_func_printf_directive_ls="guessing no";;
+           solaris*)        gl_cv_func_printf_directive_ls="guessing no";;
+           cygwin*)         gl_cv_func_printf_directive_ls="guessing no";;
+           beos* | haiku*)  gl_cv_func_printf_directive_ls="guessing no";;
+           *)               gl_cv_func_printf_directive_ls="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports POSIX/XSI format
+dnl strings with positions. (POSIX:2001)
+dnl Result is gl_cv_func_printf_positions.
+
+AC_DEFUN([gl_PRINTF_POSITIONS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
+    [gl_cv_func_printf_positions],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+/* The string "%2$d %1$d", with dollar characters protected from the shell's
+   dollar expansion (possibly an autoconf bug).  */
+static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
+static char buf[100];
+int main ()
+{
+  sprintf (buf, format, 33, 55);
+  return (strcmp (buf, "55 33") != 0);
+}]])],
+        [gl_cv_func_printf_positions=yes],
+        [gl_cv_func_printf_positions=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
+                         gl_cv_func_printf_positions="guessing no";;
+           beos*)        gl_cv_func_printf_positions="guessing no";;
+           mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
+           *)            gl_cv_func_printf_positions="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports POSIX/XSI format
+dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
+dnl Result is gl_cv_func_printf_flag_grouping.
+
+AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the grouping flag],
+    [gl_cv_func_printf_flag_grouping],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  if (sprintf (buf, "%'d %d", 1234567, 99) < 0
+      || buf[strlen (buf) - 1] != '9')
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_printf_flag_grouping=yes],
+        [gl_cv_func_printf_flag_grouping=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           cygwin*)      gl_cv_func_printf_flag_grouping="guessing no";;
+           netbsd*)      gl_cv_func_printf_flag_grouping="guessing no";;
+           mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
+           *)            gl_cv_func_printf_flag_grouping="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports the - flag correctly.
+dnl (ISO C99.) See
+dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html>
+dnl Result is gl_cv_func_printf_flag_leftadjust.
+
+AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
+    [gl_cv_func_printf_flag_leftadjust],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  /* Check that a '-' flag is not annihilated by a negative width.  */
+  if (sprintf (buf, "a%-*sc", -3, "b") < 0
+      || strcmp (buf, "ab  c") != 0)
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_printf_flag_leftadjust=yes],
+        [gl_cv_func_printf_flag_leftadjust=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                    # Guess yes on HP-UX 11.
+           hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
+                    # Guess no on HP-UX 10 and older.
+           hpux*)   gl_cv_func_printf_flag_leftadjust="guessing no";;
+                    # Guess yes otherwise.
+           *)       gl_cv_func_printf_flag_leftadjust="guessing yes";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports padding of non-finite
+dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
+dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
+dnl Result is gl_cv_func_printf_flag_zero.
+
+AC_DEFUN([gl_PRINTF_FLAG_ZERO],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the zero flag correctly],
+    [gl_cv_func_printf_flag_zero],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
+      || (strcmp (buf, "       inf") != 0
+          && strcmp (buf, "  infinity") != 0))
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_printf_flag_zero=yes],
+        [gl_cv_func_printf_flag_zero=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                   # Guess yes on glibc systems.
+           *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
+                   # Guess yes on BeOS.
+           beos*)  gl_cv_func_printf_flag_zero="guessing yes";;
+                   # If we don't know, assume the worst.
+           *)      gl_cv_func_printf_flag_zero="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions supports large precisions.
+dnl On mingw, precisions larger than 512 are treated like 512, in integer,
+dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
+dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
+dnl precisions larger than 510 in floating-point output yield wrong results.
+dnl On BeOS, precisions larger than 1044 crash the program.
+dnl Result is gl_cv_func_printf_precision.
+
+AC_DEFUN([gl_PRINTF_PRECISION],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports large precisions],
+    [gl_cv_func_printf_precision],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[5000];
+int main ()
+{
+  int result = 0;
+#ifdef __BEOS__
+  /* On BeOS, this would crash and show a dialog box.  Avoid the crash.  */
+  return 1;
+#endif
+  if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
+    result |= 1;
+  if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
+    result |= 2;
+  if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
+      || buf[0] != '1')
+    result |= 4;
+  return result;
+}]])],
+        [gl_cv_func_printf_precision=yes],
+        [gl_cv_func_printf_precision=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+           # Guess no only on Solaris, native Win32, and BeOS systems.
+           solaris*)     gl_cv_func_printf_precision="guessing no" ;;
+           mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
+           beos*)        gl_cv_func_printf_precision="guessing no" ;;
+           *)            gl_cv_func_printf_precision="guessing yes" ;;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the *printf family of functions recovers gracefully in case
+dnl of an out-of-memory condition, or whether it crashes the entire program.
+dnl Result is gl_cv_func_printf_enomem.
+
+AC_DEFUN([gl_PRINTF_ENOMEM],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_MULTIARCH])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
+    [gl_cv_func_printf_enomem],
+    [
+      gl_cv_func_printf_enomem="guessing no"
+      if test "$cross_compiling" = no; then
+        if test $APPLE_UNIVERSAL_BUILD = 0; then
+          AC_LANG_CONFTEST([AC_LANG_SOURCE([
+]GL_NOCRASH[
+changequote(,)dnl
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+int main()
+{
+  struct rlimit limit;
+  int ret;
+  nocrash_init ();
+  /* Some printf implementations allocate temporary space with malloc.  */
+  /* On BSD systems, malloc() is limited by RLIMIT_DATA.  */
+#ifdef RLIMIT_DATA
+  if (getrlimit (RLIMIT_DATA, &limit) < 0)
+    return 77;
+  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
+    limit.rlim_max = 5000000;
+  limit.rlim_cur = limit.rlim_max;
+  if (setrlimit (RLIMIT_DATA, &limit) < 0)
+    return 77;
+#endif
+  /* On Linux systems, malloc() is limited by RLIMIT_AS.  */
+#ifdef RLIMIT_AS
+  if (getrlimit (RLIMIT_AS, &limit) < 0)
+    return 77;
+  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
+    limit.rlim_max = 5000000;
+  limit.rlim_cur = limit.rlim_max;
+  if (setrlimit (RLIMIT_AS, &limit) < 0)
+    return 77;
+#endif
+  /* Some printf implementations allocate temporary space on the stack.  */
+#ifdef RLIMIT_STACK
+  if (getrlimit (RLIMIT_STACK, &limit) < 0)
+    return 77;
+  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
+    limit.rlim_max = 5000000;
+  limit.rlim_cur = limit.rlim_max;
+  if (setrlimit (RLIMIT_STACK, &limit) < 0)
+    return 77;
+#endif
+  ret = printf ("%.5000000f", 1.0);
+  return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
+}
+changequote([,])dnl
+          ])])
+          if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+            (./conftest
+             result=$?
+             if test $result != 0 && test $result != 77; then result=1; fi
+             exit $result
+            ) >/dev/null 2>/dev/null
+            case $? in
+              0) gl_cv_func_printf_enomem="yes" ;;
+              77) gl_cv_func_printf_enomem="guessing no" ;;
+              *) gl_cv_func_printf_enomem="no" ;;
+            esac
+          else
+            gl_cv_func_printf_enomem="guessing no"
+          fi
+          rm -fr conftest*
+        else
+          dnl A universal build on Apple MacOS X platforms.
+          dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
+          dnl But we need a configuration result that is valid in both modes.
+          gl_cv_func_printf_enomem="guessing no"
+        fi
+      fi
+      if test "$gl_cv_func_printf_enomem" = "guessing no"; then
+changequote(,)dnl
+        case "$host_os" in
+                    # Guess yes on glibc systems.
+          *-gnu*)   gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on Solaris.
+          solaris*) gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on AIX.
+          aix*)     gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on HP-UX/hppa.
+          hpux*)    case "$host_cpu" in
+                      hppa*) gl_cv_func_printf_enomem="guessing yes";;
+                      *)     gl_cv_func_printf_enomem="guessing no";;
+                    esac
+                    ;;
+                    # Guess yes on IRIX.
+          irix*)    gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on OSF/1.
+          osf*)     gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on BeOS.
+          beos*)    gl_cv_func_printf_enomem="guessing yes";;
+                    # Guess yes on Haiku.
+          haiku*)   gl_cv_func_printf_enomem="guessing yes";;
+                    # If we don't know, assume the worst.
+          *)        gl_cv_func_printf_enomem="guessing no";;
+        esac
+changequote([,])dnl
+      fi
+    ])
+])
+
+dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
+dnl Result is ac_cv_func_snprintf.
+
+AC_DEFUN([gl_SNPRINTF_PRESENCE],
+[
+  AC_CHECK_FUNCS_ONCE([snprintf])
+])
+
+dnl Test whether the string produced by the snprintf function is always NUL
+dnl terminated. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_snprintf_truncation_c99.
+
+AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
+    [gl_cv_func_snprintf_truncation_c99],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  strcpy (buf, "ABCDEF");
+  snprintf (buf, 3, "%d %d", 4567, 89);
+  if (memcmp (buf, "45\0DEF", 6) != 0)
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_snprintf_truncation_c99=yes],
+        [gl_cv_func_snprintf_truncation_c99=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_snprintf_truncation_c99="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_snprintf_truncation_c99="guessing no";;
+           darwin*)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on OpenBSD >= 3.9.
+           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
+                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
+           openbsd*)             gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on Solaris >= 2.6.
+           solaris2.[0-5] | solaris2.[0-5].*)
+                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
+           solaris*)             gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on AIX >= 4.
+           aix[1-3]*)            gl_cv_func_snprintf_truncation_c99="guessing no";;
+           aix*)                 gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on HP-UX >= 11.
+           hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
+           hpux*)                gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on IRIX >= 6.5.
+           irix6.5)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on OSF/1 >= 5.
+           osf[3-4]*)            gl_cv_func_snprintf_truncation_c99="guessing no";;
+           osf*)                 gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
+           netbsd*)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_snprintf_truncation_c99="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_snprintf_truncation_c99="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the return value of the snprintf function is the number
+dnl of bytes (excluding the terminating NUL) that would have been produced
+dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
+dnl For example, this test program fails on IRIX 6.5:
+dnl     ---------------------------------------------------------------------
+dnl     #include <stdio.h>
+dnl     int main()
+dnl     {
+dnl       static char buf[8];
+dnl       int retval = snprintf (buf, 3, "%d", 12345);
+dnl       return retval >= 0 && retval < 3;
+dnl     }
+dnl     ---------------------------------------------------------------------
+dnl Result is gl_cv_func_snprintf_retval_c99.
+
+AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
+    [gl_cv_func_snprintf_retval_c99],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char buf[100];
+int main ()
+{
+  strcpy (buf, "ABCDEF");
+  if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
+    return 1;
+  if (snprintf (buf, 0, "%d %d", 4567, 89) != 7)
+    return 2;
+  if (snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
+    return 3;
+  return 0;
+}]])],
+        [gl_cv_func_snprintf_retval_c99=yes],
+        [gl_cv_func_snprintf_retval_c99=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_snprintf_retval_c99="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_snprintf_retval_c99="guessing no";;
+           darwin*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on OpenBSD >= 3.9.
+           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
+                                 gl_cv_func_snprintf_retval_c99="guessing no";;
+           openbsd*)             gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on Solaris >= 2.10.
+           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
+           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
+                                 # Guess yes on AIX >= 4.
+           aix[1-3]*)            gl_cv_func_snprintf_retval_c99="guessing no";;
+           aix*)                 gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_snprintf_retval_c99="guessing no";;
+           netbsd*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_snprintf_retval_c99="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_snprintf_retval_c99="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the snprintf function supports the %n format directive
+dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
+dnl Result is gl_cv_func_snprintf_directive_n.
+
+AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
+    [gl_cv_func_snprintf_directive_n],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+static char fmtstring[10];
+static char buf[100];
+int main ()
+{
+  int count = -1;
+  /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
+     support %n in format strings in read-only memory but not in writable
+     memory.  */
+  strcpy (fmtstring, "%d %n");
+  snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
+  if (count != 6)
+    return 1;
+  return 0;
+}]])],
+        [gl_cv_func_snprintf_directive_n=yes],
+        [gl_cv_func_snprintf_directive_n=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_snprintf_directive_n="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_snprintf_directive_n="guessing no";;
+           darwin*)              gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on Solaris >= 2.6.
+           solaris2.[0-5] | solaris2.[0-5].*)
+                                 gl_cv_func_snprintf_directive_n="guessing no";;
+           solaris*)             gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on AIX >= 4.
+           aix[1-3]*)            gl_cv_func_snprintf_directive_n="guessing no";;
+           aix*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on IRIX >= 6.5.
+           irix6.5)              gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on OSF/1 >= 5.
+           osf[3-4]*)            gl_cv_func_snprintf_directive_n="guessing no";;
+           osf*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_snprintf_directive_n="guessing no";;
+           netbsd*)              gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_snprintf_directive_n="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_snprintf_directive_n="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl Test whether the snprintf function, when passed a size = 1, writes any
+dnl output without bounds in this case, behaving like sprintf. This is the
+dnl case on Linux libc5.
+dnl Result is gl_cv_func_snprintf_size1.
+
+AC_DEFUN([gl_SNPRINTF_SIZE1],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([whether snprintf respects a size of 1],
+    [gl_cv_func_snprintf_size1],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdio.h>
+int main()
+{
+  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
+  snprintf (buf, 1, "%d", 12345);
+  return buf[1] != 'E';
+}]])],
+        [gl_cv_func_snprintf_size1=yes],
+        [gl_cv_func_snprintf_size1=no],
+        [gl_cv_func_snprintf_size1="guessing yes"])
+    ])
+])
+
+dnl Test whether the vsnprintf function, when passed a zero size, produces no
+dnl output. (ISO C99, POSIX:2001)
+dnl For example, snprintf nevertheless writes a NUL byte in this case
+dnl on OSF/1 5.1:
+dnl     ---------------------------------------------------------------------
+dnl     #include <stdio.h>
+dnl     int main()
+dnl     {
+dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
+dnl       snprintf (buf, 0, "%d", 12345);
+dnl       return buf[0] != 'D';
+dnl     }
+dnl     ---------------------------------------------------------------------
+dnl And vsnprintf writes any output without bounds in this case, behaving like
+dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
+dnl     ---------------------------------------------------------------------
+dnl     #include <stdarg.h>
+dnl     #include <stdio.h>
+dnl     static int my_snprintf (char *buf, int size, const char *format, ...)
+dnl     {
+dnl       va_list args;
+dnl       int ret;
+dnl       va_start (args, format);
+dnl       ret = vsnprintf (buf, size, format, args);
+dnl       va_end (args);
+dnl       return ret;
+dnl     }
+dnl     int main()
+dnl     {
+dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
+dnl       my_snprintf (buf, 0, "%d", 12345);
+dnl       return buf[0] != 'D';
+dnl     }
+dnl     ---------------------------------------------------------------------
+dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
+
+AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
+    [gl_cv_func_vsnprintf_zerosize_c99],
+    [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdarg.h>
+#include <stdio.h>
+static int my_snprintf (char *buf, int size, const char *format, ...)
+{
+  va_list args;
+  int ret;
+  va_start (args, format);
+  ret = vsnprintf (buf, size, format, args);
+  va_end (args);
+  return ret;
+}
+int main()
+{
+  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
+  my_snprintf (buf, 0, "%d", 12345);
+  return buf[0] != 'D';
+}]])],
+        [gl_cv_func_vsnprintf_zerosize_c99=yes],
+        [gl_cv_func_vsnprintf_zerosize_c99=no],
+        [
+changequote(,)dnl
+         case "$host_os" in
+                                 # Guess yes on glibc systems.
+           *-gnu*)               gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on FreeBSD >= 5.
+           freebsd[1-4]*)        gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+           freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on MacOS X >= 10.3.
+           darwin[1-6].*)        gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+           darwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on Cygwin.
+           cygwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on Solaris >= 2.6.
+           solaris2.[0-5] | solaris2.[0-5].*)
+                                 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+           solaris*)             gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on AIX >= 4.
+           aix[1-3]*)            gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+           aix*)                 gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on IRIX >= 6.5.
+           irix6.5)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on NetBSD >= 3.
+           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
+                                 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+           netbsd*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on BeOS.
+           beos*)                gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # Guess yes on mingw.
+           mingw* | pw*)         gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+                                 # If we don't know, assume the worst.
+           *)                    gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
+         esac
+changequote([,])dnl
+        ])
+    ])
+])
+
+dnl The results of these tests on various platforms are:
+dnl
+dnl 1 = gl_PRINTF_SIZES_C99
+dnl 2 = gl_PRINTF_LONG_DOUBLE
+dnl 3 = gl_PRINTF_INFINITE
+dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
+dnl 5 = gl_PRINTF_DIRECTIVE_A
+dnl 6 = gl_PRINTF_DIRECTIVE_F
+dnl 7 = gl_PRINTF_DIRECTIVE_N
+dnl 8 = gl_PRINTF_DIRECTIVE_LS
+dnl 9 = gl_PRINTF_POSITIONS
+dnl 10 = gl_PRINTF_FLAG_GROUPING
+dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
+dnl 12 = gl_PRINTF_FLAG_ZERO
+dnl 13 = gl_PRINTF_PRECISION
+dnl 14 = gl_PRINTF_ENOMEM
+dnl 15 = gl_SNPRINTF_PRESENCE
+dnl 16 = gl_SNPRINTF_TRUNCATION_C99
+dnl 17 = gl_SNPRINTF_RETVAL_C99
+dnl 18 = gl_SNPRINTF_DIRECTIVE_N
+dnl 19 = gl_SNPRINTF_SIZE1
+dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl
+dnl 1 = checking whether printf supports size specifiers as in C99...
+dnl 2 = checking whether printf supports 'long double' arguments...
+dnl 3 = checking whether printf supports infinite 'double' arguments...
+dnl 4 = checking whether printf supports infinite 'long double' arguments...
+dnl 5 = checking whether printf supports the 'a' and 'A' directives...
+dnl 6 = checking whether printf supports the 'F' directive...
+dnl 7 = checking whether printf supports the 'n' directive...
+dnl 8 = checking whether printf supports the 'ls' directive...
+dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
+dnl 10 = checking whether printf supports the grouping flag...
+dnl 11 = checking whether printf supports the left-adjust flag correctly...
+dnl 12 = checking whether printf supports the zero flag correctly...
+dnl 13 = checking whether printf supports large precisions...
+dnl 14 = checking whether printf survives out-of-memory conditions...
+dnl 15 = checking for snprintf...
+dnl 16 = checking whether snprintf truncates the result as in C99...
+dnl 17 = checking whether snprintf returns a byte count as in C99...
+dnl 18 = checking whether snprintf fully supports the 'n' directive...
+dnl 19 = checking whether snprintf respects a size of 1...
+dnl 20 = checking whether vsnprintf respects a zero size as in C99...
+dnl
+dnl . = yes, # = no.
+dnl
+dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
+dnl   glibc 2.5                      .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   glibc 2.3.6                    .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
+dnl   MacOS X 10.5.8                 .  .  .  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   MacOS X 10.3.9                 .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
+dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  #  .  #  .  #  .  #  .  .  .  .  .  .
+dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  .  .  ?  .  .  .  .  .  ?  .  .  .  .  .  .
+dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
+dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  .  .  .  .  .  .
+dnl   Solaris 11 2010-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .
+dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  #  .  .  .  #  .  .  .
+dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  #  #  #  #  #  #
+dnl   AIX 5.2, 7.1                   .  .  #  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  .
+dnl   HP-UX 11.31                    .  .  .  .  #  .  .  .  .  .  .  #  .  .  .  .  #  #  .  .
+dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  .  .  .  .  .  #  .  .  .  .  #  #  .  #
+dnl   HP-UX 10.20                    #  .  #  .  #  #  .  ?  .  .  #  #  .  .  .  .  #  #  ?  #
+dnl   IRIX 6.5                       #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  #  .  .  .
+dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  #
+dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  .  #  .  .  #  #  #  #  #  #
+dnl   NetBSD 5.0                     .  .  .  #  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
+dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  ?  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?
+dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  .  .  .  .  .  .
+dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  .  .  ?  .  .  .
+dnl   BeOS                           #  #  .  #  #  #  .  ?  #  .  ?  .  #  ?  .  .  ?  .  .  .
+dnl   mingw                          #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .
diff --git a/gnulib/m4/putenv.m4 b/gnulib/m4/putenv.m4
new file mode 100644 (file)
index 0000000..de3900b
--- /dev/null
@@ -0,0 +1,41 @@
+# putenv.m4 serial 17
+dnl Copyright (C) 2002-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.
+
+dnl From Jim Meyering.
+dnl
+dnl Check whether putenv ("FOO") removes FOO from the environment.
+dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
+
+AC_DEFUN([gl_FUNC_PUTENV],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
+   [gl_cv_func_svid_putenv],
+   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[
+    /* Put it in env.  */
+    if (putenv ("CONFTEST_putenv=val"))
+      return 1;
+
+    /* Try to remove it.  */
+    if (putenv ("CONFTEST_putenv"))
+      return 2;
+
+    /* Make sure it was deleted.  */
+    if (getenv ("CONFTEST_putenv") != 0)
+      return 3;
+
+    return 0;
+              ]])],
+             gl_cv_func_svid_putenv=yes,
+             gl_cv_func_svid_putenv=no,
+             dnl When crosscompiling, assume putenv is broken.
+             gl_cv_func_svid_putenv=no)
+   ])
+  if test $gl_cv_func_svid_putenv = no; then
+    REPLACE_PUTENV=1
+    AC_LIBOBJ([putenv])
+  fi
+])
diff --git a/gnulib/m4/readlink.m4 b/gnulib/m4/readlink.m4
new file mode 100644 (file)
index 0000000..a502ca5
--- /dev/null
@@ -0,0 +1,62 @@
+# readlink.m4 serial 9
+dnl Copyright (C) 2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_READLINK],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([readlink])
+  if test $ac_cv_func_readlink = no; then
+    HAVE_READLINK=0
+    AC_LIBOBJ([readlink])
+    gl_PREREQ_READLINK
+  else
+    AC_CACHE_CHECK([whether readlink signature is correct],
+      [gl_cv_decl_readlink_works],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+           [[#include <unistd.h>
+      /* Cause compilation failure if original declaration has wrong type.  */
+      ssize_t readlink (const char *, char *, size_t);]])],
+         [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])])
+    dnl Solaris 9 ignores trailing slash.
+    dnl FreeBSD 7.2 dereferences only one level of links with trailing slash.
+    AC_CACHE_CHECK([whether readlink handles trailing slash correctly],
+      [gl_cv_func_readlink_works],
+      [# We have readlink, so assume ln -s works.
+       ln -s conftest.no-such conftest.link
+       ln -s conftest.link conftest.lnk2
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+           [[#include <unistd.h>
+]], [[char buf[20];
+      return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])],
+         [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no],
+         [gl_cv_func_readlink_works="guessing no"])
+      rm -f conftest.link conftest.lnk2])
+    if test "$gl_cv_func_readlink_works" != yes; then
+      AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink
+        fails to recognize a trailing slash.])
+      REPLACE_READLINK=1
+      AC_LIBOBJ([readlink])
+    elif test "$gl_cv_decl_readlink_works" != yes; then
+      REPLACE_READLINK=1
+      AC_LIBOBJ([readlink])
+    fi
+  fi
+])
+
+# Like gl_FUNC_READLINK, except prepare for separate compilation (no AC_LIBOBJ).
+AC_DEFUN([gl_FUNC_READLINK_SEPARATE],
+[
+  AC_CHECK_FUNCS_ONCE([readlink])
+  gl_PREREQ_READLINK
+])
+
+# Prerequisites of lib/readlink.c.
+AC_DEFUN([gl_PREREQ_READLINK],
+[
+  :
+])
diff --git a/gnulib/m4/realloc.m4 b/gnulib/m4/realloc.m4
new file mode 100644 (file)
index 0000000..a403d9f
--- /dev/null
@@ -0,0 +1,44 @@
+# realloc.m4 serial 11
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_FUNC_REALLOC_GNU
+# -------------------
+# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace
+# realloc if it is not.
+AC_DEFUN([gl_FUNC_REALLOC_GNU],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  dnl _AC_FUNC_REALLOC_IF is defined in Autoconf.
+  _AC_FUNC_REALLOC_IF(
+    [AC_DEFINE([HAVE_REALLOC_GNU], [1],
+               [Define to 1 if your system has a GNU libc compatible 'realloc'
+                function, and to 0 otherwise.])],
+    [AC_DEFINE([HAVE_REALLOC_GNU], [0])
+     gl_REPLACE_REALLOC
+    ])
+])# gl_FUNC_REALLOC_GNU
+
+# gl_FUNC_REALLOC_POSIX
+# ---------------------
+# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
+# fails), and replace realloc if it is not.
+AC_DEFUN([gl_FUNC_REALLOC_POSIX],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+  if test $gl_cv_func_malloc_posix = yes; then
+    AC_DEFINE([HAVE_REALLOC_POSIX], [1],
+      [Define if the 'realloc' function is POSIX compliant.])
+  else
+    gl_REPLACE_REALLOC
+  fi
+])
+
+AC_DEFUN([gl_REPLACE_REALLOC],
+[
+  AC_LIBOBJ([realloc])
+  REPLACE_REALLOC=1
+])
diff --git a/gnulib/m4/regex.m4 b/gnulib/m4/regex.m4
new file mode 100644 (file)
index 0000000..24198b5
--- /dev/null
@@ -0,0 +1,225 @@
+# serial 58
+
+# Copyright (C) 1996-2001, 2003-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.
+
+dnl Initially derived from code in GNU grep.
+dnl Mostly written by Jim Meyering.
+
+AC_PREREQ([2.50])
+
+AC_DEFUN([gl_REGEX],
+[
+  AC_ARG_WITH([included-regex],
+    [AS_HELP_STRING([--without-included-regex],
+                    [don't compile regex; this is the default on systems
+                     with recent-enough versions of the GNU C Library
+                     (use with caution on other systems).])])
+
+  case $with_included_regex in #(
+  yes|no) ac_use_included_regex=$with_included_regex
+        ;;
+  '')
+    # If the system regex support is good enough that it passes the
+    # following run test, then default to *not* using the included regex.c.
+    # If cross compiling, assume the test would fail and use the included
+    # regex.c.
+    AC_CACHE_CHECK([for working re_compile_pattern],
+                   [gl_cv_func_re_compile_pattern_working],
+      [AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM(
+          [AC_INCLUDES_DEFAULT[
+           #include <locale.h>
+           #include <limits.h>
+           #include <regex.h>
+           ]],
+          [[int result = 0;
+            static struct re_pattern_buffer regex;
+            unsigned char folded_chars[UCHAR_MAX + 1];
+            int i;
+            const char *s;
+            struct re_registers regs;
+
+            /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
+               This test needs valgrind to catch the bug on Debian
+               GNU/Linux 3.1 x86, but it might catch the bug better
+               on other platforms and it shouldn't hurt to try the
+               test here.  */
+            if (setlocale (LC_ALL, "en_US.UTF-8"))
+              {
+                static char const pat[] = "insert into";
+                static char const data[] =
+                  "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
+                re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
+                               | RE_ICASE);
+                memset (&regex, 0, sizeof regex);
+                s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+                if (s)
+                  result |= 1;
+                else if (re_search (&regex, data, sizeof data - 1,
+                                    0, sizeof data - 1, &regs)
+                         != -1)
+                  result |= 1;
+                if (! setlocale (LC_ALL, "C"))
+                  return 1;
+              }
+
+            /* This test is from glibc bug 3957, reported by Andrew Mackey.  */
+            re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("a[^x]b", 6, &regex);
+            if (s)
+              result |= 2;
+            /* This should fail, but succeeds for glibc-2.5.  */
+            else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
+              result |= 2;
+
+            /* This regular expression is from Spencer ere test number 75
+               in grep-2.3.  */
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+            memset (&regex, 0, sizeof regex);
+            for (i = 0; i <= UCHAR_MAX; i++)
+              folded_chars[i] = i;
+            regex.translate = folded_chars;
+            s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
+            /* This should fail with _Invalid character class name_ error.  */
+            if (!s)
+              result |= 4;
+
+            /* Ensure that [b-a] is diagnosed as invalid, when
+               using RE_NO_EMPTY_RANGES. */
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("a[b-a]", 6, &regex);
+            if (s == 0)
+              result |= 8;
+
+            /* This should succeed, but does not for glibc-2.1.3.  */
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("{1", 2, &regex);
+            if (s)
+              result |= 8;
+
+            /* The following example is derived from a problem report
+               against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("[an\371]*n", 7, &regex);
+            if (s)
+              result |= 8;
+            /* This should match, but does not for glibc-2.2.1.  */
+            else if (re_match (&regex, "an", 2, 0, &regs) != 2)
+              result |= 8;
+
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("x", 1, &regex);
+            if (s)
+              result |= 8;
+            /* glibc-2.2.93 does not work with a negative RANGE argument.  */
+            else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
+              result |= 8;
+
+            /* The version of regex.c in older versions of gnulib
+               ignored RE_ICASE.  Detect that problem too.  */
+            re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("x", 1, &regex);
+            if (s)
+              result |= 16;
+            else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
+              result |= 16;
+
+            /* Catch a bug reported by Vin Shelton in
+               http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html
+               */
+            re_set_syntax (RE_SYNTAX_POSIX_BASIC
+                           & ~RE_CONTEXT_INVALID_DUP
+                           & ~RE_NO_EMPTY_RANGES);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex);
+            if (s)
+              result |= 32;
+
+            /* REG_STARTEND was added to glibc on 2004-01-15.
+               Reject older versions.  */
+            if (! REG_STARTEND)
+              result |= 64;
+
+#if 0
+            /* It would be nice to reject hosts whose regoff_t values are too
+               narrow (including glibc on hosts with 64-bit ptrdiff_t and
+               32-bit int), but we should wait until glibc implements this
+               feature.  Otherwise, support for equivalence classes and
+               multibyte collation symbols would always be broken except
+               when compiling --without-included-regex.   */
+            if (sizeof (regoff_t) < sizeof (ptrdiff_t)
+                || sizeof (regoff_t) < sizeof (ssize_t))
+              result |= 64;
+#endif
+
+            return result;
+          ]])],
+       [gl_cv_func_re_compile_pattern_working=yes],
+       [gl_cv_func_re_compile_pattern_working=no],
+       dnl When crosscompiling, assume it is not working.
+       [gl_cv_func_re_compile_pattern_working=no])])
+    case $gl_cv_func_re_compile_pattern_working in #(
+    yes) ac_use_included_regex=no;; #(
+    no) ac_use_included_regex=yes;;
+    esac
+    ;;
+  *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
+    ;;
+  esac
+
+  if test $ac_use_included_regex = yes; then
+    AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
+      [Define if you want regoff_t to be at least as wide POSIX requires.])
+    AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
+      [Define to rpl_re_syntax_options if the replacement should be used.])
+    AC_DEFINE([re_set_syntax], [rpl_re_set_syntax],
+      [Define to rpl_re_set_syntax if the replacement should be used.])
+    AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern],
+      [Define to rpl_re_compile_pattern if the replacement should be used.])
+    AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap],
+      [Define to rpl_re_compile_fastmap if the replacement should be used.])
+    AC_DEFINE([re_search], [rpl_re_search],
+      [Define to rpl_re_search if the replacement should be used.])
+    AC_DEFINE([re_search_2], [rpl_re_search_2],
+      [Define to rpl_re_search_2 if the replacement should be used.])
+    AC_DEFINE([re_match], [rpl_re_match],
+      [Define to rpl_re_match if the replacement should be used.])
+    AC_DEFINE([re_match_2], [rpl_re_match_2],
+      [Define to rpl_re_match_2 if the replacement should be used.])
+    AC_DEFINE([re_set_registers], [rpl_re_set_registers],
+      [Define to rpl_re_set_registers if the replacement should be used.])
+    AC_DEFINE([re_comp], [rpl_re_comp],
+      [Define to rpl_re_comp if the replacement should be used.])
+    AC_DEFINE([re_exec], [rpl_re_exec],
+      [Define to rpl_re_exec if the replacement should be used.])
+    AC_DEFINE([regcomp], [rpl_regcomp],
+      [Define to rpl_regcomp if the replacement should be used.])
+    AC_DEFINE([regexec], [rpl_regexec],
+      [Define to rpl_regexec if the replacement should be used.])
+    AC_DEFINE([regerror], [rpl_regerror],
+      [Define to rpl_regerror if the replacement should be used.])
+    AC_DEFINE([regfree], [rpl_regfree],
+      [Define to rpl_regfree if the replacement should be used.])
+    AC_LIBOBJ([regex])
+    gl_PREREQ_REGEX
+  fi
+])
+
+# Prerequisites of lib/regex.c and lib/regex_internal.c.
+AC_DEFUN([gl_PREREQ_REGEX],
+[
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+  AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([AC_C_RESTRICT])
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  AC_CHECK_HEADERS([libintl.h])
+  AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll])
+  AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
+])
diff --git a/gnulib/m4/safe-alloc.m4 b/gnulib/m4/safe-alloc.m4
new file mode 100644 (file)
index 0000000..cdd3928
--- /dev/null
@@ -0,0 +1,9 @@
+# safe-alloc.m4 serial 1
+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,
+dnl with or without modifications, as long as this notice is preserved.
+AC_DEFUN([gl_SAFE_ALLOC],
+[
+  AC_LIBOBJ([safe-alloc])
+])
diff --git a/gnulib/m4/selinux-context-h.m4 b/gnulib/m4/selinux-context-h.m4
new file mode 100644 (file)
index 0000000..227ab6b
--- /dev/null
@@ -0,0 +1,21 @@
+# serial 2   -*- Autoconf -*-
+# Copyright (C) 2006-2007, 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
+# Provide <selinux/context.h>, if necessary.
+
+AC_DEFUN([gl_HEADERS_SELINUX_CONTEXT_H],
+[
+  AC_REQUIRE([gl_LIBSELINUX])
+  if test "$with_selinux" != no; then
+    AC_CHECK_HEADERS([selinux/context.h],
+                     [SELINUX_CONTEXT_H=],
+                     [SELINUX_CONTEXT_H=selinux/context.h])
+  else
+    SELINUX_CONTEXT_H=selinux/context.h
+  fi
+  AC_SUBST([SELINUX_CONTEXT_H])
+])
diff --git a/gnulib/m4/selinux-selinux-h.m4 b/gnulib/m4/selinux-selinux-h.m4
new file mode 100644 (file)
index 0000000..7afd416
--- /dev/null
@@ -0,0 +1,70 @@
+# serial 4   -*- Autoconf -*-
+# Copyright (C) 2006-2007, 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
+# Provide <selinux/selinux.h>, if necessary.
+# If it is already present, provide wrapper functions to guard against
+# misbehavior from getfilecon, lgetfilecon, and fgetfilecon.
+
+AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
+[
+  AC_REQUIRE([gl_LIBSELINUX])
+  if test "$with_selinux" != no; then
+    AC_CHECK_HEADERS([selinux/selinux.h])
+
+    if test "$ac_cv_header_selinux_selinux_h" = yes; then
+      # We do have <selinux/selinux.h>, so do compile getfilecon.c
+      # and arrange to use its wrappers.
+      AC_LIBOBJ([getfilecon])
+      gl_CHECK_NEXT_HEADERS([selinux/selinux.h])
+      AC_DEFINE([getfilecon], [rpl_getfilecon],
+                [Always use our getfilecon wrapper.])
+      AC_DEFINE([lgetfilecon], [rpl_lgetfilecon],
+                [Always use our lgetfilecon wrapper.])
+      AC_DEFINE([fgetfilecon], [rpl_fgetfilecon],
+                [Always use our fgetfilecon wrapper.])
+    fi
+
+    case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
+      no:*) # already warned
+        ;;
+      *:no)
+        AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
+        AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
+    esac
+  else
+    # Do as if <selinux/selinux.h> does not exist, even if
+    # AC_CHECK_HEADERS_ONCE has already determined that it exists.
+    AC_DEFINE([HAVE_SELINUX_SELINUX_H], [0])
+  fi
+])
+
+AC_DEFUN([gl_LIBSELINUX],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AC_CANONICAL_BUILD])
+
+  AC_ARG_WITH([selinux],
+    AS_HELP_STRING([--without-selinux], [do not use SELinux, even on systems with SELinux]),
+    [], [with_selinux=maybe])
+
+  LIB_SELINUX=
+  if test "$with_selinux" != no; then
+    gl_save_LIBS=$LIBS
+    AC_SEARCH_LIBS([setfilecon], [selinux],
+                   [test "$ac_cv_search_setfilecon" = "none required" ||
+                    LIB_SELINUX=$ac_cv_search_setfilecon])
+    LIBS=$gl_save_LIBS
+  fi
+  AC_SUBST([LIB_SELINUX])
+
+  # Warn if SELinux is found but libselinux is absent;
+  if test "$ac_cv_search_setfilecon" = no &&
+     test "$host" = "$build" && test -d /selinux; then
+    AC_MSG_WARN([This system supports SELinux but libselinux is missing.])
+    AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
+  fi
+])
diff --git a/gnulib/m4/setenv.m4 b/gnulib/m4/setenv.m4
new file mode 100644 (file)
index 0000000..ba619b0
--- /dev/null
@@ -0,0 +1,149 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_SETENV],
+[
+  AC_REQUIRE([gl_FUNC_SETENV_SEPARATE])
+  if test $HAVE_SETENV$REPLACE_SETENV != 10; then
+    AC_LIBOBJ([setenv])
+  fi
+])
+
+# Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
+AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_CHECK_DECLS_ONCE([setenv])
+  if test $ac_cv_have_decl_setenv = no; then
+    HAVE_DECL_SETENV=0
+  fi
+  AC_CHECK_FUNCS_ONCE([setenv])
+  if test $ac_cv_func_setenv = no; then
+    HAVE_SETENV=0
+  else
+    AC_CACHE_CHECK([whether setenv validates arguments],
+      [gl_cv_func_setenv_works],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+       #include <stdlib.h>
+       #include <errno.h>
+       #include <string.h>
+      ]], [[
+       int result = 0;
+       {
+         if (setenv ("", "", 0) != -1)
+           result |= 1;
+         else if (errno != EINVAL)
+           result |= 2;
+       }
+       {
+         if (setenv ("a", "=", 1) != 0)
+           result |= 4;
+         else if (strcmp (getenv ("a"), "=") != 0)
+           result |= 8;
+       }
+       return result;
+      ]])],
+      [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
+      [gl_cv_func_setenv_works="guessing no"])])
+    if test "$gl_cv_func_setenv_works" != yes; then
+      REPLACE_SETENV=1
+      AC_LIBOBJ([setenv])
+    fi
+  fi
+  gl_PREREQ_SETENV
+])
+
+AC_DEFUN([gl_FUNC_UNSETENV],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  AC_CHECK_DECLS_ONCE([unsetenv])
+  if test $ac_cv_have_decl_unsetenv = no; then
+    HAVE_DECL_UNSETENV=0
+  fi
+  AC_CHECK_FUNCS([unsetenv])
+  if test $ac_cv_func_unsetenv = no; then
+    AC_LIBOBJ([unsetenv])
+    gl_PREREQ_UNSETENV
+  else
+    dnl Some BSDs return void, failing to do error checking.
+    AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[
+#undef _BSD
+#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
+#include <stdlib.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+int unsetenv (const char *name);
+#else
+int unsetenv();
+#endif
+            ]],
+            [[]])],
+         [gt_cv_func_unsetenv_ret='int'],
+         [gt_cv_func_unsetenv_ret='void'])])
+    if test $gt_cv_func_unsetenv_ret = 'void'; then
+      AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void
+       instead of int.])
+      REPLACE_UNSETENV=1
+      AC_LIBOBJ([unsetenv])
+    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 entry1[] = "a=1";
+       char entry2[] = "b=2";
+       char *env[] = { entry1, entry2, NULL };
+       if (putenv ((char *) "a=1")) return 1;
+       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"])])
+    if test "$gl_cv_func_unsetenv_works" != yes; then
+      REPLACE_UNSETENV=1
+      AC_LIBOBJ([unsetenv])
+    fi
+  fi
+])
+
+# Prerequisites of lib/setenv.c.
+AC_DEFUN([gl_PREREQ_SETENV],
+[
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_REQUIRE([gl_ENVIRON])
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_CHECK_HEADERS([search.h])
+  AC_CHECK_FUNCS([tsearch])
+])
+
+# Prerequisites of lib/unsetenv.c.
+AC_DEFUN([gl_PREREQ_UNSETENV],
+[
+  AC_REQUIRE([gl_ENVIRON])
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+])
diff --git a/gnulib/m4/setlocale.m4 b/gnulib/m4/setlocale.m4
new file mode 100644 (file)
index 0000000..6672c34
--- /dev/null
@@ -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],
+[
+  :
+])
diff --git a/gnulib/m4/size_max.m4 b/gnulib/m4/size_max.m4
new file mode 100644 (file)
index 0000000..e807098
--- /dev/null
@@ -0,0 +1,79 @@
+# size_max.m4 serial 10
+dnl Copyright (C) 2003, 2005-2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_SIZE_MAX],
+[
+  AC_CHECK_HEADERS([stdint.h])
+  dnl First test whether the system already has SIZE_MAX.
+  AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [
+    gl_cv_size_max=
+    AC_EGREP_CPP([Found it], [
+#include <limits.h>
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef SIZE_MAX
+Found it
+#endif
+], [gl_cv_size_max=yes])
+    if test -z "$gl_cv_size_max"; then
+      dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
+      dnl than the type 'unsigned long'. Try hard to find a definition that can
+      dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
+      AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1],
+        [#include <stddef.h>
+#include <limits.h>], [size_t_bits_minus_1=])
+      AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)],
+        [#include <stddef.h>], [fits_in_uint=])
+      if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
+        if test $fits_in_uint = 1; then
+          dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
+          dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
+          AC_COMPILE_IFELSE(
+            [AC_LANG_PROGRAM(
+               [[#include <stddef.h>
+                 extern size_t foo;
+                 extern unsigned long foo;
+               ]],
+               [[]])],
+            [fits_in_uint=0])
+        fi
+        dnl We cannot use 'expr' to simplify this expression, because 'expr'
+        dnl works only with 'long' integers in the host environment, while we
+        dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
+        if test $fits_in_uint = 1; then
+          gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
+        else
+          gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
+        fi
+      else
+        dnl Shouldn't happen, but who knows...
+        gl_cv_size_max='((size_t)~(size_t)0)'
+      fi
+    fi
+  ])
+  if test "$gl_cv_size_max" != yes; then
+    AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max],
+      [Define as the maximum value of type 'size_t', if the system doesn't define it.])
+  fi
+  dnl Don't redefine SIZE_MAX in config.h if config.h is re-included after
+  dnl <stdint.h>. Remember that the #undef in AH_VERBATIM gets replaced with
+  dnl #define by AC_DEFINE_UNQUOTED.
+  AH_VERBATIM([SIZE_MAX],
+[/* Define as the maximum value of type 'size_t', if the system doesn't define
+   it. */
+#ifndef SIZE_MAX
+# undef SIZE_MAX
+#endif])
+])
+
+dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
+dnl Remove this when we can assume autoconf >= 2.61.
+m4_ifdef([AC_COMPUTE_INT], [], [
+  AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
+])
diff --git a/gnulib/m4/ssize_t.m4 b/gnulib/m4/ssize_t.m4
new file mode 100644 (file)
index 0000000..d712752
--- /dev/null
@@ -0,0 +1,23 @@
+# ssize_t.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 2001-2003, 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether ssize_t is defined.
+
+AC_DEFUN([gt_TYPE_SSIZE_T],
+[
+  AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>]],
+          [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
+            return !x;]])],
+       [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
+  if test $gt_cv_ssize_t = no; then
+    AC_DEFINE([ssize_t], [int],
+              [Define as a signed type of the same size as size_t.])
+  fi
+])
diff --git a/gnulib/m4/stat.m4 b/gnulib/m4/stat.m4
new file mode 100644 (file)
index 0000000..27f82d5
--- /dev/null
@@ -0,0 +1,66 @@
+# serial 7
+
+# Copyright (C) 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.
+
+AC_DEFUN([gl_FUNC_STAT],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([lstat])
+  dnl mingw is the only known platform where stat(".") and stat("./") differ
+  AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
+      [gl_cv_func_stat_dir_slash],
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+           [[#include <sys/stat.h>
+]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
+         [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
+         [case $host_os in
+            mingw*) gl_cv_func_stat_dir_slash="guessing no";;
+            *) gl_cv_func_stat_dir_slash="guessing yes";;
+          esac])])
+  dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/")
+  dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
+  AC_CACHE_CHECK([whether stat handles trailing slashes on files],
+      [gl_cv_func_stat_file_slash],
+      [touch conftest.tmp
+       # Assume that if we have lstat, we can also check symlinks.
+       if test $ac_cv_func_lstat = yes; then
+         ln -s conftest.tmp conftest.lnk
+       fi
+       AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+           [[#include <sys/stat.h>
+]], [[int result = 0;
+      struct stat st;
+      if (!stat ("conftest.tmp/", &st))
+        result |= 1;
+#if HAVE_LSTAT
+      if (!stat ("conftest.lnk/", &st))
+        result |= 2;
+#endif
+      return result;
+           ]])],
+         [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
+         [gl_cv_func_stat_file_slash="guessing no"])
+       rm -f conftest.tmp conftest.lnk])
+  case $gl_cv_func_stat_dir_slash in
+    *no) REPLACE_STAT=1
+      AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
+        help when passed a directory name with a trailing slash]);;
+  esac
+  case $gl_cv_func_stat_file_slash in
+    *no) REPLACE_STAT=1
+      AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
+        help when passed a file name with a trailing slash]);;
+  esac
+  if test $REPLACE_STAT = 1; then
+    AC_LIBOBJ([stat])
+    dnl Prerequisites of lib/stat.c.
+    AC_REQUIRE([AC_C_INLINE])
+  fi
+])
diff --git a/gnulib/m4/stdbool.m4 b/gnulib/m4/stdbool.m4
new file mode 100644 (file)
index 0000000..838cf0f
--- /dev/null
@@ -0,0 +1,99 @@
+# Check for stdbool.h that conforms to C99.
+
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+#serial 4
+
+# Prepare for substituting <stdbool.h> if it is not supported.
+
+AC_DEFUN([AM_STDBOOL_H],
+[
+  AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
+
+  # Define two additional variables used in the Makefile substitution.
+
+  if test "$ac_cv_header_stdbool_h" = yes; then
+    STDBOOL_H=''
+  else
+    STDBOOL_H='stdbool.h'
+  fi
+  AC_SUBST([STDBOOL_H])
+
+  if test "$ac_cv_type__Bool" = yes; then
+    HAVE__BOOL=1
+  else
+    HAVE__BOOL=0
+  fi
+  AC_SUBST([HAVE__BOOL])
+])
+
+# 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.68.
+
+AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
+  [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+     [ac_cv_header_stdbool_h],
+     [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[
+             #include <stdbool.h>
+             #ifndef bool
+              "error: bool is not defined"
+             #endif
+             #ifndef false
+              "error: false is not defined"
+             #endif
+             #if false
+              "error: false is not 0"
+             #endif
+             #ifndef true
+              "error: true is not defined"
+             #endif
+             #if true != 1
+              "error: true is not 1"
+             #endif
+             #ifndef __bool_true_false_are_defined
+              "error: __bool_true_false_are_defined is not defined"
+             #endif
+
+             struct s { _Bool s: 1; _Bool t; } s;
+
+             char a[true == 1 ? 1 : -1];
+             char b[false == 0 ? 1 : -1];
+             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+             char d[(bool) 0.5 == true ? 1 : -1];
+             /* See body of main program for 'e'.  */
+             char f[(_Bool) 0.0 == false ? 1 : -1];
+             char g[true];
+             char h[sizeof (_Bool)];
+             char i[sizeof s.t];
+             enum { j = false, k = true, l = false * true, m = true * 256 };
+             /* The following fails for
+                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+             _Bool n[m];
+             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+             /* Catch a bug in an HP-UX C compiler.  See
+                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+              */
+             _Bool q = true;
+             _Bool *pq = &q;
+           ]],
+           [[
+             bool e = &s;
+             *pq |= q;
+             *pq |= ! q;
+             /* Refer to every declared value, to avoid compiler optimizations.  */
+             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                     + !m + !n + !o + !p + !q + !pq);
+           ]])],
+        [ac_cv_header_stdbool_h=yes],
+        [ac_cv_header_stdbool_h=no])])
+   AC_CHECK_TYPES([_Bool])
+])
diff --git a/gnulib/m4/stddef_h.m4 b/gnulib/m4/stddef_h.m4
new file mode 100644 (file)
index 0000000..1942b6a
--- /dev/null
@@ -0,0 +1,45 @@
+dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
+# stddef_h.m4 serial 3
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDDEF_H],
+[
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
+    [gl_cv_decl_null_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+]])],
+      [gl_cv_decl_null_works=yes],
+      [gl_cv_decl_null_works=no])])
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+    gl_NEXT_HEADERS([stddef.h])
+  fi
+])
+
+AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+])
+
+AC_DEFUN([gl_STDDEF_H_DEFAULTS],
+[
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  REPLACE_NULL=0;                AC_SUBST([REPLACE_NULL])
+  HAVE_WCHAR_T=1;                AC_SUBST([HAVE_WCHAR_T])
+  STDDEF_H='';                   AC_SUBST([STDDEF_H])
+])
diff --git a/gnulib/m4/stdint.m4 b/gnulib/m4/stdint.m4
new file mode 100644 (file)
index 0000000..e7d0d07
--- /dev/null
@@ -0,0 +1,479 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert and Bruno Haible.
+dnl Test whether <stdint.h> is supported or must be substituted.
+
+AC_DEFUN([gl_STDINT_H],
+[
+  AC_PREREQ([2.59])dnl
+
+  dnl Check for long long int and unsigned long long int.
+  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+  if test $ac_cv_type_long_long_int = yes; then
+    HAVE_LONG_LONG_INT=1
+  else
+    HAVE_LONG_LONG_INT=0
+  fi
+  AC_SUBST([HAVE_LONG_LONG_INT])
+  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
+  if test $ac_cv_type_unsigned_long_long_int = yes; then
+    HAVE_UNSIGNED_LONG_LONG_INT=1
+  else
+    HAVE_UNSIGNED_LONG_LONG_INT=0
+  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
+    HAVE_INTTYPES_H=1
+  else
+    HAVE_INTTYPES_H=0
+  fi
+  AC_SUBST([HAVE_INTTYPES_H])
+
+  dnl Check for <sys/types.h>.
+  dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
+  if test $ac_cv_header_sys_types_h = yes; then
+    HAVE_SYS_TYPES_H=1
+  else
+    HAVE_SYS_TYPES_H=0
+  fi
+  AC_SUBST([HAVE_SYS_TYPES_H])
+
+  gl_CHECK_NEXT_HEADERS([stdint.h])
+  if test $ac_cv_header_stdint_h = yes; then
+    HAVE_STDINT_H=1
+  else
+    HAVE_STDINT_H=0
+  fi
+  AC_SUBST([HAVE_STDINT_H])
+
+  dnl Now see whether we need a substitute <stdint.h>.
+  if test $ac_cv_header_stdint_h = yes; then
+    AC_CACHE_CHECK([whether stdint.h conforms to C99],
+      [gl_cv_header_working_stdint_h],
+      [gl_cv_header_working_stdint_h=no
+       AC_COMPILE_IFELSE([
+         AC_LANG_PROGRAM([[
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
+#if !(defined WCHAR_MIN && defined WCHAR_MAX)
+#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
+#endif
+]
+gl_STDINT_INCLUDES
+[
+#ifdef INT8_MAX
+int8_t a1 = INT8_MAX;
+int8_t a1min = INT8_MIN;
+#endif
+#ifdef INT16_MAX
+int16_t a2 = INT16_MAX;
+int16_t a2min = INT16_MIN;
+#endif
+#ifdef INT32_MAX
+int32_t a3 = INT32_MAX;
+int32_t a3min = INT32_MIN;
+#endif
+#ifdef INT64_MAX
+int64_t a4 = INT64_MAX;
+int64_t a4min = INT64_MIN;
+#endif
+#ifdef UINT8_MAX
+uint8_t b1 = UINT8_MAX;
+#else
+typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
+#endif
+#ifdef UINT16_MAX
+uint16_t b2 = UINT16_MAX;
+#endif
+#ifdef UINT32_MAX
+uint32_t b3 = UINT32_MAX;
+#endif
+#ifdef UINT64_MAX
+uint64_t b4 = UINT64_MAX;
+#endif
+int_least8_t c1 = INT8_C (0x7f);
+int_least8_t c1max = INT_LEAST8_MAX;
+int_least8_t c1min = INT_LEAST8_MIN;
+int_least16_t c2 = INT16_C (0x7fff);
+int_least16_t c2max = INT_LEAST16_MAX;
+int_least16_t c2min = INT_LEAST16_MIN;
+int_least32_t c3 = INT32_C (0x7fffffff);
+int_least32_t c3max = INT_LEAST32_MAX;
+int_least32_t c3min = INT_LEAST32_MIN;
+int_least64_t c4 = INT64_C (0x7fffffffffffffff);
+int_least64_t c4max = INT_LEAST64_MAX;
+int_least64_t c4min = INT_LEAST64_MIN;
+uint_least8_t d1 = UINT8_C (0xff);
+uint_least8_t d1max = UINT_LEAST8_MAX;
+uint_least16_t d2 = UINT16_C (0xffff);
+uint_least16_t d2max = UINT_LEAST16_MAX;
+uint_least32_t d3 = UINT32_C (0xffffffff);
+uint_least32_t d3max = UINT_LEAST32_MAX;
+uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
+uint_least64_t d4max = UINT_LEAST64_MAX;
+int_fast8_t e1 = INT_FAST8_MAX;
+int_fast8_t e1min = INT_FAST8_MIN;
+int_fast16_t e2 = INT_FAST16_MAX;
+int_fast16_t e2min = INT_FAST16_MIN;
+int_fast32_t e3 = INT_FAST32_MAX;
+int_fast32_t e3min = INT_FAST32_MIN;
+int_fast64_t e4 = INT_FAST64_MAX;
+int_fast64_t e4min = INT_FAST64_MIN;
+uint_fast8_t f1 = UINT_FAST8_MAX;
+uint_fast16_t f2 = UINT_FAST16_MAX;
+uint_fast32_t f3 = UINT_FAST32_MAX;
+uint_fast64_t f4 = UINT_FAST64_MAX;
+#ifdef INTPTR_MAX
+intptr_t g = INTPTR_MAX;
+intptr_t gmin = INTPTR_MIN;
+#endif
+#ifdef UINTPTR_MAX
+uintptr_t h = UINTPTR_MAX;
+#endif
+intmax_t i = INTMAX_MAX;
+uintmax_t j = UINTMAX_MAX;
+
+#include <limits.h> /* for CHAR_BIT */
+#define TYPE_MINIMUM(t) \
+  ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
+#define TYPE_MAXIMUM(t) \
+  ((t) ((t) 0 < (t) -1 \
+        ? (t) -1 \
+        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+struct s {
+  int check_PTRDIFF:
+      PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
+      && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
+      ? 1 : -1;
+  /* Detect bug in FreeBSD 6.0 / ia64.  */
+  int check_SIG_ATOMIC:
+      SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
+      && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
+      ? 1 : -1;
+  int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
+  int check_WCHAR:
+      WCHAR_MIN == TYPE_MINIMUM (wchar_t)
+      && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
+      ? 1 : -1;
+  /* Detect bug in mingw.  */
+  int check_WINT:
+      WINT_MIN == TYPE_MINIMUM (wint_t)
+      && WINT_MAX == TYPE_MAXIMUM (wint_t)
+      ? 1 : -1;
+
+  /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
+  int check_UINT8_C:
+        (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
+  int check_UINT16_C:
+        (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
+
+  /* Detect bugs in OpenBSD 3.9 stdint.h.  */
+#ifdef UINT8_MAX
+  int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
+#endif
+#ifdef UINT16_MAX
+  int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
+#endif
+#ifdef UINT32_MAX
+  int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
+#endif
+#ifdef UINT64_MAX
+  int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
+#endif
+  int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
+  int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
+  int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
+  int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
+  int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
+  int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
+  int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
+  int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
+  int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
+  int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
+  int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
+};
+         ]])],
+         [dnl Determine whether the various *_MIN, *_MAX macros are usable
+          dnl in preprocessor expression. We could do it by compiling a test
+          dnl program for each of these macros. It is faster to run a program
+          dnl that inspects the macro expansion.
+          dnl This detects a bug on HP-UX 11.23/ia64.
+          AC_RUN_IFELSE([
+            AC_LANG_PROGRAM([[
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+]
+gl_STDINT_INCLUDES
+[
+#include <stdio.h>
+#include <string.h>
+#define MVAL(macro) MVAL1(macro)
+#define MVAL1(expression) #expression
+static const char *macro_values[] =
+  {
+#ifdef INT8_MAX
+    MVAL (INT8_MAX),
+#endif
+#ifdef INT16_MAX
+    MVAL (INT16_MAX),
+#endif
+#ifdef INT32_MAX
+    MVAL (INT32_MAX),
+#endif
+#ifdef INT64_MAX
+    MVAL (INT64_MAX),
+#endif
+#ifdef UINT8_MAX
+    MVAL (UINT8_MAX),
+#endif
+#ifdef UINT16_MAX
+    MVAL (UINT16_MAX),
+#endif
+#ifdef UINT32_MAX
+    MVAL (UINT32_MAX),
+#endif
+#ifdef UINT64_MAX
+    MVAL (UINT64_MAX),
+#endif
+    NULL
+  };
+]], [[
+  const char **mv;
+  for (mv = macro_values; *mv != NULL; mv++)
+    {
+      const char *value = *mv;
+      /* Test whether it looks like a cast expression.  */
+      if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
+          || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
+          || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
+          || strncmp (value, "((int)"/*)*/, 6) == 0
+          || strncmp (value, "((signed short)"/*)*/, 15) == 0
+          || strncmp (value, "((signed char)"/*)*/, 14) == 0)
+        return mv - macro_values + 1;
+    }
+  return 0;
+]])],
+              [gl_cv_header_working_stdint_h=yes],
+              [],
+              [dnl When cross-compiling, assume it works.
+               gl_cv_header_working_stdint_h=yes
+              ])
+         ])
+      ])
+  fi
+  if test "$gl_cv_header_working_stdint_h" = yes; then
+    STDINT_H=
+  else
+    dnl Check for <sys/inttypes.h>, and for
+    dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
+    AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
+    if test $ac_cv_header_sys_inttypes_h = yes; then
+      HAVE_SYS_INTTYPES_H=1
+    else
+      HAVE_SYS_INTTYPES_H=0
+    fi
+    AC_SUBST([HAVE_SYS_INTTYPES_H])
+    if test $ac_cv_header_sys_bitypes_h = yes; then
+      HAVE_SYS_BITYPES_H=1
+    else
+      HAVE_SYS_BITYPES_H=0
+    fi
+    AC_SUBST([HAVE_SYS_BITYPES_H])
+
+    gl_STDINT_TYPE_PROPERTIES
+    STDINT_H=stdint.h
+  fi
+  AC_SUBST([STDINT_H])
+])
+
+dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
+dnl Determine the size of each of the given types in bits.
+AC_DEFUN([gl_STDINT_BITSIZEOF],
+[
+  dnl Use a shell loop, to avoid bloating configure, and
+  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
+  dnl   config.h.in,
+  dnl - extra AC_SUBST calls, so that the right substitutions are made.
+  m4_foreach_w([gltype], [$1],
+    [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
+       [Define to the number of bits in type ']gltype['.])])
+  for gltype in $1 ; do
+    AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
+      [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT],
+         [$2
+#include <limits.h>], [result=unknown])
+       eval gl_cv_bitsizeof_${gltype}=\$result
+      ])
+    eval result=\$gl_cv_bitsizeof_${gltype}
+    if test $result = unknown; then
+      dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
+      dnl do a syntax check even on unused #if conditions and give an error
+      dnl on valid C code like this:
+      dnl   #if 0
+      dnl   # if  > 32
+      dnl   # endif
+      dnl   #endif
+      result=0
+    fi
+    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
+    eval BITSIZEOF_${GLTYPE}=\$result
+  done
+  m4_foreach_w([gltype], [$1],
+    [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
+])
+
+dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
+dnl Determine the signedness of each of the given types.
+dnl Define HAVE_SIGNED_TYPE if type is signed.
+AC_DEFUN([gl_CHECK_TYPES_SIGNED],
+[
+  dnl Use a shell loop, to avoid bloating configure, and
+  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
+  dnl   config.h.in,
+  dnl - extra AC_SUBST calls, so that the right substitutions are made.
+  m4_foreach_w([gltype], [$1],
+    [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
+       [Define to 1 if ']gltype[' is a signed integer type.])])
+  for gltype in $1 ; do
+    AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([$2[
+            int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
+         result=yes, result=no)
+       eval gl_cv_type_${gltype}_signed=\$result
+      ])
+    eval result=\$gl_cv_type_${gltype}_signed
+    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    if test "$result" = yes; then
+      AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
+      eval HAVE_SIGNED_${GLTYPE}=1
+    else
+      eval HAVE_SIGNED_${GLTYPE}=0
+    fi
+  done
+  m4_foreach_w([gltype], [$1],
+    [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
+])
+
+dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
+dnl Determine the suffix to use for integer constants of the given types.
+dnl Define t_SUFFIX for each such type.
+AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
+[
+  dnl Use a shell loop, to avoid bloating configure, and
+  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
+  dnl   config.h.in,
+  dnl - extra AC_SUBST calls, so that the right substitutions are made.
+  m4_foreach_w([gltype], [$1],
+    [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
+       [Define to l, ll, u, ul, ull, etc., as suitable for
+        constants of type ']gltype['.])])
+  for gltype in $1 ; do
+    AC_CACHE_CHECK([for $gltype integer literal suffix],
+      [gl_cv_type_${gltype}_suffix],
+      [eval gl_cv_type_${gltype}_suffix=no
+       eval result=\$gl_cv_type_${gltype}_signed
+       if test "$result" = yes; then
+         glsufu=
+       else
+         glsufu=u
+       fi
+       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
+         case $glsuf in
+           '')  gltype1='int';;
+           l)   gltype1='long int';;
+           ll)  gltype1='long long int';;
+           i64) gltype1='__int64';;
+           u)   gltype1='unsigned int';;
+           ul)  gltype1='unsigned long int';;
+           ull) gltype1='unsigned long long int';;
+           ui64)gltype1='unsigned __int64';;
+         esac
+         AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM([$2[
+              extern $gltype foo;
+              extern $gltype1 foo;]])],
+           [eval gl_cv_type_${gltype}_suffix=\$glsuf])
+         eval result=\$gl_cv_type_${gltype}_suffix
+         test "$result" != no && break
+       done])
+    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
+    eval result=\$gl_cv_type_${gltype}_suffix
+    test "$result" = no && result=
+    eval ${GLTYPE}_SUFFIX=\$result
+    AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
+  done
+  m4_foreach_w([gltype], [$1],
+    [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
+])
+
+dnl gl_STDINT_INCLUDES
+AC_DEFUN([gl_STDINT_INCLUDES],
+[[
+  /* 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 <signal.h>
+  #if HAVE_WCHAR_H
+  # include <stdio.h>
+  # include <time.h>
+  # include <wchar.h>
+  #endif
+]])
+
+dnl gl_STDINT_TYPE_PROPERTIES
+dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
+dnl of interest to stdint.in.h.
+AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
+[
+  AC_REQUIRE([gl_MULTIARCH])
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+    gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
+      [gl_STDINT_INCLUDES])
+  fi
+  gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
+    [gl_STDINT_INCLUDES])
+  gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
+    [gl_STDINT_INCLUDES])
+  gl_cv_type_ptrdiff_t_signed=yes
+  gl_cv_type_size_t_signed=no
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+    gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
+      [gl_STDINT_INCLUDES])
+  fi
+  gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
+    [gl_STDINT_INCLUDES])
+])
+
+dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
+dnl Remove this when we can assume autoconf >= 2.61.
+m4_ifdef([AC_COMPUTE_INT], [], [
+  AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
+])
+
+# Hey Emacs!
+# Local Variables:
+# indent-tabs-mode: nil
+# End:
diff --git a/gnulib/m4/stdint_h.m4 b/gnulib/m4/stdint_h.m4
new file mode 100644 (file)
index 0000000..356b14e
--- /dev/null
@@ -0,0 +1,27 @@
+# stdint_h.m4 serial 9
+dnl Copyright (C) 1997-2004, 2006, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert.
+
+# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+
+AC_DEFUN([gl_AC_HEADER_STDINT_H],
+[
+  AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #include <stdint.h>]],
+          [[uintmax_t i = (uintmax_t) -1; return !i;]])],
+       [gl_cv_header_stdint_h=yes],
+       [gl_cv_header_stdint_h=no])])
+  if test $gl_cv_header_stdint_h = yes; then
+    AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1],
+      [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
+       and declares uintmax_t. ])
+  fi
+])
diff --git a/gnulib/m4/stdio_h.m4 b/gnulib/m4/stdio_h.m4
new file mode 100644 (file)
index 0000000..7f3ae56
--- /dev/null
@@ -0,0 +1,140 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDIO_H],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([AC_C_INLINE])
+  gl_NEXT_HEADERS([stdio.h])
+  dnl No need to create extra modules for these functions. Everyone who uses
+  dnl <stdio.h> likely needs them.
+  GNULIB_FPRINTF=1
+  GNULIB_PRINTF=1
+  GNULIB_VFPRINTF=1
+  GNULIB_VPRINTF=1
+  GNULIB_FPUTC=1
+  GNULIB_PUTC=1
+  GNULIB_PUTCHAR=1
+  GNULIB_FPUTS=1
+  GNULIB_PUTS=1
+  GNULIB_FWRITE=1
+  dnl This ifdef is just an optimization, to avoid performing a configure
+  dnl check whose result is not used. It does not make the test of
+  dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
+  m4_ifdef([gl_SIGNAL_SIGPIPE], [
+    gl_SIGNAL_SIGPIPE
+    if test $gl_cv_header_signal_h_SIGPIPE != yes; then
+      REPLACE_STDIO_WRITE_FUNCS=1
+      AC_LIBOBJ([stdio-write])
+    fi
+  ])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use, and which is not
+  dnl guaranteed by C89.
+  gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
+    ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
+    snprintf tmpfile vdprintf vsnprintf])
+])
+
+AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDIO_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_STDIO_H_DEFAULTS],
+[
+  GNULIB_DPRINTF=0;              AC_SUBST([GNULIB_DPRINTF])
+  GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
+  GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
+  GNULIB_FOPEN=0;                AC_SUBST([GNULIB_FOPEN])
+  GNULIB_FPRINTF=0;              AC_SUBST([GNULIB_FPRINTF])
+  GNULIB_FPRINTF_POSIX=0;        AC_SUBST([GNULIB_FPRINTF_POSIX])
+  GNULIB_FPURGE=0;               AC_SUBST([GNULIB_FPURGE])
+  GNULIB_FPUTC=0;                AC_SUBST([GNULIB_FPUTC])
+  GNULIB_FPUTS=0;                AC_SUBST([GNULIB_FPUTS])
+  GNULIB_FREOPEN=0;              AC_SUBST([GNULIB_FREOPEN])
+  GNULIB_FSEEK=0;                AC_SUBST([GNULIB_FSEEK])
+  GNULIB_FSEEKO=0;               AC_SUBST([GNULIB_FSEEKO])
+  GNULIB_FTELL=0;                AC_SUBST([GNULIB_FTELL])
+  GNULIB_FTELLO=0;               AC_SUBST([GNULIB_FTELLO])
+  GNULIB_FWRITE=0;               AC_SUBST([GNULIB_FWRITE])
+  GNULIB_GETDELIM=0;             AC_SUBST([GNULIB_GETDELIM])
+  GNULIB_GETLINE=0;              AC_SUBST([GNULIB_GETLINE])
+  GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
+  GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
+  GNULIB_PERROR=0;               AC_SUBST([GNULIB_PERROR])
+  GNULIB_POPEN=0;                AC_SUBST([GNULIB_POPEN])
+  GNULIB_PRINTF=0;               AC_SUBST([GNULIB_PRINTF])
+  GNULIB_PRINTF_POSIX=0;         AC_SUBST([GNULIB_PRINTF_POSIX])
+  GNULIB_PUTC=0;                 AC_SUBST([GNULIB_PUTC])
+  GNULIB_PUTCHAR=0;              AC_SUBST([GNULIB_PUTCHAR])
+  GNULIB_PUTS=0;                 AC_SUBST([GNULIB_PUTS])
+  GNULIB_REMOVE=0;               AC_SUBST([GNULIB_REMOVE])
+  GNULIB_RENAME=0;               AC_SUBST([GNULIB_RENAME])
+  GNULIB_RENAMEAT=0;             AC_SUBST([GNULIB_RENAMEAT])
+  GNULIB_SNPRINTF=0;             AC_SUBST([GNULIB_SNPRINTF])
+  GNULIB_SPRINTF_POSIX=0;        AC_SUBST([GNULIB_SPRINTF_POSIX])
+  GNULIB_STDIO_H_SIGPIPE=0;      AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
+  GNULIB_TMPFILE=0;              AC_SUBST([GNULIB_TMPFILE])
+  GNULIB_VASPRINTF=0;            AC_SUBST([GNULIB_VASPRINTF])
+  GNULIB_VDPRINTF=0;             AC_SUBST([GNULIB_VDPRINTF])
+  GNULIB_VFPRINTF=0;             AC_SUBST([GNULIB_VFPRINTF])
+  GNULIB_VFPRINTF_POSIX=0;       AC_SUBST([GNULIB_VFPRINTF_POSIX])
+  GNULIB_VPRINTF=0;              AC_SUBST([GNULIB_VPRINTF])
+  GNULIB_VPRINTF_POSIX=0;        AC_SUBST([GNULIB_VPRINTF_POSIX])
+  GNULIB_VSNPRINTF=0;            AC_SUBST([GNULIB_VSNPRINTF])
+  GNULIB_VSPRINTF_POSIX=0;       AC_SUBST([GNULIB_VSPRINTF_POSIX])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_DECL_FPURGE=1;            AC_SUBST([HAVE_DECL_FPURGE])
+  HAVE_DECL_FSEEKO=1;            AC_SUBST([HAVE_DECL_FSEEKO])
+  HAVE_DECL_FTELLO=1;            AC_SUBST([HAVE_DECL_FTELLO])
+  HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
+  HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
+  HAVE_DECL_OBSTACK_PRINTF=1;    AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
+  HAVE_DECL_SNPRINTF=1;          AC_SUBST([HAVE_DECL_SNPRINTF])
+  HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
+  HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
+  HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
+  HAVE_FTELLO=1;                 AC_SUBST([HAVE_FTELLO])
+  HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
+  HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
+  HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
+  REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
+  REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
+  REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
+  REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
+  REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
+  REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
+  REPLACE_FREOPEN=0;             AC_SUBST([REPLACE_FREOPEN])
+  REPLACE_FSEEK=0;               AC_SUBST([REPLACE_FSEEK])
+  REPLACE_FSEEKO=0;              AC_SUBST([REPLACE_FSEEKO])
+  REPLACE_FTELL=0;               AC_SUBST([REPLACE_FTELL])
+  REPLACE_FTELLO=0;              AC_SUBST([REPLACE_FTELLO])
+  REPLACE_GETDELIM=0;            AC_SUBST([REPLACE_GETDELIM])
+  REPLACE_GETLINE=0;             AC_SUBST([REPLACE_GETLINE])
+  REPLACE_OBSTACK_PRINTF=0;      AC_SUBST([REPLACE_OBSTACK_PRINTF])
+  REPLACE_PERROR=0;              AC_SUBST([REPLACE_PERROR])
+  REPLACE_POPEN=0;               AC_SUBST([REPLACE_POPEN])
+  REPLACE_PRINTF=0;              AC_SUBST([REPLACE_PRINTF])
+  REPLACE_REMOVE=0;              AC_SUBST([REPLACE_REMOVE])
+  REPLACE_RENAME=0;              AC_SUBST([REPLACE_RENAME])
+  REPLACE_RENAMEAT=0;            AC_SUBST([REPLACE_RENAMEAT])
+  REPLACE_SNPRINTF=0;            AC_SUBST([REPLACE_SNPRINTF])
+  REPLACE_SPRINTF=0;             AC_SUBST([REPLACE_SPRINTF])
+  REPLACE_STDIO_WRITE_FUNCS=0;   AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
+  REPLACE_TMPFILE=0;             AC_SUBST([REPLACE_TMPFILE])
+  REPLACE_VASPRINTF=0;           AC_SUBST([REPLACE_VASPRINTF])
+  REPLACE_VDPRINTF=0;            AC_SUBST([REPLACE_VDPRINTF])
+  REPLACE_VFPRINTF=0;            AC_SUBST([REPLACE_VFPRINTF])
+  REPLACE_VPRINTF=0;             AC_SUBST([REPLACE_VPRINTF])
+  REPLACE_VSNPRINTF=0;           AC_SUBST([REPLACE_VSNPRINTF])
+  REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
+])
diff --git a/gnulib/m4/stdlib_h.m4 b/gnulib/m4/stdlib_h.m4
new file mode 100644 (file)
index 0000000..25fdada
--- /dev/null
@@ -0,0 +1,105 @@
+# 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDLIB_H],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  gl_NEXT_HEADERS([stdlib.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use, and which is not
+  dnl guaranteed by C89.
+  gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
+#if HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+#endif
+#if HAVE_RANDOM_H
+# include <random.h>
+#endif
+    ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp
+    mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r
+    setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt
+    unsetenv])
+])
+
+AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDLIB_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_STDLIB_H_DEFAULTS],
+[
+  GNULIB__EXIT=0;         AC_SUBST([GNULIB__EXIT])
+  GNULIB_ATOLL=0;         AC_SUBST([GNULIB_ATOLL])
+  GNULIB_CALLOC_POSIX=0;  AC_SUBST([GNULIB_CALLOC_POSIX])
+  GNULIB_CANONICALIZE_FILE_NAME=0;  AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
+  GNULIB_GETLOADAVG=0;    AC_SUBST([GNULIB_GETLOADAVG])
+  GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
+  GNULIB_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])
+  GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
+  GNULIB_MKSTEMPS=0;      AC_SUBST([GNULIB_MKSTEMPS])
+  GNULIB_PTSNAME=0;       AC_SUBST([GNULIB_PTSNAME])
+  GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
+  GNULIB_RANDOM_R=0;      AC_SUBST([GNULIB_RANDOM_R])
+  GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
+  GNULIB_REALPATH=0;      AC_SUBST([GNULIB_REALPATH])
+  GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
+  GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
+  GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
+  GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
+  GNULIB_STRTOULL=0;      AC_SUBST([GNULIB_STRTOULL])
+  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])
+  HAVE_CANONICALIZE_FILE_NAME=1;  AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
+  HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
+  HAVE_GETSUBOPT=1;          AC_SUBST([HAVE_GETSUBOPT])
+  HAVE_GRANTPT=1;            AC_SUBST([HAVE_GRANTPT])
+  HAVE_MKDTEMP=1;            AC_SUBST([HAVE_MKDTEMP])
+  HAVE_MKOSTEMP=1;           AC_SUBST([HAVE_MKOSTEMP])
+  HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
+  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])
+  HAVE_SETENV=1;             AC_SUBST([HAVE_SETENV])
+  HAVE_DECL_SETENV=1;        AC_SUBST([HAVE_DECL_SETENV])
+  HAVE_STRTOD=1;             AC_SUBST([HAVE_STRTOD])
+  HAVE_STRTOLL=1;            AC_SUBST([HAVE_STRTOLL])
+  HAVE_STRTOULL=1;           AC_SUBST([HAVE_STRTOULL])
+  HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
+  HAVE_SYS_LOADAVG_H=0;      AC_SUBST([HAVE_SYS_LOADAVG_H])
+  HAVE_UNLOCKPT=1;           AC_SUBST([HAVE_UNLOCKPT])
+  HAVE_DECL_UNSETENV=1;      AC_SUBST([HAVE_DECL_UNSETENV])
+  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])
+  REPLACE_REALPATH=0;        AC_SUBST([REPLACE_REALPATH])
+  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])
+])
diff --git a/gnulib/m4/stpcpy.m4 b/gnulib/m4/stpcpy.m4
new file mode 100644 (file)
index 0000000..c321d49
--- /dev/null
@@ -0,0 +1,26 @@
+# stpcpy.m4 serial 7
+dnl Copyright (C) 2002, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STPCPY],
+[
+  dnl Persuade glibc <string.h> to declare stpcpy().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'.
+  AC_REQUIRE([AC_C_RESTRICT])
+
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REPLACE_FUNCS([stpcpy])
+  if test $ac_cv_func_stpcpy = no; then
+    HAVE_STPCPY=0
+    gl_PREREQ_STPCPY
+  fi
+])
+
+# Prerequisites of lib/stpcpy.c.
+AC_DEFUN([gl_PREREQ_STPCPY], [
+  :
+])
diff --git a/gnulib/m4/stpncpy.m4 b/gnulib/m4/stpncpy.m4
new file mode 100644 (file)
index 0000000..cc7796a
--- /dev/null
@@ -0,0 +1,94 @@
+# stpncpy.m4 serial 13
+dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation,
+dnl 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_STPNCPY],
+[
+  dnl Persuade glibc <string.h> to declare stpncpy().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  dnl The stpncpy() declaration in lib/string.in.h uses 'restrict'.
+  AC_REQUIRE([AC_C_RESTRICT])
+
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+
+  dnl Both glibc and AIX (4.3.3, 5.1) have an stpncpy() function
+  dnl declared in <string.h>. Its side effects are the same as those
+  dnl of strncpy():
+  dnl      stpncpy (dest, src, n)
+  dnl overwrites dest[0..n-1], min(strlen(src),n) bytes coming from src,
+  dnl and the remaining bytes being NULs.  However, the return value is
+  dnl   in glibc:   dest + min(strlen(src),n)
+  dnl   in AIX:     dest + max(0,n-1)
+  dnl Only the glibc return value is useful in practice.
+
+  AC_CHECK_DECLS_ONCE([stpncpy])
+  AC_CHECK_FUNCS_ONCE([stpncpy])
+  if test $ac_cv_func_stpncpy = yes; then
+    AC_CACHE_CHECK([for working stpncpy], [gl_cv_func_stpncpy], [
+      AC_RUN_IFELSE(
+        [AC_LANG_SOURCE([[
+#include <stdlib.h>
+#include <string.h> /* for strcpy */
+/* The stpncpy prototype is missing in <string.h> on AIX 4.  */
+#if !HAVE_DECL_STPNCPY
+extern char *stpncpy (char *dest, const char *src, size_t n);
+#endif
+int main ()
+{
+  int result = 0;
+  const char *src = "Hello";
+  char dest[10];
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+1 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 2) != dest + 2)
+      result |= 1;
+  }
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+4 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 5) != dest + 5)
+      result |= 2;
+  }
+  /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+6 here.  */
+  {
+    strcpy (dest, "\377\377\377\377\377\377");
+    if (stpncpy (dest, src, 7) != dest + 5)
+      result |= 4;
+  }
+  return result;
+}
+]])],
+        [gl_cv_func_stpncpy=yes],
+        [gl_cv_func_stpncpy=no],
+        [AC_EGREP_CPP([Thanks for using GNU], [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+  Thanks for using GNU
+#endif
+], [gl_cv_func_stpncpy=yes], [gl_cv_func_stpncpy=no])
+        ])
+    ])
+    if test $gl_cv_func_stpncpy = yes; then
+      AC_DEFINE([HAVE_STPNCPY], [1],
+        [Define if you have the stpncpy() function and it works.])
+    else
+      REPLACE_STPNCPY=1
+      AC_LIBOBJ([stpncpy])
+      gl_PREREQ_STPNCPY
+    fi
+  else
+    HAVE_STPNCPY=0
+    AC_LIBOBJ([stpncpy])
+    gl_PREREQ_STPNCPY
+  fi
+])
+
+# Prerequisites of lib/stpncpy.c.
+AC_DEFUN([gl_PREREQ_STPNCPY], [
+  :
+])
diff --git a/gnulib/m4/string_h.m4 b/gnulib/m4/string_h.m4
new file mode 100644 (file)
index 0000000..30ddfbc
--- /dev/null
@@ -0,0 +1,115 @@
+# Configure a GNU-like replacement for <string.h>.
+
+# Copyright (C) 2007-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.
+
+# serial 19
+
+# Written by Paul Eggert.
+
+AC_DEFUN([gl_HEADER_STRING_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_STRING_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_STRING_H_BODY],
+[
+  AC_REQUIRE([AC_C_RESTRICT])
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  gl_NEXT_HEADERS([string.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use, and which is not
+  dnl guaranteed by C89.
+  gl_WARN_ON_USE_PREPARE([[#include <string.h>
+    ]],
+    [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
+     strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r
+     strsignal strverscmp])
+])
+
+AC_DEFUN([gl_STRING_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_HEADER_STRING_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_HEADER_STRING_H_DEFAULTS],
+[
+  GNULIB_MEMCHR=0;      AC_SUBST([GNULIB_MEMCHR])
+  GNULIB_MEMMEM=0;      AC_SUBST([GNULIB_MEMMEM])
+  GNULIB_MEMPCPY=0;     AC_SUBST([GNULIB_MEMPCPY])
+  GNULIB_MEMRCHR=0;     AC_SUBST([GNULIB_MEMRCHR])
+  GNULIB_RAWMEMCHR=0;   AC_SUBST([GNULIB_RAWMEMCHR])
+  GNULIB_STPCPY=0;      AC_SUBST([GNULIB_STPCPY])
+  GNULIB_STPNCPY=0;     AC_SUBST([GNULIB_STPNCPY])
+  GNULIB_STRCHRNUL=0;   AC_SUBST([GNULIB_STRCHRNUL])
+  GNULIB_STRDUP=0;      AC_SUBST([GNULIB_STRDUP])
+  GNULIB_STRNCAT=0;     AC_SUBST([GNULIB_STRNCAT])
+  GNULIB_STRNDUP=0;     AC_SUBST([GNULIB_STRNDUP])
+  GNULIB_STRNLEN=0;     AC_SUBST([GNULIB_STRNLEN])
+  GNULIB_STRPBRK=0;     AC_SUBST([GNULIB_STRPBRK])
+  GNULIB_STRSEP=0;      AC_SUBST([GNULIB_STRSEP])
+  GNULIB_STRSTR=0;      AC_SUBST([GNULIB_STRSTR])
+  GNULIB_STRCASESTR=0;  AC_SUBST([GNULIB_STRCASESTR])
+  GNULIB_STRTOK_R=0;    AC_SUBST([GNULIB_STRTOK_R])
+  GNULIB_MBSLEN=0;      AC_SUBST([GNULIB_MBSLEN])
+  GNULIB_MBSNLEN=0;     AC_SUBST([GNULIB_MBSNLEN])
+  GNULIB_MBSCHR=0;      AC_SUBST([GNULIB_MBSCHR])
+  GNULIB_MBSRCHR=0;     AC_SUBST([GNULIB_MBSRCHR])
+  GNULIB_MBSSTR=0;      AC_SUBST([GNULIB_MBSSTR])
+  GNULIB_MBSCASECMP=0;  AC_SUBST([GNULIB_MBSCASECMP])
+  GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP])
+  GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP])
+  GNULIB_MBSCASESTR=0;  AC_SUBST([GNULIB_MBSCASESTR])
+  GNULIB_MBSCSPN=0;     AC_SUBST([GNULIB_MBSCSPN])
+  GNULIB_MBSPBRK=0;     AC_SUBST([GNULIB_MBSPBRK])
+  GNULIB_MBSSPN=0;      AC_SUBST([GNULIB_MBSSPN])
+  GNULIB_MBSSEP=0;      AC_SUBST([GNULIB_MBSSEP])
+  GNULIB_MBSTOK_R=0;    AC_SUBST([GNULIB_MBSTOK_R])
+  GNULIB_STRERROR=0;    AC_SUBST([GNULIB_STRERROR])
+  GNULIB_STRERROR_R=0;  AC_SUBST([GNULIB_STRERROR_R])
+  GNULIB_STRSIGNAL=0;   AC_SUBST([GNULIB_STRSIGNAL])
+  GNULIB_STRVERSCMP=0;  AC_SUBST([GNULIB_STRVERSCMP])
+  HAVE_MBSLEN=0;        AC_SUBST([HAVE_MBSLEN])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_MEMCHR=1;                AC_SUBST([HAVE_MEMCHR])
+  HAVE_DECL_MEMMEM=1;           AC_SUBST([HAVE_DECL_MEMMEM])
+  HAVE_MEMPCPY=1;               AC_SUBST([HAVE_MEMPCPY])
+  HAVE_DECL_MEMRCHR=1;          AC_SUBST([HAVE_DECL_MEMRCHR])
+  HAVE_RAWMEMCHR=1;             AC_SUBST([HAVE_RAWMEMCHR])
+  HAVE_STPCPY=1;                AC_SUBST([HAVE_STPCPY])
+  HAVE_STPNCPY=1;               AC_SUBST([HAVE_STPNCPY])
+  HAVE_STRCHRNUL=1;             AC_SUBST([HAVE_STRCHRNUL])
+  HAVE_DECL_STRDUP=1;           AC_SUBST([HAVE_DECL_STRDUP])
+  HAVE_DECL_STRNDUP=1;          AC_SUBST([HAVE_DECL_STRNDUP])
+  HAVE_DECL_STRNLEN=1;          AC_SUBST([HAVE_DECL_STRNLEN])
+  HAVE_STRPBRK=1;               AC_SUBST([HAVE_STRPBRK])
+  HAVE_STRSEP=1;                AC_SUBST([HAVE_STRSEP])
+  HAVE_STRCASESTR=1;            AC_SUBST([HAVE_STRCASESTR])
+  HAVE_DECL_STRTOK_R=1;         AC_SUBST([HAVE_DECL_STRTOK_R])
+  HAVE_DECL_STRERROR_R=1;       AC_SUBST([HAVE_DECL_STRERROR_R])
+  HAVE_DECL_STRSIGNAL=1;        AC_SUBST([HAVE_DECL_STRSIGNAL])
+  HAVE_STRVERSCMP=1;            AC_SUBST([HAVE_STRVERSCMP])
+  REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
+  REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
+  REPLACE_STPNCPY=0;            AC_SUBST([REPLACE_STPNCPY])
+  REPLACE_STRDUP=0;             AC_SUBST([REPLACE_STRDUP])
+  REPLACE_STRSTR=0;             AC_SUBST([REPLACE_STRSTR])
+  REPLACE_STRCASESTR=0;         AC_SUBST([REPLACE_STRCASESTR])
+  REPLACE_STRERROR=0;           AC_SUBST([REPLACE_STRERROR])
+  REPLACE_STRERROR_R=0;         AC_SUBST([REPLACE_STRERROR_R])
+  REPLACE_STRNCAT=0;            AC_SUBST([REPLACE_STRNCAT])
+  REPLACE_STRNDUP=0;            AC_SUBST([REPLACE_STRNDUP])
+  REPLACE_STRNLEN=0;            AC_SUBST([REPLACE_STRNLEN])
+  REPLACE_STRSIGNAL=0;          AC_SUBST([REPLACE_STRSIGNAL])
+  REPLACE_STRTOK_R=0;           AC_SUBST([REPLACE_STRTOK_R])
+  UNDEFINE_STRTOK_R=0;          AC_SUBST([UNDEFINE_STRTOK_R])
+])
diff --git a/gnulib/m4/strndup.m4 b/gnulib/m4/strndup.m4
new file mode 100644 (file)
index 0000000..d8f00ca
--- /dev/null
@@ -0,0 +1,53 @@
+# strndup.m4 serial 18
+dnl Copyright (C) 2002-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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRNDUP],
+[
+  dnl Persuade glibc <string.h> to declare strndup().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_CHECK_DECLS_ONCE([strndup])
+  AC_CHECK_FUNCS_ONCE([strndup])
+  if test $ac_cv_have_decl_strndup = no; then
+    HAVE_DECL_STRNDUP=0
+  fi
+
+  if test $ac_cv_func_strndup = yes; then
+    # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
+    AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
+      [AC_RUN_IFELSE([
+         AC_LANG_PROGRAM([[#include <string.h>
+                           #include <stdlib.h>]], [[
+#ifndef HAVE_DECL_STRNDUP
+  extern char *strndup (const char *, size_t);
+#endif
+  char *s;
+  s = strndup ("some longer string", 15);
+  free (s);
+  s = strndup ("shorter string", 13);
+  return s[13] != '\0';]])],
+         [gl_cv_func_strndup_works=yes],
+         [gl_cv_func_strndup_works=no],
+         [
+changequote(,)dnl
+          case $host_os in
+            aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
+            *)               gl_cv_func_strndup_works="guessing yes";;
+          esac
+changequote([,])dnl
+         ])])
+    case $gl_cv_func_strndup_works in
+      *no)
+        REPLACE_STRNDUP=1
+        AC_LIBOBJ([strndup])
+        ;;
+    esac
+  else
+    AC_LIBOBJ([strndup])
+  fi
+])
diff --git a/gnulib/m4/strnlen.m4 b/gnulib/m4/strnlen.m4
new file mode 100644 (file)
index 0000000..a1c59ac
--- /dev/null
@@ -0,0 +1,32 @@
+# strnlen.m4 serial 12
+dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation,
+dnl 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_STRNLEN],
+[
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+
+  dnl Persuade glibc <string.h> to declare strnlen().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_DECLS_ONCE([strnlen])
+  if test $ac_cv_have_decl_strnlen = no; then
+    HAVE_DECL_STRNLEN=0
+  else
+    AC_FUNC_STRNLEN
+    dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
+    if test $ac_cv_func_strnlen_working = no; then
+      REPLACE_STRNLEN=1
+    fi
+  fi
+  if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
+    AC_LIBOBJ([strnlen])
+    gl_PREREQ_STRNLEN
+  fi
+])
+
+# Prerequisites of lib/strnlen.c.
+AC_DEFUN([gl_PREREQ_STRNLEN], [:])
diff --git a/gnulib/m4/strstr.m4 b/gnulib/m4/strstr.m4
new file mode 100644 (file)
index 0000000..a42a1db
--- /dev/null
@@ -0,0 +1,127 @@
+# strstr.m4 serial 13
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Check that strstr works.
+AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
+[
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_MEMCHR])
+  if test "$gl_cv_func_memchr_works" != yes; then
+    REPLACE_STRSTR=1
+    AC_LIBOBJ([strstr])
+  else
+    dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.
+    AC_CACHE_CHECK([whether strstr works],
+      [gl_cv_func_strstr_works_always],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <string.h> /* for strstr */
+#define P "_EF_BF_BD"
+#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
+#define NEEDLE P P P P P
+]], [[return !!strstr (HAYSTACK, NEEDLE);
+    ]])],
+        [gl_cv_func_strstr_works_always=yes],
+        [gl_cv_func_strstr_works_always=no],
+        [dnl glibc 2.12 and cygwin 1.7.7 have a known bug.  uClibc is not
+         dnl affected, since it uses different source code for strstr than
+         dnl glibc.
+         dnl Assume that it works on all other platforms, even if it is not
+         dnl linear.
+         AC_EGREP_CPP([Lucky user],
+           [
+#ifdef __GNU_LIBRARY__
+ #include <features.h>
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
+     || defined __UCLIBC__
+  Lucky user
+ #endif
+#elif defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#else
+  Lucky user
+#endif
+           ],
+           [gl_cv_func_strstr_works_always=yes],
+           [gl_cv_func_strstr_works_always="guessing no"])
+        ])
+      ])
+    if test "$gl_cv_func_strstr_works_always" != yes; then
+      REPLACE_STRSTR=1
+      AC_LIBOBJ([strstr])
+    fi
+  fi
+]) # gl_FUNC_STRSTR_SIMPLE
+
+dnl Additionally, check that strstr is efficient.
+AC_DEFUN([gl_FUNC_STRSTR],
+[
+  AC_REQUIRE([gl_FUNC_STRSTR_SIMPLE])
+  if test $REPLACE_STRSTR = 0; then
+    AC_CACHE_CHECK([whether strstr works in linear time],
+      [gl_cv_func_strstr_linear],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <signal.h> /* for signal */
+#include <string.h> /* for strstr */
+#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for alarm */
+static void quit (int sig) { exit (sig + 128); }
+]], [[
+    int result = 0;
+    size_t m = 1000000;
+    char *haystack = (char *) malloc (2 * m + 2);
+    char *needle = (char *) malloc (m + 2);
+    /* Failure to compile this test due to missing alarm is okay,
+       since all such platforms (mingw) also have quadratic strstr.  */
+    signal (SIGALRM, quit);
+    alarm (5);
+    /* Check for quadratic performance.  */
+    if (haystack && needle)
+      {
+        memset (haystack, 'A', 2 * m);
+        haystack[2 * m] = 'B';
+        haystack[2 * m + 1] = 0;
+        memset (needle, 'A', m);
+        needle[m] = 'B';
+        needle[m + 1] = 0;
+        if (!strstr (haystack, needle))
+          result |= 1;
+      }
+    return result;
+    ]])],
+        [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
+        [dnl Only glibc > 2.12 and cygwin > 1.7.7 are known to have a
+         dnl bug-free strstr that works in linear time.
+         AC_EGREP_CPP([Lucky user],
+           [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
+     && !defined __UCLIBC__
+  Lucky user
+ #endif
+#endif
+#ifdef __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#endif
+           ],
+           [gl_cv_func_strstr_linear=yes],
+           [gl_cv_func_strstr_linear="guessing no"])
+        ])
+      ])
+    if test "$gl_cv_func_strstr_linear" != yes; then
+      REPLACE_STRSTR=1
+    fi
+  fi
+  if test $REPLACE_STRSTR = 1; then
+    AC_LIBOBJ([strstr])
+  fi
+]) # gl_FUNC_STRSTR
diff --git a/gnulib/m4/symlink.m4 b/gnulib/m4/symlink.m4
new file mode 100644 (file)
index 0000000..917d5f0
--- /dev/null
@@ -0,0 +1,45 @@
+# serial 4
+# See if we need to provide symlink replacement.
+
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Written by Eric Blake.
+
+AC_DEFUN([gl_FUNC_SYMLINK],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([symlink])
+  dnl The best we can do on mingw is provide a dummy that always fails, so
+  dnl that compilation can proceed with fewer ifdefs.  On FreeBSD 7.2, AIX 7.1,
+  dnl and Solaris 9, we want to fix a bug with trailing slash handling.
+  if test $ac_cv_func_symlink = no; then
+    HAVE_SYMLINK=0
+    AC_LIBOBJ([symlink])
+  else
+    AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
+      [gl_cv_func_symlink_works],
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM(
+           [[#include <unistd.h>
+           ]],
+           [[int result = 0;
+             if (!symlink ("a", "conftest.link/"))
+               result |= 1;
+             if (symlink ("conftest.f", "conftest.lnk2"))
+               result |= 2;
+             else if (!symlink ("a", "conftest.lnk2/"))
+               result |= 4;
+             return result;
+           ]])],
+         [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
+         [gl_cv_func_symlink_works="guessing no"])
+      rm -f conftest.f conftest.link conftest.lnk2])
+    if test "$gl_cv_func_symlink_works" != yes; then
+      REPLACE_SYMLINK=1
+      AC_LIBOBJ([symlink])
+    fi
+  fi
+])
diff --git a/gnulib/m4/sys_stat_h.m4 b/gnulib/m4/sys_stat_h.m4
new file mode 100644 (file)
index 0000000..fc41912
--- /dev/null
@@ -0,0 +1,82 @@
+# sys_stat_h.m4 serial 24   -*- Autoconf -*-
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Eric Blake.
+dnl Provide a GNU-like <sys/stat.h>.
+
+AC_DEFUN([gl_HEADER_SYS_STAT_H],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+
+  dnl For the mkdir substitute.
+  AC_REQUIRE([AC_C_INLINE])
+
+  dnl Check for broken stat macros.
+  AC_REQUIRE([AC_HEADER_STAT])
+
+  gl_CHECK_NEXT_HEADERS([sys/stat.h])
+
+  dnl Define types that are supposed to be defined in <sys/types.h> or
+  dnl <sys/stat.h>.
+  AC_CHECK_TYPE([nlink_t], [],
+    [AC_DEFINE([nlink_t], [int],
+       [Define to the type of st_nlink in struct stat, or a supertype.])],
+    [#include <sys/types.h>
+     #include <sys/stat.h>])
+
+  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([[#include <sys/stat.h>
+    ]], [fchmodat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
+    mknod mknodat stat utimensat])
+]) # gl_HEADER_SYS_STAT_H
+
+AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_STAT_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_SYS_STAT_H_DEFAULTS],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
+  GNULIB_FCHMODAT=0;    AC_SUBST([GNULIB_FCHMODAT])
+  GNULIB_FSTATAT=0;     AC_SUBST([GNULIB_FSTATAT])
+  GNULIB_FUTIMENS=0;    AC_SUBST([GNULIB_FUTIMENS])
+  GNULIB_LCHMOD=0;      AC_SUBST([GNULIB_LCHMOD])
+  GNULIB_LSTAT=0;       AC_SUBST([GNULIB_LSTAT])
+  GNULIB_MKDIRAT=0;     AC_SUBST([GNULIB_MKDIRAT])
+  GNULIB_MKFIFO=0;      AC_SUBST([GNULIB_MKFIFO])
+  GNULIB_MKFIFOAT=0;    AC_SUBST([GNULIB_MKFIFOAT])
+  GNULIB_MKNOD=0;       AC_SUBST([GNULIB_MKNOD])
+  GNULIB_MKNODAT=0;     AC_SUBST([GNULIB_MKNODAT])
+  GNULIB_STAT=0;        AC_SUBST([GNULIB_STAT])
+  GNULIB_UTIMENSAT=0;   AC_SUBST([GNULIB_UTIMENSAT])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_FCHMODAT=1;      AC_SUBST([HAVE_FCHMODAT])
+  HAVE_FSTATAT=1;       AC_SUBST([HAVE_FSTATAT])
+  HAVE_FUTIMENS=1;      AC_SUBST([HAVE_FUTIMENS])
+  HAVE_LCHMOD=1;        AC_SUBST([HAVE_LCHMOD])
+  HAVE_LSTAT=1;         AC_SUBST([HAVE_LSTAT])
+  HAVE_MKDIRAT=1;       AC_SUBST([HAVE_MKDIRAT])
+  HAVE_MKFIFO=1;        AC_SUBST([HAVE_MKFIFO])
+  HAVE_MKFIFOAT=1;      AC_SUBST([HAVE_MKFIFOAT])
+  HAVE_MKNOD=1;         AC_SUBST([HAVE_MKNOD])
+  HAVE_MKNODAT=1;       AC_SUBST([HAVE_MKNODAT])
+  HAVE_UTIMENSAT=1;     AC_SUBST([HAVE_UTIMENSAT])
+  REPLACE_FSTAT=0;      AC_SUBST([REPLACE_FSTAT])
+  REPLACE_FSTATAT=0;    AC_SUBST([REPLACE_FSTATAT])
+  REPLACE_FUTIMENS=0;   AC_SUBST([REPLACE_FUTIMENS])
+  REPLACE_LSTAT=0;      AC_SUBST([REPLACE_LSTAT])
+  REPLACE_MKDIR=0;      AC_SUBST([REPLACE_MKDIR])
+  REPLACE_MKFIFO=0;     AC_SUBST([REPLACE_MKFIFO])
+  REPLACE_MKNOD=0;      AC_SUBST([REPLACE_MKNOD])
+  REPLACE_STAT=0;       AC_SUBST([REPLACE_STAT])
+  REPLACE_UTIMENSAT=0;  AC_SUBST([REPLACE_UTIMENSAT])
+])
diff --git a/gnulib/m4/sys_wait_h.m4 b/gnulib/m4/sys_wait_h.m4
new file mode 100644 (file)
index 0000000..e3b147c
--- /dev/null
@@ -0,0 +1,33 @@
+# sys_wait_h.m4 serial 5
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SYS_WAIT_H],
+[
+  AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS])
+
+  dnl <sys/wait.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_CHECK_NEXT_HEADERS([sys/wait.h])
+
+  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([[#include <sys/wait.h>]],
+    [waitpid])
+])
+
+AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_WAIT_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_SYS_WAIT_H_DEFAULTS],
+[
+  GNULIB_WAITPID=0; AC_SUBST([GNULIB_WAITPID])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+])
diff --git a/gnulib/m4/thread.m4 b/gnulib/m4/thread.m4
new file mode 100644 (file)
index 0000000..49a4bc7
--- /dev/null
@@ -0,0 +1,18 @@
+# thread.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_THREAD],
+[
+  AC_REQUIRE([gl_THREADLIB])
+  AC_REQUIRE([AC_C_INLINE])
+
+  if test $gl_threads_api = posix; then
+    gl_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBMULTITHREAD"
+    AC_CHECK_FUNCS([pthread_atfork])
+    LIBS="$gl_save_LIBS"
+  fi
+])
diff --git a/gnulib/m4/threadlib.m4 b/gnulib/m4/threadlib.m4
new file mode 100644 (file)
index 0000000..8a621fd
--- /dev/null
@@ -0,0 +1,369 @@
+# threadlib.m4 serial 8 (gettext-0.18.2)
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl gl_THREADLIB
+dnl ------------
+dnl Tests for a multithreading library to be used.
+dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO
+dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
+dnl default is 'no', otherwise it is system dependent. In both cases, the user
+dnl can change the choice through the options --enable-threads=choice or
+dnl --disable-threads.
+dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
+dnl USE_PTH_THREADS, USE_WIN32_THREADS
+dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
+dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
+dnl libtool).
+dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
+dnl programs that really need multithread functionality. The difference
+dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
+dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
+dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
+dnl multithread-safe programs.
+
+AC_DEFUN([gl_THREADLIB_EARLY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+])
+
+dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_EARLY_BODY],
+[
+  dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
+  dnl influences the result of the autoconf tests that test for *_unlocked
+  dnl declarations, on AIX 5 at least. Therefore it must come early.
+  AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
+  AC_BEFORE([$0], [gl_ARGP])dnl
+
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
+  dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
+  dnl AC_GNU_SOURCE.
+  m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
+    [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
+    [AC_REQUIRE([AC_GNU_SOURCE])])
+  dnl Check for multithreading.
+  m4_ifdef([gl_THREADLIB_DEFAULT_NO],
+    [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
+    [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
+  AC_ARG_ENABLE([threads],
+AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
+AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
+    [gl_use_threads=$enableval],
+    [if test -n "$gl_use_threads_default"; then
+       gl_use_threads="$gl_use_threads_default"
+     else
+changequote(,)dnl
+       case "$host_os" in
+         dnl Disable multithreading by default on OSF/1, because it interferes
+         dnl with fork()/exec(): When msgexec is linked with -lpthread, its
+         dnl child process gets an endless segmentation fault inside execvp().
+         dnl Disable multithreading by default on Cygwin 1.5.x, because it has
+         dnl bugs that lead to endless loops or crashes. See
+         dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
+         osf*) gl_use_threads=no ;;
+         cygwin*)
+               case `uname -r` in
+                 1.[0-5].*) gl_use_threads=no ;;
+                 *)         gl_use_threads=yes ;;
+               esac
+               ;;
+         *)    gl_use_threads=yes ;;
+       esac
+changequote([,])dnl
+     fi
+    ])
+  if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+    # For using <pthread.h>:
+    case "$host_os" in
+      osf*)
+        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
+        # groks <pthread.h>. cc also understands the flag -pthread, but
+        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
+        # 2. putting a flag into CPPFLAGS that has an effect on the linker
+        # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
+        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
+        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
+        ;;
+    esac
+    # Some systems optimize for single-threaded programs by default, and
+    # need special flags to disable these optimizations. For example, the
+    # definition of 'errno' in <errno.h>.
+    case "$host_os" in
+      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
+      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
+    esac
+  fi
+])
+
+dnl The guts of gl_THREADLIB. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_BODY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+  gl_threads_api=none
+  LIBTHREAD=
+  LTLIBTHREAD=
+  LIBMULTITHREAD=
+  LTLIBMULTITHREAD=
+  if test "$gl_use_threads" != no; then
+    dnl Check whether the compiler and linker support weak declarations.
+    AC_CACHE_CHECK([whether imported symbols can be declared weak],
+      [gl_cv_have_weak],
+      [gl_cv_have_weak=no
+       dnl First, test whether the compiler accepts it syntactically.
+       AC_LINK_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[extern void xyzzy ();
+#pragma weak xyzzy]],
+            [[xyzzy();]])],
+         [gl_cv_have_weak=maybe])
+       if test $gl_cv_have_weak = maybe; then
+         dnl Second, test whether it actually works. On Cygwin 1.7.2, with
+         dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
+         AC_RUN_IFELSE(
+           [AC_LANG_SOURCE([[
+#include <stdio.h>
+#pragma weak fputs
+int main ()
+{
+  return (fputs == NULL);
+}]])],
+           [gl_cv_have_weak=yes],
+           [gl_cv_have_weak=no],
+           [dnl When cross-compiling, assume that only ELF platforms support
+            dnl weak symbols.
+            AC_EGREP_CPP([Extensible Linking Format],
+              [#ifdef __ELF__
+               Extensible Linking Format
+               #endif
+              ],
+              [gl_cv_have_weak="guessing yes"],
+              [gl_cv_have_weak="guessing no"])
+           ])
+       fi
+      ])
+    if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+      # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
+      # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
+      AC_CHECK_HEADER([pthread.h],
+        [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
+      if test "$gl_have_pthread_h" = yes; then
+        # Other possible tests:
+        #   -lpthreads (FSU threads, PCthreads)
+        #   -lgthreads
+        gl_have_pthread=
+        # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
+        # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
+        # the second one only in libpthread, and lock.c needs it.
+        AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[#include <pthread.h>]],
+             [[pthread_mutex_lock((pthread_mutex_t*)0);
+               pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
+          [gl_have_pthread=yes])
+        # Test for libpthread by looking for pthread_kill. (Not pthread_self,
+        # since it is defined as a macro on OSF/1.)
+        if test -n "$gl_have_pthread"; then
+          # The program links fine without libpthread. But it may actually
+          # need to link with libpthread in order to create multiple threads.
+          AC_CHECK_LIB([pthread], [pthread_kill],
+            [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
+             # On Solaris and HP-UX, most pthread functions exist also in libc.
+             # Therefore pthread_in_use() needs to actually try to create a
+             # thread: pthread_create from libc will fail, whereas
+             # pthread_create will actually create a thread.
+             case "$host_os" in
+               solaris* | hpux*)
+                 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
+                   [Define if the pthread_in_use() detection is hard.])
+             esac
+            ])
+        else
+          # Some library is needed. Try libpthread and libc_r.
+          AC_CHECK_LIB([pthread], [pthread_kill],
+            [gl_have_pthread=yes
+             LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
+             LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
+          if test -z "$gl_have_pthread"; then
+            # For FreeBSD 4.
+            AC_CHECK_LIB([c_r], [pthread_kill],
+              [gl_have_pthread=yes
+               LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
+               LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
+          fi
+        fi
+        if test -n "$gl_have_pthread"; then
+          gl_threads_api=posix
+          AC_DEFINE([USE_POSIX_THREADS], [1],
+            [Define if the POSIX multithreading library can be used.])
+          if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+            if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+              AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
+                [Define if references to the POSIX multithreading library should be made weak.])
+              LIBTHREAD=
+              LTLIBTHREAD=
+            fi
+          fi
+        fi
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
+        gl_have_solaristhread=
+        gl_save_LIBS="$LIBS"
+        LIBS="$LIBS -lthread"
+        AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[
+#include <thread.h>
+#include <synch.h>
+             ]],
+             [[thr_self();]])],
+          [gl_have_solaristhread=yes])
+        LIBS="$gl_save_LIBS"
+        if test -n "$gl_have_solaristhread"; then
+          gl_threads_api=solaris
+          LIBTHREAD=-lthread
+          LTLIBTHREAD=-lthread
+          LIBMULTITHREAD="$LIBTHREAD"
+          LTLIBMULTITHREAD="$LTLIBTHREAD"
+          AC_DEFINE([USE_SOLARIS_THREADS], [1],
+            [Define if the old Solaris multithreading library can be used.])
+          if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+            AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
+              [Define if references to the old Solaris multithreading library should be made weak.])
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      fi
+    fi
+    if test "$gl_use_threads" = pth; then
+      gl_save_CPPFLAGS="$CPPFLAGS"
+      AC_LIB_LINKFLAGS([pth])
+      gl_have_pth=
+      gl_save_LIBS="$LIBS"
+      LIBS="$LIBS $LIBPTH"
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
+        [gl_have_pth=yes])
+      LIBS="$gl_save_LIBS"
+      if test -n "$gl_have_pth"; then
+        gl_threads_api=pth
+        LIBTHREAD="$LIBPTH"
+        LTLIBTHREAD="$LTLIBPTH"
+        LIBMULTITHREAD="$LIBTHREAD"
+        LTLIBMULTITHREAD="$LTLIBTHREAD"
+        AC_DEFINE([USE_PTH_THREADS], [1],
+          [Define if the GNU Pth multithreading library can be used.])
+        if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+          if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+            AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
+              [Define if references to the GNU Pth multithreading library should be made weak.])
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      else
+        CPPFLAGS="$gl_save_CPPFLAGS"
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
+        if { case "$host_os" in
+               mingw*) true;;
+               *) false;;
+             esac
+           }; then
+          gl_threads_api=win32
+          AC_DEFINE([USE_WIN32_THREADS], [1],
+            [Define if the Win32 multithreading API can be used.])
+        fi
+      fi
+    fi
+  fi
+  AC_MSG_CHECKING([for multithread API to use])
+  AC_MSG_RESULT([$gl_threads_api])
+  AC_SUBST([LIBTHREAD])
+  AC_SUBST([LTLIBTHREAD])
+  AC_SUBST([LIBMULTITHREAD])
+  AC_SUBST([LTLIBMULTITHREAD])
+])
+
+AC_DEFUN([gl_THREADLIB],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY])
+  AC_REQUIRE([gl_THREADLIB_BODY])
+])
+
+
+dnl gl_DISABLE_THREADS
+dnl ------------------
+dnl Sets the gl_THREADLIB default so that threads are not used by default.
+dnl The user can still override it at installation time, by using the
+dnl configure option '--enable-threads'.
+
+AC_DEFUN([gl_DISABLE_THREADS], [
+  m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
+])
+
+
+dnl Survey of platforms:
+dnl
+dnl Platform          Available   Compiler    Supports   test-lock
+dnl                   flavours    option      weak       result
+dnl ---------------   ---------   ---------   --------   ---------
+dnl Linux 2.4/glibc   posix       -lpthread       Y      OK
+dnl
+dnl GNU Hurd/glibc    posix
+dnl
+dnl FreeBSD 5.3       posix       -lc_r           Y
+dnl                   posix       -lkse ?         Y
+dnl                   posix       -lpthread ?     Y
+dnl                   posix       -lthr           Y
+dnl
+dnl FreeBSD 5.2       posix       -lc_r           Y
+dnl                   posix       -lkse           Y
+dnl                   posix       -lthr           Y
+dnl
+dnl FreeBSD 4.0,4.10  posix       -lc_r           Y      OK
+dnl
+dnl NetBSD 1.6        --
+dnl
+dnl OpenBSD 3.4       posix       -lpthread       Y      OK
+dnl
+dnl MacOS X 10.[123]  posix       -lpthread       Y      OK
+dnl
+dnl Solaris 7,8,9     posix       -lpthread       Y      Sol 7,8: 0.0; Sol 9: OK
+dnl                   solaris     -lthread        Y      Sol 7,8: 0.0; Sol 9: OK
+dnl
+dnl HP-UX 11          posix       -lpthread       N (cc) OK
+dnl                                               Y (gcc)
+dnl
+dnl IRIX 6.5          posix       -lpthread       Y      0.5
+dnl
+dnl AIX 4.3,5.1       posix       -lpthread       N      AIX 4: 0.5; AIX 5: OK
+dnl
+dnl OSF/1 4.0,5.1     posix       -pthread (cc)   N      OK
+dnl                               -lpthread (gcc) Y
+dnl
+dnl Cygwin            posix       -lpthread       Y      OK
+dnl
+dnl Any of the above  pth         -lpth                  0.0
+dnl
+dnl Mingw             win32                       N      OK
+dnl
+dnl BeOS 5            --
+dnl
+dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
+dnl turned off:
+dnl   OK if all three tests terminate OK,
+dnl   0.5 if the first test terminates OK but the second one loops endlessly,
+dnl   0.0 if the first test already loops endlessly.
diff --git a/gnulib/m4/time_h.m4 b/gnulib/m4/time_h.m4
new file mode 100644 (file)
index 0000000..615da1c
--- /dev/null
@@ -0,0 +1,109 @@
+# Configure a more-standard replacement for <time.h>.
+
+# Copyright (C) 2000-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
+
+# serial 4
+
+# 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.
+
+# Written by Paul Eggert and Jim Meyering.
+
+AC_DEFUN([gl_HEADER_TIME_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_TIME_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_TIME_H_BODY],
+[
+  AC_REQUIRE([AC_C_RESTRICT])
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
+  gl_NEXT_HEADERS([time.h])
+  AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
+])
+
+dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
+dnl in time.h, sys/time.h, or pthread.h.
+
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
+[
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
+  AC_CACHE_CHECK([for struct timespec in <time.h>],
+    [gl_cv_sys_struct_timespec_in_time_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <time.h>
+          ]],
+          [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+       [gl_cv_sys_struct_timespec_in_time_h=yes],
+       [gl_cv_sys_struct_timespec_in_time_h=no])])
+
+  TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
+  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
+    TIME_H_DEFINES_STRUCT_TIMESPEC=1
+  else
+    AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
+      [gl_cv_sys_struct_timespec_in_sys_time_h],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <sys/time.h>
+            ]],
+            [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+         [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
+         [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
+    if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
+      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
+    else
+      AC_CACHE_CHECK([for struct timespec in <pthread.h>],
+        [gl_cv_sys_struct_timespec_in_pthread_h],
+        [AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <pthread.h>
+              ]],
+              [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+           [gl_cv_sys_struct_timespec_in_pthread_h=yes],
+           [gl_cv_sys_struct_timespec_in_pthread_h=no])])
+      if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
+        PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
+      fi
+    fi
+  fi
+  AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
+  AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
+  AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
+])
+
+AC_DEFUN([gl_TIME_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_HEADER_TIME_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_HEADER_TIME_H_DEFAULTS],
+[
+  GNULIB_MKTIME=0;                       AC_SUBST([GNULIB_MKTIME])
+  GNULIB_NANOSLEEP=0;                    AC_SUBST([GNULIB_NANOSLEEP])
+  GNULIB_STRPTIME=0;                     AC_SUBST([GNULIB_STRPTIME])
+  GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
+  GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_DECL_LOCALTIME_R=1;               AC_SUBST([HAVE_DECL_LOCALTIME_R])
+  HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
+  HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
+  HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
+  dnl If another module says to replace or to not replace, do that.
+  dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
+  dnl this lets maintainers check for portability.
+  REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
+  REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
+  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
+  REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
+])
diff --git a/gnulib/m4/unistd_h.m4 b/gnulib/m4/unistd_h.m4
new file mode 100644 (file)
index 0000000..c81a113
--- /dev/null
@@ -0,0 +1,162 @@
+# unistd_h.m4 serial 53
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Simon Josefsson, Bruno Haible.
+
+AC_DEFUN([gl_UNISTD_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_C_INLINE])
+
+  gl_CHECK_NEXT_HEADERS([unistd.h])
+  if test $ac_cv_header_unistd_h = yes; then
+    HAVE_UNISTD_H=1
+  else
+    HAVE_UNISTD_H=0
+  fi
+  AC_SUBST([HAVE_UNISTD_H])
+
+  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([[#include <unistd.h>
+/* Some systems declare various items in the wrong headers.  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <fcntl.h>
+# include <stdio.h>
+# include <stdlib.h>
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#  include <io.h>
+# endif
+#endif
+    ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
+    fsync ftruncate getcwd getdomainname getdtablesize getgroups
+    gethostname getlogin getlogin_r getpagesize getusershell setusershell
+    endusershell lchown link linkat lseek pipe pipe2 pread pwrite readlink
+    readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
+    usleep])
+])
+
+AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_UNISTD_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_UNISTD_H_DEFAULTS],
+[
+  GNULIB_CHOWN=0;            AC_SUBST([GNULIB_CHOWN])
+  GNULIB_CLOSE=0;            AC_SUBST([GNULIB_CLOSE])
+  GNULIB_DUP2=0;             AC_SUBST([GNULIB_DUP2])
+  GNULIB_DUP3=0;             AC_SUBST([GNULIB_DUP3])
+  GNULIB_ENVIRON=0;          AC_SUBST([GNULIB_ENVIRON])
+  GNULIB_EUIDACCESS=0;       AC_SUBST([GNULIB_EUIDACCESS])
+  GNULIB_FACCESSAT=0;        AC_SUBST([GNULIB_FACCESSAT])
+  GNULIB_FCHDIR=0;           AC_SUBST([GNULIB_FCHDIR])
+  GNULIB_FCHOWNAT=0;         AC_SUBST([GNULIB_FCHOWNAT])
+  GNULIB_FSYNC=0;            AC_SUBST([GNULIB_FSYNC])
+  GNULIB_FTRUNCATE=0;        AC_SUBST([GNULIB_FTRUNCATE])
+  GNULIB_GETCWD=0;           AC_SUBST([GNULIB_GETCWD])
+  GNULIB_GETDOMAINNAME=0;    AC_SUBST([GNULIB_GETDOMAINNAME])
+  GNULIB_GETDTABLESIZE=0;    AC_SUBST([GNULIB_GETDTABLESIZE])
+  GNULIB_GETGROUPS=0;        AC_SUBST([GNULIB_GETGROUPS])
+  GNULIB_GETHOSTNAME=0;      AC_SUBST([GNULIB_GETHOSTNAME])
+  GNULIB_GETLOGIN=0;         AC_SUBST([GNULIB_GETLOGIN])
+  GNULIB_GETLOGIN_R=0;       AC_SUBST([GNULIB_GETLOGIN_R])
+  GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
+  GNULIB_GETUSERSHELL=0;     AC_SUBST([GNULIB_GETUSERSHELL])
+  GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
+  GNULIB_LINK=0;             AC_SUBST([GNULIB_LINK])
+  GNULIB_LINKAT=0;           AC_SUBST([GNULIB_LINKAT])
+  GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
+  GNULIB_PIPE=0;             AC_SUBST([GNULIB_PIPE])
+  GNULIB_PIPE2=0;            AC_SUBST([GNULIB_PIPE2])
+  GNULIB_PREAD=0;            AC_SUBST([GNULIB_PREAD])
+  GNULIB_PWRITE=0;           AC_SUBST([GNULIB_PWRITE])
+  GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
+  GNULIB_READLINKAT=0;       AC_SUBST([GNULIB_READLINKAT])
+  GNULIB_RMDIR=0;            AC_SUBST([GNULIB_RMDIR])
+  GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
+  GNULIB_SYMLINK=0;          AC_SUBST([GNULIB_SYMLINK])
+  GNULIB_SYMLINKAT=0;        AC_SUBST([GNULIB_SYMLINKAT])
+  GNULIB_TTYNAME_R=0;        AC_SUBST([GNULIB_TTYNAME_R])
+  GNULIB_UNISTD_H_GETOPT=0;  AC_SUBST([GNULIB_UNISTD_H_GETOPT])
+  GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
+  GNULIB_UNLINK=0;           AC_SUBST([GNULIB_UNLINK])
+  GNULIB_UNLINKAT=0;         AC_SUBST([GNULIB_UNLINKAT])
+  GNULIB_USLEEP=0;           AC_SUBST([GNULIB_USLEEP])
+  GNULIB_WRITE=0;            AC_SUBST([GNULIB_WRITE])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
+  HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
+  HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
+  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
+  HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
+  HAVE_FCHDIR=1;          AC_SUBST([HAVE_FCHDIR])
+  HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
+  HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
+  HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
+  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
+  HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
+  HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
+  HAVE_GETLOGIN=1;        AC_SUBST([HAVE_GETLOGIN])
+  HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
+  HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
+  HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
+  HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
+  HAVE_PIPE=1;            AC_SUBST([HAVE_PIPE])
+  HAVE_PIPE2=1;           AC_SUBST([HAVE_PIPE2])
+  HAVE_PREAD=1;           AC_SUBST([HAVE_PREAD])
+  HAVE_PWRITE=1;          AC_SUBST([HAVE_PWRITE])
+  HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
+  HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
+  HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
+  HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
+  HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
+  HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
+  HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
+  HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
+  HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
+  HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
+  HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
+  HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
+  HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
+  HAVE_DECL_TTYNAME_R=1;  AC_SUBST([HAVE_DECL_TTYNAME_R])
+  HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
+  HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
+  REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
+  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
+  REPLACE_DUP=0;          AC_SUBST([REPLACE_DUP])
+  REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
+  REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
+  REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
+  REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
+  REPLACE_GETLOGIN_R=0;   AC_SUBST([REPLACE_GETLOGIN_R])
+  REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
+  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
+  REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
+  REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
+  REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
+  REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
+  REPLACE_PREAD=0;        AC_SUBST([REPLACE_PREAD])
+  REPLACE_PWRITE=0;       AC_SUBST([REPLACE_PWRITE])
+  REPLACE_READLINK=0;     AC_SUBST([REPLACE_READLINK])
+  REPLACE_RMDIR=0;        AC_SUBST([REPLACE_RMDIR])
+  REPLACE_SLEEP=0;        AC_SUBST([REPLACE_SLEEP])
+  REPLACE_SYMLINK=0;      AC_SUBST([REPLACE_SYMLINK])
+  REPLACE_TTYNAME_R=0;    AC_SUBST([REPLACE_TTYNAME_R])
+  REPLACE_UNLINK=0;       AC_SUBST([REPLACE_UNLINK])
+  REPLACE_UNLINKAT=0;     AC_SUBST([REPLACE_UNLINKAT])
+  REPLACE_USLEEP=0;       AC_SUBST([REPLACE_USLEEP])
+  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
+  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
+  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
+                           AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
+])
diff --git a/gnulib/m4/vasnprintf.m4 b/gnulib/m4/vasnprintf.m4
new file mode 100644 (file)
index 0000000..32ea985
--- /dev/null
@@ -0,0 +1,289 @@
+# vasnprintf.m4 serial 32
+dnl Copyright (C) 2002-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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_VASNPRINTF],
+[
+  AC_CHECK_FUNCS_ONCE([vasnprintf])
+  if test $ac_cv_func_vasnprintf = no; then
+    gl_REPLACE_VASNPRINTF
+  fi
+])
+
+AC_DEFUN([gl_REPLACE_VASNPRINTF],
+[
+  AC_CHECK_FUNCS_ONCE([vasnprintf])
+  AC_LIBOBJ([vasnprintf])
+  AC_LIBOBJ([printf-args])
+  AC_LIBOBJ([printf-parse])
+  AC_LIBOBJ([asnprintf])
+  if test $ac_cv_func_vasnprintf = yes; then
+    AC_DEFINE([REPLACE_VASNPRINTF], [1],
+      [Define if vasnprintf exists but is overridden by gnulib.])
+  fi
+  gl_PREREQ_PRINTF_ARGS
+  gl_PREREQ_PRINTF_PARSE
+  gl_PREREQ_VASNPRINTF
+  gl_PREREQ_ASNPRINTF
+])
+
+# Prequisites of lib/printf-args.h, lib/printf-args.c.
+AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
+[
+  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+])
+
+# Prequisites of lib/printf-parse.h, lib/printf-parse.c.
+AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
+[
+  AC_REQUIRE([gl_FEATURES_H])
+  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  AC_REQUIRE([AC_TYPE_SIZE_T])
+  AC_CHECK_TYPE([ptrdiff_t], ,
+    [AC_DEFINE([ptrdiff_t], [long],
+       [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
+    ])
+  AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
+])
+
+# Prerequisites of lib/vasnprintf.c.
+AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
+[
+  AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
+  dnl Use the _snprintf function only if it is declared (because on NetBSD it
+  dnl is defined as a weak alias of snprintf; we prefer to use the latter).
+  AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
+  dnl We can avoid a lot of code by assuming that snprintf's return value
+  dnl conforms to ISO C99. So check that.
+  AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
+  case "$gl_cv_func_snprintf_retval_c99" in
+    *yes)
+      AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
+        [Define if the return value of the snprintf function is the number of
+         of bytes (excluding the terminating NUL) that would have been produced
+         if the buffer had been large enough.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
+# arguments.
+AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
+[
+  AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
+  case "$gl_cv_func_printf_long_double" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         'long double' arguments.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
+# arguments.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
+[
+  AC_REQUIRE([gl_PRINTF_INFINITE])
+  case "$gl_cv_func_printf_infinite" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         infinite 'double' arguments.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
+# arguments.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
+[
+  AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
+  dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
+  dnl NEED_PRINTF_LONG_DOUBLE is already set.
+  AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
+  case "$gl_cv_func_printf_long_double" in
+    *yes)
+      case "$gl_cv_func_printf_infinite_long_double" in
+        *yes)
+          ;;
+        *)
+          AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
+            [Define if the vasnprintf implementation needs special code for
+             infinite 'long double' arguments.])
+          ;;
+      esac
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
+[
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+  case "$gl_cv_func_printf_directive_a" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
+        [Define if the vasnprintf implementation needs special code for
+         the 'a' and 'A' directives.])
+      AC_CHECK_FUNCS([nl_langinfo])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
+[
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
+  case "$gl_cv_func_printf_directive_f" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
+        [Define if the vasnprintf implementation needs special code for
+         the 'F' directive.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
+[
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
+  case "$gl_cv_func_printf_directive_ls" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
+        [Define if the vasnprintf implementation needs special code for
+         the 'ls' directive.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
+[
+  AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
+  case "$gl_cv_func_printf_flag_grouping" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
+        [Define if the vasnprintf implementation needs special code for the
+         ' flag.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
+[
+  AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
+  case "$gl_cv_func_printf_flag_leftadjust" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
+        [Define if the vasnprintf implementation needs special code for the
+         '-' flag.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
+[
+  AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
+  case "$gl_cv_func_printf_flag_zero" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
+        [Define if the vasnprintf implementation needs special code for the
+         0 flag.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
+[
+  AC_REQUIRE([gl_PRINTF_PRECISION])
+  case "$gl_cv_func_printf_precision" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
+        [Define if the vasnprintf implementation needs special code for
+         supporting large precisions without arbitrary bounds.])
+      AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         'double' arguments.])
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         'long double' arguments.])
+      ;;
+  esac
+])
+
+# Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
+# conditions.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
+[
+  AC_REQUIRE([gl_PRINTF_ENOMEM])
+  case "$gl_cv_func_printf_enomem" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
+        [Define if the vasnprintf implementation needs special code for
+         surviving out-of-memory conditions.])
+      AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         'double' arguments.])
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
+        [Define if the vasnprintf implementation needs special code for
+         'long double' arguments.])
+      ;;
+  esac
+])
+
+# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
+[
+  AC_REQUIRE([gl_PREREQ_VASNPRINTF])
+  gl_PREREQ_VASNPRINTF_LONG_DOUBLE
+  gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
+  gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_A
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
+  gl_PREREQ_VASNPRINTF_FLAG_GROUPING
+  gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
+  gl_PREREQ_VASNPRINTF_FLAG_ZERO
+  gl_PREREQ_VASNPRINTF_PRECISION
+  gl_PREREQ_VASNPRINTF_ENOMEM
+])
+
+# Prerequisites of lib/asnprintf.c.
+AC_DEFUN([gl_PREREQ_ASNPRINTF],
+[
+])
diff --git a/gnulib/m4/vasprintf.m4 b/gnulib/m4/vasprintf.m4
new file mode 100644 (file)
index 0000000..6db52b1
--- /dev/null
@@ -0,0 +1,46 @@
+# vasprintf.m4 serial 6
+dnl Copyright (C) 2002-2003, 2006-2007, 2009-2011 Free Software Foundation,
+dnl 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_VASPRINTF],
+[
+  AC_CHECK_FUNCS([vasprintf])
+  if test $ac_cv_func_vasprintf = no; then
+    gl_REPLACE_VASPRINTF
+  fi
+])
+
+AC_DEFUN([gl_REPLACE_VASPRINTF],
+[
+  AC_LIBOBJ([vasprintf])
+  AC_LIBOBJ([asprintf])
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  if test $ac_cv_func_vasprintf = yes; then
+    REPLACE_VASPRINTF=1
+  else
+    HAVE_VASPRINTF=0
+  fi
+  gl_PREREQ_VASPRINTF_H
+  gl_PREREQ_VASPRINTF
+  gl_PREREQ_ASPRINTF
+])
+
+# Prerequisites of the vasprintf portion of lib/stdio.h.
+AC_DEFUN([gl_PREREQ_VASPRINTF_H],
+[
+  dnl Persuade glibc <stdio.h> to declare asprintf() and vasprintf().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+])
+
+# Prerequisites of lib/vasprintf.c.
+AC_DEFUN([gl_PREREQ_VASPRINTF],
+[
+])
+
+# Prerequisites of lib/asprintf.c.
+AC_DEFUN([gl_PREREQ_ASPRINTF],
+[
+])
diff --git a/gnulib/m4/warn-on-use.m4 b/gnulib/m4/warn-on-use.m4
new file mode 100644 (file)
index 0000000..e0d0f27
--- /dev/null
@@ -0,0 +1,45 @@
+# warn-on-use.m4 serial 2
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
+# ---------------------------------------
+# For each whitespace-separated element in the list of NAMES, define
+# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
+# even after being undefined as a macro.
+#
+# See warn-on-use.h for some hints on how to poison function names, as
+# well as ideas on poisoning global variables and macros.  NAMES may
+# include global variables, but remember that only functions work with
+# _GL_WARN_ON_USE.  Typically, INCLUDES only needs to list a single
+# header, but if the replacement header pulls in other headers because
+# some systems declare functions in the wrong header, then INCLUDES
+# should do likewise.
+#
+# If you assume C89, then it is generally safe to assume declarations
+# for functions declared in that standard (such as gets) without
+# needing gl_WARN_ON_USE_PREPARE.
+AC_DEFUN([gl_WARN_ON_USE_PREPARE],
+[
+  m4_foreach_w([gl_decl], [$2],
+    [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
+      [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
+       undefining macros.])])dnl
+  for gl_func in m4_flatten([$2]); do
+    AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
+    AC_CACHE_CHECK([whether $gl_func is declared without a macro],
+      gl_Symbol,
+      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
+[@%:@undef $gl_func
+  (void) $gl_func;])],
+        [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
+     AS_VAR_IF(gl_Symbol, [yes],
+       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
+       dnl shortcut - if the raw declaration exists, then set a cache
+       dnl variable to allow skipping any later AC_CHECK_DECL efforts
+       eval ac_cv_have_decl_$gl_func=yes])
+    AS_VAR_POPDEF([gl_Symbol])dnl
+  done
+])
diff --git a/gnulib/m4/wchar_h.m4 b/gnulib/m4/wchar_h.m4
new file mode 100644 (file)
index 0000000..6255ff3
--- /dev/null
@@ -0,0 +1,232 @@
+dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
+
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Eric Blake.
+
+# wchar_h.m4 serial 38
+
+AC_DEFUN([gl_WCHAR_H],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
+  dnl Prepare for creating substitute <wchar.h>.
+  dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
+  dnl character support).
+  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
+  gl_CHECK_NEXT_HEADERS([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])
+
+  AC_REQUIRE([gl_FEATURES_H])
+
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+  AC_SUBST([HAVE_WINT_T])
+
+  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>
+#endif
+#include <wchar.h>
+    ]],
+    [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.
+AC_DEFUN([gl_WCHAR_H_INLINE_OK],
+[
+  dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
+  dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
+  dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
+  dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
+  dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
+  AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
+    [gl_cv_header_wchar_h_correct_inline],
+    [gl_cv_header_wchar_h_correct_inline=yes
+     AC_LANG_CONFTEST([
+       AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+/* 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>
+extern int zero (void);
+int main () { return zero(); }
+]])])
+     if AC_TRY_EVAL([ac_compile]); then
+       mv conftest.$ac_objext conftest1.$ac_objext
+       AC_LANG_CONFTEST([
+         AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+/* 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>
+int zero (void) { return 0; }
+]])])
+       if AC_TRY_EVAL([ac_compile]); then
+         mv conftest.$ac_objext conftest2.$ac_objext
+         if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
+           :
+         else
+           gl_cv_header_wchar_h_correct_inline=no
+         fi
+       fi
+     fi
+     rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
+    ])
+  if test $gl_cv_header_wchar_h_correct_inline = no; then
+    AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
+This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
+C99 mode. You have four options:
+  - Add the flag -fgnu89-inline to CC and reconfigure, or
+  - Fix your include files, using parts of
+    <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
+  - Use a gcc version older than 4.3, or
+  - Don't use the flags -std=c99 or -std=gnu99.
+Configuration aborted.])
+  fi
+])
+
+dnl Unconditionally enables the replacement of <wchar.h>.
+AC_DEFUN([gl_REPLACE_WCHAR_H],
+[
+  dnl This is a no-op, because <wchar.h> is always overridden.
+  :
+])
+
+AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_WCHAR_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_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_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])
+  HAVE_MBRTOWC=1;       AC_SUBST([HAVE_MBRTOWC])
+  HAVE_MBRLEN=1;        AC_SUBST([HAVE_MBRLEN])
+  HAVE_MBSRTOWCS=1;     AC_SUBST([HAVE_MBSRTOWCS])
+  HAVE_MBSNRTOWCS=1;    AC_SUBST([HAVE_MBSNRTOWCS])
+  HAVE_WCRTOMB=1;       AC_SUBST([HAVE_WCRTOMB])
+  HAVE_WCSRTOMBS=1;     AC_SUBST([HAVE_WCSRTOMBS])
+  HAVE_WCSNRTOMBS=1;    AC_SUBST([HAVE_WCSNRTOMBS])
+  HAVE_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])
+  REPLACE_BTOWC=0;      AC_SUBST([REPLACE_BTOWC])
+  REPLACE_WCTOB=0;      AC_SUBST([REPLACE_WCTOB])
+  REPLACE_MBSINIT=0;    AC_SUBST([REPLACE_MBSINIT])
+  REPLACE_MBRTOWC=0;    AC_SUBST([REPLACE_MBRTOWC])
+  REPLACE_MBRLEN=0;     AC_SUBST([REPLACE_MBRLEN])
+  REPLACE_MBSRTOWCS=0;  AC_SUBST([REPLACE_MBSRTOWCS])
+  REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
+  REPLACE_WCRTOMB=0;    AC_SUBST([REPLACE_WCRTOMB])
+  REPLACE_WCSRTOMBS=0;  AC_SUBST([REPLACE_WCSRTOMBS])
+  REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
+  REPLACE_WCWIDTH=0;    AC_SUBST([REPLACE_WCWIDTH])
+  REPLACE_WCSWIDTH=0;   AC_SUBST([REPLACE_WCSWIDTH])
+])
diff --git a/gnulib/m4/wchar_t.m4 b/gnulib/m4/wchar_t.m4
new file mode 100644 (file)
index 0000000..d2c03c4
--- /dev/null
@@ -0,0 +1,24 @@
+# wchar_t.m4 serial 4 (gettext-0.18.2)
+dnl Copyright (C) 2002-2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether <stddef.h> has the 'wchar_t' type.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_WCHAR_T],
+[
+  AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stddef.h>
+            wchar_t foo = (wchar_t)'\0';]],
+          [[]])],
+       [gt_cv_c_wchar_t=yes],
+       [gt_cv_c_wchar_t=no])])
+  if test $gt_cv_c_wchar_t = yes; then
+    AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
+  fi
+])
diff --git a/gnulib/m4/wcrtomb.m4 b/gnulib/m4/wcrtomb.m4
new file mode 100644 (file)
index 0000000..2905d9b
--- /dev/null
@@ -0,0 +1,101 @@
+# wcrtomb.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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_WCRTOMB],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+
+  AC_CHECK_FUNCS_ONCE([wcrtomb])
+  if test $ac_cv_func_wcrtomb = no; then
+    HAVE_WCRTOMB=0
+  else
+    if test $REPLACE_MBSTATE_T = 1; then
+      REPLACE_WCRTOMB=1
+    else
+      dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
+      dnl returns 0 instead of 1.
+      AC_REQUIRE([AC_PROG_CC])
+      AC_REQUIRE([gt_LOCALE_FR])
+      AC_REQUIRE([gt_LOCALE_FR_UTF8])
+      AC_REQUIRE([gt_LOCALE_JA])
+      AC_REQUIRE([gt_LOCALE_ZH_CN])
+      AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+      AC_CACHE_CHECK([whether wcrtomb return value is correct],
+        [gl_cv_func_wcrtomb_retval],
+        [
+          dnl Initial guess, used when cross-compiling or when no suitable locale
+          dnl is present.
+changequote(,)dnl
+          case "$host_os" in
+                                     # Guess no on AIX 4, OSF/1 and Solaris.
+            aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
+                                     # Guess yes otherwise.
+            *)                       gl_cv_func_wcrtomb_retval="guessing yes" ;;
+          esac
+changequote([,])dnl
+          if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
+            AC_RUN_IFELSE(
+              [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  int result = 0;
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 1;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 2;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 4;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        result |= 8;
+    }
+  return result;
+}]])],
+              [gl_cv_func_wcrtomb_retval=yes],
+              [gl_cv_func_wcrtomb_retval=no],
+              [:])
+          fi
+        ])
+      case "$gl_cv_func_wcrtomb_retval" in
+        *yes) ;;
+        *) REPLACE_WCRTOMB=1 ;;
+      esac
+    fi
+  fi
+  if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([wcrtomb])
+    gl_PREREQ_WCRTOMB
+  fi
+])
+
+# Prerequisites of lib/wcrtomb.c.
+AC_DEFUN([gl_PREREQ_WCRTOMB], [
+  :
+])
diff --git a/gnulib/m4/wctob.m4 b/gnulib/m4/wctob.m4
new file mode 100644 (file)
index 0000000..3b4633c
--- /dev/null
@@ -0,0 +1,133 @@
+# wctob.m4 serial 7
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_WCTOB],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_CHECK_FUNCS_ONCE([wctob])
+  if test $ac_cv_func_wctob = no; then
+    HAVE_DECL_WCTOB=0
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([wctob])
+    gl_PREREQ_WCTOB
+  else
+
+    dnl Solaris 9 has the wctob() function but it does not work.
+    dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned
+    dnl registers, see <http://cygwin.com/ml/cygwin/2010-05/msg00015.html>.
+    AC_REQUIRE([AC_PROG_CC])
+    AC_REQUIRE([gt_LOCALE_FR])
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+    AC_CACHE_CHECK([whether wctob works],
+      [gl_cv_func_wctob_works],
+      [
+        dnl Initial guess, used when cross-compiling or when no suitable locale
+        dnl is present.
+changequote(,)dnl
+        case "$host_os" in
+            # Guess no on Solaris <= 9 and Cygwin.
+          solaris2.[1-9] | solaris2.[1-9].* | cygwin*)
+            gl_cv_func_wctob_works="guessing no" ;;
+            # Guess yes otherwise.
+          *) gl_cv_func_wctob_works="guessing yes" ;;
+        esac
+changequote([,])dnl
+        case "$host_os" in
+          cygwin*)
+            AC_RUN_IFELSE(
+              [AC_LANG_SOURCE([[
+#include <locale.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+
+register long global __asm__ ("%ebx");
+
+int main ()
+{
+  setlocale (LC_ALL, "en_US.UTF-8");
+
+  global = 0x12345678;
+  if (wctob (0x00FC) != -1)
+    return 1;
+  if (global != 0x12345678)
+    return 2;
+  return 0;
+}]])],
+              [:],
+              [gl_cv_func_wctob_works=no],
+              [:])
+            ;;
+        esac
+        if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#include <locale.h>
+#include <string.h>
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      wchar_t wc;
+
+      if (mbtowc (&wc, "\374", 1) == 1)
+        if (wctob (wc) != (unsigned char) '\374')
+          return 1;
+    }
+  return 0;
+}]])],
+            [gl_cv_func_wctob_works=yes],
+            [gl_cv_func_wctob_works=no],
+            [:])
+        fi
+      ])
+    case "$gl_cv_func_wctob_works" in
+      *yes) ;;
+      *) REPLACE_WCTOB=1 ;;
+    esac
+    if test $REPLACE_WCTOB = 1; then
+      gl_REPLACE_WCHAR_H
+      AC_LIBOBJ([wctob])
+      gl_PREREQ_WCTOB
+    else
+
+      dnl IRIX 6.5 has the wctob() function but does not declare it.
+      AC_CHECK_DECLS([wctob], [], [], [
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
+   before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+])
+      if test $ac_cv_have_decl_wctob != yes; then
+        HAVE_DECL_WCTOB=0
+        gl_REPLACE_WCHAR_H
+      fi
+    fi
+  fi
+])
+
+# Prerequisites of lib/wctob.c.
+AC_DEFUN([gl_PREREQ_WCTOB], [
+  :
+])
diff --git a/gnulib/m4/wctomb.m4 b/gnulib/m4/wctomb.m4
new file mode 100644 (file)
index 0000000..bc21b5b
--- /dev/null
@@ -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], [
+  :
+])
diff --git a/gnulib/m4/wctype_h.m4 b/gnulib/m4/wctype_h.m4
new file mode 100644 (file)
index 0000000..ef9fb04
--- /dev/null
@@ -0,0 +1,174 @@
+# wctype_h.m4 serial 14
+
+dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
+
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+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])
+  if test $ac_cv_func_iswcntrl = yes; then
+    HAVE_ISWCNTRL=1
+  else
+    HAVE_ISWCNTRL=0
+  fi
+  AC_SUBST([HAVE_ISWCNTRL])
+
+  AC_REQUIRE([AC_C_INLINE])
+
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+  AC_SUBST([HAVE_WINT_T])
+
+  gl_CHECK_NEXT_HEADERS([wctype.h])
+  if test $ac_cv_header_wctype_h = yes; then
+    if test $ac_cv_func_iswcntrl = yes; then
+      dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
+      dnl The other functions are likely broken in the same way.
+      AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
+        [
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+               /* 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>
+               int main () { return iswprint ('x') == 0; }
+            ]])],
+            [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
+            [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
+                          #if __GNU_LIBRARY__ == 1
+                          Linux libc5 i18n is broken.
+                          #endif]], [])],
+              [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
+            ])
+        ])
+    fi
+    HAVE_WCTYPE_H=1
+  else
+    HAVE_WCTYPE_H=0
+  fi
+  AC_SUBST([HAVE_WCTYPE_H])
+
+  if test "$gl_cv_func_iswcntrl_works" = no; then
+    REPLACE_ISWCNTRL=1
+  else
+    REPLACE_ISWCNTRL=0
+  fi
+  AC_SUBST([REPLACE_ISWCNTRL])
+
+  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
+    dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
+    :
+  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])
+])
diff --git a/gnulib/m4/wint_t.m4 b/gnulib/m4/wint_t.m4
new file mode 100644 (file)
index 0000000..da1ce3d
--- /dev/null
@@ -0,0 +1,32 @@
+# wint_t.m4 serial 5 (gettext-0.18.2)
+dnl Copyright (C) 2003, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether <wchar.h> has the 'wint_t' type.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_WINT_T],
+[
+  AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_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>
+            wint_t foo = (wchar_t)'\0';]],
+          [[]])],
+       [gt_cv_c_wint_t=yes],
+       [gt_cv_c_wint_t=no])])
+  if test $gt_cv_c_wint_t = yes; then
+    AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
+  fi
+])
diff --git a/gnulib/m4/xsize.m4 b/gnulib/m4/xsize.m4
new file mode 100644 (file)
index 0000000..8c693bc
--- /dev/null
@@ -0,0 +1,13 @@
+# xsize.m4 serial 4
+dnl Copyright (C) 2003-2004, 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_XSIZE],
+[
+  dnl Prerequisites of lib/xsize.h.
+  AC_REQUIRE([gl_SIZE_MAX])
+  AC_REQUIRE([AC_C_INLINE])
+  AC_CHECK_HEADERS([stdint.h])
+])
diff --git a/gnulib/m4/yield.m4 b/gnulib/m4/yield.m4
new file mode 100644 (file)
index 0000000..15d5ac2
--- /dev/null
@@ -0,0 +1,19 @@
+# yield.m4 serial 2
+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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_YIELD],
+[
+  AC_REQUIRE([gl_THREADLIB])
+  dnl On some systems, sched_yield is in librt, rather than in libpthread.
+  YIELD_LIB=
+  if test $gl_threads_api = posix; then
+    dnl Solaris has sched_yield in librt, not in libpthread or libc.
+    AC_CHECK_LIB([rt], [sched_yield], [YIELD_LIB=-lrt],
+      [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
+       AC_CHECK_LIB([posix4], [sched_yield], [YIELD_LIB=-lposix4])])
+  fi
+  AC_SUBST([YIELD_LIB])
+])
diff --git a/gnulib/tests/Makefile.am b/gnulib/tests/Makefile.am
new file mode 100644 (file)
index 0000000..3676a7d
--- /dev/null
@@ -0,0 +1,843 @@
+## DO NOT EDIT! GENERATED AUTOMATICALLY!
+## Process this file with automake to produce Makefile.in.
+# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+#
+# This file is free software, distributed under the terms of the GNU
+# General Public License.  As a special exception to the GNU General
+# Public License, this file may be distributed as part of a program
+# that contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+
+AUTOMAKE_OPTIONS = 1.5 foreign subdir-objects
+
+SUBDIRS = .
+TESTS =
+XFAIL_TESTS =
+TESTS_ENVIRONMENT =
+noinst_PROGRAMS =
+check_PROGRAMS =
+noinst_HEADERS =
+noinst_LIBRARIES =
+check_LIBRARIES = libtests.a
+EXTRA_DIST =
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES = core *.stackdump
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
+AM_CPPFLAGS = \
+  -D@gltests_WITNESS@=1 \
+  -I. -I$(srcdir) \
+  -I../.. -I$(srcdir)/../.. \
+  -I../../gnulib/lib -I$(srcdir)/../../gnulib/lib
+
+LDADD = libtests.a ../../gnulib/lib/libgnu.la libtests.a $(LIBTESTS_LIBDEPS)
+
+libtests_a_SOURCES =
+libtests_a_LIBADD = $(gltests_LIBOBJS)
+libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
+EXTRA_libtests_a_SOURCES =
+AM_LIBTOOLFLAGS = --preserve-dup-deps
+
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
+
+## begin gnulib module alloca-opt-tests
+
+TESTS += test-alloca-opt
+check_PROGRAMS += test-alloca-opt
+
+EXTRA_DIST += test-alloca-opt.c
+
+## end   gnulib module alloca-opt-tests
+
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/build/aux/arg-nonnull.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/build/aux/arg-nonnull.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/arg-nonnull.h
+
+## end   gnulib module arg-nonnull
+
+## begin gnulib module binary-io
+
+libtests_a_SOURCES += binary-io.h
+
+## end   gnulib module binary-io
+
+## begin gnulib module binary-io-tests
+
+TESTS += test-binary-io.sh
+check_PROGRAMS += test-binary-io
+
+EXTRA_DIST += test-binary-io.sh test-binary-io.c macros.h
+
+## end   gnulib module binary-io-tests
+
+## begin gnulib module btowc-tests
+
+TESTS += test-btowc1.sh test-btowc2.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-btowc
+
+EXTRA_DIST += test-btowc1.sh test-btowc2.sh test-btowc.c signature.h macros.h
+
+## end   gnulib module btowc-tests
+
+## begin gnulib module c++defs
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += c++defs.h
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build/aux/c++defs.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build/aux/c++defs.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+
+CXXDEFS_H=c++defs.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/c++defs.h
+
+## end   gnulib module c++defs
+
+## begin gnulib module c-ctype
+
+libtests_a_SOURCES += c-ctype.h c-ctype.c
+
+## end   gnulib module c-ctype
+
+## begin gnulib module c-ctype-tests
+
+TESTS += test-c-ctype
+check_PROGRAMS += test-c-ctype
+
+EXTRA_DIST += test-c-ctype.c macros.h
+
+## end   gnulib module c-ctype-tests
+
+## begin gnulib module c-strcase
+
+libtests_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c
+
+## end   gnulib module c-strcase
+
+## begin gnulib module c-strcase-tests
+
+TESTS += test-c-strcase.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
+check_PROGRAMS += test-c-strcasecmp test-c-strncasecmp
+EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c macros.h
+
+## end   gnulib module c-strcase-tests
+
+## begin gnulib module canonicalize-lgpl-tests
+
+TESTS += test-canonicalize-lgpl
+check_PROGRAMS += test-canonicalize-lgpl
+EXTRA_DIST += test-canonicalize-lgpl.c signature.h macros.h
+
+## end   gnulib module canonicalize-lgpl-tests
+
+## begin gnulib module ctype-tests
+
+TESTS += test-ctype
+check_PROGRAMS += test-ctype
+EXTRA_DIST += test-ctype.c
+
+## end   gnulib module ctype-tests
+
+## begin gnulib module dup2
+
+
+EXTRA_DIST += dup2.c
+
+EXTRA_libtests_a_SOURCES += dup2.c
+
+## end   gnulib module dup2
+
+## begin gnulib module dup2-tests
+
+TESTS += test-dup2
+check_PROGRAMS += test-dup2
+EXTRA_DIST += test-dup2.c signature.h macros.h
+
+## end   gnulib module dup2-tests
+
+## begin gnulib module environ-tests
+
+TESTS += test-environ
+check_PROGRAMS += test-environ
+
+EXTRA_DIST += test-environ.c
+
+## end   gnulib module environ-tests
+
+## begin gnulib module errno-tests
+
+TESTS += test-errno
+check_PROGRAMS += test-errno
+
+EXTRA_DIST += test-errno.c
+
+## end   gnulib module errno-tests
+
+## begin gnulib module fcntl-h
+
+BUILT_SOURCES += fcntl.h
+
+# We need the following in order to create <fcntl.h> when the system
+# doesn't have one that works with the given compiler.
+fcntl.h: fcntl.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
+             -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \
+             -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
+             -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
+             -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
+             -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
+             -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
+             -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
+             -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += fcntl.h fcntl.h-t
+
+EXTRA_DIST += fcntl.in.h
+
+## end   gnulib module fcntl-h
+
+## begin gnulib module fcntl-h-tests
+
+TESTS += test-fcntl-h
+check_PROGRAMS += test-fcntl-h
+EXTRA_DIST += test-fcntl-h.c
+
+## end   gnulib module fcntl-h-tests
+
+## begin gnulib module fnmatch-tests
+
+TESTS += test-fnmatch
+check_PROGRAMS += test-fnmatch
+EXTRA_DIST += test-fnmatch.c signature.h macros.h
+
+## end   gnulib module fnmatch-tests
+
+## begin gnulib module getdelim-tests
+
+TESTS += test-getdelim
+check_PROGRAMS += test-getdelim
+MOSTLYCLEANFILES += test-getdelim.txt
+EXTRA_DIST += test-getdelim.c signature.h macros.h
+
+## end   gnulib module getdelim-tests
+
+## begin gnulib module getline-tests
+
+TESTS += test-getline
+check_PROGRAMS += test-getline
+MOSTLYCLEANFILES += test-getline.txt
+EXTRA_DIST += test-getline.c signature.h macros.h
+
+## end   gnulib module getline-tests
+
+## begin gnulib module getopt-posix-tests
+
+TESTS += test-getopt
+check_PROGRAMS += test-getopt
+test_getopt_LDADD = $(LDADD) $(LIBINTL)
+EXTRA_DIST += macros.h signature.h test-getopt.c test-getopt.h test-getopt_long.h
+
+## end   gnulib module getopt-posix-tests
+
+## begin gnulib module getpagesize
+
+
+EXTRA_DIST += getpagesize.c
+
+EXTRA_libtests_a_SOURCES += getpagesize.c
+
+## end   gnulib module getpagesize
+
+## begin gnulib module havelib
+
+
+EXTRA_DIST += $(top_srcdir)/build/aux/config.rpath
+
+## end   gnulib module havelib
+
+## begin gnulib module ignore-value
+
+libtests_a_SOURCES += ignore-value.h
+
+## end   gnulib module ignore-value
+
+## begin gnulib module ignore-value-tests
+
+TESTS += test-ignore-value
+check_PROGRAMS += test-ignore-value
+EXTRA_DIST += test-ignore-value.c
+
+## end   gnulib module ignore-value-tests
+
+## begin gnulib module intprops
+
+
+EXTRA_DIST += intprops.h
+
+## end   gnulib module intprops
+
+## begin gnulib module isblank-tests
+
+TESTS += test-isblank
+check_PROGRAMS += test-isblank
+EXTRA_DIST += test-isblank.c signature.h macros.h
+
+## end   gnulib module isblank-tests
+
+## begin gnulib module langinfo-tests
+
+TESTS += test-langinfo
+check_PROGRAMS += test-langinfo
+EXTRA_DIST += test-langinfo.c
+
+## end   gnulib module langinfo-tests
+
+## begin gnulib module locale-tests
+
+TESTS += test-locale
+check_PROGRAMS += test-locale
+EXTRA_DIST += test-locale.c
+
+## end   gnulib module locale-tests
+
+## begin gnulib module localename
+
+libtests_a_SOURCES += localename.c
+
+EXTRA_DIST += localename.h
+
+## end   gnulib module localename
+
+## begin gnulib module localename-tests
+
+TESTS += test-localename
+check_PROGRAMS += test-localename
+test_localename_LDADD = $(LDADD) @INTL_MACOSX_LIBS@
+
+EXTRA_DIST += test-localename.c macros.h
+
+## end   gnulib module localename-tests
+
+## begin gnulib module lock
+
+libtests_a_SOURCES += glthread/lock.h glthread/lock.c
+
+## end   gnulib module lock
+
+## begin gnulib module lock-tests
+
+TESTS += test-lock
+check_PROGRAMS += test-lock
+test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
+EXTRA_DIST += test-lock.c
+
+## end   gnulib module lock-tests
+
+## begin gnulib module lstat-tests
+
+TESTS += test-lstat
+check_PROGRAMS += test-lstat
+EXTRA_DIST += test-lstat.h test-lstat.c signature.h macros.h
+
+## end   gnulib module lstat-tests
+
+## begin gnulib module malloc-gnu-tests
+
+TESTS += test-malloc-gnu
+check_PROGRAMS += test-malloc-gnu
+EXTRA_DIST += test-malloc-gnu.c
+
+## end   gnulib module malloc-gnu-tests
+
+## begin gnulib module malloca-tests
+
+TESTS += test-malloca
+check_PROGRAMS += test-malloca
+
+EXTRA_DIST += test-malloca.c
+
+## end   gnulib module malloca-tests
+
+## begin gnulib module mbrtowc-tests
+
+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 test-mbrtowc-w32
+
+EXTRA_DIST += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc.c 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 test-mbrtowc-w32.c signature.h macros.h
+
+## end   gnulib module mbrtowc-tests
+
+## begin gnulib module mbsinit-tests
+
+TESTS += test-mbsinit.sh
+TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-mbsinit
+
+EXTRA_DIST += test-mbsinit.sh test-mbsinit.c signature.h macros.h
+
+## end   gnulib module mbsinit-tests
+
+## begin gnulib module mbsrtowcs-tests
+
+TESTS += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.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-mbsrtowcs
+
+EXTRA_DIST += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh test-mbsrtowcs.c signature.h macros.h
+
+## end   gnulib module mbsrtowcs-tests
+
+## begin gnulib module memchr-tests
+
+TESTS += test-memchr
+check_PROGRAMS += test-memchr
+EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h
+
+## end   gnulib module memchr-tests
+
+## begin gnulib module nl_langinfo-tests
+
+TESTS += test-nl_langinfo.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-nl_langinfo
+EXTRA_DIST += test-nl_langinfo.sh test-nl_langinfo.c signature.h macros.h
+
+## end   gnulib module nl_langinfo-tests
+
+## begin gnulib module open
+
+
+EXTRA_DIST += open.c
+
+EXTRA_libtests_a_SOURCES += open.c
+
+## end   gnulib module open
+
+## begin gnulib module open-tests
+
+TESTS += test-open
+check_PROGRAMS += test-open
+EXTRA_DIST += test-open.h test-open.c signature.h macros.h
+
+## end   gnulib module open-tests
+
+## begin gnulib module putenv
+
+
+EXTRA_DIST += putenv.c
+
+EXTRA_libtests_a_SOURCES += putenv.c
+
+## end   gnulib module putenv
+
+## begin gnulib module readlink-tests
+
+TESTS += test-readlink
+check_PROGRAMS += test-readlink
+EXTRA_DIST += test-readlink.h test-readlink.c signature.h macros.h
+
+## end   gnulib module readlink-tests
+
+## begin gnulib module safe-alloc-tests
+
+TESTS += test-safe-alloc
+check_PROGRAMS += test-safe-alloc
+EXTRA_DIST += test-safe-alloc.c macros.h
+
+## end   gnulib module safe-alloc-tests
+
+## begin gnulib module same-inode
+
+
+EXTRA_DIST += same-inode.h
+
+## end   gnulib module same-inode
+
+## begin gnulib module setenv
+
+
+EXTRA_DIST += setenv.c
+
+EXTRA_libtests_a_SOURCES += setenv.c
+
+## end   gnulib module setenv
+
+## begin gnulib module setenv-tests
+
+TESTS += test-setenv
+check_PROGRAMS += test-setenv
+EXTRA_DIST += test-setenv.c signature.h macros.h
+
+## end   gnulib module setenv-tests
+
+## begin gnulib module setlocale
+
+
+EXTRA_DIST += setlocale.c
+
+EXTRA_libtests_a_SOURCES += setlocale.c
+
+## end   gnulib module setlocale
+
+## begin gnulib module setlocale-tests
+
+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
+EXTRA_DIST += test-setlocale1.sh test-setlocale1.c test-setlocale2.sh test-setlocale2.c signature.h macros.h
+
+## end   gnulib module setlocale-tests
+
+## begin gnulib module stat-tests
+
+TESTS += test-stat
+check_PROGRAMS += test-stat
+EXTRA_DIST += test-stat.h test-stat.c signature.h macros.h
+
+## end   gnulib module stat-tests
+
+## begin gnulib module stdbool-tests
+
+TESTS += test-stdbool
+check_PROGRAMS += test-stdbool
+EXTRA_DIST += test-stdbool.c
+
+## end   gnulib module stdbool-tests
+
+## begin gnulib module stddef-tests
+
+TESTS += test-stddef
+check_PROGRAMS += test-stddef
+EXTRA_DIST += test-stddef.c
+
+## end   gnulib module stddef-tests
+
+## begin gnulib module stdint-tests
+
+TESTS += test-stdint
+check_PROGRAMS += test-stdint
+EXTRA_DIST += test-stdint.c
+
+## end   gnulib module stdint-tests
+
+## begin gnulib module stdio-tests
+
+TESTS += test-stdio
+check_PROGRAMS += test-stdio
+EXTRA_DIST += test-stdio.c
+
+## end   gnulib module stdio-tests
+
+## begin gnulib module stdlib-tests
+
+TESTS += test-stdlib
+check_PROGRAMS += test-stdlib
+EXTRA_DIST += test-stdlib.c test-sys_wait.h
+
+## end   gnulib module stdlib-tests
+
+## begin gnulib module string-tests
+
+TESTS += test-string
+check_PROGRAMS += test-string
+EXTRA_DIST += test-string.c
+
+## end   gnulib module string-tests
+
+## begin gnulib module strnlen-tests
+
+TESTS += test-strnlen
+check_PROGRAMS += test-strnlen
+EXTRA_DIST += test-strnlen.c zerosize-ptr.h signature.h macros.h
+
+## end   gnulib module strnlen-tests
+
+## begin gnulib module strstr-tests
+
+TESTS += test-strstr
+check_PROGRAMS += test-strstr
+EXTRA_DIST += test-strstr.c zerosize-ptr.h signature.h macros.h
+
+## end   gnulib module strstr-tests
+
+## begin gnulib module symlink
+
+
+EXTRA_DIST += symlink.c
+
+EXTRA_libtests_a_SOURCES += symlink.c
+
+## end   gnulib module symlink
+
+## begin gnulib module symlink-tests
+
+TESTS += test-symlink
+check_PROGRAMS += test-symlink
+EXTRA_DIST += test-symlink.h test-symlink.c signature.h macros.h
+
+## end   gnulib module symlink-tests
+
+## begin gnulib module sys_stat-tests
+
+TESTS += test-sys_stat
+check_PROGRAMS += test-sys_stat
+EXTRA_DIST += test-sys_stat.c
+
+## end   gnulib module sys_stat-tests
+
+## begin gnulib module sys_wait-tests
+
+TESTS += test-sys_wait
+check_PROGRAMS += test-sys_wait
+EXTRA_DIST += test-sys_wait.c test-sys_wait.h
+
+## end   gnulib module sys_wait-tests
+
+## begin gnulib module thread
+
+libtests_a_SOURCES += glthread/thread.h glthread/thread.c
+
+## end   gnulib module thread
+
+## begin gnulib module threadlib
+
+libtests_a_SOURCES += glthread/threadlib.c
+
+EXTRA_DIST += $(top_srcdir)/build/aux/config.rpath
+
+## end   gnulib module threadlib
+
+## begin gnulib module time-tests
+
+TESTS += test-time
+check_PROGRAMS += test-time
+EXTRA_DIST += test-time.c
+
+## end   gnulib module time-tests
+
+## begin gnulib module unistd-tests
+
+TESTS += test-unistd
+check_PROGRAMS += test-unistd
+EXTRA_DIST += test-unistd.c
+
+## end   gnulib module unistd-tests
+
+## begin gnulib module unsetenv
+
+
+EXTRA_DIST += unsetenv.c
+
+EXTRA_libtests_a_SOURCES += unsetenv.c
+
+## end   gnulib module unsetenv
+
+## begin gnulib module unsetenv-tests
+
+TESTS += test-unsetenv
+check_PROGRAMS += test-unsetenv
+EXTRA_DIST += test-unsetenv.c signature.h macros.h
+
+## end   gnulib module unsetenv-tests
+
+## begin gnulib module unused-parameter
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += unused-parameter.h
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/unused-parameter.h, except that it has the copyright header cut
+# off.
+unused-parameter.h: $(top_srcdir)/build/aux/unused-parameter.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/build/aux/unused-parameter.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
+
+UNUSED_PARAMETER_H=unused-parameter.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/unused-parameter.h
+
+## end   gnulib module unused-parameter
+
+## begin gnulib module vasnprintf-tests
+
+TESTS += test-vasnprintf
+check_PROGRAMS += test-vasnprintf
+
+EXTRA_DIST += test-vasnprintf.c macros.h
+
+## end   gnulib module vasnprintf-tests
+
+## begin gnulib module vasprintf-tests
+
+TESTS += test-vasprintf
+check_PROGRAMS += test-vasprintf
+
+EXTRA_DIST += test-vasprintf.c signature.h macros.h
+
+## end   gnulib module vasprintf-tests
+
+## begin gnulib module verify-tests
+
+TESTS_ENVIRONMENT += MAKE='$(MAKE)'
+TESTS += test-verify test-verify.sh
+check_PROGRAMS += test-verify
+EXTRA_DIST += test-verify.c test-verify.sh init.sh
+
+## end   gnulib module verify-tests
+
+## begin gnulib module warn-on-use
+
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build/aux/warn-on-use.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/build/aux/warn-on-use.h \
+         > $@-t && \
+       mv $@-t $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+EXTRA_DIST += $(top_srcdir)/build/aux/warn-on-use.h
+
+## end   gnulib module warn-on-use
+
+## begin gnulib module wchar-tests
+
+TESTS += test-wchar
+check_PROGRAMS += test-wchar
+EXTRA_DIST += test-wchar.c
+
+## end   gnulib module wchar-tests
+
+## begin gnulib module wcrtomb-tests
+
+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 test-wcrtomb-w32
+
+EXTRA_DIST += test-wcrtomb.sh test-wcrtomb.c 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 test-wcrtomb-w32.c signature.h macros.h
+
+## end   gnulib module wcrtomb-tests
+
+## begin gnulib module wctob
+
+
+EXTRA_DIST += wctob.c
+
+EXTRA_libtests_a_SOURCES += wctob.c
+
+## end   gnulib module wctob
+
+## begin gnulib module wctomb
+
+
+EXTRA_DIST += wctomb-impl.h wctomb.c
+
+EXTRA_libtests_a_SOURCES += wctomb.c
+
+## end   gnulib module wctomb
+
+## begin gnulib module wctype-h-tests
+
+TESTS += test-wctype-h
+check_PROGRAMS += test-wctype-h
+EXTRA_DIST += test-wctype-h.c macros.h
+
+## end   gnulib module wctype-h-tests
+
+## begin gnulib module yield
+
+libtests_a_SOURCES += glthread/yield.h
+
+## end   gnulib module yield
+
+# Clean up after Solaris cc.
+clean-local:
+       rm -rf SunWS_cache
+
+mostlyclean-local: mostlyclean-generic
+       @for dir in '' $(MOSTLYCLEANDIRS); do \
+         if test -n "$$dir" && test -d $$dir; then \
+           echo "rmdir $$dir"; rmdir $$dir; \
+         fi; \
+       done; \
+       :
diff --git a/gnulib/tests/Makefile.in b/gnulib/tests/Makefile.in
new file mode 100644 (file)
index 0000000..16640fd
--- /dev/null
@@ -0,0 +1,2662 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+#
+# This file is free software, distributed under the terms of the GNU
+# General Public License.  As a special exception to the GNU General
+# Public License, this file may be distributed as part of a program
+# that contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+TESTS = test-alloca-opt$(EXEEXT) test-binary-io.sh test-btowc1.sh \
+       test-btowc2.sh test-c-ctype$(EXEEXT) test-c-strcase.sh \
+       test-canonicalize-lgpl$(EXEEXT) test-ctype$(EXEEXT) \
+       test-dup2$(EXEEXT) test-environ$(EXEEXT) test-errno$(EXEEXT) \
+       test-fcntl-h$(EXEEXT) test-fnmatch$(EXEEXT) \
+       test-getdelim$(EXEEXT) test-getline$(EXEEXT) \
+       test-getopt$(EXEEXT) test-ignore-value$(EXEEXT) \
+       test-isblank$(EXEEXT) test-langinfo$(EXEEXT) \
+       test-locale$(EXEEXT) test-localename$(EXEEXT) \
+       test-lock$(EXEEXT) test-lstat$(EXEEXT) \
+       test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \
+       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 test-mbsinit.sh test-mbsrtowcs1.sh \
+       test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh \
+       test-memchr$(EXEEXT) test-nl_langinfo.sh test-open$(EXEEXT) \
+       test-readlink$(EXEEXT) test-safe-alloc$(EXEEXT) \
+       test-setenv$(EXEEXT) test-setlocale1.sh test-setlocale2.sh \
+       test-stat$(EXEEXT) test-stdbool$(EXEEXT) test-stddef$(EXEEXT) \
+       test-stdint$(EXEEXT) test-stdio$(EXEEXT) test-stdlib$(EXEEXT) \
+       test-string$(EXEEXT) test-strnlen$(EXEEXT) \
+       test-strstr$(EXEEXT) test-symlink$(EXEEXT) \
+       test-sys_stat$(EXEEXT) test-sys_wait$(EXEEXT) \
+       test-time$(EXEEXT) test-unistd$(EXEEXT) test-unsetenv$(EXEEXT) \
+       test-vasnprintf$(EXEEXT) test-vasprintf$(EXEEXT) \
+       test-verify$(EXEEXT) test-verify.sh test-wchar$(EXEEXT) \
+       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 test-wctype-h$(EXEEXT)
+XFAIL_TESTS =
+noinst_PROGRAMS =
+check_PROGRAMS = test-alloca-opt$(EXEEXT) test-binary-io$(EXEEXT) \
+       test-btowc$(EXEEXT) test-c-ctype$(EXEEXT) \
+       test-c-strcasecmp$(EXEEXT) test-c-strncasecmp$(EXEEXT) \
+       test-canonicalize-lgpl$(EXEEXT) test-ctype$(EXEEXT) \
+       test-dup2$(EXEEXT) test-environ$(EXEEXT) test-errno$(EXEEXT) \
+       test-fcntl-h$(EXEEXT) test-fnmatch$(EXEEXT) \
+       test-getdelim$(EXEEXT) test-getline$(EXEEXT) \
+       test-getopt$(EXEEXT) test-ignore-value$(EXEEXT) \
+       test-isblank$(EXEEXT) test-langinfo$(EXEEXT) \
+       test-locale$(EXEEXT) test-localename$(EXEEXT) \
+       test-lock$(EXEEXT) test-lstat$(EXEEXT) \
+       test-malloc-gnu$(EXEEXT) test-malloca$(EXEEXT) \
+       test-mbrtowc$(EXEEXT) test-mbrtowc-w32$(EXEEXT) \
+       test-mbsinit$(EXEEXT) test-mbsrtowcs$(EXEEXT) \
+       test-memchr$(EXEEXT) test-nl_langinfo$(EXEEXT) \
+       test-open$(EXEEXT) test-readlink$(EXEEXT) \
+       test-safe-alloc$(EXEEXT) test-setenv$(EXEEXT) \
+       test-setlocale1$(EXEEXT) test-setlocale2$(EXEEXT) \
+       test-stat$(EXEEXT) test-stdbool$(EXEEXT) test-stddef$(EXEEXT) \
+       test-stdint$(EXEEXT) test-stdio$(EXEEXT) test-stdlib$(EXEEXT) \
+       test-string$(EXEEXT) test-strnlen$(EXEEXT) \
+       test-strstr$(EXEEXT) test-symlink$(EXEEXT) \
+       test-sys_stat$(EXEEXT) test-sys_wait$(EXEEXT) \
+       test-time$(EXEEXT) test-unistd$(EXEEXT) test-unsetenv$(EXEEXT) \
+       test-vasnprintf$(EXEEXT) test-vasprintf$(EXEEXT) \
+       test-verify$(EXEEXT) test-wchar$(EXEEXT) test-wcrtomb$(EXEEXT) \
+       test-wcrtomb-w32$(EXEEXT) test-wctype-h$(EXEEXT)
+subdir = gnulib/tests
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo "  AR    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+libtests_a_AR = $(AR) $(ARFLAGS)
+am__DEPENDENCIES_1 =
+am__dirstamp = $(am__leading_dot)dirstamp
+am_libtests_a_OBJECTS = c-ctype.$(OBJEXT) c-strcasecmp.$(OBJEXT) \
+       c-strncasecmp.$(OBJEXT) localename.$(OBJEXT) \
+       glthread/lock.$(OBJEXT) glthread/thread.$(OBJEXT) \
+       glthread/threadlib.$(OBJEXT)
+libtests_a_OBJECTS = $(am_libtests_a_OBJECTS)
+PROGRAMS = $(noinst_PROGRAMS)
+test_alloca_opt_SOURCES = test-alloca-opt.c
+test_alloca_opt_OBJECTS = test-alloca-opt.$(OBJEXT)
+test_alloca_opt_LDADD = $(LDADD)
+test_alloca_opt_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+test_binary_io_SOURCES = test-binary-io.c
+test_binary_io_OBJECTS = test-binary-io.$(OBJEXT)
+test_binary_io_LDADD = $(LDADD)
+test_binary_io_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_btowc_SOURCES = test-btowc.c
+test_btowc_OBJECTS = test-btowc.$(OBJEXT)
+test_btowc_LDADD = $(LDADD)
+test_btowc_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_c_ctype_SOURCES = test-c-ctype.c
+test_c_ctype_OBJECTS = test-c-ctype.$(OBJEXT)
+test_c_ctype_LDADD = $(LDADD)
+test_c_ctype_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_c_strcasecmp_SOURCES = test-c-strcasecmp.c
+test_c_strcasecmp_OBJECTS = test-c-strcasecmp.$(OBJEXT)
+test_c_strcasecmp_LDADD = $(LDADD)
+test_c_strcasecmp_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_c_strncasecmp_SOURCES = test-c-strncasecmp.c
+test_c_strncasecmp_OBJECTS = test-c-strncasecmp.$(OBJEXT)
+test_c_strncasecmp_LDADD = $(LDADD)
+test_c_strncasecmp_DEPENDENCIES = libtests.a \
+       ../../gnulib/lib/libgnu.la libtests.a $(am__DEPENDENCIES_1)
+test_canonicalize_lgpl_SOURCES = test-canonicalize-lgpl.c
+test_canonicalize_lgpl_OBJECTS = test-canonicalize-lgpl.$(OBJEXT)
+test_canonicalize_lgpl_LDADD = $(LDADD)
+test_canonicalize_lgpl_DEPENDENCIES = libtests.a \
+       ../../gnulib/lib/libgnu.la libtests.a $(am__DEPENDENCIES_1)
+test_ctype_SOURCES = test-ctype.c
+test_ctype_OBJECTS = test-ctype.$(OBJEXT)
+test_ctype_LDADD = $(LDADD)
+test_ctype_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_dup2_SOURCES = test-dup2.c
+test_dup2_OBJECTS = test-dup2.$(OBJEXT)
+test_dup2_LDADD = $(LDADD)
+test_dup2_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_environ_SOURCES = test-environ.c
+test_environ_OBJECTS = test-environ.$(OBJEXT)
+test_environ_LDADD = $(LDADD)
+test_environ_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_errno_SOURCES = test-errno.c
+test_errno_OBJECTS = test-errno.$(OBJEXT)
+test_errno_LDADD = $(LDADD)
+test_errno_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_fcntl_h_SOURCES = test-fcntl-h.c
+test_fcntl_h_OBJECTS = test-fcntl-h.$(OBJEXT)
+test_fcntl_h_LDADD = $(LDADD)
+test_fcntl_h_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_fnmatch_SOURCES = test-fnmatch.c
+test_fnmatch_OBJECTS = test-fnmatch.$(OBJEXT)
+test_fnmatch_LDADD = $(LDADD)
+test_fnmatch_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_getdelim_SOURCES = test-getdelim.c
+test_getdelim_OBJECTS = test-getdelim.$(OBJEXT)
+test_getdelim_LDADD = $(LDADD)
+test_getdelim_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_getline_SOURCES = test-getline.c
+test_getline_OBJECTS = test-getline.$(OBJEXT)
+test_getline_LDADD = $(LDADD)
+test_getline_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_getopt_SOURCES = test-getopt.c
+test_getopt_OBJECTS = test-getopt.$(OBJEXT)
+am__DEPENDENCIES_2 = libtests.a ../../gnulib/lib/libgnu.la libtests.a \
+       $(am__DEPENDENCIES_1)
+test_getopt_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
+test_ignore_value_SOURCES = test-ignore-value.c
+test_ignore_value_OBJECTS = test-ignore-value.$(OBJEXT)
+test_ignore_value_LDADD = $(LDADD)
+test_ignore_value_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_isblank_SOURCES = test-isblank.c
+test_isblank_OBJECTS = test-isblank.$(OBJEXT)
+test_isblank_LDADD = $(LDADD)
+test_isblank_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_langinfo_SOURCES = test-langinfo.c
+test_langinfo_OBJECTS = test-langinfo.$(OBJEXT)
+test_langinfo_LDADD = $(LDADD)
+test_langinfo_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_locale_SOURCES = test-locale.c
+test_locale_OBJECTS = test-locale.$(OBJEXT)
+test_locale_LDADD = $(LDADD)
+test_locale_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_localename_SOURCES = test-localename.c
+test_localename_OBJECTS = test-localename.$(OBJEXT)
+test_localename_DEPENDENCIES = $(am__DEPENDENCIES_2)
+test_lock_SOURCES = test-lock.c
+test_lock_OBJECTS = test-lock.$(OBJEXT)
+test_lock_DEPENDENCIES = $(am__DEPENDENCIES_2)
+test_lstat_SOURCES = test-lstat.c
+test_lstat_OBJECTS = test-lstat.$(OBJEXT)
+test_lstat_LDADD = $(LDADD)
+test_lstat_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_malloc_gnu_SOURCES = test-malloc-gnu.c
+test_malloc_gnu_OBJECTS = test-malloc-gnu.$(OBJEXT)
+test_malloc_gnu_LDADD = $(LDADD)
+test_malloc_gnu_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_malloca_SOURCES = test-malloca.c
+test_malloca_OBJECTS = test-malloca.$(OBJEXT)
+test_malloca_LDADD = $(LDADD)
+test_malloca_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_mbrtowc_SOURCES = test-mbrtowc.c
+test_mbrtowc_OBJECTS = test-mbrtowc.$(OBJEXT)
+test_mbrtowc_LDADD = $(LDADD)
+test_mbrtowc_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_mbrtowc_w32_SOURCES = test-mbrtowc-w32.c
+test_mbrtowc_w32_OBJECTS = test-mbrtowc-w32.$(OBJEXT)
+test_mbrtowc_w32_LDADD = $(LDADD)
+test_mbrtowc_w32_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_mbsinit_SOURCES = test-mbsinit.c
+test_mbsinit_OBJECTS = test-mbsinit.$(OBJEXT)
+test_mbsinit_LDADD = $(LDADD)
+test_mbsinit_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_mbsrtowcs_SOURCES = test-mbsrtowcs.c
+test_mbsrtowcs_OBJECTS = test-mbsrtowcs.$(OBJEXT)
+test_mbsrtowcs_LDADD = $(LDADD)
+test_mbsrtowcs_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_memchr_SOURCES = test-memchr.c
+test_memchr_OBJECTS = test-memchr.$(OBJEXT)
+test_memchr_LDADD = $(LDADD)
+test_memchr_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_nl_langinfo_SOURCES = test-nl_langinfo.c
+test_nl_langinfo_OBJECTS = test-nl_langinfo.$(OBJEXT)
+test_nl_langinfo_LDADD = $(LDADD)
+test_nl_langinfo_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_open_SOURCES = test-open.c
+test_open_OBJECTS = test-open.$(OBJEXT)
+test_open_LDADD = $(LDADD)
+test_open_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_readlink_SOURCES = test-readlink.c
+test_readlink_OBJECTS = test-readlink.$(OBJEXT)
+test_readlink_LDADD = $(LDADD)
+test_readlink_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_safe_alloc_SOURCES = test-safe-alloc.c
+test_safe_alloc_OBJECTS = test-safe-alloc.$(OBJEXT)
+test_safe_alloc_LDADD = $(LDADD)
+test_safe_alloc_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_setenv_SOURCES = test-setenv.c
+test_setenv_OBJECTS = test-setenv.$(OBJEXT)
+test_setenv_LDADD = $(LDADD)
+test_setenv_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_setlocale1_SOURCES = test-setlocale1.c
+test_setlocale1_OBJECTS = test-setlocale1.$(OBJEXT)
+test_setlocale1_LDADD = $(LDADD)
+test_setlocale1_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_setlocale2_SOURCES = test-setlocale2.c
+test_setlocale2_OBJECTS = test-setlocale2.$(OBJEXT)
+test_setlocale2_LDADD = $(LDADD)
+test_setlocale2_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stat_SOURCES = test-stat.c
+test_stat_OBJECTS = test-stat.$(OBJEXT)
+test_stat_LDADD = $(LDADD)
+test_stat_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stdbool_SOURCES = test-stdbool.c
+test_stdbool_OBJECTS = test-stdbool.$(OBJEXT)
+test_stdbool_LDADD = $(LDADD)
+test_stdbool_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stddef_SOURCES = test-stddef.c
+test_stddef_OBJECTS = test-stddef.$(OBJEXT)
+test_stddef_LDADD = $(LDADD)
+test_stddef_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stdint_SOURCES = test-stdint.c
+test_stdint_OBJECTS = test-stdint.$(OBJEXT)
+test_stdint_LDADD = $(LDADD)
+test_stdint_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stdio_SOURCES = test-stdio.c
+test_stdio_OBJECTS = test-stdio.$(OBJEXT)
+test_stdio_LDADD = $(LDADD)
+test_stdio_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_stdlib_SOURCES = test-stdlib.c
+test_stdlib_OBJECTS = test-stdlib.$(OBJEXT)
+test_stdlib_LDADD = $(LDADD)
+test_stdlib_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_string_SOURCES = test-string.c
+test_string_OBJECTS = test-string.$(OBJEXT)
+test_string_LDADD = $(LDADD)
+test_string_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_strnlen_SOURCES = test-strnlen.c
+test_strnlen_OBJECTS = test-strnlen.$(OBJEXT)
+test_strnlen_LDADD = $(LDADD)
+test_strnlen_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_strstr_SOURCES = test-strstr.c
+test_strstr_OBJECTS = test-strstr.$(OBJEXT)
+test_strstr_LDADD = $(LDADD)
+test_strstr_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_symlink_SOURCES = test-symlink.c
+test_symlink_OBJECTS = test-symlink.$(OBJEXT)
+test_symlink_LDADD = $(LDADD)
+test_symlink_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_sys_stat_SOURCES = test-sys_stat.c
+test_sys_stat_OBJECTS = test-sys_stat.$(OBJEXT)
+test_sys_stat_LDADD = $(LDADD)
+test_sys_stat_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_sys_wait_SOURCES = test-sys_wait.c
+test_sys_wait_OBJECTS = test-sys_wait.$(OBJEXT)
+test_sys_wait_LDADD = $(LDADD)
+test_sys_wait_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_time_SOURCES = test-time.c
+test_time_OBJECTS = test-time.$(OBJEXT)
+test_time_LDADD = $(LDADD)
+test_time_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_unistd_SOURCES = test-unistd.c
+test_unistd_OBJECTS = test-unistd.$(OBJEXT)
+test_unistd_LDADD = $(LDADD)
+test_unistd_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_unsetenv_SOURCES = test-unsetenv.c
+test_unsetenv_OBJECTS = test-unsetenv.$(OBJEXT)
+test_unsetenv_LDADD = $(LDADD)
+test_unsetenv_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_vasnprintf_SOURCES = test-vasnprintf.c
+test_vasnprintf_OBJECTS = test-vasnprintf.$(OBJEXT)
+test_vasnprintf_LDADD = $(LDADD)
+test_vasnprintf_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_vasprintf_SOURCES = test-vasprintf.c
+test_vasprintf_OBJECTS = test-vasprintf.$(OBJEXT)
+test_vasprintf_LDADD = $(LDADD)
+test_vasprintf_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_verify_SOURCES = test-verify.c
+test_verify_OBJECTS = test-verify.$(OBJEXT)
+test_verify_LDADD = $(LDADD)
+test_verify_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_wchar_SOURCES = test-wchar.c
+test_wchar_OBJECTS = test-wchar.$(OBJEXT)
+test_wchar_LDADD = $(LDADD)
+test_wchar_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_wcrtomb_SOURCES = test-wcrtomb.c
+test_wcrtomb_OBJECTS = test-wcrtomb.$(OBJEXT)
+test_wcrtomb_LDADD = $(LDADD)
+test_wcrtomb_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_wcrtomb_w32_SOURCES = test-wcrtomb-w32.c
+test_wcrtomb_w32_OBJECTS = test-wcrtomb-w32.$(OBJEXT)
+test_wcrtomb_w32_LDADD = $(LDADD)
+test_wcrtomb_w32_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+test_wctype_h_SOURCES = test-wctype-h.c
+test_wctype_h_OBJECTS = test-wctype-h.$(OBJEXT)
+test_wctype_h_LDADD = $(LDADD)
+test_wctype_h_DEPENDENCIES = libtests.a ../../gnulib/lib/libgnu.la \
+       libtests.a $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \
+       test-alloca-opt.c test-binary-io.c test-btowc.c test-c-ctype.c \
+       test-c-strcasecmp.c test-c-strncasecmp.c \
+       test-canonicalize-lgpl.c test-ctype.c test-dup2.c \
+       test-environ.c test-errno.c test-fcntl-h.c test-fnmatch.c \
+       test-getdelim.c test-getline.c test-getopt.c \
+       test-ignore-value.c test-isblank.c test-langinfo.c \
+       test-locale.c test-localename.c test-lock.c test-lstat.c \
+       test-malloc-gnu.c test-malloca.c test-mbrtowc.c \
+       test-mbrtowc-w32.c test-mbsinit.c test-mbsrtowcs.c \
+       test-memchr.c test-nl_langinfo.c test-open.c test-readlink.c \
+       test-safe-alloc.c test-setenv.c test-setlocale1.c \
+       test-setlocale2.c test-stat.c test-stdbool.c test-stddef.c \
+       test-stdint.c test-stdio.c test-stdlib.c test-string.c \
+       test-strnlen.c test-strstr.c test-symlink.c test-sys_stat.c \
+       test-sys_wait.c test-time.c test-unistd.c test-unsetenv.c \
+       test-vasnprintf.c test-vasprintf.c test-verify.c test-wchar.c \
+       test-wcrtomb.c test-wcrtomb-w32.c test-wctype-h.c
+DIST_SOURCES = $(libtests_a_SOURCES) $(EXTRA_libtests_a_SOURCES) \
+       test-alloca-opt.c test-binary-io.c test-btowc.c test-c-ctype.c \
+       test-c-strcasecmp.c test-c-strncasecmp.c \
+       test-canonicalize-lgpl.c test-ctype.c test-dup2.c \
+       test-environ.c test-errno.c test-fcntl-h.c test-fnmatch.c \
+       test-getdelim.c test-getline.c test-getopt.c \
+       test-ignore-value.c test-isblank.c test-langinfo.c \
+       test-locale.c test-localename.c test-lock.c test-lstat.c \
+       test-malloc-gnu.c test-malloca.c test-mbrtowc.c \
+       test-mbrtowc-w32.c test-mbsinit.c test-mbsrtowcs.c \
+       test-memchr.c test-nl_langinfo.c test-open.c test-readlink.c \
+       test-safe-alloc.c test-setenv.c test-setlocale1.c \
+       test-setlocale2.c test-stat.c test-stdbool.c test-stddef.c \
+       test-stdint.c test-stdio.c test-stdlib.c test-string.c \
+       test-strnlen.c test-strstr.c test-symlink.c test-sys_stat.c \
+       test-sys_wait.c test-time.c test-unistd.c test-unsetenv.c \
+       test-vasnprintf.c test-vasprintf.c test-verify.c test-wchar.c \
+       test-wcrtomb.c test-wcrtomb-w32.c test-wctype-h.c
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+HEADERS = $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       check check-html recheck recheck-html distdir
+ETAGS = etags
+CTAGS = ctags
+# If stdout is a non-dumb tty, use colors.  If test -t is not supported,
+# then this fails; a conservative approach.  Of course do not redirect
+# stdout here, just stderr.
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=; \
+test "X$(AM_COLOR_TESTS)" != Xno \
+&& test "X$$TERM" != Xdumb \
+&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
+&& { \
+  red='\e[0;31m'; \
+  grn='\e[0;32m'; \
+  lgn='\e[1;32m'; \
+  blu='\e[1;34m'; \
+  std='\e[m'; \
+}
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+# Restructured Text title and section.
+am__rst_title = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
+am__rst_section = sed 'p;s/./=/g;p;g'
+# Put stdin (possibly several lines separated by ".  ") in a box.
+am__text_box = $(AWK) '{                               \
+  n = split($$0, lines, "\\.  "); max = 0;             \
+  for (i = 1; i <= n; ++i)                             \
+    if (max < length(lines[i]))                                \
+      max = length(lines[i]);                          \
+  for (i = 0; i < max; ++i) line = line "=";           \
+  print line;                                          \
+  for (i = 1; i <= n; ++i) if (lines[i]) print lines[i];\
+  print line;                                          \
+}'
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL).  This contradicts POSIX.  Work around the problem
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# To be inserted before the command running the test.  Creates the
+# directory for the log if needed.  Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log, and passes
+# TESTS_ENVIRONMENT.  Save and restore TERM around use of
+# TESTS_ENVIRONMENT, in case that unsets it.
+am__check_pre = \
+$(am__sh_e_setup);                                     \
+$(am__vpath_adj_setup) $(am__vpath_adj)                        \
+srcdir=$(srcdir); export srcdir;                       \
+rm -f $@-t;                                            \
+trap 'st=$$?; rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st' \
+  1 2 13 15;                                           \
+am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;           \
+test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?;        \
+if test -f "./$$f"; then dir=./;                       \
+elif test -f "$$f"; then dir=;                         \
+else dir="$(srcdir)/"; fi;                             \
+tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM;           \
+$(TESTS_ENVIRONMENT)
+RECHECK_LOGS = $(TEST_LOGS)
+TEST_SUITE_LOG = test-suite.log
+TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+       $(TEST_LOG_FLAGS)
+TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = 1.5 foreign subdir-objects
+SUBDIRS = .
+TESTS_ENVIRONMENT = EXEEXT='@EXEEXT@' srcdir='$(srcdir)' \
+       LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+       LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' \
+       LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+       LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@' \
+       LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \
+       LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_JA='@LOCALE_JA@' \
+       LOCALE_ZH_CN='@LOCALE_ZH_CN@' LOCALE_FR='@LOCALE_FR@' \
+       LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_FR='@LOCALE_FR@' \
+       LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' LOCALE_JA='@LOCALE_JA@' \
+       LOCALE_ZH_CN='@LOCALE_ZH_CN@' MAKE='$(MAKE)' \
+       LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+       LOCALE_JA='@LOCALE_JA@' LOCALE_ZH_CN='@LOCALE_ZH_CN@'
+noinst_HEADERS = 
+noinst_LIBRARIES = 
+check_LIBRARIES = libtests.a
+EXTRA_DIST = test-alloca-opt.c $(top_srcdir)/build/aux/arg-nonnull.h \
+       test-binary-io.sh test-binary-io.c macros.h test-btowc1.sh \
+       test-btowc2.sh test-btowc.c signature.h macros.h \
+       $(top_srcdir)/build/aux/c++defs.h test-c-ctype.c macros.h \
+       test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c \
+       macros.h test-canonicalize-lgpl.c signature.h macros.h \
+       test-ctype.c dup2.c test-dup2.c signature.h macros.h \
+       test-environ.c test-errno.c fcntl.in.h test-fcntl-h.c \
+       test-fnmatch.c signature.h macros.h test-getdelim.c \
+       signature.h macros.h test-getline.c signature.h macros.h \
+       macros.h signature.h test-getopt.c test-getopt.h \
+       test-getopt_long.h getpagesize.c \
+       $(top_srcdir)/build/aux/config.rpath test-ignore-value.c \
+       intprops.h test-isblank.c signature.h macros.h test-langinfo.c \
+       test-locale.c localename.h test-localename.c macros.h \
+       test-lock.c test-lstat.h test-lstat.c signature.h macros.h \
+       test-malloc-gnu.c test-malloca.c test-mbrtowc1.sh \
+       test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \
+       test-mbrtowc.c 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 test-mbrtowc-w32.c signature.h macros.h \
+       test-mbsinit.sh test-mbsinit.c signature.h macros.h \
+       test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh \
+       test-mbsrtowcs4.sh test-mbsrtowcs.c signature.h macros.h \
+       test-memchr.c zerosize-ptr.h signature.h macros.h \
+       test-nl_langinfo.sh test-nl_langinfo.c signature.h macros.h \
+       open.c test-open.h test-open.c signature.h macros.h putenv.c \
+       test-readlink.h test-readlink.c signature.h macros.h \
+       test-safe-alloc.c macros.h same-inode.h setenv.c test-setenv.c \
+       signature.h macros.h setlocale.c test-setlocale1.sh \
+       test-setlocale1.c test-setlocale2.sh test-setlocale2.c \
+       signature.h macros.h test-stat.h test-stat.c signature.h \
+       macros.h test-stdbool.c test-stddef.c test-stdint.c \
+       test-stdio.c test-stdlib.c test-sys_wait.h test-string.c \
+       test-strnlen.c zerosize-ptr.h signature.h macros.h \
+       test-strstr.c zerosize-ptr.h signature.h macros.h symlink.c \
+       test-symlink.h test-symlink.c signature.h macros.h \
+       test-sys_stat.c test-sys_wait.c test-sys_wait.h \
+       $(top_srcdir)/build/aux/config.rpath test-time.c test-unistd.c \
+       unsetenv.c test-unsetenv.c signature.h macros.h \
+       $(top_srcdir)/build/aux/unused-parameter.h test-vasnprintf.c \
+       macros.h test-vasprintf.c signature.h macros.h test-verify.c \
+       test-verify.sh init.sh $(top_srcdir)/build/aux/warn-on-use.h \
+       test-wchar.c test-wcrtomb.sh test-wcrtomb.c \
+       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 test-wcrtomb-w32.c signature.h macros.h \
+       wctob.c wctomb-impl.h wctomb.c test-wctype-h.c macros.h
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+BUILT_SOURCES = arg-nonnull.h c++defs.h fcntl.h unused-parameter.h \
+       warn-on-use.h
+SUFFIXES = 
+MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
+       c++defs.h c++defs.h-t fcntl.h fcntl.h-t test-getdelim.txt \
+       test-getline.txt unused-parameter.h unused-parameter.h-t \
+       warn-on-use.h warn-on-use.h-t
+MOSTLYCLEANDIRS = 
+CLEANFILES = 
+DISTCLEANFILES = 
+MAINTAINERCLEANFILES = 
+AM_CPPFLAGS = \
+  -D@gltests_WITNESS@=1 \
+  -I. -I$(srcdir) \
+  -I../.. -I$(srcdir)/../.. \
+  -I../../gnulib/lib -I$(srcdir)/../../gnulib/lib
+
+LDADD = libtests.a ../../gnulib/lib/libgnu.la libtests.a $(LIBTESTS_LIBDEPS)
+libtests_a_SOURCES = binary-io.h c-ctype.h c-ctype.c c-strcase.h \
+       c-strcasecmp.c c-strncasecmp.c ignore-value.h localename.c \
+       glthread/lock.h glthread/lock.c glthread/thread.h \
+       glthread/thread.c glthread/threadlib.c glthread/yield.h
+libtests_a_LIBADD = $(gltests_LIBOBJS)
+libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
+EXTRA_libtests_a_SOURCES = dup2.c getpagesize.c open.c putenv.c \
+       setenv.c setlocale.c symlink.c unsetenv.c wctob.c wctomb.c
+AM_LIBTOOLFLAGS = --preserve-dup-deps
+ARG_NONNULL_H = arg-nonnull.h
+CXXDEFS_H = c++defs.h
+test_getopt_LDADD = $(LDADD) $(LIBINTL)
+test_localename_LDADD = $(LDADD) @INTL_MACOSX_LIBS@
+test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
+UNUSED_PARAMETER_H = unused-parameter.h
+WARN_ON_USE_H = warn-on-use.h
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .html .lo .log .o .obj .test .test$(EXEEXT)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gnulib/tests/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign gnulib/tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkLIBRARIES:
+       -test -z "$(check_LIBRARIES)" || rm -f $(check_LIBRARIES)
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+glthread/$(am__dirstamp):
+       @$(MKDIR_P) glthread
+       @: > glthread/$(am__dirstamp)
+glthread/$(DEPDIR)/$(am__dirstamp):
+       @$(MKDIR_P) glthread/$(DEPDIR)
+       @: > glthread/$(DEPDIR)/$(am__dirstamp)
+glthread/lock.$(OBJEXT): glthread/$(am__dirstamp) \
+       glthread/$(DEPDIR)/$(am__dirstamp)
+glthread/thread.$(OBJEXT): glthread/$(am__dirstamp) \
+       glthread/$(DEPDIR)/$(am__dirstamp)
+glthread/threadlib.$(OBJEXT): glthread/$(am__dirstamp) \
+       glthread/$(DEPDIR)/$(am__dirstamp)
+libtests.a: $(libtests_a_OBJECTS) $(libtests_a_DEPENDENCIES) 
+       $(AM_V_at)-rm -f libtests.a
+       $(AM_V_AR)$(libtests_a_AR) libtests.a $(libtests_a_OBJECTS) $(libtests_a_LIBADD)
+       $(AM_V_at)$(RANLIB) libtests.a
+
+clean-checkPROGRAMS:
+       @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+test-alloca-opt$(EXEEXT): $(test_alloca_opt_OBJECTS) $(test_alloca_opt_DEPENDENCIES) 
+       @rm -f test-alloca-opt$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_alloca_opt_OBJECTS) $(test_alloca_opt_LDADD) $(LIBS)
+test-binary-io$(EXEEXT): $(test_binary_io_OBJECTS) $(test_binary_io_DEPENDENCIES) 
+       @rm -f test-binary-io$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_binary_io_OBJECTS) $(test_binary_io_LDADD) $(LIBS)
+test-btowc$(EXEEXT): $(test_btowc_OBJECTS) $(test_btowc_DEPENDENCIES) 
+       @rm -f test-btowc$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_btowc_OBJECTS) $(test_btowc_LDADD) $(LIBS)
+test-c-ctype$(EXEEXT): $(test_c_ctype_OBJECTS) $(test_c_ctype_DEPENDENCIES) 
+       @rm -f test-c-ctype$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_c_ctype_OBJECTS) $(test_c_ctype_LDADD) $(LIBS)
+test-c-strcasecmp$(EXEEXT): $(test_c_strcasecmp_OBJECTS) $(test_c_strcasecmp_DEPENDENCIES) 
+       @rm -f test-c-strcasecmp$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_c_strcasecmp_OBJECTS) $(test_c_strcasecmp_LDADD) $(LIBS)
+test-c-strncasecmp$(EXEEXT): $(test_c_strncasecmp_OBJECTS) $(test_c_strncasecmp_DEPENDENCIES) 
+       @rm -f test-c-strncasecmp$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_c_strncasecmp_OBJECTS) $(test_c_strncasecmp_LDADD) $(LIBS)
+test-canonicalize-lgpl$(EXEEXT): $(test_canonicalize_lgpl_OBJECTS) $(test_canonicalize_lgpl_DEPENDENCIES) 
+       @rm -f test-canonicalize-lgpl$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_canonicalize_lgpl_OBJECTS) $(test_canonicalize_lgpl_LDADD) $(LIBS)
+test-ctype$(EXEEXT): $(test_ctype_OBJECTS) $(test_ctype_DEPENDENCIES) 
+       @rm -f test-ctype$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_ctype_OBJECTS) $(test_ctype_LDADD) $(LIBS)
+test-dup2$(EXEEXT): $(test_dup2_OBJECTS) $(test_dup2_DEPENDENCIES) 
+       @rm -f test-dup2$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_dup2_OBJECTS) $(test_dup2_LDADD) $(LIBS)
+test-environ$(EXEEXT): $(test_environ_OBJECTS) $(test_environ_DEPENDENCIES) 
+       @rm -f test-environ$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_environ_OBJECTS) $(test_environ_LDADD) $(LIBS)
+test-errno$(EXEEXT): $(test_errno_OBJECTS) $(test_errno_DEPENDENCIES) 
+       @rm -f test-errno$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_errno_OBJECTS) $(test_errno_LDADD) $(LIBS)
+test-fcntl-h$(EXEEXT): $(test_fcntl_h_OBJECTS) $(test_fcntl_h_DEPENDENCIES) 
+       @rm -f test-fcntl-h$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_fcntl_h_OBJECTS) $(test_fcntl_h_LDADD) $(LIBS)
+test-fnmatch$(EXEEXT): $(test_fnmatch_OBJECTS) $(test_fnmatch_DEPENDENCIES) 
+       @rm -f test-fnmatch$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_fnmatch_OBJECTS) $(test_fnmatch_LDADD) $(LIBS)
+test-getdelim$(EXEEXT): $(test_getdelim_OBJECTS) $(test_getdelim_DEPENDENCIES) 
+       @rm -f test-getdelim$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_getdelim_OBJECTS) $(test_getdelim_LDADD) $(LIBS)
+test-getline$(EXEEXT): $(test_getline_OBJECTS) $(test_getline_DEPENDENCIES) 
+       @rm -f test-getline$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_getline_OBJECTS) $(test_getline_LDADD) $(LIBS)
+test-getopt$(EXEEXT): $(test_getopt_OBJECTS) $(test_getopt_DEPENDENCIES) 
+       @rm -f test-getopt$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_getopt_OBJECTS) $(test_getopt_LDADD) $(LIBS)
+test-ignore-value$(EXEEXT): $(test_ignore_value_OBJECTS) $(test_ignore_value_DEPENDENCIES) 
+       @rm -f test-ignore-value$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_ignore_value_OBJECTS) $(test_ignore_value_LDADD) $(LIBS)
+test-isblank$(EXEEXT): $(test_isblank_OBJECTS) $(test_isblank_DEPENDENCIES) 
+       @rm -f test-isblank$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_isblank_OBJECTS) $(test_isblank_LDADD) $(LIBS)
+test-langinfo$(EXEEXT): $(test_langinfo_OBJECTS) $(test_langinfo_DEPENDENCIES) 
+       @rm -f test-langinfo$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_langinfo_OBJECTS) $(test_langinfo_LDADD) $(LIBS)
+test-locale$(EXEEXT): $(test_locale_OBJECTS) $(test_locale_DEPENDENCIES) 
+       @rm -f test-locale$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_locale_OBJECTS) $(test_locale_LDADD) $(LIBS)
+test-localename$(EXEEXT): $(test_localename_OBJECTS) $(test_localename_DEPENDENCIES) 
+       @rm -f test-localename$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_localename_OBJECTS) $(test_localename_LDADD) $(LIBS)
+test-lock$(EXEEXT): $(test_lock_OBJECTS) $(test_lock_DEPENDENCIES) 
+       @rm -f test-lock$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_lock_OBJECTS) $(test_lock_LDADD) $(LIBS)
+test-lstat$(EXEEXT): $(test_lstat_OBJECTS) $(test_lstat_DEPENDENCIES) 
+       @rm -f test-lstat$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_lstat_OBJECTS) $(test_lstat_LDADD) $(LIBS)
+test-malloc-gnu$(EXEEXT): $(test_malloc_gnu_OBJECTS) $(test_malloc_gnu_DEPENDENCIES) 
+       @rm -f test-malloc-gnu$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_malloc_gnu_OBJECTS) $(test_malloc_gnu_LDADD) $(LIBS)
+test-malloca$(EXEEXT): $(test_malloca_OBJECTS) $(test_malloca_DEPENDENCIES) 
+       @rm -f test-malloca$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_malloca_OBJECTS) $(test_malloca_LDADD) $(LIBS)
+test-mbrtowc$(EXEEXT): $(test_mbrtowc_OBJECTS) $(test_mbrtowc_DEPENDENCIES) 
+       @rm -f test-mbrtowc$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_mbrtowc_OBJECTS) $(test_mbrtowc_LDADD) $(LIBS)
+test-mbrtowc-w32$(EXEEXT): $(test_mbrtowc_w32_OBJECTS) $(test_mbrtowc_w32_DEPENDENCIES) 
+       @rm -f test-mbrtowc-w32$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_mbrtowc_w32_OBJECTS) $(test_mbrtowc_w32_LDADD) $(LIBS)
+test-mbsinit$(EXEEXT): $(test_mbsinit_OBJECTS) $(test_mbsinit_DEPENDENCIES) 
+       @rm -f test-mbsinit$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_mbsinit_OBJECTS) $(test_mbsinit_LDADD) $(LIBS)
+test-mbsrtowcs$(EXEEXT): $(test_mbsrtowcs_OBJECTS) $(test_mbsrtowcs_DEPENDENCIES) 
+       @rm -f test-mbsrtowcs$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_mbsrtowcs_OBJECTS) $(test_mbsrtowcs_LDADD) $(LIBS)
+test-memchr$(EXEEXT): $(test_memchr_OBJECTS) $(test_memchr_DEPENDENCIES) 
+       @rm -f test-memchr$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_memchr_OBJECTS) $(test_memchr_LDADD) $(LIBS)
+test-nl_langinfo$(EXEEXT): $(test_nl_langinfo_OBJECTS) $(test_nl_langinfo_DEPENDENCIES) 
+       @rm -f test-nl_langinfo$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_nl_langinfo_OBJECTS) $(test_nl_langinfo_LDADD) $(LIBS)
+test-open$(EXEEXT): $(test_open_OBJECTS) $(test_open_DEPENDENCIES) 
+       @rm -f test-open$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_open_OBJECTS) $(test_open_LDADD) $(LIBS)
+test-readlink$(EXEEXT): $(test_readlink_OBJECTS) $(test_readlink_DEPENDENCIES) 
+       @rm -f test-readlink$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_readlink_OBJECTS) $(test_readlink_LDADD) $(LIBS)
+test-safe-alloc$(EXEEXT): $(test_safe_alloc_OBJECTS) $(test_safe_alloc_DEPENDENCIES) 
+       @rm -f test-safe-alloc$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_safe_alloc_OBJECTS) $(test_safe_alloc_LDADD) $(LIBS)
+test-setenv$(EXEEXT): $(test_setenv_OBJECTS) $(test_setenv_DEPENDENCIES) 
+       @rm -f test-setenv$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_setenv_OBJECTS) $(test_setenv_LDADD) $(LIBS)
+test-setlocale1$(EXEEXT): $(test_setlocale1_OBJECTS) $(test_setlocale1_DEPENDENCIES) 
+       @rm -f test-setlocale1$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_setlocale1_OBJECTS) $(test_setlocale1_LDADD) $(LIBS)
+test-setlocale2$(EXEEXT): $(test_setlocale2_OBJECTS) $(test_setlocale2_DEPENDENCIES) 
+       @rm -f test-setlocale2$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_setlocale2_OBJECTS) $(test_setlocale2_LDADD) $(LIBS)
+test-stat$(EXEEXT): $(test_stat_OBJECTS) $(test_stat_DEPENDENCIES) 
+       @rm -f test-stat$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stat_OBJECTS) $(test_stat_LDADD) $(LIBS)
+test-stdbool$(EXEEXT): $(test_stdbool_OBJECTS) $(test_stdbool_DEPENDENCIES) 
+       @rm -f test-stdbool$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stdbool_OBJECTS) $(test_stdbool_LDADD) $(LIBS)
+test-stddef$(EXEEXT): $(test_stddef_OBJECTS) $(test_stddef_DEPENDENCIES) 
+       @rm -f test-stddef$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stddef_OBJECTS) $(test_stddef_LDADD) $(LIBS)
+test-stdint$(EXEEXT): $(test_stdint_OBJECTS) $(test_stdint_DEPENDENCIES) 
+       @rm -f test-stdint$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stdint_OBJECTS) $(test_stdint_LDADD) $(LIBS)
+test-stdio$(EXEEXT): $(test_stdio_OBJECTS) $(test_stdio_DEPENDENCIES) 
+       @rm -f test-stdio$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stdio_OBJECTS) $(test_stdio_LDADD) $(LIBS)
+test-stdlib$(EXEEXT): $(test_stdlib_OBJECTS) $(test_stdlib_DEPENDENCIES) 
+       @rm -f test-stdlib$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_stdlib_OBJECTS) $(test_stdlib_LDADD) $(LIBS)
+test-string$(EXEEXT): $(test_string_OBJECTS) $(test_string_DEPENDENCIES) 
+       @rm -f test-string$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_string_OBJECTS) $(test_string_LDADD) $(LIBS)
+test-strnlen$(EXEEXT): $(test_strnlen_OBJECTS) $(test_strnlen_DEPENDENCIES) 
+       @rm -f test-strnlen$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_strnlen_OBJECTS) $(test_strnlen_LDADD) $(LIBS)
+test-strstr$(EXEEXT): $(test_strstr_OBJECTS) $(test_strstr_DEPENDENCIES) 
+       @rm -f test-strstr$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_strstr_OBJECTS) $(test_strstr_LDADD) $(LIBS)
+test-symlink$(EXEEXT): $(test_symlink_OBJECTS) $(test_symlink_DEPENDENCIES) 
+       @rm -f test-symlink$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_symlink_OBJECTS) $(test_symlink_LDADD) $(LIBS)
+test-sys_stat$(EXEEXT): $(test_sys_stat_OBJECTS) $(test_sys_stat_DEPENDENCIES) 
+       @rm -f test-sys_stat$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_sys_stat_OBJECTS) $(test_sys_stat_LDADD) $(LIBS)
+test-sys_wait$(EXEEXT): $(test_sys_wait_OBJECTS) $(test_sys_wait_DEPENDENCIES) 
+       @rm -f test-sys_wait$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_sys_wait_OBJECTS) $(test_sys_wait_LDADD) $(LIBS)
+test-time$(EXEEXT): $(test_time_OBJECTS) $(test_time_DEPENDENCIES) 
+       @rm -f test-time$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_time_OBJECTS) $(test_time_LDADD) $(LIBS)
+test-unistd$(EXEEXT): $(test_unistd_OBJECTS) $(test_unistd_DEPENDENCIES) 
+       @rm -f test-unistd$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_unistd_OBJECTS) $(test_unistd_LDADD) $(LIBS)
+test-unsetenv$(EXEEXT): $(test_unsetenv_OBJECTS) $(test_unsetenv_DEPENDENCIES) 
+       @rm -f test-unsetenv$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_unsetenv_OBJECTS) $(test_unsetenv_LDADD) $(LIBS)
+test-vasnprintf$(EXEEXT): $(test_vasnprintf_OBJECTS) $(test_vasnprintf_DEPENDENCIES) 
+       @rm -f test-vasnprintf$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_vasnprintf_OBJECTS) $(test_vasnprintf_LDADD) $(LIBS)
+test-vasprintf$(EXEEXT): $(test_vasprintf_OBJECTS) $(test_vasprintf_DEPENDENCIES) 
+       @rm -f test-vasprintf$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_vasprintf_OBJECTS) $(test_vasprintf_LDADD) $(LIBS)
+test-verify$(EXEEXT): $(test_verify_OBJECTS) $(test_verify_DEPENDENCIES) 
+       @rm -f test-verify$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_verify_OBJECTS) $(test_verify_LDADD) $(LIBS)
+test-wchar$(EXEEXT): $(test_wchar_OBJECTS) $(test_wchar_DEPENDENCIES) 
+       @rm -f test-wchar$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_wchar_OBJECTS) $(test_wchar_LDADD) $(LIBS)
+test-wcrtomb$(EXEEXT): $(test_wcrtomb_OBJECTS) $(test_wcrtomb_DEPENDENCIES) 
+       @rm -f test-wcrtomb$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_wcrtomb_OBJECTS) $(test_wcrtomb_LDADD) $(LIBS)
+test-wcrtomb-w32$(EXEEXT): $(test_wcrtomb_w32_OBJECTS) $(test_wcrtomb_w32_DEPENDENCIES) 
+       @rm -f test-wcrtomb-w32$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_wcrtomb_w32_OBJECTS) $(test_wcrtomb_w32_LDADD) $(LIBS)
+test-wctype-h$(EXEEXT): $(test_wctype_h_OBJECTS) $(test_wctype_h_DEPENDENCIES) 
+       @rm -f test-wctype-h$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_wctype_h_OBJECTS) $(test_wctype_h_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+       -rm -f glthread/lock.$(OBJEXT)
+       -rm -f glthread/thread.$(OBJEXT)
+       -rm -f glthread/threadlib.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-ctype.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strcasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c-strncasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getpagesize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localename.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setlocale.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlink.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-alloca-opt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-binary-io.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-btowc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-ctype.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strcasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-c-strncasecmp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-canonicalize-lgpl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ctype.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dup2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-environ.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-errno.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fcntl-h.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fnmatch.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getdelim.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-getopt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ignore-value.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-isblank.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-langinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-locale.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-localename.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lock.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-lstat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-malloc-gnu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-malloca.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbrtowc-w32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbrtowc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsinit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mbsrtowcs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-memchr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nl_langinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-open.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-readlink.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-safe-alloc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-setlocale2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdbool.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stddef.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdio.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-stdlib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-string.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strnlen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-strstr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-symlink.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sys_wait.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-time.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unistd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unsetenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasnprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-vasprintf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-verify.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wchar.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wcrtomb-w32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wcrtomb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-wctype-h.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctob.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctomb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/thread.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@   $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@   $(am__mv) $$depbase.Tpo $$depbase.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+# To be appended to the command running the test.  Handle the stdout
+# and stderr redirection, and catch the exit status.
+am__check_post =                                       \
+>$@-t 2>&1;                                            \
+estatus=$$?;                                           \
+if test -n '$(DISABLE_HARD_ERRORS)'                    \
+   && test $$estatus -eq 99; then                      \
+  estatus=1;                                           \
+fi;                                                    \
+TERM=$$__SAVED_TERM; export TERM;                      \
+$(am__tty_colors);                                     \
+xfailed=PASS;                                          \
+case " $(XFAIL_TESTS) " in                             \
+  *[\ \        ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
+    xfailed=XFAIL;;                                    \
+esac;                                                  \
+case $$estatus:$$xfailed in                            \
+    0:XFAIL) col=$$red; res=XPASS;;                    \
+    0:*)     col=$$grn; res=PASS ;;                    \
+    77:*)    col=$$blu; res=SKIP ;;                    \
+    99:*)    col=$$red; res=FAIL ;;                    \
+    *:XFAIL) col=$$lgn; res=XFAIL;;                    \
+    *:*)     col=$$red; res=FAIL ;;                    \
+esac;                                                  \
+echo "$${col}$$res$${std}: $$f";                       \
+echo "$$res: $$f (exit: $$estatus)" |                  \
+  $(am__rst_section) >$@;                              \
+cat $@-t >>$@;                                         \
+rm -f $@-t
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+       @$(am__sh_e_setup);                                             \
+       list='$(TEST_LOGS)';                                            \
+       results=`for f in $$list; do                                    \
+                  read line < $$f && echo "$$line" || echo FAIL;       \
+                done`;                                                 \
+       all=`echo "$$results" | sed '/^$$/d' | wc -l | sed -e 's/^[      ]*//'`; \
+       fail=`echo "$$results" | grep -c '^FAIL'`;                      \
+       pass=`echo "$$results" | grep -c '^PASS'`;                      \
+       skip=`echo "$$results" | grep -c '^SKIP'`;                      \
+       xfail=`echo "$$results" | grep -c '^XFAIL'`;                    \
+       xpass=`echo "$$results" | grep -c '^XPASS'`;                    \
+       failures=`expr $$fail + $$xpass`;                               \
+       all=`expr $$all - $$skip`;                                      \
+       if test "$$all" -eq 1; then tests=test; All=;                   \
+       else tests=tests; All="All "; fi;                               \
+       case fail=$$fail:xpass=$$xpass:xfail=$$xfail in                 \
+         fail=0:xpass=0:xfail=0)                                       \
+           msg="$$All$$all $$tests passed.  ";                         \
+           exit=true;;                                                 \
+         fail=0:xpass=0:xfail=*)                                       \
+           msg="$$All$$all $$tests behaved as expected";               \
+           if test "$$xfail" -eq 1; then xfailures=failure;            \
+           else xfailures=failures; fi;                                \
+           msg="$$msg ($$xfail expected $$xfailures).  ";              \
+           exit=true;;                                                 \
+         fail=*:xpass=0:xfail=*)                                       \
+           msg="$$fail of $$all $$tests failed.  ";                    \
+           exit=false;;                                                \
+         fail=*:xpass=*:xfail=*)                                       \
+           msg="$$failures of $$all $$tests did not behave as expected"; \
+           if test "$$xpass" -eq 1; then xpasses=pass;                 \
+           else xpasses=passes; fi;                                    \
+           msg="$$msg ($$xpass unexpected $$xpasses).  ";              \
+           exit=false;;                                                \
+         *)                                                            \
+           echo >&2 "incorrect case"; exit 4;;                         \
+       esac;                                                           \
+       if test "$$skip" -ne 0; then                                    \
+         if test "$$skip" -eq 1; then                                  \
+           msg="$$msg($$skip test was not run).  ";                    \
+         else                                                          \
+           msg="$$msg($$skip tests were not run).  ";                  \
+         fi;                                                           \
+       fi;                                                             \
+       {                                                               \
+         echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
+           $(am__rst_title);                                           \
+         echo "$$msg";                                                 \
+         echo;                                                         \
+         echo ".. contents:: :depth: 2";                               \
+         echo;                                                         \
+         for f in $$list; do                                           \
+           read line < $$f;                                            \
+           case $$line in                                              \
+             PASS:*|XFAIL:*);;                                         \
+             *) echo; cat $$f;;                                        \
+           esac;                                                       \
+         done;                                                         \
+       } >$(TEST_SUITE_LOG).tmp;                                       \
+       mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
+       if test "$$failures" -ne 0; then                                \
+         msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";              \
+         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
+           msg="$${msg}Please report to $(PACKAGE_BUGREPORT).  ";      \
+         fi;                                                           \
+       fi;                                                             \
+       test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);       \
+       $(am__tty_colors);                                              \
+       if $$exit; then                                                 \
+         echo $(ECHO_N) "$$grn$(ECHO_C)";                              \
+        else                                                           \
+         echo $(ECHO_N) "$$red$(ECHO_C)";                              \
+       fi;                                                             \
+       echo "$$msg" | $(am__text_box);                                 \
+       echo $(ECHO_N) "$$std$(ECHO_C)";                                \
+       $$exit
+
+# Run all the tests.
+check-TESTS:
+       @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+       @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+       @list='$(TEST_LOGS)';                                           \
+       list=`for f in $$list; do                                       \
+         test .log = $$f || echo $$f;                                  \
+       done | tr '\012\015' '  '`;                                     \
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
+
+.log.html:
+       @list='$(RST2HTML) $$RST2HTML rst2html rst2html.py';            \
+       for r2h in $$list; do                                           \
+         if ($$r2h --version) >/dev/null 2>&1; then                    \
+           R2H=$$r2h;                                                  \
+         fi;                                                           \
+       done;                                                           \
+       if test -z "$$R2H"; then                                        \
+         echo >&2 "cannot find rst2html, cannot create $@";            \
+         exit 2;                                                       \
+       fi;                                                             \
+       $$R2H $< >$@.tmp
+       @mv $@.tmp $@
+
+# Be sure to run check first, and then to convert the result.
+# Beware of concurrent executions.  Run "check" not "check-TESTS", as
+# check-SCRIPTS and other dependencies are rebuilt by the former only.
+# And expect check to fail.
+check-html:
+       @if $(MAKE) $(AM_MAKEFLAGS) check; then                 \
+         rv=0; else rv=$$?;                                    \
+       fi;                                                     \
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4;   \
+       exit $$rv
+recheck recheck-html:
+       @target=`echo $@ | sed 's,^re,,'`;                              \
+       list='$(TEST_LOGS)';                                            \
+       list=`for f in $$list; do                                       \
+               test -f $$f || continue;                                \
+               if read line < $$f; then                                \
+                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
+               else echo $$f; fi;                                      \
+             done | tr '\012\015' '  '`;                               \
+       $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
+test-alloca-opt.log: test-alloca-opt$(EXEEXT)
+       @p='test-alloca-opt$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-binary-io.sh.log: test-binary-io.sh
+       @p='test-binary-io.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-btowc1.sh.log: test-btowc1.sh
+       @p='test-btowc1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-btowc2.sh.log: test-btowc2.sh
+       @p='test-btowc2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-c-ctype.log: test-c-ctype$(EXEEXT)
+       @p='test-c-ctype$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-c-strcase.sh.log: test-c-strcase.sh
+       @p='test-c-strcase.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-canonicalize-lgpl.log: test-canonicalize-lgpl$(EXEEXT)
+       @p='test-canonicalize-lgpl$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-ctype.log: test-ctype$(EXEEXT)
+       @p='test-ctype$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-dup2.log: test-dup2$(EXEEXT)
+       @p='test-dup2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-environ.log: test-environ$(EXEEXT)
+       @p='test-environ$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-errno.log: test-errno$(EXEEXT)
+       @p='test-errno$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-fcntl-h.log: test-fcntl-h$(EXEEXT)
+       @p='test-fcntl-h$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-fnmatch.log: test-fnmatch$(EXEEXT)
+       @p='test-fnmatch$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-getdelim.log: test-getdelim$(EXEEXT)
+       @p='test-getdelim$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-getline.log: test-getline$(EXEEXT)
+       @p='test-getline$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-getopt.log: test-getopt$(EXEEXT)
+       @p='test-getopt$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-ignore-value.log: test-ignore-value$(EXEEXT)
+       @p='test-ignore-value$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-isblank.log: test-isblank$(EXEEXT)
+       @p='test-isblank$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-langinfo.log: test-langinfo$(EXEEXT)
+       @p='test-langinfo$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-locale.log: test-locale$(EXEEXT)
+       @p='test-locale$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-localename.log: test-localename$(EXEEXT)
+       @p='test-localename$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-lock.log: test-lock$(EXEEXT)
+       @p='test-lock$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-lstat.log: test-lstat$(EXEEXT)
+       @p='test-lstat$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-malloc-gnu.log: test-malloc-gnu$(EXEEXT)
+       @p='test-malloc-gnu$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-malloca.log: test-malloca$(EXEEXT)
+       @p='test-malloca$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc1.sh.log: test-mbrtowc1.sh
+       @p='test-mbrtowc1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc2.sh.log: test-mbrtowc2.sh
+       @p='test-mbrtowc2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc3.sh.log: test-mbrtowc3.sh
+       @p='test-mbrtowc3.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc4.sh.log: test-mbrtowc4.sh
+       @p='test-mbrtowc4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc-w32-1.sh.log: test-mbrtowc-w32-1.sh
+       @p='test-mbrtowc-w32-1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc-w32-2.sh.log: test-mbrtowc-w32-2.sh
+       @p='test-mbrtowc-w32-2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc-w32-3.sh.log: test-mbrtowc-w32-3.sh
+       @p='test-mbrtowc-w32-3.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc-w32-4.sh.log: test-mbrtowc-w32-4.sh
+       @p='test-mbrtowc-w32-4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbrtowc-w32-5.sh.log: test-mbrtowc-w32-5.sh
+       @p='test-mbrtowc-w32-5.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbsinit.sh.log: test-mbsinit.sh
+       @p='test-mbsinit.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbsrtowcs1.sh.log: test-mbsrtowcs1.sh
+       @p='test-mbsrtowcs1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbsrtowcs2.sh.log: test-mbsrtowcs2.sh
+       @p='test-mbsrtowcs2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbsrtowcs3.sh.log: test-mbsrtowcs3.sh
+       @p='test-mbsrtowcs3.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mbsrtowcs4.sh.log: test-mbsrtowcs4.sh
+       @p='test-mbsrtowcs4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-memchr.log: test-memchr$(EXEEXT)
+       @p='test-memchr$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-nl_langinfo.sh.log: test-nl_langinfo.sh
+       @p='test-nl_langinfo.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-open.log: test-open$(EXEEXT)
+       @p='test-open$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-readlink.log: test-readlink$(EXEEXT)
+       @p='test-readlink$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-safe-alloc.log: test-safe-alloc$(EXEEXT)
+       @p='test-safe-alloc$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-setenv.log: test-setenv$(EXEEXT)
+       @p='test-setenv$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-setlocale1.sh.log: test-setlocale1.sh
+       @p='test-setlocale1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-setlocale2.sh.log: test-setlocale2.sh
+       @p='test-setlocale2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stat.log: test-stat$(EXEEXT)
+       @p='test-stat$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stdbool.log: test-stdbool$(EXEEXT)
+       @p='test-stdbool$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stddef.log: test-stddef$(EXEEXT)
+       @p='test-stddef$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stdint.log: test-stdint$(EXEEXT)
+       @p='test-stdint$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stdio.log: test-stdio$(EXEEXT)
+       @p='test-stdio$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-stdlib.log: test-stdlib$(EXEEXT)
+       @p='test-stdlib$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-string.log: test-string$(EXEEXT)
+       @p='test-string$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-strnlen.log: test-strnlen$(EXEEXT)
+       @p='test-strnlen$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-strstr.log: test-strstr$(EXEEXT)
+       @p='test-strstr$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-symlink.log: test-symlink$(EXEEXT)
+       @p='test-symlink$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-sys_stat.log: test-sys_stat$(EXEEXT)
+       @p='test-sys_stat$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-sys_wait.log: test-sys_wait$(EXEEXT)
+       @p='test-sys_wait$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-time.log: test-time$(EXEEXT)
+       @p='test-time$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-unistd.log: test-unistd$(EXEEXT)
+       @p='test-unistd$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-unsetenv.log: test-unsetenv$(EXEEXT)
+       @p='test-unsetenv$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-vasnprintf.log: test-vasnprintf$(EXEEXT)
+       @p='test-vasnprintf$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-vasprintf.log: test-vasprintf$(EXEEXT)
+       @p='test-vasprintf$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-verify.log: test-verify$(EXEEXT)
+       @p='test-verify$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-verify.sh.log: test-verify.sh
+       @p='test-verify.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wchar.log: test-wchar$(EXEEXT)
+       @p='test-wchar$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb.sh.log: test-wcrtomb.sh
+       @p='test-wcrtomb.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb-w32-1.sh.log: test-wcrtomb-w32-1.sh
+       @p='test-wcrtomb-w32-1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb-w32-2.sh.log: test-wcrtomb-w32-2.sh
+       @p='test-wcrtomb-w32-2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb-w32-3.sh.log: test-wcrtomb-w32-3.sh
+       @p='test-wcrtomb-w32-3.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb-w32-4.sh.log: test-wcrtomb-w32-4.sh
+       @p='test-wcrtomb-w32-4.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wcrtomb-w32-5.sh.log: test-wcrtomb-w32-5.sh
+       @p='test-wcrtomb-w32-5.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-wctype-h.log: test-wctype-h$(EXEEXT)
+       @p='test-wctype-h$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+.test.log:
+       @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@      @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) $(check_LIBRARIES) $(check_PROGRAMS)
+       $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-recursive
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS)
+installdirs: installdirs-recursive
+installdirs-am:
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+       -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+       -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+       -test -z "$(TEST_LOGS_TMP)" || rm -f $(TEST_LOGS_TMP)
+       -test -z "$(TEST_SUITE_HTML)" || rm -f $(TEST_SUITE_HTML)
+       -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -rm -f glthread/$(DEPDIR)/$(am__dirstamp)
+       -rm -f glthread/$(am__dirstamp)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+       -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-recursive
+
+clean-am: clean-checkLIBRARIES clean-checkPROGRAMS clean-generic \
+       clean-libtool clean-local clean-noinstLIBRARIES \
+       clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -rf ./$(DEPDIR) glthread/$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -rf ./$(DEPDIR) glthread/$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool mostlyclean-local
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
+       check-am check-html ctags-recursive install install-am \
+       install-strip recheck recheck-html tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am check check-TESTS check-am check-html clean \
+       clean-checkLIBRARIES clean-checkPROGRAMS clean-generic \
+       clean-libtool clean-local clean-noinstLIBRARIES \
+       clean-noinstPROGRAMS ctags ctags-recursive distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       installdirs-am maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool mostlyclean-local pdf pdf-am ps ps-am \
+       recheck recheck-html tags tags-recursive uninstall \
+       uninstall-am
+
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/build/aux/arg-nonnull.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_ARG_NONNULL/,$$p' \
+         < $(top_srcdir)/build/aux/arg-nonnull.h \
+         > $@-t && \
+       mv $@-t $@
+# The c++defs.h that gets inserted into generated .h files is the same as
+# build-aux/c++defs.h, except that it has the copyright header cut off.
+c++defs.h: $(top_srcdir)/build/aux/c++defs.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/_GL_CXXDEFS/,$$p' \
+         < $(top_srcdir)/build/aux/c++defs.h \
+         > $@-t && \
+       mv $@-t $@
+
+# We need the following in order to create <fcntl.h> when the system
+# doesn't have one that works with the given compiler.
+fcntl.h: fcntl.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
+             -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \
+             -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
+             -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
+             -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
+             -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
+             -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
+             -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
+             -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+# The unused-parameter.h that gets inserted into generated .h files is the same
+# as build-aux/unused-parameter.h, except that it has the copyright header cut
+# off.
+unused-parameter.h: $(top_srcdir)/build/aux/unused-parameter.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
+         < $(top_srcdir)/build/aux/unused-parameter.h \
+         > $@-t && \
+       mv $@-t $@
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build/aux/warn-on-use.h
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/build/aux/warn-on-use.h \
+         > $@-t && \
+       mv $@-t $@
+
+# Clean up after Solaris cc.
+clean-local:
+       rm -rf SunWS_cache
+
+mostlyclean-local: mostlyclean-generic
+       @for dir in '' $(MOSTLYCLEANDIRS); do \
+         if test -n "$$dir" && test -d $$dir; then \
+           echo "rmdir $$dir"; rmdir $$dir; \
+         fi; \
+       done; \
+       :
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/gnulib/tests/binary-io.h b/gnulib/tests/binary-io.h
new file mode 100644 (file)
index 0000000..c09dbf5
--- /dev/null
@@ -0,0 +1,52 @@
+/* Binary mode I/O.
+   Copyright (C) 2001, 2003, 2005, 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/>.  */
+
+#ifndef _BINARY_H
+#define _BINARY_H
+
+/* For systems that distinguish between text and binary I/O.
+   O_BINARY is guaranteed by the gnulib <fcntl.h>. */
+#include <fcntl.h>
+
+/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
+   so we include it here first.  */
+#include <stdio.h>
+
+/* SET_BINARY (fd);
+   changes the file descriptor fd to perform binary I/O.  */
+#if O_BINARY
+# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
+#  include <io.h> /* declares setmode() */
+# else
+#  define setmode _setmode
+#  undef fileno
+#  define fileno _fileno
+# endif
+# ifdef __DJGPP__
+#  include <unistd.h> /* declares isatty() */
+   /* Avoid putting stdin/stdout in binary mode if it is connected to
+      the console, because that would make it impossible for the user
+      to interrupt the program through Ctrl-C or Ctrl-Break.  */
+#  define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0))
+# else
+#  define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
+# endif
+#else
+  /* On reasonable systems, binary I/O is the default.  */
+# define SET_BINARY(fd) /* do nothing */ ((void) 0)
+#endif
+
+#endif /* _BINARY_H */
diff --git a/gnulib/tests/c-ctype.c b/gnulib/tests/c-ctype.c
new file mode 100644 (file)
index 0000000..0fb4295
--- /dev/null
@@ -0,0 +1,396 @@
+/* Character handling in C locale.
+
+   Copyright 2000-2003, 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, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#define NO_C_CTYPE_MACROS
+#include "c-ctype.h"
+
+/* The function isascii is not locale dependent. Its use in EBCDIC is
+   questionable. */
+bool
+c_isascii (int c)
+{
+  return (c >= 0x00 && c <= 0x7f);
+}
+
+bool
+c_isalnum (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c >= '0' && c <= '9')
+          || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
+#else
+  return ((c >= '0' && c <= '9')
+          || (c >= 'A' && c <= 'Z')
+          || (c >= 'a' && c <= 'z'));
+#endif
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isalpha (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
+#else
+  return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
+#endif
+#else
+  switch (c)
+    {
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isblank (int c)
+{
+  return (c == ' ' || c == '\t');
+}
+
+bool
+c_iscntrl (int c)
+{
+#if C_CTYPE_ASCII
+  return ((c & ~0x1f) == 0 || c == 0x7f);
+#else
+  switch (c)
+    {
+    case ' ': case '!': case '"': case '#': case '$': case '%':
+    case '&': case '\'': case '(': case ')': case '*': case '+':
+    case ',': case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 0;
+    default:
+      return 1;
+    }
+#endif
+}
+
+bool
+c_isdigit (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS
+  return (c >= '0' && c <= '9');
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_islower (int c)
+{
+#if C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'a' && c <= 'z');
+#else
+  switch (c)
+    {
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isgraph (int c)
+{
+#if C_CTYPE_ASCII
+  return (c >= '!' && c <= '~');
+#else
+  switch (c)
+    {
+    case '!': case '"': case '#': case '$': case '%': case '&':
+    case '\'': case '(': case ')': case '*': case '+': case ',':
+    case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isprint (int c)
+{
+#if C_CTYPE_ASCII
+  return (c >= ' ' && c <= '~');
+#else
+  switch (c)
+    {
+    case ' ': case '!': case '"': case '#': case '$': case '%':
+    case '&': case '\'': case '(': case ')': case '*': case '+':
+    case ',': case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_ispunct (int c)
+{
+#if C_CTYPE_ASCII
+  return ((c >= '!' && c <= '~')
+          && !((c >= '0' && c <= '9')
+               || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
+#else
+  switch (c)
+    {
+    case '!': case '"': case '#': case '$': case '%': case '&':
+    case '\'': case '(': case ')': case '*': case '+': case ',':
+    case '-': case '.': case '/':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isspace (int c)
+{
+  return (c == ' ' || c == '\t'
+          || c == '\n' || c == '\v' || c == '\f' || c == '\r');
+}
+
+bool
+c_isupper (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE
+  return (c >= 'A' && c <= 'Z');
+#else
+  switch (c)
+    {
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isxdigit (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c >= '0' && c <= '9')
+          || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
+#else
+  return ((c >= '0' && c <= '9')
+          || (c >= 'A' && c <= 'F')
+          || (c >= 'a' && c <= 'f'));
+#endif
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+int
+c_tolower (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
+#else
+  switch (c)
+    {
+    case 'A': return 'a';
+    case 'B': return 'b';
+    case 'C': return 'c';
+    case 'D': return 'd';
+    case 'E': return 'e';
+    case 'F': return 'f';
+    case 'G': return 'g';
+    case 'H': return 'h';
+    case 'I': return 'i';
+    case 'J': return 'j';
+    case 'K': return 'k';
+    case 'L': return 'l';
+    case 'M': return 'm';
+    case 'N': return 'n';
+    case 'O': return 'o';
+    case 'P': return 'p';
+    case 'Q': return 'q';
+    case 'R': return 'r';
+    case 'S': return 's';
+    case 'T': return 't';
+    case 'U': return 'u';
+    case 'V': return 'v';
+    case 'W': return 'w';
+    case 'X': return 'x';
+    case 'Y': return 'y';
+    case 'Z': return 'z';
+    default: return c;
+    }
+#endif
+}
+
+int
+c_toupper (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
+#else
+  switch (c)
+    {
+    case 'a': return 'A';
+    case 'b': return 'B';
+    case 'c': return 'C';
+    case 'd': return 'D';
+    case 'e': return 'E';
+    case 'f': return 'F';
+    case 'g': return 'G';
+    case 'h': return 'H';
+    case 'i': return 'I';
+    case 'j': return 'J';
+    case 'k': return 'K';
+    case 'l': return 'L';
+    case 'm': return 'M';
+    case 'n': return 'N';
+    case 'o': return 'O';
+    case 'p': return 'P';
+    case 'q': return 'Q';
+    case 'r': return 'R';
+    case 's': return 'S';
+    case 't': return 'T';
+    case 'u': return 'U';
+    case 'v': return 'V';
+    case 'w': return 'W';
+    case 'x': return 'X';
+    case 'y': return 'Y';
+    case 'z': return 'Z';
+    default: return c;
+    }
+#endif
+}
diff --git a/gnulib/tests/c-ctype.h b/gnulib/tests/c-ctype.h
new file mode 100644 (file)
index 0000000..57e71ee
--- /dev/null
@@ -0,0 +1,295 @@
+/* Character handling in C locale.
+
+   These functions work like the corresponding functions in <ctype.h>,
+   except that they have the C (POSIX) locale hardwired, whereas the
+   <ctype.h> functions' behaviour depends on the current locale set via
+   setlocale.
+
+   Copyright (C) 2000-2003, 2006, 2008-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, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef C_CTYPE_H
+#define C_CTYPE_H
+
+#include <stdbool.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* The functions defined in this file assume the "C" locale and a character
+   set without diacritics (ASCII-US or EBCDIC-US or something like that).
+   Even if the "C" locale on a particular system is an extension of the ASCII
+   character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
+   is ISO-8859-1), the functions in this file recognize only the ASCII
+   characters.  */
+
+
+/* Check whether the ASCII optimizations apply. */
+
+/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that
+   '0', '1', ..., '9' have consecutive integer values.  */
+#define C_CTYPE_CONSECUTIVE_DIGITS 1
+
+#if ('A' <= 'Z') \
+    && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
+    && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
+    && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
+    && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
+    && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
+    && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
+    && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
+    && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
+    && ('Y' + 1 == 'Z')
+#define C_CTYPE_CONSECUTIVE_UPPERCASE 1
+#endif
+
+#if ('a' <= 'z') \
+    && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
+    && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
+    && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
+    && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
+    && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
+    && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
+    && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
+    && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
+    && ('y' + 1 == 'z')
+#define C_CTYPE_CONSECUTIVE_LOWERCASE 1
+#endif
+
+#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+    && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+    && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+    && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+    && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+    && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+    && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+    && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+    && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+    && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+    && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+    && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+    && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+    && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+    && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+    && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+    && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+    && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+    && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+    && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+    && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+    && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+    && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
+/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
+   Testing the value of '\n' and '\r' is not relevant.  */
+#define C_CTYPE_ASCII 1
+#endif
+
+
+/* Function declarations. */
+
+/* Unlike the functions in <ctype.h>, which require an argument in the range
+   of the 'unsigned char' type, the functions here operate on values that are
+   in the 'unsigned char' range or in the 'char' range.  In other words,
+   when you have a 'char' value, you need to cast it before using it as
+   argument to a <ctype.h> function:
+
+         const char *s = ...;
+         if (isalpha ((unsigned char) *s)) ...
+
+   but you don't need to cast it for the functions defined in this file:
+
+         const char *s = ...;
+         if (c_isalpha (*s)) ...
+ */
+
+extern bool c_isascii (int c); /* not locale dependent */
+
+extern bool c_isalnum (int c);
+extern bool c_isalpha (int c);
+extern bool c_isblank (int c);
+extern bool c_iscntrl (int c);
+extern bool c_isdigit (int c);
+extern bool c_islower (int c);
+extern bool c_isgraph (int c);
+extern bool c_isprint (int c);
+extern bool c_ispunct (int c);
+extern bool c_isspace (int c);
+extern bool c_isupper (int c);
+extern bool c_isxdigit (int c);
+
+extern int c_tolower (int c);
+extern int c_toupper (int c);
+
+
+#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
+
+/* ASCII optimizations. */
+
+#undef c_isascii
+#define c_isascii(c) \
+  ({ int __c = (c); \
+     (__c >= 0x00 && __c <= 0x7f); \
+   })
+
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isalnum
+#define c_isalnum(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
+   })
+#else
+#undef c_isalnum
+#define c_isalnum(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || (__c >= 'A' && __c <= 'Z') \
+      || (__c >= 'a' && __c <= 'z')); \
+   })
+#endif
+#endif
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isalpha
+#define c_isalpha(c) \
+  ({ int __c = (c); \
+     ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
+   })
+#else
+#undef c_isalpha
+#define c_isalpha(c) \
+  ({ int __c = (c); \
+     ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
+   })
+#endif
+#endif
+
+#undef c_isblank
+#define c_isblank(c) \
+  ({ int __c = (c); \
+     (__c == ' ' || __c == '\t'); \
+   })
+
+#if C_CTYPE_ASCII
+#undef c_iscntrl
+#define c_iscntrl(c) \
+  ({ int __c = (c); \
+     ((__c & ~0x1f) == 0 || __c == 0x7f); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_DIGITS
+#undef c_isdigit
+#define c_isdigit(c) \
+  ({ int __c = (c); \
+     (__c >= '0' && __c <= '9'); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_LOWERCASE
+#undef c_islower
+#define c_islower(c) \
+  ({ int __c = (c); \
+     (__c >= 'a' && __c <= 'z'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_isgraph
+#define c_isgraph(c) \
+  ({ int __c = (c); \
+     (__c >= '!' && __c <= '~'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_isprint
+#define c_isprint(c) \
+  ({ int __c = (c); \
+     (__c >= ' ' && __c <= '~'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_ispunct
+#define c_ispunct(c) \
+  ({ int _c = (c); \
+     (c_isgraph (_c) && ! c_isalnum (_c)); \
+   })
+#endif
+
+#undef c_isspace
+#define c_isspace(c) \
+  ({ int __c = (c); \
+     (__c == ' ' || __c == '\t' \
+      || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
+   })
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE
+#undef c_isupper
+#define c_isupper(c) \
+  ({ int __c = (c); \
+     (__c >= 'A' && __c <= 'Z'); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isxdigit
+#define c_isxdigit(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
+   })
+#else
+#undef c_isxdigit
+#define c_isxdigit(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || (__c >= 'A' && __c <= 'F') \
+      || (__c >= 'a' && __c <= 'f')); \
+   })
+#endif
+#endif
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#undef c_tolower
+#define c_tolower(c) \
+  ({ int __c = (c); \
+     (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
+   })
+#undef c_toupper
+#define c_toupper(c) \
+  ({ int __c = (c); \
+     (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
+   })
+#endif
+
+#endif /* optimizing for speed */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* C_CTYPE_H */
diff --git a/gnulib/tests/c-strcase.h b/gnulib/tests/c-strcase.h
new file mode 100644 (file)
index 0000000..4148c34
--- /dev/null
@@ -0,0 +1,56 @@
+/* Case-insensitive string comparison functions in C locale.
+   Copyright (C) 1995-1996, 2001, 2003, 2005, 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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef C_STRCASE_H
+#define C_STRCASE_H
+
+#include <stddef.h>
+
+
+/* The functions defined in this file assume the "C" locale and a character
+   set without diacritics (ASCII-US or EBCDIC-US or something like that).
+   Even if the "C" locale on a particular system is an extension of the ASCII
+   character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
+   is ISO-8859-1), the functions in this file recognize only the ASCII
+   characters.  More precisely, one of the string arguments must be an ASCII
+   string; the other one can also contain non-ASCII characters (but then
+   the comparison result will be nonzero).  */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+   greater than zero if S1 is lexicographically less than, equal to or greater
+   than S2.  */
+extern int c_strcasecmp (const char *s1, const char *s2);
+
+/* Compare no more than N characters of strings S1 and S2, ignoring case,
+   returning less than, equal to or greater than zero if S1 is
+   lexicographically less than, equal to or greater than S2.  */
+extern int c_strncasecmp (const char *s1, const char *s2, size_t n);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* C_STRCASE_H */
diff --git a/gnulib/tests/c-strcasecmp.c b/gnulib/tests/c-strcasecmp.c
new file mode 100644 (file)
index 0000000..4c4e106
--- /dev/null
@@ -0,0 +1,57 @@
+/* c-strcasecmp.c -- case insensitive string comparator in C locale
+   Copyright (C) 1998-1999, 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "c-strcase.h"
+
+#include <limits.h>
+
+#include "c-ctype.h"
+
+int
+c_strcasecmp (const char *s1, const char *s2)
+{
+  register const unsigned char *p1 = (const unsigned char *) s1;
+  register const unsigned char *p2 = (const unsigned char *) s2;
+  unsigned char c1, c2;
+
+  if (p1 == p2)
+    return 0;
+
+  do
+    {
+      c1 = c_tolower (*p1);
+      c2 = c_tolower (*p2);
+
+      if (c1 == '\0')
+        break;
+
+      ++p1;
+      ++p2;
+    }
+  while (c1 == c2);
+
+  if (UCHAR_MAX <= INT_MAX)
+    return c1 - c2;
+  else
+    /* On machines where 'char' and 'int' are types of the same size, the
+       difference of two 'unsigned char' values - including the sign bit -
+       doesn't fit in an 'int'.  */
+    return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/gnulib/tests/c-strncasecmp.c b/gnulib/tests/c-strncasecmp.c
new file mode 100644 (file)
index 0000000..0c433b9
--- /dev/null
@@ -0,0 +1,57 @@
+/* c-strncasecmp.c -- case insensitive string comparator in C locale
+   Copyright (C) 1998-1999, 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "c-strcase.h"
+
+#include <limits.h>
+
+#include "c-ctype.h"
+
+int
+c_strncasecmp (const char *s1, const char *s2, size_t n)
+{
+  register const unsigned char *p1 = (const unsigned char *) s1;
+  register const unsigned char *p2 = (const unsigned char *) s2;
+  unsigned char c1, c2;
+
+  if (p1 == p2 || n == 0)
+    return 0;
+
+  do
+    {
+      c1 = c_tolower (*p1);
+      c2 = c_tolower (*p2);
+
+      if (--n == 0 || c1 == '\0')
+        break;
+
+      ++p1;
+      ++p2;
+    }
+  while (c1 == c2);
+
+  if (UCHAR_MAX <= INT_MAX)
+    return c1 - c2;
+  else
+    /* On machines where 'char' and 'int' are types of the same size, the
+       difference of two 'unsigned char' values - including the sign bit -
+       doesn't fit in an 'int'.  */
+    return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/gnulib/tests/dup2.c b/gnulib/tests/dup2.c
new file mode 100644 (file)
index 0000000..e00dc7b
--- /dev/null
@@ -0,0 +1,132 @@
+/* Duplicate an open file descriptor to a specified file descriptor.
+
+   Copyright (C) 1999, 2004-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/>.  */
+
+/* written by Paul Eggert */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#include <errno.h>
+#include <fcntl.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Get declarations of the Win32 API functions.  */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
+#if HAVE_DUP2
+
+# undef dup2
+
+int
+rpl_dup2 (int fd, int desired_fd)
+{
+  int result;
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
+     dup2 (fd, fd) returns 0, but all further attempts to use fd in
+     future dup2 calls will hang.  */
+  if (fd == desired_fd)
+    {
+      if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
+        {
+          errno = EBADF;
+          return -1;
+        }
+      return fd;
+    }
+  /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
+     http://bugs.winehq.org/show_bug.cgi?id=21289 */
+  if (desired_fd < 0)
+    {
+      errno = EBADF;
+      return -1;
+    }
+# elif !defined __linux__
+  /* On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
+  if (fd == desired_fd)
+    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
+# endif
+  result = dup2 (fd, desired_fd);
+# ifdef __linux__
+  /* Correct a Linux return value.
+     <http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802>
+   */
+  if (fd == desired_fd && result == (unsigned int) -EBADF)
+    {
+      errno = EBADF;
+      result = -1;
+    }
+# endif
+  if (result == 0)
+    result = desired_fd;
+  /* Correct a cygwin 1.5.x errno value.  */
+  else if (result == -1 && errno == EMFILE)
+    errno = EBADF;
+# if REPLACE_FCHDIR
+  if (fd != desired_fd && result != -1)
+    result = _gl_register_dup (fd, result);
+# endif
+  return result;
+}
+
+#else /* !HAVE_DUP2 */
+
+/* On older platforms, dup2 did not exist.  */
+
+# ifndef F_DUPFD
+static int
+dupfd (int fd, int desired_fd)
+{
+  int duplicated_fd = dup (fd);
+  if (duplicated_fd < 0 || duplicated_fd == desired_fd)
+    return duplicated_fd;
+  else
+    {
+      int r = dupfd (fd, desired_fd);
+      int e = errno;
+      close (duplicated_fd);
+      errno = e;
+      return r;
+    }
+}
+# endif
+
+int
+dup2 (int fd, int desired_fd)
+{
+  int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
+  if (result == -1 || fd == desired_fd)
+    return result;
+  close (desired_fd);
+# ifdef F_DUPFD
+  result = fcntl (fd, F_DUPFD, desired_fd);
+#  if REPLACE_FCHDIR
+  if (0 <= result)
+    result = _gl_register_dup (fd, result);
+#  endif
+# else
+  result = dupfd (fd, desired_fd);
+# endif
+  if (result == -1 && (errno == EMFILE || errno == EINVAL))
+    errno = EBADF;
+  return result;
+}
+#endif /* !HAVE_DUP2 */
diff --git a/gnulib/tests/fcntl.in.h b/gnulib/tests/fcntl.in.h
new file mode 100644 (file)
index 0000000..18cac45
--- /dev/null
@@ -0,0 +1,308 @@
+/* Like <fcntl.h>, but with non-working flags defined to 0.
+
+   Copyright (C) 2006-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 */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if defined __need_system_fcntl_h
+/* Special invocation convention.  */
+
+#include <sys/types.h>
+/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
+   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
+   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
+   extern "C" { ... } block, which leads to errors in C++ mode with the
+   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
+   with g++ version >= 4.3.  */
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
+# include <sys/stat.h>
+#endif
+#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _GL_FCNTL_H
+
+#include <sys/types.h>
+/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
+   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
+   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
+   extern "C" { ... } block, which leads to errors in C++ mode with the
+   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
+   with g++ version >= 4.3.  */
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
+# include <sys/stat.h>
+#endif
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
+
+#ifndef _GL_FCNTL_H
+#define _GL_FCNTL_H
+
+#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
+# include <unistd.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+/* Declare overridden functions.  */
+
+#if @GNULIB_FCNTL@
+# if @REPLACE_FCNTL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fcntl
+#   define fcntl rpl_fcntl
+#  endif
+_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
+_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
+# else
+#  if !@HAVE_FCNTL@
+_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
+#  endif
+_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
+# endif
+_GL_CXXALIASWARN (fcntl);
+#elif defined GNULIB_POSIXCHECK
+# undef fcntl
+# if HAVE_RAW_DECL_FCNTL
+_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
+                 "use gnulib module fcntl for portability");
+# endif
+#endif
+
+#if @GNULIB_OPEN@
+# if @REPLACE_OPEN@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef open
+#   define open rpl_open
+#  endif
+_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+                             _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+# else
+_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
+# endif
+/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
+   default argument.  _GL_CXXALIASWARN does not work in this case.  */
+# if !defined __hpux
+_GL_CXXALIASWARN (open);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef open
+/* Assume open is always declared.  */
+_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
+                 "use gnulib module open for portability");
+#endif
+
+#if @GNULIB_OPENAT@
+# if @REPLACE_OPENAT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef openat
+#   define openat rpl_openat
+#  endif
+_GL_FUNCDECL_RPL (openat, int,
+                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (openat, int,
+                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
+# else
+#  if !@HAVE_OPENAT@
+_GL_FUNCDECL_SYS (openat, int,
+                  (int fd, char const *file, int flags, /* mode_t mode */ ...)
+                  _GL_ARG_NONNULL ((2)));
+#  endif
+_GL_CXXALIAS_SYS (openat, int,
+                  (int fd, char const *file, int flags, /* mode_t mode */ ...));
+# endif
+_GL_CXXALIASWARN (openat);
+#elif defined GNULIB_POSIXCHECK
+# undef openat
+# if HAVE_RAW_DECL_OPENAT
+_GL_WARN_ON_USE (openat, "openat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
+#endif
+
+
+/* Fix up the FD_* macros, only known to be missing on mingw.  */
+
+#ifndef FD_CLOEXEC
+# define FD_CLOEXEC 1
+#endif
+
+/* Fix up the supported F_* macros.  Intentionally leave other F_*
+   macros undefined.  Only known to be missing on mingw.  */
+
+#ifndef F_DUPFD_CLOEXEC
+# define F_DUPFD_CLOEXEC 0x40000000
+/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise.  */
+# define GNULIB_defined_F_DUPFD_CLOEXEC 1
+#else
+# define GNULIB_defined_F_DUPFD_CLOEXEC 0
+#endif
+
+#ifndef F_DUPFD
+# define F_DUPFD 1
+#endif
+
+#ifndef F_GETFD
+# define F_GETFD 2
+#endif
+
+/* Fix up the O_* macros.  */
+
+#if !defined O_DIRECT && defined O_DIRECTIO
+/* Tru64 spells it `O_DIRECTIO'.  */
+# define O_DIRECT O_DIRECTIO
+#endif
+
+#if !defined O_CLOEXEC && defined O_NOINHERIT
+/* Mingw spells it `O_NOINHERIT'.  Intentionally leave it
+   undefined if not available.  */
+# define O_CLOEXEC O_NOINHERIT
+#endif
+
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
+#ifndef O_DIRECTORY
+# define O_DIRECTORY 0
+#endif
+
+#ifndef O_DSYNC
+# define O_DSYNC 0
+#endif
+
+#ifndef O_EXEC
+# define O_EXEC O_RDONLY /* This is often close enough in older systems.  */
+#endif
+
+#ifndef O_NDELAY
+# define O_NDELAY 0
+#endif
+
+#ifndef O_NOATIME
+# define O_NOATIME 0
+#endif
+
+#ifndef O_NONBLOCK
+# define O_NONBLOCK O_NDELAY
+#endif
+
+#ifndef O_NOCTTY
+# define O_NOCTTY 0
+#endif
+
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
+#ifndef O_NOLINKS
+# define O_NOLINKS 0
+#endif
+
+#ifndef O_RSYNC
+# define O_RSYNC 0
+#endif
+
+#ifndef O_SEARCH
+# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
+#endif
+
+#ifndef O_SYNC
+# define O_SYNC 0
+#endif
+
+#ifndef O_TTY_INIT
+# define O_TTY_INIT 0
+#endif
+
+/* For systems that distinguish between text and binary I/O.
+   O_BINARY is usually declared in fcntl.h  */
+#if !defined O_BINARY && defined _O_BINARY
+  /* For MSC-compatible compilers.  */
+# define O_BINARY _O_BINARY
+# define O_TEXT _O_TEXT
+#endif
+
+#if defined __BEOS__ || defined __HAIKU__
+  /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
+# undef O_BINARY
+# undef O_TEXT
+#endif
+
+#ifndef O_BINARY
+# define O_BINARY 0
+# define O_TEXT 0
+#endif
+
+/* Fix up the AT_* macros.  */
+
+/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
+   value exceeds INT_MAX, so its use as an int doesn't conform to the
+   C standard, and GCC and Sun C complain in some cases.  If the bug
+   is present, undef AT_FDCWD here, so it can be redefined below.  */
+#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
+# undef AT_FDCWD
+#endif
+
+/* Use the same bit pattern as Solaris 9, but with the proper
+   signedness.  The bit pattern is important, in case this actually is
+   Solaris with the above workaround.  */
+#ifndef AT_FDCWD
+# define AT_FDCWD (-3041965)
+#endif
+
+/* Use the same values as Solaris 9.  This shouldn't matter, but
+   there's no real reason to differ.  */
+#ifndef AT_SYMLINK_NOFOLLOW
+# define AT_SYMLINK_NOFOLLOW 4096
+#endif
+
+#ifndef AT_REMOVEDIR
+# define AT_REMOVEDIR 1
+#endif
+
+/* Solaris 9 lacks these two, so just pick unique values.  */
+#ifndef AT_SYMLINK_FOLLOW
+# define AT_SYMLINK_FOLLOW 2
+#endif
+
+#ifndef AT_EACCESS
+# define AT_EACCESS 4
+#endif
+
+
+#endif /* _GL_FCNTL_H */
+#endif /* _GL_FCNTL_H */
+#endif
diff --git a/gnulib/tests/getpagesize.c b/gnulib/tests/getpagesize.c
new file mode 100644 (file)
index 0000000..d7c1ba8
--- /dev/null
@@ -0,0 +1,39 @@
+/* getpagesize emulation for systems where it cannot be done in a C macro.
+
+   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/>.  */
+
+/* Written by Bruno Haible and Martin Lambers.  */
+
+#include <config.h>
+
+/* Specification. */
+#include <unistd.h>
+
+/* This implementation is only for native Win32 systems.  */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+int
+getpagesize (void)
+{
+  SYSTEM_INFO system_info;
+  GetSystemInfo (&system_info);
+  return system_info.dwPageSize;
+}
+
+#endif
diff --git a/gnulib/tests/glthread/lock.c b/gnulib/tests/glthread/lock.c
new file mode 100644 (file)
index 0000000..64dbd3f
--- /dev/null
@@ -0,0 +1,1058 @@
+/* Locking in multithreaded situations.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+   gthr-win32.h.  */
+
+#include <config.h>
+
+#include "glthread/lock.h"
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+# if HAVE_PTHREAD_RWLOCK
+
+#  if !defined PTHREAD_RWLOCK_INITIALIZER
+
+int
+glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_rwlock_init (&lock->rwlock, NULL);
+  if (err != 0)
+    return err;
+  lock->initialized = 1;
+  return 0;
+}
+
+int
+glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
+{
+  if (!lock->initialized)
+    {
+      int err;
+
+      err = pthread_mutex_lock (&lock->guard);
+      if (err != 0)
+        return err;
+      if (!lock->initialized)
+        {
+          err = glthread_rwlock_init_multithreaded (lock);
+          if (err != 0)
+            {
+              pthread_mutex_unlock (&lock->guard);
+              return err;
+            }
+        }
+      err = pthread_mutex_unlock (&lock->guard);
+      if (err != 0)
+        return err;
+    }
+  return pthread_rwlock_rdlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
+{
+  if (!lock->initialized)
+    {
+      int err;
+
+      err = pthread_mutex_lock (&lock->guard);
+      if (err != 0)
+        return err;
+      if (!lock->initialized)
+        {
+          err = glthread_rwlock_init_multithreaded (lock);
+          if (err != 0)
+            {
+              pthread_mutex_unlock (&lock->guard);
+              return err;
+            }
+        }
+      err = pthread_mutex_unlock (&lock->guard);
+      if (err != 0)
+        return err;
+    }
+  return pthread_rwlock_wrlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
+{
+  if (!lock->initialized)
+    return EINVAL;
+  return pthread_rwlock_unlock (&lock->rwlock);
+}
+
+int
+glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  if (!lock->initialized)
+    return EINVAL;
+  err = pthread_rwlock_destroy (&lock->rwlock);
+  if (err != 0)
+    return err;
+  lock->initialized = 0;
+  return 0;
+}
+
+#  endif
+
+# else
+
+int
+glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_init (&lock->lock, NULL);
+  if (err != 0)
+    return err;
+  err = pthread_cond_init (&lock->waiting_readers, NULL);
+  if (err != 0)
+    return err;
+  err = pthread_cond_init (&lock->waiting_writers, NULL);
+  if (err != 0)
+    return err;
+  lock->waiting_writers_count = 0;
+  lock->runcount = 0;
+  return 0;
+}
+
+int
+glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_lock (&lock->lock);
+  if (err != 0)
+    return err;
+  /* Test whether only readers are currently running, and whether the runcount
+     field will not overflow.  */
+  /* POSIX says: "It is implementation-defined whether the calling thread
+     acquires the lock when a writer does not hold the lock and there are
+     writers blocked on the lock."  Let's say, no: give the writers a higher
+     priority.  */
+  while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
+    {
+      /* This thread has to wait for a while.  Enqueue it among the
+         waiting_readers.  */
+      err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
+      if (err != 0)
+        {
+          pthread_mutex_unlock (&lock->lock);
+          return err;
+        }
+    }
+  lock->runcount++;
+  return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_lock (&lock->lock);
+  if (err != 0)
+    return err;
+  /* Test whether no readers or writers are currently running.  */
+  while (!(lock->runcount == 0))
+    {
+      /* This thread has to wait for a while.  Enqueue it among the
+         waiting_writers.  */
+      lock->waiting_writers_count++;
+      err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
+      if (err != 0)
+        {
+          lock->waiting_writers_count--;
+          pthread_mutex_unlock (&lock->lock);
+          return err;
+        }
+      lock->waiting_writers_count--;
+    }
+  lock->runcount--; /* runcount becomes -1 */
+  return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_lock (&lock->lock);
+  if (err != 0)
+    return err;
+  if (lock->runcount < 0)
+    {
+      /* Drop a writer lock.  */
+      if (!(lock->runcount == -1))
+        {
+          pthread_mutex_unlock (&lock->lock);
+          return EINVAL;
+        }
+      lock->runcount = 0;
+    }
+  else
+    {
+      /* Drop a reader lock.  */
+      if (!(lock->runcount > 0))
+        {
+          pthread_mutex_unlock (&lock->lock);
+          return EINVAL;
+        }
+      lock->runcount--;
+    }
+  if (lock->runcount == 0)
+    {
+      /* POSIX recommends that "write locks shall take precedence over read
+         locks", to avoid "writer starvation".  */
+      if (lock->waiting_writers_count > 0)
+        {
+          /* Wake up one of the waiting writers.  */
+          err = pthread_cond_signal (&lock->waiting_writers);
+          if (err != 0)
+            {
+              pthread_mutex_unlock (&lock->lock);
+              return err;
+            }
+        }
+      else
+        {
+          /* Wake up all waiting readers.  */
+          err = pthread_cond_broadcast (&lock->waiting_readers);
+          if (err != 0)
+            {
+              pthread_mutex_unlock (&lock->lock);
+              return err;
+            }
+        }
+    }
+  return pthread_mutex_unlock (&lock->lock);
+}
+
+int
+glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_destroy (&lock->lock);
+  if (err != 0)
+    return err;
+  err = pthread_cond_destroy (&lock->waiting_readers);
+  if (err != 0)
+    return err;
+  err = pthread_cond_destroy (&lock->waiting_writers);
+  if (err != 0)
+    return err;
+  return 0;
+}
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+# if HAVE_PTHREAD_MUTEX_RECURSIVE
+
+#  if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+  pthread_mutexattr_t attributes;
+  int err;
+
+  err = pthread_mutexattr_init (&attributes);
+  if (err != 0)
+    return err;
+  err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
+  if (err != 0)
+    {
+      pthread_mutexattr_destroy (&attributes);
+      return err;
+    }
+  err = pthread_mutex_init (lock, &attributes);
+  if (err != 0)
+    {
+      pthread_mutexattr_destroy (&attributes);
+      return err;
+    }
+  err = pthread_mutexattr_destroy (&attributes);
+  if (err != 0)
+    return err;
+  return 0;
+}
+
+#  else
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+  pthread_mutexattr_t attributes;
+  int err;
+
+  err = pthread_mutexattr_init (&attributes);
+  if (err != 0)
+    return err;
+  err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
+  if (err != 0)
+    {
+      pthread_mutexattr_destroy (&attributes);
+      return err;
+    }
+  err = pthread_mutex_init (&lock->recmutex, &attributes);
+  if (err != 0)
+    {
+      pthread_mutexattr_destroy (&attributes);
+      return err;
+    }
+  err = pthread_mutexattr_destroy (&attributes);
+  if (err != 0)
+    return err;
+  lock->initialized = 1;
+  return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (!lock->initialized)
+    {
+      int err;
+
+      err = pthread_mutex_lock (&lock->guard);
+      if (err != 0)
+        return err;
+      if (!lock->initialized)
+        {
+          err = glthread_recursive_lock_init_multithreaded (lock);
+          if (err != 0)
+            {
+              pthread_mutex_unlock (&lock->guard);
+              return err;
+            }
+        }
+      err = pthread_mutex_unlock (&lock->guard);
+      if (err != 0)
+        return err;
+    }
+  return pthread_mutex_lock (&lock->recmutex);
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (!lock->initialized)
+    return EINVAL;
+  return pthread_mutex_unlock (&lock->recmutex);
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+  int err;
+
+  if (!lock->initialized)
+    return EINVAL;
+  err = pthread_mutex_destroy (&lock->recmutex);
+  if (err != 0)
+    return err;
+  lock->initialized = 0;
+  return 0;
+}
+
+#  endif
+
+# else
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+  int err;
+
+  err = pthread_mutex_init (&lock->mutex, NULL);
+  if (err != 0)
+    return err;
+  lock->owner = (pthread_t) 0;
+  lock->depth = 0;
+  return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+  pthread_t self = pthread_self ();
+  if (lock->owner != self)
+    {
+      int err;
+
+      err = pthread_mutex_lock (&lock->mutex);
+      if (err != 0)
+        return err;
+      lock->owner = self;
+    }
+  if (++(lock->depth) == 0) /* wraparound? */
+    {
+      lock->depth--;
+      return EAGAIN;
+    }
+  return 0;
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != pthread_self ())
+    return EPERM;
+  if (lock->depth == 0)
+    return EINVAL;
+  if (--(lock->depth) == 0)
+    {
+      lock->owner = (pthread_t) 0;
+      return pthread_mutex_unlock (&lock->mutex);
+    }
+  else
+    return 0;
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != (pthread_t) 0)
+    return EBUSY;
+  return pthread_mutex_destroy (&lock->mutex);
+}
+
+# endif
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
+
+int
+glthread_once_singlethreaded (pthread_once_t *once_control)
+{
+  /* We don't know whether pthread_once_t is an integer type, a floating-point
+     type, a pointer type, or a structure type.  */
+  char *firstbyte = (char *)once_control;
+  if (*firstbyte == *(const char *)&fresh_once)
+    {
+      /* First time use of once_control.  Invert the first byte.  */
+      *firstbyte = ~ *(const char *)&fresh_once;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library.  */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+static void
+glthread_once_call (void *arg)
+{
+  void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
+  void (*initfunction) (void) = *gl_once_temp_addr;
+  initfunction ();
+}
+
+int
+glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
+{
+  void (*temp) (void) = initfunction;
+  return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
+}
+
+int
+glthread_once_singlethreaded (pth_once_t *once_control)
+{
+  /* We know that pth_once_t is an integer type.  */
+  if (*once_control == PTH_ONCE_INIT)
+    {
+      /* First time use of once_control.  Invert the marker.  */
+      *once_control = ~ PTH_ONCE_INIT;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library.  */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+int
+glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
+{
+  int err;
+
+  err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
+  if (err != 0)
+    return err;
+  lock->owner = (thread_t) 0;
+  lock->depth = 0;
+  return 0;
+}
+
+int
+glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
+{
+  thread_t self = thr_self ();
+  if (lock->owner != self)
+    {
+      int err;
+
+      err = mutex_lock (&lock->mutex);
+      if (err != 0)
+        return err;
+      lock->owner = self;
+    }
+  if (++(lock->depth) == 0) /* wraparound? */
+    {
+      lock->depth--;
+      return EAGAIN;
+    }
+  return 0;
+}
+
+int
+glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != thr_self ())
+    return EPERM;
+  if (lock->depth == 0)
+    return EINVAL;
+  if (--(lock->depth) == 0)
+    {
+      lock->owner = (thread_t) 0;
+      return mutex_unlock (&lock->mutex);
+    }
+  else
+    return 0;
+}
+
+int
+glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != (thread_t) 0)
+    return EBUSY;
+  return mutex_destroy (&lock->mutex);
+}
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+int
+glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
+{
+  if (!once_control->inited)
+    {
+      int err;
+
+      /* Use the mutex to guarantee that if another thread is already calling
+         the initfunction, this thread waits until it's finished.  */
+      err = mutex_lock (&once_control->mutex);
+      if (err != 0)
+        return err;
+      if (!once_control->inited)
+        {
+          once_control->inited = 1;
+          initfunction ();
+        }
+      return mutex_unlock (&once_control->mutex);
+    }
+  else
+    return 0;
+}
+
+int
+glthread_once_singlethreaded (gl_once_t *once_control)
+{
+  /* We know that gl_once_t contains an integer type.  */
+  if (!once_control->inited)
+    {
+      /* First time use of once_control.  Invert the marker.  */
+      once_control->inited = ~ 0;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WIN32_THREADS
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+void
+glthread_lock_init_func (gl_lock_t *lock)
+{
+  InitializeCriticalSection (&lock->lock);
+  lock->guard.done = 1;
+}
+
+int
+glthread_lock_lock_func (gl_lock_t *lock)
+{
+  if (!lock->guard.done)
+    {
+      if (InterlockedIncrement (&lock->guard.started) == 0)
+        /* This thread is the first one to need this lock.  Initialize it.  */
+        glthread_lock_init (lock);
+      else
+        /* Yield the CPU while waiting for another thread to finish
+           initializing this lock.  */
+        while (!lock->guard.done)
+          Sleep (0);
+    }
+  EnterCriticalSection (&lock->lock);
+  return 0;
+}
+
+int
+glthread_lock_unlock_func (gl_lock_t *lock)
+{
+  if (!lock->guard.done)
+    return EINVAL;
+  LeaveCriticalSection (&lock->lock);
+  return 0;
+}
+
+int
+glthread_lock_destroy_func (gl_lock_t *lock)
+{
+  if (!lock->guard.done)
+    return EINVAL;
+  DeleteCriticalSection (&lock->lock);
+  lock->guard.done = 0;
+  return 0;
+}
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* In this file, the waitqueues are implemented as circular arrays.  */
+#define gl_waitqueue_t gl_carray_waitqueue_t
+
+static inline void
+gl_waitqueue_init (gl_waitqueue_t *wq)
+{
+  wq->array = NULL;
+  wq->count = 0;
+  wq->alloc = 0;
+  wq->offset = 0;
+}
+
+/* Enqueues the current thread, represented by an event, in a wait queue.
+   Returns INVALID_HANDLE_VALUE if an allocation failure occurs.  */
+static HANDLE
+gl_waitqueue_add (gl_waitqueue_t *wq)
+{
+  HANDLE event;
+  unsigned int index;
+
+  if (wq->count == wq->alloc)
+    {
+      unsigned int new_alloc = 2 * wq->alloc + 1;
+      HANDLE *new_array =
+        (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
+      if (new_array == NULL)
+        /* No more memory.  */
+        return INVALID_HANDLE_VALUE;
+      /* Now is a good opportunity to rotate the array so that its contents
+         starts at offset 0.  */
+      if (wq->offset > 0)
+        {
+          unsigned int old_count = wq->count;
+          unsigned int old_alloc = wq->alloc;
+          unsigned int old_offset = wq->offset;
+          unsigned int i;
+          if (old_offset + old_count > old_alloc)
+            {
+              unsigned int limit = old_offset + old_count - old_alloc;
+              for (i = 0; i < limit; i++)
+                new_array[old_alloc + i] = new_array[i];
+            }
+          for (i = 0; i < old_count; i++)
+            new_array[i] = new_array[old_offset + i];
+          wq->offset = 0;
+        }
+      wq->array = new_array;
+      wq->alloc = new_alloc;
+    }
+  /* Whether the created event is a manual-reset one or an auto-reset one,
+     does not matter, since we will wait on it only once.  */
+  event = CreateEvent (NULL, TRUE, FALSE, NULL);
+  if (event == INVALID_HANDLE_VALUE)
+    /* No way to allocate an event.  */
+    return INVALID_HANDLE_VALUE;
+  index = wq->offset + wq->count;
+  if (index >= wq->alloc)
+    index -= wq->alloc;
+  wq->array[index] = event;
+  wq->count++;
+  return event;
+}
+
+/* Notifies the first thread from a wait queue and dequeues it.  */
+static inline void
+gl_waitqueue_notify_first (gl_waitqueue_t *wq)
+{
+  SetEvent (wq->array[wq->offset + 0]);
+  wq->offset++;
+  wq->count--;
+  if (wq->count == 0 || wq->offset == wq->alloc)
+    wq->offset = 0;
+}
+
+/* Notifies all threads from a wait queue and dequeues them all.  */
+static inline void
+gl_waitqueue_notify_all (gl_waitqueue_t *wq)
+{
+  unsigned int i;
+
+  for (i = 0; i < wq->count; i++)
+    {
+      unsigned int index = wq->offset + i;
+      if (index >= wq->alloc)
+        index -= wq->alloc;
+      SetEvent (wq->array[index]);
+    }
+  wq->count = 0;
+  wq->offset = 0;
+}
+
+void
+glthread_rwlock_init_func (gl_rwlock_t *lock)
+{
+  InitializeCriticalSection (&lock->lock);
+  gl_waitqueue_init (&lock->waiting_readers);
+  gl_waitqueue_init (&lock->waiting_writers);
+  lock->runcount = 0;
+  lock->guard.done = 1;
+}
+
+int
+glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
+{
+  if (!lock->guard.done)
+    {
+      if (InterlockedIncrement (&lock->guard.started) == 0)
+        /* This thread is the first one to need this lock.  Initialize it.  */
+        glthread_rwlock_init (lock);
+      else
+        /* Yield the CPU while waiting for another thread to finish
+           initializing this lock.  */
+        while (!lock->guard.done)
+          Sleep (0);
+    }
+  EnterCriticalSection (&lock->lock);
+  /* Test whether only readers are currently running, and whether the runcount
+     field will not overflow.  */
+  if (!(lock->runcount + 1 > 0))
+    {
+      /* This thread has to wait for a while.  Enqueue it among the
+         waiting_readers.  */
+      HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
+      if (event != INVALID_HANDLE_VALUE)
+        {
+          DWORD result;
+          LeaveCriticalSection (&lock->lock);
+          /* Wait until another thread signals this event.  */
+          result = WaitForSingleObject (event, INFINITE);
+          if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
+            abort ();
+          CloseHandle (event);
+          /* The thread which signalled the event already did the bookkeeping:
+             removed us from the waiting_readers, incremented lock->runcount.  */
+          if (!(lock->runcount > 0))
+            abort ();
+          return 0;
+        }
+      else
+        {
+          /* Allocation failure.  Weird.  */
+          do
+            {
+              LeaveCriticalSection (&lock->lock);
+              Sleep (1);
+              EnterCriticalSection (&lock->lock);
+            }
+          while (!(lock->runcount + 1 > 0));
+        }
+    }
+  lock->runcount++;
+  LeaveCriticalSection (&lock->lock);
+  return 0;
+}
+
+int
+glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
+{
+  if (!lock->guard.done)
+    {
+      if (InterlockedIncrement (&lock->guard.started) == 0)
+        /* This thread is the first one to need this lock.  Initialize it.  */
+        glthread_rwlock_init (lock);
+      else
+        /* Yield the CPU while waiting for another thread to finish
+           initializing this lock.  */
+        while (!lock->guard.done)
+          Sleep (0);
+    }
+  EnterCriticalSection (&lock->lock);
+  /* Test whether no readers or writers are currently running.  */
+  if (!(lock->runcount == 0))
+    {
+      /* This thread has to wait for a while.  Enqueue it among the
+         waiting_writers.  */
+      HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
+      if (event != INVALID_HANDLE_VALUE)
+        {
+          DWORD result;
+          LeaveCriticalSection (&lock->lock);
+          /* Wait until another thread signals this event.  */
+          result = WaitForSingleObject (event, INFINITE);
+          if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
+            abort ();
+          CloseHandle (event);
+          /* The thread which signalled the event already did the bookkeeping:
+             removed us from the waiting_writers, set lock->runcount = -1.  */
+          if (!(lock->runcount == -1))
+            abort ();
+          return 0;
+        }
+      else
+        {
+          /* Allocation failure.  Weird.  */
+          do
+            {
+              LeaveCriticalSection (&lock->lock);
+              Sleep (1);
+              EnterCriticalSection (&lock->lock);
+            }
+          while (!(lock->runcount == 0));
+        }
+    }
+  lock->runcount--; /* runcount becomes -1 */
+  LeaveCriticalSection (&lock->lock);
+  return 0;
+}
+
+int
+glthread_rwlock_unlock_func (gl_rwlock_t *lock)
+{
+  if (!lock->guard.done)
+    return EINVAL;
+  EnterCriticalSection (&lock->lock);
+  if (lock->runcount < 0)
+    {
+      /* Drop a writer lock.  */
+      if (!(lock->runcount == -1))
+        abort ();
+      lock->runcount = 0;
+    }
+  else
+    {
+      /* Drop a reader lock.  */
+      if (!(lock->runcount > 0))
+        {
+          LeaveCriticalSection (&lock->lock);
+          return EPERM;
+        }
+      lock->runcount--;
+    }
+  if (lock->runcount == 0)
+    {
+      /* POSIX recommends that "write locks shall take precedence over read
+         locks", to avoid "writer starvation".  */
+      if (lock->waiting_writers.count > 0)
+        {
+          /* Wake up one of the waiting writers.  */
+          lock->runcount--;
+          gl_waitqueue_notify_first (&lock->waiting_writers);
+        }
+      else
+        {
+          /* Wake up all waiting readers.  */
+          lock->runcount += lock->waiting_readers.count;
+          gl_waitqueue_notify_all (&lock->waiting_readers);
+        }
+    }
+  LeaveCriticalSection (&lock->lock);
+  return 0;
+}
+
+int
+glthread_rwlock_destroy_func (gl_rwlock_t *lock)
+{
+  if (!lock->guard.done)
+    return EINVAL;
+  if (lock->runcount != 0)
+    return EBUSY;
+  DeleteCriticalSection (&lock->lock);
+  if (lock->waiting_readers.array != NULL)
+    free (lock->waiting_readers.array);
+  if (lock->waiting_writers.array != NULL)
+    free (lock->waiting_writers.array);
+  lock->guard.done = 0;
+  return 0;
+}
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+void
+glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
+{
+  lock->owner = 0;
+  lock->depth = 0;
+  InitializeCriticalSection (&lock->lock);
+  lock->guard.done = 1;
+}
+
+int
+glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
+{
+  if (!lock->guard.done)
+    {
+      if (InterlockedIncrement (&lock->guard.started) == 0)
+        /* This thread is the first one to need this lock.  Initialize it.  */
+        glthread_recursive_lock_init (lock);
+      else
+        /* Yield the CPU while waiting for another thread to finish
+           initializing this lock.  */
+        while (!lock->guard.done)
+          Sleep (0);
+    }
+  {
+    DWORD self = GetCurrentThreadId ();
+    if (lock->owner != self)
+      {
+        EnterCriticalSection (&lock->lock);
+        lock->owner = self;
+      }
+    if (++(lock->depth) == 0) /* wraparound? */
+      {
+        lock->depth--;
+        return EAGAIN;
+      }
+  }
+  return 0;
+}
+
+int
+glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != GetCurrentThreadId ())
+    return EPERM;
+  if (lock->depth == 0)
+    return EINVAL;
+  if (--(lock->depth) == 0)
+    {
+      lock->owner = 0;
+      LeaveCriticalSection (&lock->lock);
+    }
+  return 0;
+}
+
+int
+glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
+{
+  if (lock->owner != 0)
+    return EBUSY;
+  DeleteCriticalSection (&lock->lock);
+  lock->guard.done = 0;
+  return 0;
+}
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+void
+glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
+{
+  if (once_control->inited <= 0)
+    {
+      if (InterlockedIncrement (&once_control->started) == 0)
+        {
+          /* This thread is the first one to come to this once_control.  */
+          InitializeCriticalSection (&once_control->lock);
+          EnterCriticalSection (&once_control->lock);
+          once_control->inited = 0;
+          initfunction ();
+          once_control->inited = 1;
+          LeaveCriticalSection (&once_control->lock);
+        }
+      else
+        {
+          /* Undo last operation.  */
+          InterlockedDecrement (&once_control->started);
+          /* Some other thread has already started the initialization.
+             Yield the CPU while waiting for the other thread to finish
+             initializing and taking the lock.  */
+          while (once_control->inited < 0)
+            Sleep (0);
+          if (once_control->inited <= 0)
+            {
+              /* Take the lock.  This blocks until the other thread has
+                 finished calling the initfunction.  */
+              EnterCriticalSection (&once_control->lock);
+              LeaveCriticalSection (&once_control->lock);
+              if (!(once_control->inited > 0))
+                abort ();
+            }
+        }
+    }
+}
+
+#endif
+
+/* ========================================================================= */
diff --git a/gnulib/tests/glthread/lock.h b/gnulib/tests/glthread/lock.h
new file mode 100644 (file)
index 0000000..6267500
--- /dev/null
@@ -0,0 +1,927 @@
+/* Locking in multithreaded situations.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+   gthr-win32.h.  */
+
+/* This file contains locking primitives for use with a given thread library.
+   It does not contain primitives for creating threads or for other
+   synchronization primitives.
+
+   Normal (non-recursive) locks:
+     Type:                gl_lock_t
+     Declaration:         gl_lock_define(extern, name)
+     Initializer:         gl_lock_define_initialized(, name)
+     Initialization:      gl_lock_init (name);
+     Taking the lock:     gl_lock_lock (name);
+     Releasing the lock:  gl_lock_unlock (name);
+     De-initialization:   gl_lock_destroy (name);
+   Equivalent functions with control of error handling:
+     Initialization:      err = glthread_lock_init (&name);
+     Taking the lock:     err = glthread_lock_lock (&name);
+     Releasing the lock:  err = glthread_lock_unlock (&name);
+     De-initialization:   err = glthread_lock_destroy (&name);
+
+   Read-Write (non-recursive) locks:
+     Type:                gl_rwlock_t
+     Declaration:         gl_rwlock_define(extern, name)
+     Initializer:         gl_rwlock_define_initialized(, name)
+     Initialization:      gl_rwlock_init (name);
+     Taking the lock:     gl_rwlock_rdlock (name);
+                          gl_rwlock_wrlock (name);
+     Releasing the lock:  gl_rwlock_unlock (name);
+     De-initialization:   gl_rwlock_destroy (name);
+   Equivalent functions with control of error handling:
+     Initialization:      err = glthread_rwlock_init (&name);
+     Taking the lock:     err = glthread_rwlock_rdlock (&name);
+                          err = glthread_rwlock_wrlock (&name);
+     Releasing the lock:  err = glthread_rwlock_unlock (&name);
+     De-initialization:   err = glthread_rwlock_destroy (&name);
+
+   Recursive locks:
+     Type:                gl_recursive_lock_t
+     Declaration:         gl_recursive_lock_define(extern, name)
+     Initializer:         gl_recursive_lock_define_initialized(, name)
+     Initialization:      gl_recursive_lock_init (name);
+     Taking the lock:     gl_recursive_lock_lock (name);
+     Releasing the lock:  gl_recursive_lock_unlock (name);
+     De-initialization:   gl_recursive_lock_destroy (name);
+   Equivalent functions with control of error handling:
+     Initialization:      err = glthread_recursive_lock_init (&name);
+     Taking the lock:     err = glthread_recursive_lock_lock (&name);
+     Releasing the lock:  err = glthread_recursive_lock_unlock (&name);
+     De-initialization:   err = glthread_recursive_lock_destroy (&name);
+
+  Once-only execution:
+     Type:                gl_once_t
+     Initializer:         gl_once_define(extern, name)
+     Execution:           gl_once (name, initfunction);
+   Equivalent functions with control of error handling:
+     Execution:           err = glthread_once (&name, initfunction);
+*/
+
+
+#ifndef _LOCK_H
+#define _LOCK_H
+
+#include <errno.h>
+#include <stdlib.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library.  */
+
+# include <pthread.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The pthread_in_use() detection needs to be done at runtime.  */
+#  define pthread_in_use() \
+     glthread_in_use ()
+extern int glthread_in_use (void);
+
+# endif
+
+# if USE_POSIX_THREADS_WEAK
+
+/* Use weak references to the POSIX threads library.  */
+
+/* Weak references avoid dragging in external libraries if the other parts
+   of the program don't use them.  Here we use them, because we don't want
+   every program that uses libintl to depend on libpthread.  This assumes
+   that libpthread would not be loaded after libintl; i.e. if libintl is
+   loaded first, by an executable that does not depend on libpthread, and
+   then a module is dynamically loaded that depends on libpthread, libintl
+   will not be multithread-safe.  */
+
+/* The way to test at runtime whether libpthread is present is to test
+   whether a function pointer's value, such as &pthread_mutex_init, is
+   non-NULL.  However, some versions of GCC have a bug through which, in
+   PIC mode, &foo != NULL always evaluates to true if there is a direct
+   call to foo(...) in the same function.  To avoid this, we test the
+   address of a function in libpthread that we don't use.  */
+
+#  pragma weak pthread_mutex_init
+#  pragma weak pthread_mutex_lock
+#  pragma weak pthread_mutex_unlock
+#  pragma weak pthread_mutex_destroy
+#  pragma weak pthread_rwlock_init
+#  pragma weak pthread_rwlock_rdlock
+#  pragma weak pthread_rwlock_wrlock
+#  pragma weak pthread_rwlock_unlock
+#  pragma weak pthread_rwlock_destroy
+#  pragma weak pthread_once
+#  pragma weak pthread_cond_init
+#  pragma weak pthread_cond_wait
+#  pragma weak pthread_cond_signal
+#  pragma weak pthread_cond_broadcast
+#  pragma weak pthread_cond_destroy
+#  pragma weak pthread_mutexattr_init
+#  pragma weak pthread_mutexattr_settype
+#  pragma weak pthread_mutexattr_destroy
+#  ifndef pthread_self
+#   pragma weak pthread_self
+#  endif
+
+#  if !PTHREAD_IN_USE_DETECTION_HARD
+#   pragma weak pthread_cancel
+#   define pthread_in_use() (pthread_cancel != NULL)
+#  endif
+
+# else
+
+#  if !PTHREAD_IN_USE_DETECTION_HARD
+#   define pthread_in_use() 1
+#  endif
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef pthread_mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS pthread_mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+    PTHREAD_MUTEX_INITIALIZER
+# define glthread_lock_init(LOCK) \
+    (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
+# define glthread_lock_lock(LOCK) \
+    (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
+# define glthread_lock_unlock(LOCK) \
+    (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
+# define glthread_lock_destroy(LOCK) \
+    (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+# if HAVE_PTHREAD_RWLOCK
+
+#  ifdef PTHREAD_RWLOCK_INITIALIZER
+
+typedef pthread_rwlock_t gl_rwlock_t;
+#   define gl_rwlock_define(STORAGECLASS, NAME) \
+      STORAGECLASS pthread_rwlock_t NAME;
+#   define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+      STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
+#   define gl_rwlock_initializer \
+      PTHREAD_RWLOCK_INITIALIZER
+#   define glthread_rwlock_init(LOCK) \
+      (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
+#   define glthread_rwlock_rdlock(LOCK) \
+      (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
+#   define glthread_rwlock_wrlock(LOCK) \
+      (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
+#   define glthread_rwlock_unlock(LOCK) \
+      (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
+#   define glthread_rwlock_destroy(LOCK) \
+      (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
+
+#  else
+
+typedef struct
+        {
+          int initialized;
+          pthread_mutex_t guard;   /* protects the initialization */
+          pthread_rwlock_t rwlock; /* read-write lock */
+        }
+        gl_rwlock_t;
+#   define gl_rwlock_define(STORAGECLASS, NAME) \
+      STORAGECLASS gl_rwlock_t NAME;
+#   define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+      STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+#   define gl_rwlock_initializer \
+      { 0, PTHREAD_MUTEX_INITIALIZER }
+#   define glthread_rwlock_init(LOCK) \
+      (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
+#   define glthread_rwlock_rdlock(LOCK) \
+      (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
+#   define glthread_rwlock_wrlock(LOCK) \
+      (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
+#   define glthread_rwlock_unlock(LOCK) \
+      (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
+#   define glthread_rwlock_destroy(LOCK) \
+      (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
+
+#  endif
+
+# else
+
+typedef struct
+        {
+          pthread_mutex_t lock; /* protects the remaining fields */
+          pthread_cond_t waiting_readers; /* waiting readers */
+          pthread_cond_t waiting_writers; /* waiting writers */
+          unsigned int waiting_writers_count; /* number of waiting writers */
+          int runcount; /* number of readers running, or -1 when a writer runs */
+        }
+        gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+    { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
+# define glthread_rwlock_init(LOCK) \
+    (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+    (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+    (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+    (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+    (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
+
+# endif
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+# if HAVE_PTHREAD_MUTEX_RECURSIVE
+
+#  if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+
+typedef pthread_mutex_t gl_recursive_lock_t;
+#   define gl_recursive_lock_define(STORAGECLASS, NAME) \
+      STORAGECLASS pthread_mutex_t NAME;
+#   define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+      STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
+#   ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#    define gl_recursive_lock_initializer \
+       PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#   else
+#    define gl_recursive_lock_initializer \
+       PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#   endif
+#   define glthread_recursive_lock_init(LOCK) \
+      (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+#   define glthread_recursive_lock_lock(LOCK) \
+      (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
+#   define glthread_recursive_lock_unlock(LOCK) \
+      (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
+#   define glthread_recursive_lock_destroy(LOCK) \
+      (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+
+#  else
+
+typedef struct
+        {
+          pthread_mutex_t recmutex; /* recursive mutex */
+          pthread_mutex_t guard;    /* protects the initialization */
+          int initialized;
+        }
+        gl_recursive_lock_t;
+#   define gl_recursive_lock_define(STORAGECLASS, NAME) \
+      STORAGECLASS gl_recursive_lock_t NAME;
+#   define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+      STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+#   define gl_recursive_lock_initializer \
+      { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
+#   define glthread_recursive_lock_init(LOCK) \
+      (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+#   define glthread_recursive_lock_lock(LOCK) \
+      (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+#   define glthread_recursive_lock_unlock(LOCK) \
+      (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+#   define glthread_recursive_lock_destroy(LOCK) \
+      (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+#  endif
+
+# else
+
+/* Old versions of POSIX threads on Solaris did not have recursive locks.
+   We have to implement them ourselves.  */
+
+typedef struct
+        {
+          pthread_mutex_t mutex;
+          pthread_t owner;
+          unsigned long depth;
+        }
+        gl_recursive_lock_t;
+#  define gl_recursive_lock_define(STORAGECLASS, NAME) \
+     STORAGECLASS gl_recursive_lock_t NAME;
+#  define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+     STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+#  define gl_recursive_lock_initializer \
+     { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
+#  define glthread_recursive_lock_init(LOCK) \
+     (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+#  define glthread_recursive_lock_lock(LOCK) \
+     (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+#  define glthread_recursive_lock_unlock(LOCK) \
+     (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+#  define glthread_recursive_lock_destroy(LOCK) \
+     (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+# endif
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef pthread_once_t gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+    STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+    (pthread_in_use ()                                                         \
+     ? pthread_once (ONCE_CONTROL, INITFUNCTION)                               \
+     : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_singlethreaded (pthread_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library.  */
+
+# include <pth.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_PTH_THREADS_WEAK
+
+/* Use weak references to the GNU Pth threads library.  */
+
+#  pragma weak pth_mutex_init
+#  pragma weak pth_mutex_acquire
+#  pragma weak pth_mutex_release
+#  pragma weak pth_rwlock_init
+#  pragma weak pth_rwlock_acquire
+#  pragma weak pth_rwlock_release
+#  pragma weak pth_once
+
+#  pragma weak pth_cancel
+#  define pth_in_use() (pth_cancel != NULL)
+
+# else
+
+#  define pth_in_use() 1
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef pth_mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS pth_mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+    PTH_MUTEX_INIT
+# define glthread_lock_init(LOCK) \
+    (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
+# define glthread_lock_lock(LOCK) \
+    (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
+# define glthread_lock_unlock(LOCK) \
+    (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
+# define glthread_lock_destroy(LOCK) \
+    ((void)(LOCK), 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+typedef pth_rwlock_t gl_rwlock_t;
+#  define gl_rwlock_define(STORAGECLASS, NAME) \
+     STORAGECLASS pth_rwlock_t NAME;
+#  define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+     STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
+#  define gl_rwlock_initializer \
+     PTH_RWLOCK_INIT
+#  define glthread_rwlock_init(LOCK) \
+     (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
+#  define glthread_rwlock_rdlock(LOCK) \
+     (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
+#  define glthread_rwlock_wrlock(LOCK) \
+     (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
+#  define glthread_rwlock_unlock(LOCK) \
+     (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
+#  define glthread_rwlock_destroy(LOCK) \
+     ((void)(LOCK), 0)
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* In Pth, mutexes are recursive by default.  */
+typedef pth_mutex_t gl_recursive_lock_t;
+#  define gl_recursive_lock_define(STORAGECLASS, NAME) \
+     STORAGECLASS pth_mutex_t NAME;
+#  define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+     STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
+#  define gl_recursive_lock_initializer \
+     PTH_MUTEX_INIT
+#  define glthread_recursive_lock_init(LOCK) \
+     (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
+#  define glthread_recursive_lock_lock(LOCK) \
+     (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
+#  define glthread_recursive_lock_unlock(LOCK) \
+     (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
+#  define glthread_recursive_lock_destroy(LOCK) \
+     ((void)(LOCK), 0)
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef pth_once_t gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+    STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+    (pth_in_use ()                                                             \
+     ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION)                \
+     : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
+extern int glthread_once_singlethreaded (pth_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library.  */
+
+# include <thread.h>
+# include <synch.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_SOLARIS_THREADS_WEAK
+
+/* Use weak references to the old Solaris threads library.  */
+
+#  pragma weak mutex_init
+#  pragma weak mutex_lock
+#  pragma weak mutex_unlock
+#  pragma weak mutex_destroy
+#  pragma weak rwlock_init
+#  pragma weak rw_rdlock
+#  pragma weak rw_wrlock
+#  pragma weak rw_unlock
+#  pragma weak rwlock_destroy
+#  pragma weak thr_self
+
+#  pragma weak thr_suspend
+#  define thread_in_use() (thr_suspend != NULL)
+
+# else
+
+#  define thread_in_use() 1
+
+# endif
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef mutex_t gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS mutex_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS mutex_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+    DEFAULTMUTEX
+# define glthread_lock_init(LOCK) \
+    (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
+# define glthread_lock_lock(LOCK) \
+    (thread_in_use () ? mutex_lock (LOCK) : 0)
+# define glthread_lock_unlock(LOCK) \
+    (thread_in_use () ? mutex_unlock (LOCK) : 0)
+# define glthread_lock_destroy(LOCK) \
+    (thread_in_use () ? mutex_destroy (LOCK) : 0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+typedef rwlock_t gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+    STORAGECLASS rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+    DEFAULTRWLOCK
+# define glthread_rwlock_init(LOCK) \
+    (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
+# define glthread_rwlock_rdlock(LOCK) \
+    (thread_in_use () ? rw_rdlock (LOCK) : 0)
+# define glthread_rwlock_wrlock(LOCK) \
+    (thread_in_use () ? rw_wrlock (LOCK) : 0)
+# define glthread_rwlock_unlock(LOCK) \
+    (thread_in_use () ? rw_unlock (LOCK) : 0)
+# define glthread_rwlock_destroy(LOCK) \
+    (thread_in_use () ? rwlock_destroy (LOCK) : 0)
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* Old Solaris threads did not have recursive locks.
+   We have to implement them ourselves.  */
+
+typedef struct
+        {
+          mutex_t mutex;
+          thread_t owner;
+          unsigned long depth;
+        }
+        gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+    { DEFAULTMUTEX, (thread_t) 0, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+    (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_lock(LOCK) \
+    (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_unlock(LOCK) \
+    (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
+# define glthread_recursive_lock_destroy(LOCK) \
+    (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
+extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef struct
+        {
+          volatile int inited;
+          mutex_t mutex;
+        }
+        gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+    (thread_in_use ()                                                          \
+     ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION)                \
+     : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
+extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
+extern int glthread_once_singlethreaded (gl_once_t *once_control);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WIN32_THREADS
+
+# include <windows.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex,
+   Semaphore types, because
+     - we need only to synchronize inside a single process (address space),
+       not inter-process locking,
+     - we don't need to support trylock operations.  (TryEnterCriticalSection
+       does not work on Windows 95/98/ME.  Packages that need trylock usually
+       define their own mutex type.)  */
+
+/* There is no way to statically initialize a CRITICAL_SECTION.  It needs
+   to be done lazily, once only.  For this we need spinlocks.  */
+
+typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef struct
+        {
+          gl_spinlock_t guard; /* protects the initialization */
+          CRITICAL_SECTION lock;
+        }
+        gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_lock_t NAME;
+# define gl_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
+# define gl_lock_initializer \
+    { { 0, -1 } }
+# define glthread_lock_init(LOCK) \
+    (glthread_lock_init_func (LOCK), 0)
+# define glthread_lock_lock(LOCK) \
+    glthread_lock_lock_func (LOCK)
+# define glthread_lock_unlock(LOCK) \
+    glthread_lock_unlock_func (LOCK)
+# define glthread_lock_destroy(LOCK) \
+    glthread_lock_destroy_func (LOCK)
+extern void glthread_lock_init_func (gl_lock_t *lock);
+extern int glthread_lock_lock_func (gl_lock_t *lock);
+extern int glthread_lock_unlock_func (gl_lock_t *lock);
+extern int glthread_lock_destroy_func (gl_lock_t *lock);
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+/* It is impossible to implement read-write locks using plain locks, without
+   introducing an extra thread dedicated to managing read-write locks.
+   Therefore here we need to use the low-level Event type.  */
+
+typedef struct
+        {
+          HANDLE *array; /* array of waiting threads, each represented by an event */
+          unsigned int count; /* number of waiting threads */
+          unsigned int alloc; /* length of allocated array */
+          unsigned int offset; /* index of first waiting thread in array */
+        }
+        gl_carray_waitqueue_t;
+typedef struct
+        {
+          gl_spinlock_t guard; /* protects the initialization */
+          CRITICAL_SECTION lock; /* protects the remaining fields */
+          gl_carray_waitqueue_t waiting_readers; /* waiting readers */
+          gl_carray_waitqueue_t waiting_writers; /* waiting writers */
+          int runcount; /* number of readers running, or -1 when a writer runs */
+        }
+        gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_rwlock_t NAME;
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
+# define gl_rwlock_initializer \
+    { { 0, -1 } }
+# define glthread_rwlock_init(LOCK) \
+    (glthread_rwlock_init_func (LOCK), 0)
+# define glthread_rwlock_rdlock(LOCK) \
+    glthread_rwlock_rdlock_func (LOCK)
+# define glthread_rwlock_wrlock(LOCK) \
+    glthread_rwlock_wrlock_func (LOCK)
+# define glthread_rwlock_unlock(LOCK) \
+    glthread_rwlock_unlock_func (LOCK)
+# define glthread_rwlock_destroy(LOCK) \
+    glthread_rwlock_destroy_func (LOCK)
+extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
+extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+/* The Win32 documentation says that CRITICAL_SECTION already implements a
+   recursive lock.  But we need not rely on it: It's easy to implement a
+   recursive lock without this assumption.  */
+
+typedef struct
+        {
+          gl_spinlock_t guard; /* protects the initialization */
+          DWORD owner;
+          unsigned long depth;
+          CRITICAL_SECTION lock;
+        }
+        gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_recursive_lock_t NAME;
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
+    STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
+# define gl_recursive_lock_initializer \
+    { { 0, -1 }, 0, 0 }
+# define glthread_recursive_lock_init(LOCK) \
+    (glthread_recursive_lock_init_func (LOCK), 0)
+# define glthread_recursive_lock_lock(LOCK) \
+    glthread_recursive_lock_lock_func (LOCK)
+# define glthread_recursive_lock_unlock(LOCK) \
+    glthread_recursive_lock_unlock_func (LOCK)
+# define glthread_recursive_lock_destroy(LOCK) \
+    glthread_recursive_lock_destroy_func (LOCK)
+extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
+extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef struct
+        {
+          volatile int inited;
+          volatile long started;
+          CRITICAL_SECTION lock;
+        }
+        gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_once_t NAME = { -1, -1 };
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+    (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
+extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
+
+/* Provide dummy implementation if threads are not supported.  */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+typedef int gl_lock_t;
+# define gl_lock_define(STORAGECLASS, NAME)
+# define gl_lock_define_initialized(STORAGECLASS, NAME)
+# define glthread_lock_init(NAME) 0
+# define glthread_lock_lock(NAME) 0
+# define glthread_lock_unlock(NAME) 0
+# define glthread_lock_destroy(NAME) 0
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+typedef int gl_rwlock_t;
+# define gl_rwlock_define(STORAGECLASS, NAME)
+# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
+# define glthread_rwlock_init(NAME) 0
+# define glthread_rwlock_rdlock(NAME) 0
+# define glthread_rwlock_wrlock(NAME) 0
+# define glthread_rwlock_unlock(NAME) 0
+# define glthread_rwlock_destroy(NAME) 0
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+typedef int gl_recursive_lock_t;
+# define gl_recursive_lock_define(STORAGECLASS, NAME)
+# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
+# define glthread_recursive_lock_init(NAME) 0
+# define glthread_recursive_lock_lock(NAME) 0
+# define glthread_recursive_lock_unlock(NAME) 0
+# define glthread_recursive_lock_destroy(NAME) 0
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+typedef int gl_once_t;
+# define gl_once_define(STORAGECLASS, NAME) \
+    STORAGECLASS gl_once_t NAME = 0;
+# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
+    (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
+
+#endif
+
+/* ========================================================================= */
+
+/* Macros with built-in error handling.  */
+
+/* -------------------------- gl_lock_t datatype -------------------------- */
+
+#define gl_lock_init(NAME) \
+   do                                  \
+     {                                 \
+       if (glthread_lock_init (&NAME)) \
+         abort ();                     \
+     }                                 \
+   while (0)
+#define gl_lock_lock(NAME) \
+   do                                  \
+     {                                 \
+       if (glthread_lock_lock (&NAME)) \
+         abort ();                     \
+     }                                 \
+   while (0)
+#define gl_lock_unlock(NAME) \
+   do                                    \
+     {                                   \
+       if (glthread_lock_unlock (&NAME)) \
+         abort ();                       \
+     }                                   \
+   while (0)
+#define gl_lock_destroy(NAME) \
+   do                                     \
+     {                                    \
+       if (glthread_lock_destroy (&NAME)) \
+         abort ();                        \
+     }                                    \
+   while (0)
+
+/* ------------------------- gl_rwlock_t datatype ------------------------- */
+
+#define gl_rwlock_init(NAME) \
+   do                                    \
+     {                                   \
+       if (glthread_rwlock_init (&NAME)) \
+         abort ();                       \
+     }                                   \
+   while (0)
+#define gl_rwlock_rdlock(NAME) \
+   do                                      \
+     {                                     \
+       if (glthread_rwlock_rdlock (&NAME)) \
+         abort ();                         \
+     }                                     \
+   while (0)
+#define gl_rwlock_wrlock(NAME) \
+   do                                      \
+     {                                     \
+       if (glthread_rwlock_wrlock (&NAME)) \
+         abort ();                         \
+     }                                     \
+   while (0)
+#define gl_rwlock_unlock(NAME) \
+   do                                      \
+     {                                     \
+       if (glthread_rwlock_unlock (&NAME)) \
+         abort ();                         \
+     }                                     \
+   while (0)
+#define gl_rwlock_destroy(NAME) \
+   do                                       \
+     {                                      \
+       if (glthread_rwlock_destroy (&NAME)) \
+         abort ();                          \
+     }                                      \
+   while (0)
+
+/* --------------------- gl_recursive_lock_t datatype --------------------- */
+
+#define gl_recursive_lock_init(NAME) \
+   do                                            \
+     {                                           \
+       if (glthread_recursive_lock_init (&NAME)) \
+         abort ();                               \
+     }                                           \
+   while (0)
+#define gl_recursive_lock_lock(NAME) \
+   do                                            \
+     {                                           \
+       if (glthread_recursive_lock_lock (&NAME)) \
+         abort ();                               \
+     }                                           \
+   while (0)
+#define gl_recursive_lock_unlock(NAME) \
+   do                                              \
+     {                                             \
+       if (glthread_recursive_lock_unlock (&NAME)) \
+         abort ();                                 \
+     }                                             \
+   while (0)
+#define gl_recursive_lock_destroy(NAME) \
+   do                                               \
+     {                                              \
+       if (glthread_recursive_lock_destroy (&NAME)) \
+         abort ();                                  \
+     }                                              \
+   while (0)
+
+/* -------------------------- gl_once_t datatype -------------------------- */
+
+#define gl_once(NAME, INITFUNCTION) \
+   do                                           \
+     {                                          \
+       if (glthread_once (&NAME, INITFUNCTION)) \
+         abort ();                              \
+     }                                          \
+   while (0)
+
+/* ========================================================================= */
+
+#endif /* _LOCK_H */
diff --git a/gnulib/tests/glthread/thread.c b/gnulib/tests/glthread/thread.c
new file mode 100644 (file)
index 0000000..bb40092
--- /dev/null
@@ -0,0 +1,218 @@
+/* Creating and controlling threads.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+   gthr-win32.h.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "glthread/thread.h"
+
+#include <stdlib.h>
+#include "glthread/lock.h"
+
+/* ========================================================================= */
+
+#if USE_WIN32_THREADS
+
+#include <process.h>
+
+/* -------------------------- gl_thread_t datatype -------------------------- */
+
+/* The Thread-Local Storage (TLS) key that allows to access each thread's
+   'struct gl_thread_struct *' pointer.  */
+static DWORD self_key = (DWORD)-1;
+
+/* Initializes self_key.  This function must only be called once.  */
+static void
+do_init_self_key (void)
+{
+  self_key = TlsAlloc ();
+  /* If this fails, we're hosed.  */
+  if (self_key == (DWORD)-1)
+    abort ();
+}
+
+/* Initializes self_key.  */
+static void
+init_self_key (void)
+{
+  gl_once_define(static, once)
+  gl_once (once, do_init_self_key);
+}
+
+/* This structure contains information about a thread.
+   It is stored in TLS under key self_key.  */
+struct gl_thread_struct
+{
+  /* Fields for managing the handle.  */
+  HANDLE volatile handle;
+  CRITICAL_SECTION handle_lock;
+  /* Fields for managing the exit value.  */
+  void * volatile result;
+  /* Fields for managing the thread start.  */
+  void * (*func) (void *);
+  void *arg;
+};
+
+/* Return a real HANDLE object for the current thread.  */
+static inline HANDLE
+get_current_thread_handle (void)
+{
+  HANDLE this_handle;
+
+  /* GetCurrentThread() returns a pseudo-handle, i.e. only a symbolic
+     identifier, not a real handle.  */
+  if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
+                        GetCurrentProcess (), &this_handle,
+                        0, FALSE, DUPLICATE_SAME_ACCESS))
+    abort ();
+  return this_handle;
+}
+
+gl_thread_t
+gl_thread_self_func (void)
+{
+  gl_thread_t thread;
+
+  if (self_key == (DWORD)-1)
+    init_self_key ();
+  thread = TlsGetValue (self_key);
+  if (thread == NULL)
+    {
+      /* This happens only in threads that have not been created through
+         glthread_create(), such as the main thread.  */
+      for (;;)
+        {
+          thread =
+            (struct gl_thread_struct *)
+            malloc (sizeof (struct gl_thread_struct));
+          if (thread != NULL)
+            break;
+          /* Memory allocation failed.  There is not much we can do.  Have to
+             busy-loop, waiting for the availability of memory.  */
+          Sleep (1);
+        }
+
+      thread->handle = get_current_thread_handle ();
+      InitializeCriticalSection (&thread->handle_lock);
+      thread->result = NULL; /* just to be deterministic */
+      TlsSetValue (self_key, thread);
+    }
+  return thread;
+}
+
+/* The main function of a freshly creating thread.  It's a wrapper around
+   the FUNC and ARG arguments passed to glthread_create_func.  */
+static unsigned int WINAPI
+wrapper_func (void *varg)
+{
+  struct gl_thread_struct *thread = (struct gl_thread_struct *)varg;
+
+  EnterCriticalSection (&thread->handle_lock);
+  /* Create a new handle for the thread only if the parent thread did not yet
+     fill in the handle.  */
+  if (thread->handle == NULL)
+    thread->handle = get_current_thread_handle ();
+  LeaveCriticalSection (&thread->handle_lock);
+
+  if (self_key == (DWORD)-1)
+    init_self_key ();
+  TlsSetValue (self_key, thread);
+
+  /* Run the thread.  Store the exit value if the thread was not terminated
+     otherwise.  */
+  thread->result = thread->func (thread->arg);
+  return 0;
+}
+
+int
+glthread_create_func (gl_thread_t *threadp, void * (*func) (void *), void *arg)
+{
+  struct gl_thread_struct *thread =
+    (struct gl_thread_struct *) malloc (sizeof (struct gl_thread_struct));
+  if (thread == NULL)
+    return ENOMEM;
+  thread->handle = NULL;
+  InitializeCriticalSection (&thread->handle_lock);
+  thread->result = NULL; /* just to be deterministic */
+  thread->func = func;
+  thread->arg = arg;
+
+  {
+    unsigned int thread_id;
+    HANDLE thread_handle;
+
+    thread_handle = (HANDLE)
+      _beginthreadex (NULL, 100000, wrapper_func, thread, 0, &thread_id);
+      /* calls CreateThread with the same arguments */
+    if (thread_handle == NULL)
+      {
+        DeleteCriticalSection (&thread->handle_lock);
+        free (thread);
+        return EAGAIN;
+      }
+
+    EnterCriticalSection (&thread->handle_lock);
+    if (thread->handle == NULL)
+      thread->handle = thread_handle;
+    else
+      /* thread->handle was already set by the thread itself.  */
+      CloseHandle (thread_handle);
+    LeaveCriticalSection (&thread->handle_lock);
+
+    *threadp = thread;
+    return 0;
+  }
+}
+
+int
+glthread_join_func (gl_thread_t thread, void **retvalp)
+{
+  if (thread == NULL)
+    return EINVAL;
+
+  if (thread == gl_thread_self ())
+    return EDEADLK;
+
+  if (WaitForSingleObject (thread->handle, INFINITE) == WAIT_FAILED)
+    return EINVAL;
+
+  if (retvalp != NULL)
+    *retvalp = thread->result;
+
+  DeleteCriticalSection (&thread->handle_lock);
+  CloseHandle (thread->handle);
+  free (thread);
+
+  return 0;
+}
+
+int
+gl_thread_exit_func (void *retval)
+{
+  gl_thread_t thread = gl_thread_self ();
+  thread->result = retval;
+  _endthreadex (0); /* calls ExitThread (0) */
+  abort ();
+}
+
+#endif
+
+/* ========================================================================= */
diff --git a/gnulib/tests/glthread/thread.h b/gnulib/tests/glthread/thread.h
new file mode 100644 (file)
index 0000000..370f09a
--- /dev/null
@@ -0,0 +1,376 @@
+/* Creating and controlling threads.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.
+   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
+   gthr-win32.h.  */
+
+/* This file contains primitives for creating and controlling threads.
+
+   Thread data type: gl_thread_t.
+
+   Creating a thread:
+       thread = gl_thread_create (func, arg);
+   Or with control of error handling:
+       err = glthread_create (&thread, func, arg);
+       extern int glthread_create (gl_thread_t *result,
+                                   void *(*func) (void *), void *arg);
+
+   Querying and changing the signal mask of a thread (not supported on all
+   platforms):
+       gl_thread_sigmask (how, newmask, oldmask);
+   Or with control of error handling:
+       err = glthread_sigmask (how, newmask, oldmask);
+       extern int glthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask);
+
+   Waiting for termination of another thread:
+       gl_thread_join (thread, &return_value);
+   Or with control of error handling:
+       err = glthread_join (thread, &return_value);
+       extern int glthread_join (gl_thread_t thread, void **return_value_ptr);
+
+   Getting a reference to the current thread:
+       current = gl_thread_self ();
+       extern gl_thread_t gl_thread_self (void);
+
+   Terminating the current thread:
+       gl_thread_exit (return_value);
+       extern void gl_thread_exit (void *return_value) __attribute__ ((noreturn));
+
+   Requesting custom code to be executed at fork() time(not supported on all
+   platforms):
+       gl_thread_atfork (prepare_func, parent_func, child_func);
+   Or with control of error handling:
+       err = glthread_atfork (prepare_func, parent_func, child_func);
+       extern int glthread_atfork (void (*prepare_func) (void),
+                                   void (*parent_func) (void),
+                                   void (*child_func) (void));
+   Note that even on platforms where this is supported, use of fork() and
+   threads together is problematic, see
+     <http://lists.gnu.org/archive/html/bug-gnulib/2008-08/msg00062.html>
+ */
+
+
+#ifndef _GLTHREAD_THREAD_H
+#define _GLTHREAD_THREAD_H
+
+#include <errno.h>
+#include <stdlib.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library.  */
+
+# include <pthread.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The pthread_in_use() detection needs to be done at runtime.  */
+#  define pthread_in_use() \
+     glthread_in_use ()
+extern int glthread_in_use (void);
+
+# endif
+
+# if USE_POSIX_THREADS_WEAK
+
+/* Use weak references to the POSIX threads library.  */
+
+/* Weak references avoid dragging in external libraries if the other parts
+   of the program don't use them.  Here we use them, because we don't want
+   every program that uses libintl to depend on libpthread.  This assumes
+   that libpthread would not be loaded after libintl; i.e. if libintl is
+   loaded first, by an executable that does not depend on libpthread, and
+   then a module is dynamically loaded that depends on libpthread, libintl
+   will not be multithread-safe.  */
+
+/* The way to test at runtime whether libpthread is present is to test
+   whether a function pointer's value, such as &pthread_mutex_init, is
+   non-NULL.  However, some versions of GCC have a bug through which, in
+   PIC mode, &foo != NULL always evaluates to true if there is a direct
+   call to foo(...) in the same function.  To avoid this, we test the
+   address of a function in libpthread that we don't use.  */
+
+#  pragma weak pthread_create
+#  pragma weak pthread_sigmask
+#  pragma weak pthread_join
+#  ifndef pthread_self
+#   pragma weak pthread_self
+#  endif
+#  pragma weak pthread_exit
+#  if HAVE_PTHREAD_ATFORK
+#   pragma weak pthread_atfork
+#  endif
+
+#  if !PTHREAD_IN_USE_DETECTION_HARD
+#   pragma weak pthread_cancel
+#   define pthread_in_use() (pthread_cancel != NULL)
+#  endif
+
+# else
+
+#  if !PTHREAD_IN_USE_DETECTION_HARD
+#   define pthread_in_use() 1
+#  endif
+
+# endif
+
+/* -------------------------- gl_thread_t datatype -------------------------- */
+
+/* This choice of gl_thread_t assumes that
+     pthread_equal (a, b)  is equivalent to  ((a) == (b)).
+   This is the case on all platforms in use in 2008.  */
+typedef pthread_t gl_thread_t;
+# define glthread_create(THREADP, FUNC, ARG) \
+    (pthread_in_use () ? pthread_create (THREADP, NULL, FUNC, ARG) : ENOSYS)
+# define glthread_sigmask(HOW, SET, OSET) \
+    (pthread_in_use () ? pthread_sigmask (HOW, SET, OSET) : 0)
+# define glthread_join(THREAD, RETVALP) \
+    (pthread_in_use () ? pthread_join (THREAD, RETVALP) : 0)
+# define gl_thread_self() \
+    (pthread_in_use () ? (void *) pthread_self () : NULL)
+# define gl_thread_exit(RETVAL) \
+    (pthread_in_use () ? pthread_exit (RETVAL) : 0)
+
+# if HAVE_PTHREAD_ATFORK
+#  define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) \
+     (pthread_in_use () ? pthread_atfork (PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) : 0)
+# else
+#  define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library.  */
+
+# include <pth.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_PTH_THREADS_WEAK
+
+/* Use weak references to the GNU Pth threads library.  */
+
+#  pragma weak pth_spawn
+#  pragma weak pth_sigmask
+#  pragma weak pth_join
+#  pragma weak pth_self
+#  pragma weak pth_exit
+
+#  pragma weak pth_cancel
+#  define pth_in_use() (pth_cancel != NULL)
+
+# else
+
+#  define pth_in_use() 1
+
+# endif
+/* -------------------------- gl_thread_t datatype -------------------------- */
+
+typedef pth_t gl_thread_t;
+# define glthread_create(THREADP, FUNC, ARG) \
+    (pth_in_use () ? ((*(THREADP) = pth_spawn (NULL, FUNC, ARG)) ? 0 : errno) : 0)
+# define glthread_sigmask(HOW, SET, OSET) \
+    (pth_in_use () && !pth_sigmask (HOW, SET, OSET) ? errno : 0)
+# define glthread_join(THREAD, RETVALP) \
+    (pth_in_use () && !pth_join (THREAD, RETVALP) ? errno : 0)
+# define gl_thread_self() \
+    (pth_in_use () ? (void *) pth_self () : 0)
+# define gl_thread_exit(RETVAL) \
+    (pth_in_use () ? pth_exit (RETVAL) : 0)
+# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library.  */
+
+# include <thread.h>
+# include <synch.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if USE_SOLARIS_THREADS_WEAK
+
+/* Use weak references to the old Solaris threads library.  */
+
+#  pragma weak thr_create
+#  pragma weak thr_join
+#  pragma weak thr_self
+#  pragma weak thr_exit
+
+#  pragma weak thr_suspend
+#  define thread_in_use() (thr_suspend != NULL)
+
+# else
+
+#  define thread_in_use() 1
+
+# endif
+
+/* -------------------------- gl_thread_t datatype -------------------------- */
+
+typedef thread_t gl_thread_t;
+# define glthread_create(THREADP, FUNC, ARG) \
+    (thread_in_use () ? thr_create (NULL, 0, FUNC, ARG, 0, THREADP) : 0)
+# define glthread_sigmask(HOW, SET, OSET) \
+    (thread_in_use () ? sigprocmask (HOW, SET, OSET) : 0)
+# define glthread_join(THREAD, RETVALP) \
+    (thread_in_use () ? thr_join (THREAD, NULL, RETVALP) : 0)
+# define gl_thread_self() \
+    (thread_in_use () ? (void *) thr_self () : 0)
+# define gl_thread_exit(RETVAL) \
+    (thread_in_use () ? thr_exit (RETVAL) : 0)
+# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WIN32_THREADS
+
+# include <windows.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* -------------------------- gl_thread_t datatype -------------------------- */
+
+/* The gl_thread_t is a pointer to a structure in memory.
+   Why not the thread handle?  If it were the thread handle, it would be hard
+   to implement gl_thread_self() (since GetCurrentThread () returns a pseudo-
+   handle, DuplicateHandle (GetCurrentThread ()) returns a handle that must be
+   closed afterwards, and there is no function for quickly retrieving a thread
+   handle from its id).
+   Why not the thread id?  I tried it.  It did not work: Sometimes ids appeared
+   that did not belong to running threads, and glthread_join failed with ESRCH.
+ */
+typedef struct gl_thread_struct *gl_thread_t;
+# define glthread_create(THREADP, FUNC, ARG) \
+    glthread_create_func (THREADP, FUNC, ARG)
+# define glthread_sigmask(HOW, SET, OSET) \
+    /* unsupported */ 0
+# define glthread_join(THREAD, RETVALP) \
+    glthread_join_func (THREAD, RETVALP)
+# define gl_thread_self() \
+    gl_thread_self_func ()
+# define gl_thread_exit(RETVAL) \
+    gl_thread_exit_func (RETVAL)
+# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
+extern int glthread_create_func (gl_thread_t *threadp, void * (*func) (void *), void *arg);
+extern int glthread_join_func (gl_thread_t thread, void **retvalp);
+extern gl_thread_t gl_thread_self_func (void);
+extern int gl_thread_exit_func (void *retval);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
+
+/* Provide dummy implementation if threads are not supported.  */
+
+typedef int gl_thread_t;
+# define glthread_create(THREADP, FUNC, ARG) ENOSYS
+# define glthread_sigmask(HOW, SET, OSET) 0
+# define glthread_join(THREAD, RETVALP) 0
+# define gl_thread_self() NULL
+# define gl_thread_exit(RETVAL) 0
+# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
+
+#endif
+
+/* ========================================================================= */
+
+/* Macros with built-in error handling.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline gl_thread_t
+gl_thread_create (void *(*func) (void *arg), void *arg)
+{
+  gl_thread_t thread;
+  int ret;
+
+  ret = glthread_create (&thread, func, arg);
+  if (ret != 0)
+    abort ();
+  return thread;
+}
+#define gl_thread_sigmask(HOW, SET, OSET)     \
+   do                                         \
+     {                                        \
+       if (glthread_sigmask (HOW, SET, OSET)) \
+         abort ();                            \
+     }                                        \
+   while (0)
+#define gl_thread_join(THREAD, RETVAL)     \
+   do                                      \
+     {                                     \
+       if (glthread_join (THREAD, RETVAL)) \
+         abort ();                         \
+     }                                     \
+   while (0)
+#define gl_thread_atfork(PREPARE, PARENT, CHILD)     \
+   do                                                \
+     {                                               \
+       if (glthread_atfork (PREPARE, PARENT, CHILD)) \
+         abort ();                                   \
+     }                                               \
+   while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GLTHREAD_THREAD_H */
diff --git a/gnulib/tests/glthread/threadlib.c b/gnulib/tests/glthread/threadlib.c
new file mode 100644 (file)
index 0000000..646defa
--- /dev/null
@@ -0,0 +1,74 @@
+/* Multithreading primitives.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.  */
+
+#include <config.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library.  */
+
+# include <pthread.h>
+# include <stdlib.h>
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The function to be executed by a dummy thread.  */
+static void *
+dummy_thread_func (void *arg)
+{
+  return arg;
+}
+
+int
+glthread_in_use (void)
+{
+  static int tested;
+  static int result; /* 1: linked with -lpthread, 0: only with libc */
+
+  if (!tested)
+    {
+      pthread_t thread;
+
+      if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
+        /* Thread creation failed.  */
+        result = 0;
+      else
+        {
+          /* Thread creation works.  */
+          void *retval;
+          if (pthread_join (thread, &retval) != 0)
+            abort ();
+          result = 1;
+        }
+      tested = 1;
+    }
+  return result;
+}
+
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+/* This declaration is solely to ensure that after preprocessing
+   this file is never empty.  */
+typedef int dummy;
diff --git a/gnulib/tests/glthread/yield.h b/gnulib/tests/glthread/yield.h
new file mode 100644 (file)
index 0000000..4eb1cb8
--- /dev/null
@@ -0,0 +1,121 @@
+/* Yielding the processor to other threads and processes.
+   Copyright (C) 2005-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This file contains a primitive for yielding the processor to other threads.
+     extern void gl_thread_yield (void);
+ */
+
+#ifndef _GLTHREAD_YIELD_H
+#define _GLTHREAD_YIELD_H
+
+#include <errno.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library.  */
+
+# include <sched.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define gl_thread_yield() \
+    sched_yield ()
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_PTH_THREADS
+
+/* Use the GNU Pth threads library.  */
+
+# include <pth.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define gl_thread_yield() \
+    pth_yield (NULL)
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_SOLARIS_THREADS
+
+/* Use the old Solaris threads library.  */
+
+# include <thread.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define gl_thread_yield() \
+    thr_yield ()
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if USE_WIN32_THREADS
+
+# include <windows.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define gl_thread_yield() \
+    Sleep (0)
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
+
+/* ========================================================================= */
+
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
+
+/* Provide dummy implementation if threads are not supported.  */
+
+# define gl_thread_yield() 0
+
+#endif
+
+/* ========================================================================= */
+
+#endif /* _GLTHREAD_YIELD_H */
diff --git a/gnulib/tests/ignore-value.h b/gnulib/tests/ignore-value.h
new file mode 100644 (file)
index 0000000..f021a1a
--- /dev/null
@@ -0,0 +1,62 @@
+/* ignore a function return without a compiler warning
+
+   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/>.  */
+
+/* Written by Jim Meyering, Eric Blake and Pádraig Brady.  */
+
+/* Use "ignore_value" to avoid a warning when using a function declared with
+   gcc's warn_unused_result attribute, but for which you really do want to
+   ignore the result.  Traditionally, people have used a "(void)" cast to
+   indicate that a function's return value is deliberately unused.  However,
+   if the function is declared with __attribute__((warn_unused_result)),
+   gcc issues a warning even with the cast.
+
+   Caution: most of the time, you really should heed gcc's warning, and
+   check the return value.  However, in those exceptional cases in which
+   you're sure you know what you're doing, use this function.
+
+   For the record, here's one of the ignorable warnings:
+   "copy.c:233: warning: ignoring return value of 'fchown',
+   declared with attribute warn_unused_result".  */
+
+#ifndef _GL_IGNORE_VALUE_H
+# define _GL_IGNORE_VALUE_H
+
+# 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 _GL_ATTRIBUTE_DEPRECATED /* empty */
+#  else
+#   define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
+#  endif
+# endif
+
+/* The __attribute__((__warn_unused_result__)) feature
+   is available in gcc versions 3.4 and newer,
+   while the typeof feature has been available since 2.7 at least.  */
+# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+#  define ignore_value(x) ((void) (x))
+# else
+#  define ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
+# endif
+
+/* ignore_value works for scalars, pointers and aggregates;
+   deprecate ignore_ptr.  */
+static inline void _GL_ATTRIBUTE_DEPRECATED
+ignore_ptr (void *p) { (void) p; } /* deprecated: use ignore_value */
+
+#endif
diff --git a/gnulib/tests/init.sh b/gnulib/tests/init.sh
new file mode 100644 (file)
index 0000000..71c6516
--- /dev/null
@@ -0,0 +1,474 @@
+# source this file; set up for tests
+
+# 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/>.
+
+# Using this file in a test
+# =========================
+#
+# The typical skeleton of a test looks like this:
+#
+#   #!/bin/sh
+#   . "${srcdir=.}/init.sh"; path_prepend_ .
+#   Execute some commands.
+#   Note that these commands are executed in a subdirectory, therefore you
+#   need to prepend "../" to relative filenames in the build directory.
+#   Note that the "path_prepend_ ." is useful only if the body of your
+#   test invokes programs residing in the initial directory.
+#   For example, if the programs you want to test are in src/, and this test
+#   script is named tests/test-1, then you would use "path_prepend_ ../src",
+#   or perhaps export PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH"
+#   to all tests via automake's TESTS_ENVIRONMENT.
+#   Set the exit code 0 for success, 77 for skipped, or 1 or other for failure.
+#   Use the skip_ and fail_ functions to print a diagnostic and then exit
+#   with the corresponding exit code.
+#   Exit $?
+
+# Executing a test that uses this file
+# ====================================
+#
+# Running a single test:
+#   $ make check TESTS=test-foo.sh
+#
+# Running a single test, with verbose output:
+#   $ make check TESTS=test-foo.sh VERBOSE=yes
+#
+# Running a single test, with single-stepping:
+#   1. Go into a sub-shell:
+#   $ bash
+#   2. Set relevant environment variables from TESTS_ENVIRONMENT in the
+#      Makefile:
+#   $ export srcdir=../../tests # this is an example
+#   3. Execute the commands from the test, copy&pasting them one by one:
+#   $ . "$srcdir/init.sh"; path_prepend_ .
+#   ...
+#   4. Finally
+#   $ exit
+
+ME_=`expr "./$0" : '.*/\(.*\)$'`
+
+# We use a trap below for cleanup.  This requires us to go through
+# hoops to get the right exit status transported through the handler.
+# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit () { set +e; (exit $1); exit $1; }
+
+# Print warnings (e.g., about skipped and failed tests) to this file number.
+# Override by defining to say, 9, in init.cfg, and putting say,
+# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition
+# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
+# This is useful when using automake's parallel tests mode, to print
+# the reason for skip/failure to console, rather than to the .log files.
+: ${stderr_fileno_=2}
+
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; }
+skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
+framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; }
+
+# Sanitize this shell to POSIX mode, if possible.
+DUALCASE=1; export DUALCASE
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+    *posix*) set -o posix ;;
+  esac
+fi
+
+# We require $(...) support unconditionally.
+# We require a few additional shell features only when $EXEEXT is nonempty,
+# in order to support automatic $EXEEXT emulation:
+# - hyphen-containing alias names
+# - we prefer to use ${var#...} substitution, rather than having
+#   to work around lack of support for that feature.
+# The following code attempts to find a shell with support for these features.
+# If the current shell passes the test, we're done.  Otherwise, test other
+# shells until we find one that passes.  If one is found, re-exec it.
+# If no acceptable shell is found, skip the current test.
+#
+# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that
+# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do.
+#
+# Use "9" to indicate success (rather than 0), in case some shell acts
+# like Solaris 10's /bin/sh but exits successfully instead of with status 2.
+
+# Eval this code in a subshell to determine a shell's suitability.
+# 10 - passes all tests; ok to use
+#  9 - ok, but enabling "set -x" corrupts app stderr; prefer higher score
+#  ? - not ok
+gl_shell_test_script_='
+test $(echo y) = y || exit 1
+score_=10
+if test "$VERBOSE" = yes; then
+  test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9
+fi
+test -z "$EXEEXT" && exit $score_
+shopt -s expand_aliases
+alias a-b="echo zoo"
+v=abx
+     test ${v%x} = ab \
+  && test ${v#a} = bx \
+  && test $(a-b) = zoo \
+  && exit $score_
+'
+
+if test "x$1" = "x--no-reexec"; then
+  shift
+else
+  # Assume a working shell.  Export to subshells (setup_ needs this).
+  gl_set_x_corrupts_stderr_=false
+  export gl_set_x_corrupts_stderr_
+
+  # Record the first marginally acceptable shell.
+  marginal_=
+
+  # Search for a shell that meets our requirements.
+  for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \
+      /bin/sh bash dash zsh pdksh fail
+  do
+    test "$re_shell_" = no_shell && continue
+
+    # If we've made it all the way to the sentinel, "fail" without
+    # finding even a marginal shell, skip this test.
+    if test "$re_shell_" = fail; then
+      test -z "$marginal_" && skip_ failed to find an adequate shell
+      re_shell_=$marginal_
+      break
+    fi
+
+    # When testing the current shell, simply "eval" the test code.
+    # Otherwise, run it via $re_shell_ -c ...
+    if test "$re_shell_" = __current__; then
+      # 'eval'ing this code makes Solaris 10's /bin/sh exit with
+      # $? set to 2.  It does not evaluate any of the code after the
+      # "unexpected" first `('.  Thus, we must run it in a subshell.
+      ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1
+    else
+      "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null
+    fi
+
+    st_=$?
+
+    # $re_shell_ works just fine.  Use it.
+    test $st_ = 10 && break
+
+    # If this is our first marginally acceptable shell, remember it.
+    if test "$st_:$marginal_" = 9: ; then
+      marginal_="$re_shell_"
+      gl_set_x_corrupts_stderr_=true
+    fi
+  done
+
+  if test "$re_shell_" != __current__; then
+    # Found a usable shell.  Preserve -v and -x.
+    case $- in
+      *v*x* | *x*v*) opts_=-vx ;;
+      *v*) opts_=-v ;;
+      *x*) opts_=-x ;;
+      *) opts_= ;;
+    esac
+    exec "$re_shell_" $opts_ "$0" --no-reexec "$@"
+    echo "$ME_: exec failed" 1>&2
+    exit 127
+  fi
+fi
+
+test -n "$EXEEXT" && shopt -s expand_aliases
+
+# Enable glibc's malloc-perturbing option.
+# This is useful for exposing code that depends on the fact that
+# malloc-related functions often return memory that is mostly zeroed.
+# If you have the time and cycles, use valgrind to do an even better job.
+: ${MALLOC_PERTURB_=87}
+export MALLOC_PERTURB_
+
+# This is a stub function that is run upon trap (upon regular exit and
+# interrupt).  Override it with a per-test function, e.g., to unmount
+# a partition, or to undo any other global state changes.
+cleanup_ () { :; }
+
+if ( diff --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
+  compare () { diff -u "$@"; }
+elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
+  compare () { cmp -s "$@"; }
+else
+  compare () { cmp "$@"; }
+fi
+
+# An arbitrary prefix to help distinguish test directories.
+testdir_prefix_ () { printf gt; }
+
+# Run the user-overridable cleanup_ function, remove the temporary
+# directory and exit with the incoming value of $?.
+remove_tmp_ ()
+{
+  __st=$?
+  cleanup_
+  # cd out of the directory we're about to remove
+  cd "$initial_cwd_" || cd / || cd /tmp
+  chmod -R u+rwx "$test_dir_"
+  # If removal fails and exit status was to be 0, then change it to 1.
+  rm -rf "$test_dir_" || { test $__st = 0 && __st=1; }
+  exit $__st
+}
+
+# Given a directory name, DIR, if every entry in it that matches *.exe
+# contains only the specified bytes (see the case stmt below), then print
+# a space-separated list of those names and return 0.  Otherwise, don't
+# print anything and return 1.  Naming constraints apply also to DIR.
+find_exe_basenames_ ()
+{
+  feb_dir_=$1
+  feb_fail_=0
+  feb_result_=
+  feb_sp_=
+  for feb_file_ in $feb_dir_/*.exe; do
+    # If there was no *.exe file, or there existed a file named "*.exe" that
+    # was deleted between the above glob expansion and the existence test
+    # below, just skip it.
+    test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \
+      && continue
+    # Exempt [.exe, since we can't create a function by that name, yet
+    # we can't invoke [ by PATH search anyways due to shell builtins.
+    test "x$feb_file_" = "x$feb_dir_/[.exe" && continue
+    case $feb_file_ in
+      *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;;
+      *) # Remove leading file name components as well as the .exe suffix.
+         feb_file_=${feb_file_##*/}
+         feb_file_=${feb_file_%.exe}
+         feb_result_="$feb_result_$feb_sp_$feb_file_";;
+    esac
+    feb_sp_=' '
+  done
+  test $feb_fail_ = 0 && printf %s "$feb_result_"
+  return $feb_fail_
+}
+
+# Consider the files in directory, $1.
+# For each file name of the form PROG.exe, create an alias named
+# PROG that simply invokes PROG.exe, then return 0.  If any selected
+# file name or the directory name, $1, contains an unexpected character,
+# define no alias and return 1.
+create_exe_shims_ ()
+{
+  case $EXEEXT in
+    '') return 0 ;;
+    .exe) ;;
+    *) echo "$0: unexpected \$EXEEXT value: $EXEEXT" 1>&2; return 1 ;;
+  esac
+
+  base_names_=`find_exe_basenames_ $1` \
+    || { echo "$0 (exe_shim): skipping directory: $1" 1>&2; return 0; }
+
+  if test -n "$base_names_"; then
+    for base_ in $base_names_; do
+      alias "$base_"="$base_$EXEEXT"
+    done
+  fi
+
+  return 0
+}
+
+# Use this function to prepend to PATH an absolute name for each
+# specified, possibly-$initial_cwd_-relative, directory.
+path_prepend_ ()
+{
+  while test $# != 0; do
+    path_dir_=$1
+    case $path_dir_ in
+      '') fail_ "invalid path dir: '$1'";;
+      /*) abs_path_dir_=$path_dir_;;
+      *) abs_path_dir_=`cd "$initial_cwd_/$path_dir_" && echo "$PWD"` \
+           || fail_ "invalid path dir: $path_dir_";;
+    esac
+    case $abs_path_dir_ in
+      *:*) fail_ "invalid path dir: '$abs_path_dir_'";;
+    esac
+    PATH="$abs_path_dir_:$PATH"
+
+    # Create an alias, FOO, for each FOO.exe in this directory.
+    create_exe_shims_ "$abs_path_dir_" \
+      || fail_ "something failed (above): $abs_path_dir_"
+    shift
+  done
+  export PATH
+}
+
+setup_ ()
+{
+  if test "$VERBOSE" = yes; then
+    # Test whether set -x may cause the selected shell to corrupt an
+    # application's stderr.  Many do, including zsh-4.3.10 and the /bin/sh
+    # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5.
+    # If enabling verbose output this way would cause trouble, simply
+    # issue a warning and refrain.
+    if $gl_set_x_corrupts_stderr_; then
+      warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr"
+    else
+      set -x
+    fi
+  fi
+
+  initial_cwd_=$PWD
+  fail=0
+
+  pfx_=`testdir_prefix_`
+  test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
+    || fail_ "failed to create temporary directory in $initial_cwd_"
+  cd "$test_dir_"
+
+  # As autoconf-generated configure scripts do, ensure that IFS
+  # is defined initially, so that saving and restoring $IFS works.
+  gl_init_sh_nl_='
+'
+  IFS=" ""     $gl_init_sh_nl_"
+
+  # This trap statement, along with a trap on 0 below, ensure that the
+  # temporary directory, $test_dir_, is removed upon exit as well as
+  # upon receipt of any of the listed signals.
+  for sig_ in 1 2 3 13 15; do
+    eval "trap 'Exit $(expr $sig_ + 128)' $sig_"
+  done
+}
+
+# Create a temporary directory, much like mktemp -d does.
+# Written by Jim Meyering.
+#
+# Usage: mktempd_ /tmp phoey.XXXXXXXXXX
+#
+# First, try to use the mktemp program.
+# Failing that, we'll roll our own mktemp-like function:
+#  - try to get random bytes from /dev/urandom
+#  - failing that, generate output from a combination of quickly-varying
+#      sources and gzip.  Ignore non-varying gzip header, and extract
+#      "random" bits from there.
+#  - given those bits, map to file-name bytes using tr, and try to create
+#      the desired directory.
+#  - make only $MAX_TRIES_ attempts
+
+# Helper function.  Print $N pseudo-random bytes from a-zA-Z0-9.
+rand_bytes_ ()
+{
+  n_=$1
+
+  # Maybe try openssl rand -base64 $n_prime_|tr '+/=\012' abcd first?
+  # But if they have openssl, they probably have mktemp, too.
+
+  chars_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
+  dev_rand_=/dev/urandom
+  if test -r "$dev_rand_"; then
+    # Note: 256-length($chars_) == 194; 3 copies of $chars_ is 186 + 8 = 194.
+    dd ibs=$n_ count=1 if=$dev_rand_ 2>/dev/null \
+      | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_
+    return
+  fi
+
+  n_plus_50_=`expr $n_ + 50`
+  cmds_='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n'
+  data_=` (eval "$cmds_") 2>&1 | gzip `
+
+  # Ensure that $data_ has length at least 50+$n_
+  while :; do
+    len_=`echo "$data_"|wc -c`
+    test $n_plus_50_ -le $len_ && break;
+    data_=` (echo "$data_"; eval "$cmds_") 2>&1 | gzip `
+  done
+
+  echo "$data_" \
+    | dd bs=1 skip=50 count=$n_ 2>/dev/null \
+    | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_
+}
+
+mktempd_ ()
+{
+  case $# in
+  2);;
+  *) fail_ "Usage: $ME DIR TEMPLATE";;
+  esac
+
+  destdir_=$1
+  template_=$2
+
+  MAX_TRIES_=4
+
+  # Disallow any trailing slash on specified destdir:
+  # it would subvert the post-mktemp "case"-based destdir test.
+  case $destdir_ in
+  /) ;;
+  */) fail_ "invalid destination dir: remove trailing slash(es)";;
+  esac
+
+  case $template_ in
+  *XXXX) ;;
+  *) fail_ \
+       "invalid template: $template_ (must have a suffix of at least 4 X's)";;
+  esac
+
+  # First, try to use mktemp.
+  d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
+    || fail=1
+
+  # The resulting name must be in the specified directory.
+  case $d in "$destdir_"*);; *) fail=1;; esac
+
+  # It must have created the directory.
+  test -d "$d" || fail=1
+
+  # It must have 0700 permissions.  Handle sticky "S" bits.
+  perms=`ls -dgo "$d" 2>/dev/null|tr S -` || fail=1
+  case $perms in drwx------*) ;; *) fail=1;; esac
+
+  test $fail = 0 && {
+    echo "$d"
+    return
+  }
+
+  # If we reach this point, we'll have to create a directory manually.
+
+  # Get a copy of the template without its suffix of X's.
+  base_template_=`echo "$template_"|sed 's/XX*$//'`
+
+  # Calculate how many X's we've just removed.
+  template_length_=`echo "$template_" | wc -c`
+  nx_=`echo "$base_template_" | wc -c`
+  nx_=`expr $template_length_ - $nx_`
+
+  err_=
+  i_=1
+  while :; do
+    X_=`rand_bytes_ $nx_`
+    candidate_dir_="$destdir_/$base_template_$X_"
+    err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \
+      && { echo "$candidate_dir_"; return; }
+    test $MAX_TRIES_ -le $i_ && break;
+    i_=`expr $i_ + 1`
+  done
+  fail_ "$err_"
+}
+
+# If you want to override the testdir_prefix_ function,
+# or to add more utility functions, use this file.
+test -f "$srcdir/init.cfg" \
+  && . "$srcdir/init.cfg"
+
+setup_ "$@"
+# This trap is here, rather than in the setup_ function, because some
+# shells run the exit trap at shell function exit, rather than script exit.
+trap remove_tmp_ 0
diff --git a/gnulib/tests/intprops.h b/gnulib/tests/intprops.h
new file mode 100644 (file)
index 0000000..58b1b3f
--- /dev/null
@@ -0,0 +1,86 @@
+/* intprops.h -- properties of integer types
+
+   Copyright (C) 2001-2005, 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.  */
+
+#ifndef GL_INTPROPS_H
+# define GL_INTPROPS_H
+
+# include <limits.h>
+
+/* The extra casts in the following macros work around compiler bugs,
+   e.g., in Cray C 5.0.3.0.  */
+
+/* True if the arithmetic type T is an integer type.  bool counts as
+   an integer.  */
+# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+
+/* True if negative values of the signed integer type T use two's
+   complement, ones' complement, or signed magnitude representation,
+   respectively.  Much GNU code assumes two's complement, but some
+   people like to be portable to all possible C hosts.  */
+# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
+# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
+# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
+
+/* True if the arithmetic type T is signed.  */
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* The maximum and minimum values for the integer type T.  These
+   macros have undefined behavior if T is signed and has padding bits.
+   If this is a problem for you, please let us know how to fix it for
+   your host.  */
+# define TYPE_MINIMUM(t) \
+  ((t) (! TYPE_SIGNED (t) \
+        ? (t) 0 \
+        : TYPE_SIGNED_MAGNITUDE (t) \
+        ? ~ (t) 0 \
+        : ~ TYPE_MAXIMUM (t)))
+# define TYPE_MAXIMUM(t) \
+  ((t) (! TYPE_SIGNED (t) \
+        ? (t) -1 \
+        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+
+/* Return zero if T can be determined to be an unsigned type.
+   Otherwise, return 1.
+   When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
+   tighter bound.  Otherwise, it overestimates the true bound by one byte
+   when applied to unsigned types of size 2, 4, 16, ... bytes.
+   The symbol signed_type_or_expr__ is private to this header file.  */
+# if __GNUC__ >= 2
+#  define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
+# else
+#  define signed_type_or_expr__(t) 1
+# endif
+
+/* Bound on length of the string representing an unsigned integer
+   value representable in B bits.  log10 (2.0) < 146/485.  The
+   smallest value of B where this bound is not tight is 2621.  */
+# define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
+
+/* Bound on length of the string representing an integer type or expression T.
+   Subtract 1 for the sign bit if T is signed, and then add 1 more for
+   a minus sign if needed.  */
+# define INT_STRLEN_BOUND(t) \
+  (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) \
+   + signed_type_or_expr__ (t))
+
+/* Bound on buffer size needed to represent an integer type or expression T,
+   including the terminating null.  */
+# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+
+#endif /* GL_INTPROPS_H */
diff --git a/gnulib/tests/localename.c b/gnulib/tests/localename.c
new file mode 100644 (file)
index 0000000..a5bfea7
--- /dev/null
@@ -0,0 +1,2959 @@
+/* Determine name of the currently selected locale.
+   Copyright (C) 1995-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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+/* Written by Ulrich Drepper <drepper@gnu.org>, 1995.  */
+/* Win32 code written by Tor Lillqvist <tml@iki.fi>.  */
+/* MacOS X code written by Bruno Haible <bruno@clisp.org>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#ifdef IN_LIBINTL
+# include "gettextP.h"
+#else
+# include "localename.h"
+#endif
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <string.h>
+
+#if HAVE_USELOCALE
+/* MacOS X 10.5 defines the locale_t type in <xlocale.h>.  */
+# if defined __APPLE__ && defined __MACH__
+#  include <xlocale.h>
+# endif
+# include <langinfo.h>
+# if !defined IN_LIBINTL
+#  include "glthread/lock.h"
+# endif
+#endif
+
+#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
+# include <CoreFoundation/CFString.h>
+# if HAVE_CFLOCALECOPYCURRENT
+#  include <CoreFoundation/CFLocale.h>
+# elif HAVE_CFPREFERENCESCOPYAPPVALUE
+#  include <CoreFoundation/CFPreferences.h>
+# endif
+#endif
+
+#if defined _WIN32 || defined __WIN32__
+# define WIN32_NATIVE
+#endif
+
+#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+/* List of language codes, sorted by value:
+   0x01 LANG_ARABIC
+   0x02 LANG_BULGARIAN
+   0x03 LANG_CATALAN
+   0x04 LANG_CHINESE
+   0x05 LANG_CZECH
+   0x06 LANG_DANISH
+   0x07 LANG_GERMAN
+   0x08 LANG_GREEK
+   0x09 LANG_ENGLISH
+   0x0a LANG_SPANISH
+   0x0b LANG_FINNISH
+   0x0c LANG_FRENCH
+   0x0d LANG_HEBREW
+   0x0e LANG_HUNGARIAN
+   0x0f LANG_ICELANDIC
+   0x10 LANG_ITALIAN
+   0x11 LANG_JAPANESE
+   0x12 LANG_KOREAN
+   0x13 LANG_DUTCH
+   0x14 LANG_NORWEGIAN
+   0x15 LANG_POLISH
+   0x16 LANG_PORTUGUESE
+   0x17 LANG_ROMANSH
+   0x18 LANG_ROMANIAN
+   0x19 LANG_RUSSIAN
+   0x1a LANG_CROATIAN == LANG_SERBIAN
+   0x1b LANG_SLOVAK
+   0x1c LANG_ALBANIAN
+   0x1d LANG_SWEDISH
+   0x1e LANG_THAI
+   0x1f LANG_TURKISH
+   0x20 LANG_URDU
+   0x21 LANG_INDONESIAN
+   0x22 LANG_UKRAINIAN
+   0x23 LANG_BELARUSIAN
+   0x24 LANG_SLOVENIAN
+   0x25 LANG_ESTONIAN
+   0x26 LANG_LATVIAN
+   0x27 LANG_LITHUANIAN
+   0x28 LANG_TAJIK
+   0x29 LANG_FARSI
+   0x2a LANG_VIETNAMESE
+   0x2b LANG_ARMENIAN
+   0x2c LANG_AZERI
+   0x2d LANG_BASQUE
+   0x2e LANG_SORBIAN
+   0x2f LANG_MACEDONIAN
+   0x30 LANG_SUTU
+   0x31 LANG_TSONGA
+   0x32 LANG_TSWANA
+   0x33 LANG_VENDA
+   0x34 LANG_XHOSA
+   0x35 LANG_ZULU
+   0x36 LANG_AFRIKAANS
+   0x37 LANG_GEORGIAN
+   0x38 LANG_FAEROESE
+   0x39 LANG_HINDI
+   0x3a LANG_MALTESE
+   0x3b LANG_SAMI
+   0x3c LANG_GAELIC
+   0x3d LANG_YIDDISH
+   0x3e LANG_MALAY
+   0x3f LANG_KAZAK
+   0x40 LANG_KYRGYZ
+   0x41 LANG_SWAHILI
+   0x42 LANG_TURKMEN
+   0x43 LANG_UZBEK
+   0x44 LANG_TATAR
+   0x45 LANG_BENGALI
+   0x46 LANG_PUNJABI
+   0x47 LANG_GUJARATI
+   0x48 LANG_ORIYA
+   0x49 LANG_TAMIL
+   0x4a LANG_TELUGU
+   0x4b LANG_KANNADA
+   0x4c LANG_MALAYALAM
+   0x4d LANG_ASSAMESE
+   0x4e LANG_MARATHI
+   0x4f LANG_SANSKRIT
+   0x50 LANG_MONGOLIAN
+   0x51 LANG_TIBETAN
+   0x52 LANG_WELSH
+   0x53 LANG_CAMBODIAN
+   0x54 LANG_LAO
+   0x55 LANG_BURMESE
+   0x56 LANG_GALICIAN
+   0x57 LANG_KONKANI
+   0x58 LANG_MANIPURI
+   0x59 LANG_SINDHI
+   0x5a LANG_SYRIAC
+   0x5b LANG_SINHALESE
+   0x5c LANG_CHEROKEE
+   0x5d LANG_INUKTITUT
+   0x5e LANG_AMHARIC
+   0x5f LANG_TAMAZIGHT
+   0x60 LANG_KASHMIRI
+   0x61 LANG_NEPALI
+   0x62 LANG_FRISIAN
+   0x63 LANG_PASHTO
+   0x64 LANG_TAGALOG
+   0x65 LANG_DIVEHI
+   0x66 LANG_EDO
+   0x67 LANG_FULFULDE
+   0x68 LANG_HAUSA
+   0x69 LANG_IBIBIO
+   0x6a LANG_YORUBA
+   0x6d LANG_BASHKIR
+   0x6e LANG_LUXEMBOURGISH
+   0x6f LANG_GREENLANDIC
+   0x70 LANG_IGBO
+   0x71 LANG_KANURI
+   0x72 LANG_OROMO
+   0x73 LANG_TIGRINYA
+   0x74 LANG_GUARANI
+   0x75 LANG_HAWAIIAN
+   0x76 LANG_LATIN
+   0x77 LANG_SOMALI
+   0x78 LANG_YI
+   0x79 LANG_PAPIAMENTU
+   0x7a LANG_MAPUDUNGUN
+   0x7c LANG_MOHAWK
+   0x7e LANG_BRETON
+   0x82 LANG_OCCITAN
+   0x83 LANG_CORSICAN
+   0x84 LANG_ALSATIAN
+   0x85 LANG_YAKUT
+   0x86 LANG_KICHE
+   0x87 LANG_KINYARWANDA
+   0x88 LANG_WOLOF
+   0x8c LANG_DARI
+   0x91 LANG_SCOTTISH_GAELIC
+*/
+/* Mingw headers don't have latest language and sublanguage codes.  */
+# ifndef LANG_AFRIKAANS
+# define LANG_AFRIKAANS 0x36
+# endif
+# ifndef LANG_ALBANIAN
+# define LANG_ALBANIAN 0x1c
+# endif
+# ifndef LANG_ALSATIAN
+# define LANG_ALSATIAN 0x84
+# endif
+# ifndef LANG_AMHARIC
+# define LANG_AMHARIC 0x5e
+# endif
+# ifndef LANG_ARABIC
+# define LANG_ARABIC 0x01
+# endif
+# ifndef LANG_ARMENIAN
+# define LANG_ARMENIAN 0x2b
+# endif
+# ifndef LANG_ASSAMESE
+# define LANG_ASSAMESE 0x4d
+# endif
+# ifndef LANG_AZERI
+# define LANG_AZERI 0x2c
+# endif
+# ifndef LANG_BASHKIR
+# define LANG_BASHKIR 0x6d
+# endif
+# ifndef LANG_BASQUE
+# define LANG_BASQUE 0x2d
+# endif
+# ifndef LANG_BELARUSIAN
+# define LANG_BELARUSIAN 0x23
+# endif
+# ifndef LANG_BENGALI
+# define LANG_BENGALI 0x45
+# endif
+# ifndef LANG_BRETON
+# define LANG_BRETON 0x7e
+# endif
+# ifndef LANG_BURMESE
+# define LANG_BURMESE 0x55
+# endif
+# ifndef LANG_CAMBODIAN
+# define LANG_CAMBODIAN 0x53
+# endif
+# ifndef LANG_CATALAN
+# define LANG_CATALAN 0x03
+# endif
+# ifndef LANG_CHEROKEE
+# define LANG_CHEROKEE 0x5c
+# endif
+# ifndef LANG_CORSICAN
+# define LANG_CORSICAN 0x83
+# endif
+# ifndef LANG_DARI
+# define LANG_DARI 0x8c
+# endif
+# ifndef LANG_DIVEHI
+# define LANG_DIVEHI 0x65
+# endif
+# ifndef LANG_EDO
+# define LANG_EDO 0x66
+# endif
+# ifndef LANG_ESTONIAN
+# define LANG_ESTONIAN 0x25
+# endif
+# ifndef LANG_FAEROESE
+# define LANG_FAEROESE 0x38
+# endif
+# ifndef LANG_FARSI
+# define LANG_FARSI 0x29
+# endif
+# ifndef LANG_FRISIAN
+# define LANG_FRISIAN 0x62
+# endif
+# ifndef LANG_FULFULDE
+# define LANG_FULFULDE 0x67
+# endif
+# ifndef LANG_GAELIC
+# define LANG_GAELIC 0x3c
+# endif
+# ifndef LANG_GALICIAN
+# define LANG_GALICIAN 0x56
+# endif
+# ifndef LANG_GEORGIAN
+# define LANG_GEORGIAN 0x37
+# endif
+# ifndef LANG_GREENLANDIC
+# define LANG_GREENLANDIC 0x6f
+# endif
+# ifndef LANG_GUARANI
+# define LANG_GUARANI 0x74
+# endif
+# ifndef LANG_GUJARATI
+# define LANG_GUJARATI 0x47
+# endif
+# ifndef LANG_HAUSA
+# define LANG_HAUSA 0x68
+# endif
+# ifndef LANG_HAWAIIAN
+# define LANG_HAWAIIAN 0x75
+# endif
+# ifndef LANG_HEBREW
+# define LANG_HEBREW 0x0d
+# endif
+# ifndef LANG_HINDI
+# define LANG_HINDI 0x39
+# endif
+# ifndef LANG_IBIBIO
+# define LANG_IBIBIO 0x69
+# endif
+# ifndef LANG_IGBO
+# define LANG_IGBO 0x70
+# endif
+# ifndef LANG_INDONESIAN
+# define LANG_INDONESIAN 0x21
+# endif
+# ifndef LANG_INUKTITUT
+# define LANG_INUKTITUT 0x5d
+# endif
+# ifndef LANG_KANNADA
+# define LANG_KANNADA 0x4b
+# endif
+# ifndef LANG_KANURI
+# define LANG_KANURI 0x71
+# endif
+# ifndef LANG_KASHMIRI
+# define LANG_KASHMIRI 0x60
+# endif
+# ifndef LANG_KAZAK
+# define LANG_KAZAK 0x3f
+# endif
+# ifndef LANG_KICHE
+# define LANG_KICHE 0x86
+# endif
+# ifndef LANG_KINYARWANDA
+# define LANG_KINYARWANDA 0x87
+# endif
+# ifndef LANG_KONKANI
+# define LANG_KONKANI 0x57
+# endif
+# ifndef LANG_KYRGYZ
+# define LANG_KYRGYZ 0x40
+# endif
+# ifndef LANG_LAO
+# define LANG_LAO 0x54
+# endif
+# ifndef LANG_LATIN
+# define LANG_LATIN 0x76
+# endif
+# ifndef LANG_LATVIAN
+# define LANG_LATVIAN 0x26
+# endif
+# ifndef LANG_LITHUANIAN
+# define LANG_LITHUANIAN 0x27
+# endif
+# ifndef LANG_LUXEMBOURGISH
+# define LANG_LUXEMBOURGISH 0x6e
+# endif
+# ifndef LANG_MACEDONIAN
+# define LANG_MACEDONIAN 0x2f
+# endif
+# ifndef LANG_MALAY
+# define LANG_MALAY 0x3e
+# endif
+# ifndef LANG_MALAYALAM
+# define LANG_MALAYALAM 0x4c
+# endif
+# ifndef LANG_MALTESE
+# define LANG_MALTESE 0x3a
+# endif
+# ifndef LANG_MANIPURI
+# define LANG_MANIPURI 0x58
+# endif
+# ifndef LANG_MAORI
+# define LANG_MAORI 0x81
+# endif
+# ifndef LANG_MAPUDUNGUN
+# define LANG_MAPUDUNGUN 0x7a
+# endif
+# ifndef LANG_MARATHI
+# define LANG_MARATHI 0x4e
+# endif
+# ifndef LANG_MOHAWK
+# define LANG_MOHAWK 0x7c
+# endif
+# ifndef LANG_MONGOLIAN
+# define LANG_MONGOLIAN 0x50
+# endif
+# ifndef LANG_NEPALI
+# define LANG_NEPALI 0x61
+# endif
+# ifndef LANG_OCCITAN
+# define LANG_OCCITAN 0x82
+# endif
+# ifndef LANG_ORIYA
+# define LANG_ORIYA 0x48
+# endif
+# ifndef LANG_OROMO
+# define LANG_OROMO 0x72
+# endif
+# ifndef LANG_PAPIAMENTU
+# define LANG_PAPIAMENTU 0x79
+# endif
+# ifndef LANG_PASHTO
+# define LANG_PASHTO 0x63
+# endif
+# ifndef LANG_PUNJABI
+# define LANG_PUNJABI 0x46
+# endif
+# ifndef LANG_QUECHUA
+# define LANG_QUECHUA 0x6b
+# endif
+# ifndef LANG_ROMANSH
+# define LANG_ROMANSH 0x17
+# endif
+# ifndef LANG_SAMI
+# define LANG_SAMI 0x3b
+# endif
+# ifndef LANG_SANSKRIT
+# define LANG_SANSKRIT 0x4f
+# endif
+# ifndef LANG_SCOTTISH_GAELIC
+# define LANG_SCOTTISH_GAELIC 0x91
+# endif
+# ifndef LANG_SERBIAN
+# define LANG_SERBIAN 0x1a
+# endif
+# ifndef LANG_SINDHI
+# define LANG_SINDHI 0x59
+# endif
+# ifndef LANG_SINHALESE
+# define LANG_SINHALESE 0x5b
+# endif
+# ifndef LANG_SLOVAK
+# define LANG_SLOVAK 0x1b
+# endif
+# ifndef LANG_SOMALI
+# define LANG_SOMALI 0x77
+# endif
+# ifndef LANG_SORBIAN
+# define LANG_SORBIAN 0x2e
+# endif
+# ifndef LANG_SOTHO
+# define LANG_SOTHO 0x6c
+# endif
+# ifndef LANG_SUTU
+# define LANG_SUTU 0x30
+# endif
+# ifndef LANG_SWAHILI
+# define LANG_SWAHILI 0x41
+# endif
+# ifndef LANG_SYRIAC
+# define LANG_SYRIAC 0x5a
+# endif
+# ifndef LANG_TAGALOG
+# define LANG_TAGALOG 0x64
+# endif
+# ifndef LANG_TAJIK
+# define LANG_TAJIK 0x28
+# endif
+# ifndef LANG_TAMAZIGHT
+# define LANG_TAMAZIGHT 0x5f
+# endif
+# ifndef LANG_TAMIL
+# define LANG_TAMIL 0x49
+# endif
+# ifndef LANG_TATAR
+# define LANG_TATAR 0x44
+# endif
+# ifndef LANG_TELUGU
+# define LANG_TELUGU 0x4a
+# endif
+# ifndef LANG_THAI
+# define LANG_THAI 0x1e
+# endif
+# ifndef LANG_TIBETAN
+# define LANG_TIBETAN 0x51
+# endif
+# ifndef LANG_TIGRINYA
+# define LANG_TIGRINYA 0x73
+# endif
+# ifndef LANG_TSONGA
+# define LANG_TSONGA 0x31
+# endif
+# ifndef LANG_TSWANA
+# define LANG_TSWANA 0x32
+# endif
+# ifndef LANG_TURKMEN
+# define LANG_TURKMEN 0x42
+# endif
+# ifndef LANG_UIGHUR
+# define LANG_UIGHUR 0x80
+# endif
+# ifndef LANG_UKRAINIAN
+# define LANG_UKRAINIAN 0x22
+# endif
+# ifndef LANG_URDU
+# define LANG_URDU 0x20
+# endif
+# ifndef LANG_UZBEK
+# define LANG_UZBEK 0x43
+# endif
+# ifndef LANG_VENDA
+# define LANG_VENDA 0x33
+# endif
+# ifndef LANG_VIETNAMESE
+# define LANG_VIETNAMESE 0x2a
+# endif
+# ifndef LANG_WELSH
+# define LANG_WELSH 0x52
+# endif
+# ifndef LANG_WOLOF
+# define LANG_WOLOF 0x88
+# endif
+# ifndef LANG_XHOSA
+# define LANG_XHOSA 0x34
+# endif
+# ifndef LANG_YAKUT
+# define LANG_YAKUT 0x85
+# endif
+# ifndef LANG_YI
+# define LANG_YI 0x78
+# endif
+# ifndef LANG_YIDDISH
+# define LANG_YIDDISH 0x3d
+# endif
+# ifndef LANG_YORUBA
+# define LANG_YORUBA 0x6a
+# endif
+# ifndef LANG_ZULU
+# define LANG_ZULU 0x35
+# endif
+# ifndef SUBLANG_AFRIKAANS_SOUTH_AFRICA
+# define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
+# endif
+# ifndef SUBLANG_ALBANIAN_ALBANIA
+# define SUBLANG_ALBANIAN_ALBANIA 0x01
+# endif
+# ifndef SUBLANG_ALSATIAN_FRANCE
+# define SUBLANG_ALSATIAN_FRANCE 0x01
+# endif
+# ifndef SUBLANG_AMHARIC_ETHIOPIA
+# define SUBLANG_AMHARIC_ETHIOPIA 0x01
+# endif
+# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
+# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
+# endif
+# ifndef SUBLANG_ARABIC_IRAQ
+# define SUBLANG_ARABIC_IRAQ 0x02
+# endif
+# ifndef SUBLANG_ARABIC_EGYPT
+# define SUBLANG_ARABIC_EGYPT 0x03
+# endif
+# ifndef SUBLANG_ARABIC_LIBYA
+# define SUBLANG_ARABIC_LIBYA 0x04
+# endif
+# ifndef SUBLANG_ARABIC_ALGERIA
+# define SUBLANG_ARABIC_ALGERIA 0x05
+# endif
+# ifndef SUBLANG_ARABIC_MOROCCO
+# define SUBLANG_ARABIC_MOROCCO 0x06
+# endif
+# ifndef SUBLANG_ARABIC_TUNISIA
+# define SUBLANG_ARABIC_TUNISIA 0x07
+# endif
+# ifndef SUBLANG_ARABIC_OMAN
+# define SUBLANG_ARABIC_OMAN 0x08
+# endif
+# ifndef SUBLANG_ARABIC_YEMEN
+# define SUBLANG_ARABIC_YEMEN 0x09
+# endif
+# ifndef SUBLANG_ARABIC_SYRIA
+# define SUBLANG_ARABIC_SYRIA 0x0a
+# endif
+# ifndef SUBLANG_ARABIC_JORDAN
+# define SUBLANG_ARABIC_JORDAN 0x0b
+# endif
+# ifndef SUBLANG_ARABIC_LEBANON
+# define SUBLANG_ARABIC_LEBANON 0x0c
+# endif
+# ifndef SUBLANG_ARABIC_KUWAIT
+# define SUBLANG_ARABIC_KUWAIT 0x0d
+# endif
+# ifndef SUBLANG_ARABIC_UAE
+# define SUBLANG_ARABIC_UAE 0x0e
+# endif
+# ifndef SUBLANG_ARABIC_BAHRAIN
+# define SUBLANG_ARABIC_BAHRAIN 0x0f
+# endif
+# ifndef SUBLANG_ARABIC_QATAR
+# define SUBLANG_ARABIC_QATAR 0x10
+# endif
+# ifndef SUBLANG_ARMENIAN_ARMENIA
+# define SUBLANG_ARMENIAN_ARMENIA 0x01
+# endif
+# ifndef SUBLANG_ASSAMESE_INDIA
+# define SUBLANG_ASSAMESE_INDIA 0x01
+# endif
+# ifndef SUBLANG_AZERI_LATIN
+# define SUBLANG_AZERI_LATIN 0x01
+# endif
+# ifndef SUBLANG_AZERI_CYRILLIC
+# define SUBLANG_AZERI_CYRILLIC 0x02
+# endif
+# ifndef SUBLANG_BASHKIR_RUSSIA
+# define SUBLANG_BASHKIR_RUSSIA 0x01
+# endif
+# ifndef SUBLANG_BASQUE_BASQUE
+# define SUBLANG_BASQUE_BASQUE 0x01
+# endif
+# ifndef SUBLANG_BELARUSIAN_BELARUS
+# define SUBLANG_BELARUSIAN_BELARUS 0x01
+# endif
+# ifndef SUBLANG_BENGALI_INDIA
+# define SUBLANG_BENGALI_INDIA 0x01
+# endif
+# ifndef SUBLANG_BENGALI_BANGLADESH
+# define SUBLANG_BENGALI_BANGLADESH 0x02
+# endif
+# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
+# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
+# endif
+# ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC
+# define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
+# endif
+# ifndef SUBLANG_BRETON_FRANCE
+# define SUBLANG_BRETON_FRANCE 0x01
+# endif
+# ifndef SUBLANG_BULGARIAN_BULGARIA
+# define SUBLANG_BULGARIAN_BULGARIA 0x01
+# endif
+# ifndef SUBLANG_CAMBODIAN_CAMBODIA
+# define SUBLANG_CAMBODIAN_CAMBODIA 0x01
+# endif
+# ifndef SUBLANG_CATALAN_SPAIN
+# define SUBLANG_CATALAN_SPAIN 0x01
+# endif
+# ifndef SUBLANG_CORSICAN_FRANCE
+# define SUBLANG_CORSICAN_FRANCE 0x01
+# endif
+# ifndef SUBLANG_CROATIAN_CROATIA
+# define SUBLANG_CROATIAN_CROATIA 0x01
+# endif
+# ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
+# define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
+# endif
+# ifndef SUBLANG_CHINESE_MACAU
+# define SUBLANG_CHINESE_MACAU 0x05
+# endif
+# ifndef SUBLANG_CZECH_CZECH_REPUBLIC
+# define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
+# endif
+# ifndef SUBLANG_DANISH_DENMARK
+# define SUBLANG_DANISH_DENMARK 0x01
+# endif
+# ifndef SUBLANG_DARI_AFGHANISTAN
+# define SUBLANG_DARI_AFGHANISTAN 0x01
+# endif
+# ifndef SUBLANG_DIVEHI_MALDIVES
+# define SUBLANG_DIVEHI_MALDIVES 0x01
+# endif
+# ifndef SUBLANG_DUTCH_SURINAM
+# define SUBLANG_DUTCH_SURINAM 0x03
+# endif
+# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
+# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
+# endif
+# ifndef SUBLANG_ENGLISH_JAMAICA
+# define SUBLANG_ENGLISH_JAMAICA 0x08
+# endif
+# ifndef SUBLANG_ENGLISH_CARIBBEAN
+# define SUBLANG_ENGLISH_CARIBBEAN 0x09
+# endif
+# ifndef SUBLANG_ENGLISH_BELIZE
+# define SUBLANG_ENGLISH_BELIZE 0x0a
+# endif
+# ifndef SUBLANG_ENGLISH_TRINIDAD
+# define SUBLANG_ENGLISH_TRINIDAD 0x0b
+# endif
+# ifndef SUBLANG_ENGLISH_ZIMBABWE
+# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
+# endif
+# ifndef SUBLANG_ENGLISH_PHILIPPINES
+# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
+# endif
+# ifndef SUBLANG_ENGLISH_INDONESIA
+# define SUBLANG_ENGLISH_INDONESIA 0x0e
+# endif
+# ifndef SUBLANG_ENGLISH_HONGKONG
+# define SUBLANG_ENGLISH_HONGKONG 0x0f
+# endif
+# ifndef SUBLANG_ENGLISH_INDIA
+# define SUBLANG_ENGLISH_INDIA 0x10
+# endif
+# ifndef SUBLANG_ENGLISH_MALAYSIA
+# define SUBLANG_ENGLISH_MALAYSIA 0x11
+# endif
+# ifndef SUBLANG_ENGLISH_SINGAPORE
+# define SUBLANG_ENGLISH_SINGAPORE 0x12
+# endif
+# ifndef SUBLANG_ESTONIAN_ESTONIA
+# define SUBLANG_ESTONIAN_ESTONIA 0x01
+# endif
+# ifndef SUBLANG_FAEROESE_FAROE_ISLANDS
+# define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
+# endif
+# ifndef SUBLANG_FARSI_IRAN
+# define SUBLANG_FARSI_IRAN 0x01
+# endif
+# ifndef SUBLANG_FINNISH_FINLAND
+# define SUBLANG_FINNISH_FINLAND 0x01
+# endif
+# ifndef SUBLANG_FRENCH_LUXEMBOURG
+# define SUBLANG_FRENCH_LUXEMBOURG 0x05
+# endif
+# ifndef SUBLANG_FRENCH_MONACO
+# define SUBLANG_FRENCH_MONACO 0x06
+# endif
+# ifndef SUBLANG_FRENCH_WESTINDIES
+# define SUBLANG_FRENCH_WESTINDIES 0x07
+# endif
+# ifndef SUBLANG_FRENCH_REUNION
+# define SUBLANG_FRENCH_REUNION 0x08
+# endif
+# ifndef SUBLANG_FRENCH_CONGO
+# define SUBLANG_FRENCH_CONGO 0x09
+# endif
+# ifndef SUBLANG_FRENCH_SENEGAL
+# define SUBLANG_FRENCH_SENEGAL 0x0a
+# endif
+# ifndef SUBLANG_FRENCH_CAMEROON
+# define SUBLANG_FRENCH_CAMEROON 0x0b
+# endif
+# ifndef SUBLANG_FRENCH_COTEDIVOIRE
+# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
+# endif
+# ifndef SUBLANG_FRENCH_MALI
+# define SUBLANG_FRENCH_MALI 0x0d
+# endif
+# ifndef SUBLANG_FRENCH_MOROCCO
+# define SUBLANG_FRENCH_MOROCCO 0x0e
+# endif
+# ifndef SUBLANG_FRENCH_HAITI
+# define SUBLANG_FRENCH_HAITI 0x0f
+# endif
+# ifndef SUBLANG_FRISIAN_NETHERLANDS
+# define SUBLANG_FRISIAN_NETHERLANDS 0x01
+# endif
+# ifndef SUBLANG_GALICIAN_SPAIN
+# define SUBLANG_GALICIAN_SPAIN 0x01
+# endif
+# ifndef SUBLANG_GEORGIAN_GEORGIA
+# define SUBLANG_GEORGIAN_GEORGIA 0x01
+# endif
+# ifndef SUBLANG_GERMAN_LUXEMBOURG
+# define SUBLANG_GERMAN_LUXEMBOURG 0x04
+# endif
+# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
+# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
+# endif
+# ifndef SUBLANG_GREEK_GREECE
+# define SUBLANG_GREEK_GREECE 0x01
+# endif
+# ifndef SUBLANG_GREENLANDIC_GREENLAND
+# define SUBLANG_GREENLANDIC_GREENLAND 0x01
+# endif
+# ifndef SUBLANG_GUJARATI_INDIA
+# define SUBLANG_GUJARATI_INDIA 0x01
+# endif
+# ifndef SUBLANG_HAUSA_NIGERIA_LATIN
+# define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
+# endif
+# ifndef SUBLANG_HEBREW_ISRAEL
+# define SUBLANG_HEBREW_ISRAEL 0x01
+# endif
+# ifndef SUBLANG_HINDI_INDIA
+# define SUBLANG_HINDI_INDIA 0x01
+# endif
+# ifndef SUBLANG_HUNGARIAN_HUNGARY
+# define SUBLANG_HUNGARIAN_HUNGARY 0x01
+# endif
+# ifndef SUBLANG_ICELANDIC_ICELAND
+# define SUBLANG_ICELANDIC_ICELAND 0x01
+# endif
+# ifndef SUBLANG_IGBO_NIGERIA
+# define SUBLANG_IGBO_NIGERIA 0x01
+# endif
+# ifndef SUBLANG_INDONESIAN_INDONESIA
+# define SUBLANG_INDONESIAN_INDONESIA 0x01
+# endif
+# ifndef SUBLANG_INUKTITUT_CANADA
+# define SUBLANG_INUKTITUT_CANADA 0x01
+# endif
+# undef SUBLANG_INUKTITUT_CANADA_LATIN
+# define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
+# undef SUBLANG_IRISH_IRELAND
+# define SUBLANG_IRISH_IRELAND 0x02
+# ifndef SUBLANG_JAPANESE_JAPAN
+# define SUBLANG_JAPANESE_JAPAN 0x01
+# endif
+# ifndef SUBLANG_KANNADA_INDIA
+# define SUBLANG_KANNADA_INDIA 0x01
+# endif
+# ifndef SUBLANG_KASHMIRI_INDIA
+# define SUBLANG_KASHMIRI_INDIA 0x02
+# endif
+# ifndef SUBLANG_KAZAK_KAZAKHSTAN
+# define SUBLANG_KAZAK_KAZAKHSTAN 0x01
+# endif
+# ifndef SUBLANG_KICHE_GUATEMALA
+# define SUBLANG_KICHE_GUATEMALA 0x01
+# endif
+# ifndef SUBLANG_KINYARWANDA_RWANDA
+# define SUBLANG_KINYARWANDA_RWANDA 0x01
+# endif
+# ifndef SUBLANG_KONKANI_INDIA
+# define SUBLANG_KONKANI_INDIA 0x01
+# endif
+# ifndef SUBLANG_KYRGYZ_KYRGYZSTAN
+# define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
+# endif
+# ifndef SUBLANG_LAO_LAOS
+# define SUBLANG_LAO_LAOS 0x01
+# endif
+# ifndef SUBLANG_LATVIAN_LATVIA
+# define SUBLANG_LATVIAN_LATVIA 0x01
+# endif
+# ifndef SUBLANG_LITHUANIAN_LITHUANIA
+# define SUBLANG_LITHUANIAN_LITHUANIA 0x01
+# endif
+# undef SUBLANG_LOWER_SORBIAN_GERMANY
+# define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
+# ifndef SUBLANG_LUXEMBOURGISH_LUXEMBOURG
+# define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
+# endif
+# ifndef SUBLANG_MACEDONIAN_MACEDONIA
+# define SUBLANG_MACEDONIAN_MACEDONIA 0x01
+# endif
+# ifndef SUBLANG_MALAY_MALAYSIA
+# define SUBLANG_MALAY_MALAYSIA 0x01
+# endif
+# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
+# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
+# endif
+# ifndef SUBLANG_MALAYALAM_INDIA
+# define SUBLANG_MALAYALAM_INDIA 0x01
+# endif
+# ifndef SUBLANG_MALTESE_MALTA
+# define SUBLANG_MALTESE_MALTA 0x01
+# endif
+# ifndef SUBLANG_MAORI_NEW_ZEALAND
+# define SUBLANG_MAORI_NEW_ZEALAND 0x01
+# endif
+# ifndef SUBLANG_MAPUDUNGUN_CHILE
+# define SUBLANG_MAPUDUNGUN_CHILE 0x01
+# endif
+# ifndef SUBLANG_MARATHI_INDIA
+# define SUBLANG_MARATHI_INDIA 0x01
+# endif
+# ifndef SUBLANG_MOHAWK_CANADA
+# define SUBLANG_MOHAWK_CANADA 0x01
+# endif
+# ifndef SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA
+# define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
+# endif
+# ifndef SUBLANG_MONGOLIAN_PRC
+# define SUBLANG_MONGOLIAN_PRC 0x02
+# endif
+# ifndef SUBLANG_NEPALI_NEPAL
+# define SUBLANG_NEPALI_NEPAL 0x01
+# endif
+# ifndef SUBLANG_NEPALI_INDIA
+# define SUBLANG_NEPALI_INDIA 0x02
+# endif
+# ifndef SUBLANG_OCCITAN_FRANCE
+# define SUBLANG_OCCITAN_FRANCE 0x01
+# endif
+# ifndef SUBLANG_ORIYA_INDIA
+# define SUBLANG_ORIYA_INDIA 0x01
+# endif
+# ifndef SUBLANG_PASHTO_AFGHANISTAN
+# define SUBLANG_PASHTO_AFGHANISTAN 0x01
+# endif
+# ifndef SUBLANG_POLISH_POLAND
+# define SUBLANG_POLISH_POLAND 0x01
+# endif
+# ifndef SUBLANG_PUNJABI_INDIA
+# define SUBLANG_PUNJABI_INDIA 0x01
+# endif
+# ifndef SUBLANG_PUNJABI_PAKISTAN
+# define SUBLANG_PUNJABI_PAKISTAN 0x02
+# endif
+# ifndef SUBLANG_QUECHUA_BOLIVIA
+# define SUBLANG_QUECHUA_BOLIVIA 0x01
+# endif
+# ifndef SUBLANG_QUECHUA_ECUADOR
+# define SUBLANG_QUECHUA_ECUADOR 0x02
+# endif
+# ifndef SUBLANG_QUECHUA_PERU
+# define SUBLANG_QUECHUA_PERU 0x03
+# endif
+# ifndef SUBLANG_ROMANIAN_ROMANIA
+# define SUBLANG_ROMANIAN_ROMANIA 0x01
+# endif
+# ifndef SUBLANG_ROMANIAN_MOLDOVA
+# define SUBLANG_ROMANIAN_MOLDOVA 0x02
+# endif
+# ifndef SUBLANG_ROMANSH_SWITZERLAND
+# define SUBLANG_ROMANSH_SWITZERLAND 0x01
+# endif
+# ifndef SUBLANG_RUSSIAN_RUSSIA
+# define SUBLANG_RUSSIAN_RUSSIA 0x01
+# endif
+# ifndef SUBLANG_RUSSIAN_MOLDAVIA
+# define SUBLANG_RUSSIAN_MOLDAVIA 0x02
+# endif
+# ifndef SUBLANG_SAMI_NORTHERN_NORWAY
+# define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
+# endif
+# ifndef SUBLANG_SAMI_NORTHERN_SWEDEN
+# define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
+# endif
+# ifndef SUBLANG_SAMI_NORTHERN_FINLAND
+# define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
+# endif
+# ifndef SUBLANG_SAMI_LULE_NORWAY
+# define SUBLANG_SAMI_LULE_NORWAY 0x04
+# endif
+# ifndef SUBLANG_SAMI_LULE_SWEDEN
+# define SUBLANG_SAMI_LULE_SWEDEN 0x05
+# endif
+# ifndef SUBLANG_SAMI_SOUTHERN_NORWAY
+# define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
+# endif
+# ifndef SUBLANG_SAMI_SOUTHERN_SWEDEN
+# define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
+# endif
+# undef SUBLANG_SAMI_SKOLT_FINLAND
+# define SUBLANG_SAMI_SKOLT_FINLAND 0x08
+# undef SUBLANG_SAMI_INARI_FINLAND
+# define SUBLANG_SAMI_INARI_FINLAND 0x09
+# ifndef SUBLANG_SANSKRIT_INDIA
+# define SUBLANG_SANSKRIT_INDIA 0x01
+# endif
+# ifndef SUBLANG_SERBIAN_LATIN
+# define SUBLANG_SERBIAN_LATIN 0x02
+# endif
+# ifndef SUBLANG_SERBIAN_CYRILLIC
+# define SUBLANG_SERBIAN_CYRILLIC 0x03
+# endif
+# ifndef SUBLANG_SINDHI_INDIA
+# define SUBLANG_SINDHI_INDIA 0x01
+# endif
+# undef SUBLANG_SINDHI_PAKISTAN
+# define SUBLANG_SINDHI_PAKISTAN 0x02
+# ifndef SUBLANG_SINDHI_AFGHANISTAN
+# define SUBLANG_SINDHI_AFGHANISTAN 0x02
+# endif
+# ifndef SUBLANG_SINHALESE_SRI_LANKA
+# define SUBLANG_SINHALESE_SRI_LANKA 0x01
+# endif
+# ifndef SUBLANG_SLOVAK_SLOVAKIA
+# define SUBLANG_SLOVAK_SLOVAKIA 0x01
+# endif
+# ifndef SUBLANG_SLOVENIAN_SLOVENIA
+# define SUBLANG_SLOVENIAN_SLOVENIA 0x01
+# endif
+# ifndef SUBLANG_SOTHO_SOUTH_AFRICA
+# define SUBLANG_SOTHO_SOUTH_AFRICA 0x01
+# endif
+# ifndef SUBLANG_SPANISH_GUATEMALA
+# define SUBLANG_SPANISH_GUATEMALA 0x04
+# endif
+# ifndef SUBLANG_SPANISH_COSTA_RICA
+# define SUBLANG_SPANISH_COSTA_RICA 0x05
+# endif
+# ifndef SUBLANG_SPANISH_PANAMA
+# define SUBLANG_SPANISH_PANAMA 0x06
+# endif
+# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
+# endif
+# ifndef SUBLANG_SPANISH_VENEZUELA
+# define SUBLANG_SPANISH_VENEZUELA 0x08
+# endif
+# ifndef SUBLANG_SPANISH_COLOMBIA
+# define SUBLANG_SPANISH_COLOMBIA 0x09
+# endif
+# ifndef SUBLANG_SPANISH_PERU
+# define SUBLANG_SPANISH_PERU 0x0a
+# endif
+# ifndef SUBLANG_SPANISH_ARGENTINA
+# define SUBLANG_SPANISH_ARGENTINA 0x0b
+# endif
+# ifndef SUBLANG_SPANISH_ECUADOR
+# define SUBLANG_SPANISH_ECUADOR 0x0c
+# endif
+# ifndef SUBLANG_SPANISH_CHILE
+# define SUBLANG_SPANISH_CHILE 0x0d
+# endif
+# ifndef SUBLANG_SPANISH_URUGUAY
+# define SUBLANG_SPANISH_URUGUAY 0x0e
+# endif
+# ifndef SUBLANG_SPANISH_PARAGUAY
+# define SUBLANG_SPANISH_PARAGUAY 0x0f
+# endif
+# ifndef SUBLANG_SPANISH_BOLIVIA
+# define SUBLANG_SPANISH_BOLIVIA 0x10
+# endif
+# ifndef SUBLANG_SPANISH_EL_SALVADOR
+# define SUBLANG_SPANISH_EL_SALVADOR 0x11
+# endif
+# ifndef SUBLANG_SPANISH_HONDURAS
+# define SUBLANG_SPANISH_HONDURAS 0x12
+# endif
+# ifndef SUBLANG_SPANISH_NICARAGUA
+# define SUBLANG_SPANISH_NICARAGUA 0x13
+# endif
+# ifndef SUBLANG_SPANISH_PUERTO_RICO
+# define SUBLANG_SPANISH_PUERTO_RICO 0x14
+# endif
+# ifndef SUBLANG_SPANISH_US
+# define SUBLANG_SPANISH_US 0x15
+# endif
+# ifndef SUBLANG_SWAHILI_KENYA
+# define SUBLANG_SWAHILI_KENYA 0x01
+# endif
+# ifndef SUBLANG_SWEDISH_SWEDEN
+# define SUBLANG_SWEDISH_SWEDEN 0x01
+# endif
+# ifndef SUBLANG_SWEDISH_FINLAND
+# define SUBLANG_SWEDISH_FINLAND 0x02
+# endif
+# ifndef SUBLANG_SYRIAC_SYRIA
+# define SUBLANG_SYRIAC_SYRIA 0x01
+# endif
+# ifndef SUBLANG_TAGALOG_PHILIPPINES
+# define SUBLANG_TAGALOG_PHILIPPINES 0x01
+# endif
+# ifndef SUBLANG_TAJIK_TAJIKISTAN
+# define SUBLANG_TAJIK_TAJIKISTAN 0x01
+# endif
+# ifndef SUBLANG_TAMAZIGHT_ARABIC
+# define SUBLANG_TAMAZIGHT_ARABIC 0x01
+# endif
+# ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN
+# define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
+# endif
+# ifndef SUBLANG_TAMIL_INDIA
+# define SUBLANG_TAMIL_INDIA 0x01
+# endif
+# ifndef SUBLANG_TATAR_RUSSIA
+# define SUBLANG_TATAR_RUSSIA 0x01
+# endif
+# ifndef SUBLANG_TELUGU_INDIA
+# define SUBLANG_TELUGU_INDIA 0x01
+# endif
+# ifndef SUBLANG_THAI_THAILAND
+# define SUBLANG_THAI_THAILAND 0x01
+# endif
+# ifndef SUBLANG_TIBETAN_PRC
+# define SUBLANG_TIBETAN_PRC 0x01
+# endif
+# undef SUBLANG_TIBETAN_BHUTAN
+# define SUBLANG_TIBETAN_BHUTAN 0x02
+# ifndef SUBLANG_TIGRINYA_ETHIOPIA
+# define SUBLANG_TIGRINYA_ETHIOPIA 0x01
+# endif
+# ifndef SUBLANG_TIGRINYA_ERITREA
+# define SUBLANG_TIGRINYA_ERITREA 0x02
+# endif
+# ifndef SUBLANG_TSWANA_SOUTH_AFRICA
+# define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
+# endif
+# ifndef SUBLANG_TURKISH_TURKEY
+# define SUBLANG_TURKISH_TURKEY 0x01
+# endif
+# ifndef SUBLANG_TURKMEN_TURKMENISTAN
+# define SUBLANG_TURKMEN_TURKMENISTAN 0x01
+# endif
+# ifndef SUBLANG_UIGHUR_PRC
+# define SUBLANG_UIGHUR_PRC 0x01
+# endif
+# ifndef SUBLANG_UKRAINIAN_UKRAINE
+# define SUBLANG_UKRAINIAN_UKRAINE 0x01
+# endif
+# ifndef SUBLANG_UPPER_SORBIAN_GERMANY
+# define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
+# endif
+# ifndef SUBLANG_URDU_PAKISTAN
+# define SUBLANG_URDU_PAKISTAN 0x01
+# endif
+# ifndef SUBLANG_URDU_INDIA
+# define SUBLANG_URDU_INDIA 0x02
+# endif
+# ifndef SUBLANG_UZBEK_LATIN
+# define SUBLANG_UZBEK_LATIN 0x01
+# endif
+# ifndef SUBLANG_UZBEK_CYRILLIC
+# define SUBLANG_UZBEK_CYRILLIC 0x02
+# endif
+# ifndef SUBLANG_VIETNAMESE_VIETNAM
+# define SUBLANG_VIETNAMESE_VIETNAM 0x01
+# endif
+# ifndef SUBLANG_WELSH_UNITED_KINGDOM
+# define SUBLANG_WELSH_UNITED_KINGDOM 0x01
+# endif
+# ifndef SUBLANG_WOLOF_SENEGAL
+# define SUBLANG_WOLOF_SENEGAL 0x01
+# endif
+# ifndef SUBLANG_XHOSA_SOUTH_AFRICA
+# define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
+# endif
+# ifndef SUBLANG_YAKUT_RUSSIA
+# define SUBLANG_YAKUT_RUSSIA 0x01
+# endif
+# ifndef SUBLANG_YI_PRC
+# define SUBLANG_YI_PRC 0x01
+# endif
+# ifndef SUBLANG_YORUBA_NIGERIA
+# define SUBLANG_YORUBA_NIGERIA 0x01
+# endif
+# ifndef SUBLANG_ZULU_SOUTH_AFRICA
+# define SUBLANG_ZULU_SOUTH_AFRICA 0x01
+# endif
+/* GetLocaleInfoA operations.  */
+# ifndef LOCALE_SNAME
+# define LOCALE_SNAME 0x5c
+# endif
+#endif
+
+
+#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
+/* MacOS X 10.2 or newer */
+
+/* Canonicalize a MacOS X locale name to a Unix locale name.
+   NAME is a sufficiently large buffer.
+   On input, it contains the MacOS X locale name.
+   On output, it contains the Unix locale name.  */
+# if !defined IN_LIBINTL
+static
+# endif
+void
+gl_locale_name_canonicalize (char *name)
+{
+  /* This conversion is based on a posting by
+     Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08,
+     http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
+
+  /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
+     ISO 3166) names.  Prior to MacOS X 10.3, there is no API for doing this.
+     Therefore we do it ourselves, using a table based on the results of the
+     MacOS X 10.3.8 function
+     CFLocaleCreateCanonicalLocaleIdentifierFromString().  */
+  typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
+          legacy_entry;
+  static const legacy_entry legacy_table[] = {
+    { "Afrikaans",             "af" },
+    { "Albanian",              "sq" },
+    { "Amharic",               "am" },
+    { "Arabic",                "ar" },
+    { "Armenian",              "hy" },
+    { "Assamese",              "as" },
+    { "Aymara",                "ay" },
+    { "Azerbaijani",           "az" },
+    { "Basque",                "eu" },
+    { "Belarusian",            "be" },
+    { "Belorussian",           "be" },
+    { "Bengali",               "bn" },
+    { "Brazilian Portugese",   "pt_BR" },
+    { "Brazilian Portuguese",  "pt_BR" },
+    { "Breton",                "br" },
+    { "Bulgarian",             "bg" },
+    { "Burmese",               "my" },
+    { "Byelorussian",          "be" },
+    { "Catalan",               "ca" },
+    { "Chewa",                 "ny" },
+    { "Chichewa",              "ny" },
+    { "Chinese",               "zh" },
+    { "Chinese, Simplified",   "zh_CN" },
+    { "Chinese, Traditional",  "zh_TW" },
+    { "Chinese, Tradtional",   "zh_TW" },
+    { "Croatian",              "hr" },
+    { "Czech",                 "cs" },
+    { "Danish",                "da" },
+    { "Dutch",                 "nl" },
+    { "Dzongkha",              "dz" },
+    { "English",               "en" },
+    { "Esperanto",             "eo" },
+    { "Estonian",              "et" },
+    { "Faroese",               "fo" },
+    { "Farsi",                 "fa" },
+    { "Finnish",               "fi" },
+    { "Flemish",               "nl_BE" },
+    { "French",                "fr" },
+    { "Galician",              "gl" },
+    { "Gallegan",              "gl" },
+    { "Georgian",              "ka" },
+    { "German",                "de" },
+    { "Greek",                 "el" },
+    { "Greenlandic",           "kl" },
+    { "Guarani",               "gn" },
+    { "Gujarati",              "gu" },
+    { "Hawaiian",              "haw" }, /* Yes, "haw", not "cpe".  */
+    { "Hebrew",                "he" },
+    { "Hindi",                 "hi" },
+    { "Hungarian",             "hu" },
+    { "Icelandic",             "is" },
+    { "Indonesian",            "id" },
+    { "Inuktitut",             "iu" },
+    { "Irish",                 "ga" },
+    { "Italian",               "it" },
+    { "Japanese",              "ja" },
+    { "Javanese",              "jv" },
+    { "Kalaallisut",           "kl" },
+    { "Kannada",               "kn" },
+    { "Kashmiri",              "ks" },
+    { "Kazakh",                "kk" },
+    { "Khmer",                 "km" },
+    { "Kinyarwanda",           "rw" },
+    { "Kirghiz",               "ky" },
+    { "Korean",                "ko" },
+    { "Kurdish",               "ku" },
+    { "Latin",                 "la" },
+    { "Latvian",               "lv" },
+    { "Lithuanian",            "lt" },
+    { "Macedonian",            "mk" },
+    { "Malagasy",              "mg" },
+    { "Malay",                 "ms" },
+    { "Malayalam",             "ml" },
+    { "Maltese",               "mt" },
+    { "Manx",                  "gv" },
+    { "Marathi",               "mr" },
+    { "Moldavian",             "mo" },
+    { "Mongolian",             "mn" },
+    { "Nepali",                "ne" },
+    { "Norwegian",             "nb" }, /* Yes, "nb", not the obsolete "no".  */
+    { "Nyanja",                "ny" },
+    { "Nynorsk",               "nn" },
+    { "Oriya",                 "or" },
+    { "Oromo",                 "om" },
+    { "Panjabi",               "pa" },
+    { "Pashto",                "ps" },
+    { "Persian",               "fa" },
+    { "Polish",                "pl" },
+    { "Portuguese",            "pt" },
+    { "Portuguese, Brazilian", "pt_BR" },
+    { "Punjabi",               "pa" },
+    { "Pushto",                "ps" },
+    { "Quechua",               "qu" },
+    { "Romanian",              "ro" },
+    { "Ruanda",                "rw" },
+    { "Rundi",                 "rn" },
+    { "Russian",               "ru" },
+    { "Sami",                  "se_NO" }, /* Not just "se".  */
+    { "Sanskrit",              "sa" },
+    { "Scottish",              "gd" },
+    { "Serbian",               "sr" },
+    { "Simplified Chinese",    "zh_CN" },
+    { "Sindhi",                "sd" },
+    { "Sinhalese",             "si" },
+    { "Slovak",                "sk" },
+    { "Slovenian",             "sl" },
+    { "Somali",                "so" },
+    { "Spanish",               "es" },
+    { "Sundanese",             "su" },
+    { "Swahili",               "sw" },
+    { "Swedish",               "sv" },
+    { "Tagalog",               "tl" },
+    { "Tajik",                 "tg" },
+    { "Tajiki",                "tg" },
+    { "Tamil",                 "ta" },
+    { "Tatar",                 "tt" },
+    { "Telugu",                "te" },
+    { "Thai",                  "th" },
+    { "Tibetan",               "bo" },
+    { "Tigrinya",              "ti" },
+    { "Tongan",                "to" },
+    { "Traditional Chinese",   "zh_TW" },
+    { "Turkish",               "tr" },
+    { "Turkmen",               "tk" },
+    { "Uighur",                "ug" },
+    { "Ukrainian",             "uk" },
+    { "Urdu",                  "ur" },
+    { "Uzbek",                 "uz" },
+    { "Vietnamese",            "vi" },
+    { "Welsh",                 "cy" },
+    { "Yiddish",               "yi" }
+  };
+
+  /* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
+     to Unix (ISO 639 and ISO 3166) names.  */
+  typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
+          langtag_entry;
+  static const langtag_entry langtag_table[] = {
+    /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn".
+       The default script for az on Unix is Latin.  */
+    { "az-Latn", "az" },
+    /* MacOS X has "ga-dots".  Does not yet exist on Unix.  */
+    { "ga-dots", "ga" },
+    /* MacOS X has "kk-Cyrl".  Does not yet exist on Unix.  */
+    /* MacOS X has "mn-Cyrl", "mn-Mong".
+       The default script for mn on Unix is Cyrillic.  */
+    { "mn-Cyrl", "mn" },
+    /* MacOS X has "ms-Arab", "ms-Latn".
+       The default script for ms on Unix is Latin.  */
+    { "ms-Latn", "ms" },
+    /* MacOS X has "tg-Cyrl".
+       The default script for tg on Unix is Cyrillic.  */
+    { "tg-Cyrl", "tg" },
+    /* MacOS X has "tk-Cyrl".  Does not yet exist on Unix.  */
+    /* MacOS X has "tt-Cyrl".
+       The default script for tt on Unix is Cyrillic.  */
+    { "tt-Cyrl", "tt" },
+    /* MacOS X has "zh-Hans", "zh-Hant".
+       Country codes are used to distinguish these on Unix.  */
+    { "zh-Hans", "zh_CN" },
+    { "zh-Hant", "zh_TW" }
+  };
+
+  /* Convert script names (ISO 15924) to Unix conventions.
+     See http://www.unicode.org/iso15924/iso15924-codes.html  */
+  typedef struct { const char script[4+1]; const char unixy[9+1]; }
+          script_entry;
+  static const script_entry script_table[] = {
+    { "Arab", "arabic" },
+    { "Cyrl", "cyrillic" },
+    { "Mong", "mongolian" }
+  };
+
+  /* Step 1: Convert using legacy_table.  */
+  if (name[0] >= 'A' && name[0] <= 'Z')
+    {
+      unsigned int i1, i2;
+      i1 = 0;
+      i2 = sizeof (legacy_table) / sizeof (legacy_entry);
+      while (i2 - i1 > 1)
+        {
+          /* At this point we know that if name occurs in legacy_table,
+             its index must be >= i1 and < i2.  */
+          unsigned int i = (i1 + i2) >> 1;
+          const legacy_entry *p = &legacy_table[i];
+          if (strcmp (name, p->legacy) < 0)
+            i2 = i;
+          else
+            i1 = i;
+        }
+      if (strcmp (name, legacy_table[i1].legacy) == 0)
+        {
+          strcpy (name, legacy_table[i1].unixy);
+          return;
+        }
+    }
+
+  /* Step 2: Convert using langtag_table and script_table.  */
+  if (strlen (name) == 7 && name[2] == '-')
+    {
+      unsigned int i1, i2;
+      i1 = 0;
+      i2 = sizeof (langtag_table) / sizeof (langtag_entry);
+      while (i2 - i1 > 1)
+        {
+          /* At this point we know that if name occurs in langtag_table,
+             its index must be >= i1 and < i2.  */
+          unsigned int i = (i1 + i2) >> 1;
+          const langtag_entry *p = &langtag_table[i];
+          if (strcmp (name, p->langtag) < 0)
+            i2 = i;
+          else
+            i1 = i;
+        }
+      if (strcmp (name, langtag_table[i1].langtag) == 0)
+        {
+          strcpy (name, langtag_table[i1].unixy);
+          return;
+        }
+
+      i1 = 0;
+      i2 = sizeof (script_table) / sizeof (script_entry);
+      while (i2 - i1 > 1)
+        {
+          /* At this point we know that if (name + 3) occurs in script_table,
+             its index must be >= i1 and < i2.  */
+          unsigned int i = (i1 + i2) >> 1;
+          const script_entry *p = &script_table[i];
+          if (strcmp (name + 3, p->script) < 0)
+            i2 = i;
+          else
+            i1 = i;
+        }
+      if (strcmp (name + 3, script_table[i1].script) == 0)
+        {
+          name[2] = '@';
+          strcpy (name + 3, script_table[i1].unixy);
+          return;
+        }
+    }
+
+  /* Step 3: Convert new-style dash to Unix underscore. */
+  {
+    char *p;
+    for (p = name; *p != '\0'; p++)
+      if (*p == '-')
+        *p = '_';
+  }
+}
+
+#endif
+
+
+#if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+
+/* Canonicalize a Win32 native locale name to a Unix locale name.
+   NAME is a sufficiently large buffer.
+   On input, it contains the Win32 locale name.
+   On output, it contains the Unix locale name.  */
+# if !defined IN_LIBINTL
+static
+# endif
+void
+gl_locale_name_canonicalize (char *name)
+{
+  /* FIXME: This is probably incomplete: it does not handle "zh-Hans" and
+     "zh-Hant".  */
+  char *p;
+
+  for (p = name; *p != '\0'; p++)
+    if (*p == '-')
+      {
+        *p = '_';
+        p++;
+        for (; *p != '\0'; p++)
+          {
+            if (*p >= 'a' && *p <= 'z')
+              *p += 'A' - 'a';
+            if (*p == '-')
+              {
+                *p = '\0';
+                return;
+              }
+          }
+        return;
+      }
+}
+
+# if !defined IN_LIBINTL
+static
+# endif
+const char *
+gl_locale_name_from_win32_LANGID (LANGID langid)
+{
+  /* Activate the new code only when the GETTEXT_MUI environment variable is
+     set, for the time being, since the new code is not well tested.  */
+  if (getenv ("GETTEXT_MUI") != NULL)
+    {
+      static char namebuf[256];
+
+      /* Query the system's notion of locale name.
+         On Windows95/98/ME, GetLocaleInfoA returns some incorrect results.
+         But we don't need to support systems that are so old.  */
+      if (GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), LOCALE_SNAME,
+                          namebuf, sizeof (namebuf) - 1))
+        {
+          /* Convert it to a Unix locale name.  */
+          gl_locale_name_canonicalize (namebuf);
+          return namebuf;
+        }
+    }
+  /* Internet Explorer has an LCID to RFC3066 name mapping stored in
+     HKEY_CLASSES_ROOT\Mime\Database\Rfc1766.  But we better don't use that
+     since IE's i18n subsystem is known to be inconsistent with the Win32 base
+     (e.g. they have different character conversion facilities that produce
+     different results).  */
+  /* Use our own table.  */
+  {
+    int primary, sub;
+
+    /* Split into language and territory part.  */
+    primary = PRIMARYLANGID (langid);
+    sub = SUBLANGID (langid);
+
+    /* Dispatch on language.
+       See also http://www.unicode.org/unicode/onlinedat/languages.html .
+       For details about languages, see http://www.ethnologue.com/ .  */
+    switch (primary)
+      {
+      case LANG_AFRIKAANS:
+        switch (sub)
+          {
+          case SUBLANG_AFRIKAANS_SOUTH_AFRICA: return "af_ZA";
+          }
+        return "af";
+      case LANG_ALBANIAN:
+        switch (sub)
+          {
+          case SUBLANG_ALBANIAN_ALBANIA: return "sq_AL";
+          }
+        return "sq";
+      case LANG_ALSATIAN:
+        switch (sub)
+          {
+          case SUBLANG_ALSATIAN_FRANCE: return "gsw_FR";
+          }
+        return "gsw";
+      case LANG_AMHARIC:
+        switch (sub)
+          {
+          case SUBLANG_AMHARIC_ETHIOPIA: return "am_ET";
+          }
+        return "am";
+      case LANG_ARABIC:
+        switch (sub)
+          {
+          case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
+          case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
+          case SUBLANG_ARABIC_EGYPT: return "ar_EG";
+          case SUBLANG_ARABIC_LIBYA: return "ar_LY";
+          case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
+          case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
+          case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
+          case SUBLANG_ARABIC_OMAN: return "ar_OM";
+          case SUBLANG_ARABIC_YEMEN: return "ar_YE";
+          case SUBLANG_ARABIC_SYRIA: return "ar_SY";
+          case SUBLANG_ARABIC_JORDAN: return "ar_JO";
+          case SUBLANG_ARABIC_LEBANON: return "ar_LB";
+          case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
+          case SUBLANG_ARABIC_UAE: return "ar_AE";
+          case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
+          case SUBLANG_ARABIC_QATAR: return "ar_QA";
+          }
+        return "ar";
+      case LANG_ARMENIAN:
+        switch (sub)
+          {
+          case SUBLANG_ARMENIAN_ARMENIA: return "hy_AM";
+          }
+        return "hy";
+      case LANG_ASSAMESE:
+        switch (sub)
+          {
+          case SUBLANG_ASSAMESE_INDIA: return "as_IN";
+          }
+        return "as";
+      case LANG_AZERI:
+        switch (sub)
+          {
+          /* FIXME: Adjust this when Azerbaijani locales appear on Unix.  */
+          case 0x1e: return "az@latin";
+          case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
+          case 0x1d: return "az@cyrillic";
+          case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
+          }
+        return "az";
+      case LANG_BASHKIR:
+        switch (sub)
+          {
+          case SUBLANG_BASHKIR_RUSSIA: return "ba_RU";
+          }
+        return "ba";
+      case LANG_BASQUE:
+        switch (sub)
+          {
+          case SUBLANG_BASQUE_BASQUE: return "eu_ES";
+          }
+        return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR".  */
+      case LANG_BELARUSIAN:
+        switch (sub)
+          {
+          case SUBLANG_BELARUSIAN_BELARUS: return "be_BY";
+          }
+        return "be";
+      case LANG_BENGALI:
+        switch (sub)
+          {
+          case SUBLANG_BENGALI_INDIA: return "bn_IN";
+          case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
+          }
+        return "bn";
+      case LANG_BRETON:
+        switch (sub)
+          {
+          case SUBLANG_BRETON_FRANCE: return "br_FR";
+          }
+        return "br";
+      case LANG_BULGARIAN:
+        switch (sub)
+          {
+          case SUBLANG_BULGARIAN_BULGARIA: return "bg_BG";
+          }
+        return "bg";
+      case LANG_BURMESE:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "my_MM";
+          }
+        return "my";
+      case LANG_CAMBODIAN:
+        switch (sub)
+          {
+          case SUBLANG_CAMBODIAN_CAMBODIA: return "km_KH";
+          }
+        return "km";
+      case LANG_CATALAN:
+        switch (sub)
+          {
+          case SUBLANG_CATALAN_SPAIN: return "ca_ES";
+          }
+        return "ca";
+      case LANG_CHEROKEE:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "chr_US";
+          }
+        return "chr";
+      case LANG_CHINESE:
+        switch (sub)
+          {
+          case SUBLANG_CHINESE_TRADITIONAL: case 0x1f: return "zh_TW";
+          case SUBLANG_CHINESE_SIMPLIFIED: case 0x00: return "zh_CN";
+          case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; /* traditional */
+          case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; /* simplified */
+          case SUBLANG_CHINESE_MACAU: return "zh_MO"; /* traditional */
+          }
+        return "zh";
+      case LANG_CORSICAN:
+        switch (sub)
+          {
+          case SUBLANG_CORSICAN_FRANCE: return "co_FR";
+          }
+        return "co";
+      case LANG_CROATIAN:      /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN
+                                * What used to be called Serbo-Croatian
+                                * should really now be two separate
+                                * languages because of political reasons.
+                                * (Says tml, who knows nothing about Serbian
+                                * or Croatian.)
+                                * (I can feel those flames coming already.)
+                                */
+        switch (sub)
+          {
+          /* Croatian */
+          case 0x00: return "hr";
+          case SUBLANG_CROATIAN_CROATIA: return "hr_HR";
+          case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: return "hr_BA";
+          /* Serbian */
+          case 0x1f: return "sr";
+          case 0x1c: return "sr"; /* latin */
+          case SUBLANG_SERBIAN_LATIN: return "sr_CS"; /* latin */
+          case 0x09: return "sr_RS"; /* latin */
+          case 0x0b: return "sr_ME"; /* latin */
+          case 0x06: return "sr_BA"; /* latin */
+          case 0x1b: return "sr@cyrillic";
+          case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
+          case 0x0a: return "sr_RS@cyrillic";
+          case 0x0c: return "sr_ME@cyrillic";
+          case 0x07: return "sr_BA@cyrillic";
+          /* Bosnian */
+          case 0x1e: return "bs";
+          case 0x1a: return "bs"; /* latin */
+          case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: return "bs_BA"; /* latin */
+          case 0x19: return "bs@cyrillic";
+          case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: return "bs_BA@cyrillic";
+          }
+        return "hr";
+      case LANG_CZECH:
+        switch (sub)
+          {
+          case SUBLANG_CZECH_CZECH_REPUBLIC: return "cs_CZ";
+          }
+        return "cs";
+      case LANG_DANISH:
+        switch (sub)
+          {
+          case SUBLANG_DANISH_DENMARK: return "da_DK";
+          }
+        return "da";
+      case LANG_DARI:
+        /* FIXME: Adjust this when such locales appear on Unix.  */
+        switch (sub)
+          {
+          case SUBLANG_DARI_AFGHANISTAN: return "prs_AF";
+          }
+        return "prs";
+      case LANG_DIVEHI:
+        switch (sub)
+          {
+          case SUBLANG_DIVEHI_MALDIVES: return "dv_MV";
+          }
+        return "dv";
+      case LANG_DUTCH:
+        switch (sub)
+          {
+          case SUBLANG_DUTCH: return "nl_NL";
+          case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
+          case SUBLANG_DUTCH_SURINAM: return "nl_SR";
+          }
+        return "nl";
+      case LANG_EDO:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "bin_NG";
+          }
+        return "bin";
+      case LANG_ENGLISH:
+        switch (sub)
+          {
+          /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
+           * English was the language spoken in England.
+           * Oh well.
+           */
+          case SUBLANG_ENGLISH_US: return "en_US";
+          case SUBLANG_ENGLISH_UK: return "en_GB";
+          case SUBLANG_ENGLISH_AUS: return "en_AU";
+          case SUBLANG_ENGLISH_CAN: return "en_CA";
+          case SUBLANG_ENGLISH_NZ: return "en_NZ";
+          case SUBLANG_ENGLISH_EIRE: return "en_IE";
+          case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
+          case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
+          case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
+          case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
+          case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
+          case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
+          case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
+          case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
+          case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
+          case SUBLANG_ENGLISH_INDIA: return "en_IN";
+          case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
+          case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
+          }
+        return "en";
+      case LANG_ESTONIAN:
+        switch (sub)
+          {
+          case SUBLANG_ESTONIAN_ESTONIA: return "et_EE";
+          }
+        return "et";
+      case LANG_FAEROESE:
+        switch (sub)
+          {
+          case SUBLANG_FAEROESE_FAROE_ISLANDS: return "fo_FO";
+          }
+        return "fo";
+      case LANG_FARSI:
+        switch (sub)
+          {
+          case SUBLANG_FARSI_IRAN: return "fa_IR";
+          }
+        return "fa";
+      case LANG_FINNISH:
+        switch (sub)
+          {
+          case SUBLANG_FINNISH_FINLAND: return "fi_FI";
+          }
+        return "fi";
+      case LANG_FRENCH:
+        switch (sub)
+          {
+          case SUBLANG_FRENCH: return "fr_FR";
+          case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
+          case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
+          case SUBLANG_FRENCH_SWISS: return "fr_CH";
+          case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
+          case SUBLANG_FRENCH_MONACO: return "fr_MC";
+          case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
+          case SUBLANG_FRENCH_REUNION: return "fr_RE";
+          case SUBLANG_FRENCH_CONGO: return "fr_CG";
+          case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
+          case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
+          case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
+          case SUBLANG_FRENCH_MALI: return "fr_ML";
+          case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
+          case SUBLANG_FRENCH_HAITI: return "fr_HT";
+          }
+        return "fr";
+      case LANG_FRISIAN:
+        switch (sub)
+          {
+          case SUBLANG_FRISIAN_NETHERLANDS: return "fy_NL";
+          }
+        return "fy";
+      case LANG_FULFULDE:
+        /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin.  */
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "ff_NG";
+          }
+        return "ff";
+      case LANG_GAELIC:
+        switch (sub)
+          {
+          case 0x01: /* SCOTTISH */
+            /* old, superseded by LANG_SCOTTISH_GAELIC */
+            return "gd_GB";
+          case SUBLANG_IRISH_IRELAND: return "ga_IE";
+          }
+        return "ga";
+      case LANG_GALICIAN:
+        switch (sub)
+          {
+          case SUBLANG_GALICIAN_SPAIN: return "gl_ES";
+          }
+        return "gl";
+      case LANG_GEORGIAN:
+        switch (sub)
+          {
+          case SUBLANG_GEORGIAN_GEORGIA: return "ka_GE";
+          }
+        return "ka";
+      case LANG_GERMAN:
+        switch (sub)
+          {
+          case SUBLANG_GERMAN: return "de_DE";
+          case SUBLANG_GERMAN_SWISS: return "de_CH";
+          case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
+          case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
+          case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
+          }
+        return "de";
+      case LANG_GREEK:
+        switch (sub)
+          {
+          case SUBLANG_GREEK_GREECE: return "el_GR";
+          }
+        return "el";
+      case LANG_GREENLANDIC:
+        switch (sub)
+          {
+          case SUBLANG_GREENLANDIC_GREENLAND: return "kl_GL";
+          }
+        return "kl";
+      case LANG_GUARANI:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "gn_PY";
+          }
+        return "gn";
+      case LANG_GUJARATI:
+        switch (sub)
+          {
+          case SUBLANG_GUJARATI_INDIA: return "gu_IN";
+          }
+        return "gu";
+      case LANG_HAUSA:
+        switch (sub)
+          {
+          case 0x1f: return "ha";
+          case SUBLANG_HAUSA_NIGERIA_LATIN: return "ha_NG";
+          }
+        return "ha";
+      case LANG_HAWAIIAN:
+        /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
+           or Hawaii Creole English ("cpe_US", 600000 speakers)?  */
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "cpe_US";
+          }
+        return "cpe";
+      case LANG_HEBREW:
+        switch (sub)
+          {
+          case SUBLANG_HEBREW_ISRAEL: return "he_IL";
+          }
+        return "he";
+      case LANG_HINDI:
+        switch (sub)
+          {
+          case SUBLANG_HINDI_INDIA: return "hi_IN";
+          }
+        return "hi";
+      case LANG_HUNGARIAN:
+        switch (sub)
+          {
+          case SUBLANG_HUNGARIAN_HUNGARY: return "hu_HU";
+          }
+        return "hu";
+      case LANG_IBIBIO:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "nic_NG";
+          }
+        return "nic";
+      case LANG_ICELANDIC:
+        switch (sub)
+          {
+          case SUBLANG_ICELANDIC_ICELAND: return "is_IS";
+          }
+        return "is";
+      case LANG_IGBO:
+        switch (sub)
+          {
+          case SUBLANG_IGBO_NIGERIA: return "ig_NG";
+          }
+        return "ig";
+      case LANG_INDONESIAN:
+        switch (sub)
+          {
+          case SUBLANG_INDONESIAN_INDONESIA: return "id_ID";
+          }
+        return "id";
+      case LANG_INUKTITUT:
+        switch (sub)
+          {
+          case 0x1e: return "iu"; /* syllabic */
+          case SUBLANG_INUKTITUT_CANADA: return "iu_CA"; /* syllabic */
+          case 0x1f: return "iu@latin";
+          case SUBLANG_INUKTITUT_CANADA_LATIN: return "iu_CA@latin";
+          }
+        return "iu";
+      case LANG_ITALIAN:
+        switch (sub)
+          {
+          case SUBLANG_ITALIAN: return "it_IT";
+          case SUBLANG_ITALIAN_SWISS: return "it_CH";
+          }
+        return "it";
+      case LANG_JAPANESE:
+        switch (sub)
+          {
+          case SUBLANG_JAPANESE_JAPAN: return "ja_JP";
+          }
+        return "ja";
+      case LANG_KANNADA:
+        switch (sub)
+          {
+          case SUBLANG_KANNADA_INDIA: return "kn_IN";
+          }
+        return "kn";
+      case LANG_KANURI:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "kr_NG";
+          }
+        return "kr";
+      case LANG_KASHMIRI:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "ks_PK";
+          case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
+          }
+        return "ks";
+      case LANG_KAZAK:
+        switch (sub)
+          {
+          case SUBLANG_KAZAK_KAZAKHSTAN: return "kk_KZ";
+          }
+        return "kk";
+      case LANG_KICHE:
+        /* FIXME: Adjust this when such locales appear on Unix.  */
+        switch (sub)
+          {
+          case SUBLANG_KICHE_GUATEMALA: return "qut_GT";
+          }
+        return "qut";
+      case LANG_KINYARWANDA:
+        switch (sub)
+          {
+          case SUBLANG_KINYARWANDA_RWANDA: return "rw_RW";
+          }
+        return "rw";
+      case LANG_KONKANI:
+        /* FIXME: Adjust this when such locales appear on Unix.  */
+        switch (sub)
+          {
+          case SUBLANG_KONKANI_INDIA: return "kok_IN";
+          }
+        return "kok";
+      case LANG_KOREAN:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "ko_KR";
+          }
+        return "ko";
+      case LANG_KYRGYZ:
+        switch (sub)
+          {
+          case SUBLANG_KYRGYZ_KYRGYZSTAN: return "ky_KG";
+          }
+        return "ky";
+      case LANG_LAO:
+        switch (sub)
+          {
+          case SUBLANG_LAO_LAOS: return "lo_LA";
+          }
+        return "lo";
+      case LANG_LATIN:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "la_VA";
+          }
+        return "la";
+      case LANG_LATVIAN:
+        switch (sub)
+          {
+          case SUBLANG_LATVIAN_LATVIA: return "lv_LV";
+          }
+        return "lv";
+      case LANG_LITHUANIAN:
+        switch (sub)
+          {
+          case SUBLANG_LITHUANIAN_LITHUANIA: return "lt_LT";
+          }
+        return "lt";
+      case LANG_LUXEMBOURGISH:
+        switch (sub)
+          {
+          case SUBLANG_LUXEMBOURGISH_LUXEMBOURG: return "lb_LU";
+          }
+        return "lb";
+      case LANG_MACEDONIAN:
+        switch (sub)
+          {
+          case SUBLANG_MACEDONIAN_MACEDONIA: return "mk_MK";
+          }
+        return "mk";
+      case LANG_MALAY:
+        switch (sub)
+          {
+          case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
+          case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
+          }
+        return "ms";
+      case LANG_MALAYALAM:
+        switch (sub)
+          {
+          case SUBLANG_MALAYALAM_INDIA: return "ml_IN";
+          }
+        return "ml";
+      case LANG_MALTESE:
+        switch (sub)
+          {
+          case SUBLANG_MALTESE_MALTA: return "mt_MT";
+          }
+        return "mt";
+      case LANG_MANIPURI:
+        /* FIXME: Adjust this when such locales appear on Unix.  */
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "mni_IN";
+          }
+        return "mni";
+      case LANG_MAORI:
+        switch (sub)
+          {
+          case SUBLANG_MAORI_NEW_ZEALAND: return "mi_NZ";
+          }
+        return "mi";
+      case LANG_MAPUDUNGUN:
+        switch (sub)
+          {
+          case SUBLANG_MAPUDUNGUN_CHILE: return "arn_CL";
+          }
+        return "arn";
+      case LANG_MARATHI:
+        switch (sub)
+          {
+          case SUBLANG_MARATHI_INDIA: return "mr_IN";
+          }
+        return "mr";
+      case LANG_MOHAWK:
+        switch (sub)
+          {
+          case SUBLANG_MOHAWK_CANADA: return "moh_CA";
+          }
+        return "moh";
+      case LANG_MONGOLIAN:
+        switch (sub)
+          {
+          case SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: case 0x1e: return "mn_MN";
+          case SUBLANG_MONGOLIAN_PRC: case 0x1f: return "mn_CN";
+          }
+        return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN".  */
+      case LANG_NEPALI:
+        switch (sub)
+          {
+          case SUBLANG_NEPALI_NEPAL: return "ne_NP";
+          case SUBLANG_NEPALI_INDIA: return "ne_IN";
+          }
+        return "ne";
+      case LANG_NORWEGIAN:
+        switch (sub)
+          {
+          case 0x1f: return "nb";
+          case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO";
+          case 0x1e: return "nn";
+          case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
+          }
+        return "no";
+      case LANG_OCCITAN:
+        switch (sub)
+          {
+          case SUBLANG_OCCITAN_FRANCE: return "oc_FR";
+          }
+        return "oc";
+      case LANG_ORIYA:
+        switch (sub)
+          {
+          case SUBLANG_ORIYA_INDIA: return "or_IN";
+          }
+        return "or";
+      case LANG_OROMO:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "om_ET";
+          }
+        return "om";
+      case LANG_PAPIAMENTU:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "pap_AN";
+          }
+        return "pap";
+      case LANG_PASHTO:
+        switch (sub)
+          {
+          case SUBLANG_PASHTO_AFGHANISTAN: return "ps_AF";
+          }
+        return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF".  */
+      case LANG_POLISH:
+        switch (sub)
+          {
+          case SUBLANG_POLISH_POLAND: return "pl_PL";
+          }
+        return "pl";
+      case LANG_PORTUGUESE:
+        switch (sub)
+          {
+          /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
+             Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
+          case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
+          case SUBLANG_PORTUGUESE: return "pt_PT";
+          }
+        return "pt";
+      case LANG_PUNJABI:
+        switch (sub)
+          {
+          case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
+          case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
+          }
+        return "pa";
+      case LANG_QUECHUA:
+        /* Note: Microsoft uses the non-ISO language code "quz".  */
+        switch (sub)
+          {
+          case SUBLANG_QUECHUA_BOLIVIA: return "qu_BO";
+          case SUBLANG_QUECHUA_ECUADOR: return "qu_EC";
+          case SUBLANG_QUECHUA_PERU: return "qu_PE";
+          }
+        return "qu";
+      case LANG_ROMANIAN:
+        switch (sub)
+          {
+          case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
+          case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
+          }
+        return "ro";
+      case LANG_ROMANSH:
+        switch (sub)
+          {
+          case SUBLANG_ROMANSH_SWITZERLAND: return "rm_CH";
+          }
+        return "rm";
+      case LANG_RUSSIAN:
+        switch (sub)
+          {
+          case SUBLANG_RUSSIAN_RUSSIA: return "ru_RU";
+          case SUBLANG_RUSSIAN_MOLDAVIA: return "ru_MD";
+          }
+        return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD".  */
+      case LANG_SAMI:
+        switch (sub)
+          {
+          /* Northern Sami */
+          case 0x00: return "se";
+          case SUBLANG_SAMI_NORTHERN_NORWAY: return "se_NO";
+          case SUBLANG_SAMI_NORTHERN_SWEDEN: return "se_SE";
+          case SUBLANG_SAMI_NORTHERN_FINLAND: return "se_FI";
+          /* Lule Sami */
+          case 0x1f: return "smj";
+          case SUBLANG_SAMI_LULE_NORWAY: return "smj_NO";
+          case SUBLANG_SAMI_LULE_SWEDEN: return "smj_SE";
+          /* Southern Sami */
+          case 0x1e: return "sma";
+          case SUBLANG_SAMI_SOUTHERN_NORWAY: return "sma_NO";
+          case SUBLANG_SAMI_SOUTHERN_SWEDEN: return "sma_SE";
+          /* Skolt Sami */
+          case 0x1d: return "sms";
+          case SUBLANG_SAMI_SKOLT_FINLAND: return "sms_FI";
+          /* Inari Sami */
+          case 0x1c: return "smn";
+          case SUBLANG_SAMI_INARI_FINLAND: return "smn_FI";
+          }
+        return "se"; /* or "smi"? */
+      case LANG_SANSKRIT:
+        switch (sub)
+          {
+          case SUBLANG_SANSKRIT_INDIA: return "sa_IN";
+          }
+        return "sa";
+      case LANG_SCOTTISH_GAELIC:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "gd_GB";
+          }
+        return "gd";
+      case LANG_SINDHI:
+        switch (sub)
+          {
+          case SUBLANG_SINDHI_INDIA: return "sd_IN";
+          case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
+          /*case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF";*/
+          }
+        return "sd";
+      case LANG_SINHALESE:
+        switch (sub)
+          {
+          case SUBLANG_SINHALESE_SRI_LANKA: return "si_LK";
+          }
+        return "si";
+      case LANG_SLOVAK:
+        switch (sub)
+          {
+          case SUBLANG_SLOVAK_SLOVAKIA: return "sk_SK";
+          }
+        return "sk";
+      case LANG_SLOVENIAN:
+        switch (sub)
+          {
+          case SUBLANG_SLOVENIAN_SLOVENIA: return "sl_SI";
+          }
+        return "sl";
+      case LANG_SOMALI:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "so_SO";
+          }
+        return "so";
+      case LANG_SORBIAN:
+        /* FIXME: Adjust this when such locales appear on Unix.  */
+        switch (sub)
+          {
+          /* Upper Sorbian */
+          case 0x00: return "hsb";
+          case SUBLANG_UPPER_SORBIAN_GERMANY: return "hsb_DE";
+          /* Lower Sorbian */
+          case 0x1f: return "dsb";
+          case SUBLANG_LOWER_SORBIAN_GERMANY: return "dsb_DE";
+          }
+        return "wen";
+      case LANG_SOTHO:
+        /* <http://www.microsoft.com/globaldev/reference/lcid-all.mspx> calls
+           it "Sepedi"; according to
+           <http://www.ethnologue.com/show_language.asp?code=nso>
+           <http://www.ethnologue.com/show_language.asp?code=sot>
+           it's the same as Northern Sotho.  */
+        switch (sub)
+          {
+          case SUBLANG_SOTHO_SOUTH_AFRICA: return "nso_ZA";
+          }
+        return "nso";
+      case LANG_SPANISH:
+        switch (sub)
+          {
+          case SUBLANG_SPANISH: return "es_ES";
+          case SUBLANG_SPANISH_MEXICAN: return "es_MX";
+          case SUBLANG_SPANISH_MODERN:
+            return "es_ES@modern";      /* not seen on Unix */
+          case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
+          case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
+          case SUBLANG_SPANISH_PANAMA: return "es_PA";
+          case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
+          case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
+          case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
+          case SUBLANG_SPANISH_PERU: return "es_PE";
+          case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
+          case SUBLANG_SPANISH_ECUADOR: return "es_EC";
+          case SUBLANG_SPANISH_CHILE: return "es_CL";
+          case SUBLANG_SPANISH_URUGUAY: return "es_UY";
+          case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
+          case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
+          case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
+          case SUBLANG_SPANISH_HONDURAS: return "es_HN";
+          case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
+          case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
+          case SUBLANG_SPANISH_US: return "es_US";
+          }
+        return "es";
+      case LANG_SUTU:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
+          }
+        return "bnt";
+      case LANG_SWAHILI:
+        switch (sub)
+          {
+          case SUBLANG_SWAHILI_KENYA: return "sw_KE";
+          }
+        return "sw";
+      case LANG_SWEDISH:
+        switch (sub)
+          {
+          case SUBLANG_SWEDISH_SWEDEN: return "sv_SE";
+          case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
+          }
+        return "sv";
+      case LANG_SYRIAC:
+        switch (sub)
+          {
+          case SUBLANG_SYRIAC_SYRIA: return "syr_SY"; /* An extinct language.  */
+          }
+        return "syr";
+      case LANG_TAGALOG:
+        switch (sub)
+          {
+          case SUBLANG_TAGALOG_PHILIPPINES: return "tl_PH"; /* or "fil_PH"? */
+          }
+        return "tl"; /* or "fil"? */
+      case LANG_TAJIK:
+        switch (sub)
+          {
+          case 0x1f: return "tg";
+          case SUBLANG_TAJIK_TAJIKISTAN: return "tg_TJ";
+          }
+        return "tg";
+      case LANG_TAMAZIGHT:
+        /* Note: Microsoft uses the non-ISO language code "tmz".  */
+        switch (sub)
+          {
+          /* FIXME: Adjust this when Tamazight locales appear on Unix.  */
+          case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
+          case 0x1f: return "ber@latin";
+          case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin";
+          }
+        return "ber";
+      case LANG_TAMIL:
+        switch (sub)
+          {
+          case SUBLANG_TAMIL_INDIA: return "ta_IN";
+          }
+        return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG".  */
+      case LANG_TATAR:
+        switch (sub)
+          {
+          case SUBLANG_TATAR_RUSSIA: return "tt_RU";
+          }
+        return "tt";
+      case LANG_TELUGU:
+        switch (sub)
+          {
+          case SUBLANG_TELUGU_INDIA: return "te_IN";
+          }
+        return "te";
+      case LANG_THAI:
+        switch (sub)
+          {
+          case SUBLANG_THAI_THAILAND: return "th_TH";
+          }
+        return "th";
+      case LANG_TIBETAN:
+        switch (sub)
+          {
+          case SUBLANG_TIBETAN_PRC:
+            /* Most Tibetans would not like "bo_CN".  But Tibet does not yet
+               have a country code of its own.  */
+            return "bo";
+          case SUBLANG_TIBETAN_BHUTAN: return "bo_BT";
+          }
+        return "bo";
+      case LANG_TIGRINYA:
+        switch (sub)
+          {
+          case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
+          case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
+          }
+        return "ti";
+      case LANG_TSONGA:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "ts_ZA";
+          }
+        return "ts";
+      case LANG_TSWANA:
+        /* Spoken in South Africa, Botswana.  */
+        switch (sub)
+          {
+          case SUBLANG_TSWANA_SOUTH_AFRICA: return "tn_ZA";
+          }
+        return "tn";
+      case LANG_TURKISH:
+        switch (sub)
+          {
+          case SUBLANG_TURKISH_TURKEY: return "tr_TR";
+          }
+        return "tr";
+      case LANG_TURKMEN:
+        switch (sub)
+          {
+          case SUBLANG_TURKMEN_TURKMENISTAN: return "tk_TM";
+          }
+        return "tk";
+      case LANG_UIGHUR:
+        switch (sub)
+          {
+          case SUBLANG_UIGHUR_PRC: return "ug_CN";
+          }
+        return "ug";
+      case LANG_UKRAINIAN:
+        switch (sub)
+          {
+          case SUBLANG_UKRAINIAN_UKRAINE: return "uk_UA";
+          }
+        return "uk";
+      case LANG_URDU:
+        switch (sub)
+          {
+          case SUBLANG_URDU_PAKISTAN: return "ur_PK";
+          case SUBLANG_URDU_INDIA: return "ur_IN";
+          }
+        return "ur";
+      case LANG_UZBEK:
+        switch (sub)
+          {
+          case 0x1f: return "uz";
+          case SUBLANG_UZBEK_LATIN: return "uz_UZ";
+          case 0x1e: return "uz@cyrillic";
+          case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
+          }
+        return "uz";
+      case LANG_VENDA:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "ve_ZA";
+          }
+        return "ve";
+      case LANG_VIETNAMESE:
+        switch (sub)
+          {
+          case SUBLANG_VIETNAMESE_VIETNAM: return "vi_VN";
+          }
+        return "vi";
+      case LANG_WELSH:
+        switch (sub)
+          {
+          case SUBLANG_WELSH_UNITED_KINGDOM: return "cy_GB";
+          }
+        return "cy";
+      case LANG_WOLOF:
+        switch (sub)
+          {
+          case SUBLANG_WOLOF_SENEGAL: return "wo_SN";
+          }
+        return "wo";
+      case LANG_XHOSA:
+        switch (sub)
+          {
+          case SUBLANG_XHOSA_SOUTH_AFRICA: return "xh_ZA";
+          }
+        return "xh";
+      case LANG_YAKUT:
+        switch (sub)
+          {
+          case SUBLANG_YAKUT_RUSSIA: return "sah_RU";
+          }
+        return "sah";
+      case LANG_YI:
+        switch (sub)
+          {
+          case SUBLANG_YI_PRC: return "ii_CN";
+          }
+        return "ii";
+      case LANG_YIDDISH:
+        switch (sub)
+          {
+          case SUBLANG_DEFAULT: return "yi_IL";
+          }
+        return "yi";
+      case LANG_YORUBA:
+        switch (sub)
+          {
+          case SUBLANG_YORUBA_NIGERIA: return "yo_NG";
+          }
+        return "yo";
+      case LANG_ZULU:
+        switch (sub)
+          {
+          case SUBLANG_ZULU_SOUTH_AFRICA: return "zu_ZA";
+          }
+        return "zu";
+      default: return "C";
+      }
+  }
+}
+
+# if !defined IN_LIBINTL
+static
+# endif
+const char *
+gl_locale_name_from_win32_LCID (LCID lcid)
+{
+  LANGID langid;
+
+  /* Strip off the sorting rules, keep only the language part.  */
+  langid = LANGIDFROMLCID (lcid);
+
+  return gl_locale_name_from_win32_LANGID (langid);
+}
+
+#endif
+
+
+#if HAVE_USELOCALE /* glibc or MacOS X */
+
+/* Simple hash set of strings.  We don't want to drag in lots of hash table
+   code here.  */
+
+# define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
+
+/* A hash function for NUL-terminated char* strings using
+   the method described by Bruno Haible.
+   See http://www.haible.de/bruno/hashfunc.html.  */
+static size_t
+string_hash (const void *x)
+{
+  const char *s = (const char *) x;
+  size_t h = 0;
+
+  for (; *s; s++)
+    h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
+
+  return h;
+}
+
+/* A hash table of fixed size.  Multiple threads can access it read-only
+   simultaneously, but only one thread can insert into it at the same time.  */
+
+/* A node in a hash bucket collision list.  */
+struct hash_node
+  {
+    struct hash_node * volatile next;
+    char contents[100]; /* has variable size */
+  };
+
+# define HASH_TABLE_SIZE 257
+static struct hash_node * volatile struniq_hash_table[HASH_TABLE_SIZE]
+  /* = { NULL, ..., NULL } */;
+
+/* This lock protects the struniq_hash_table against multiple simultaneous
+   insertions.  */
+gl_lock_define_initialized(static, struniq_lock)
+
+/* Store a copy of the given string in a string pool with indefinite extent.
+   Return a pointer to this copy.  */
+static const char *
+struniq (const char *string)
+{
+  size_t hashcode = string_hash (string);
+  size_t slot = hashcode % HASH_TABLE_SIZE;
+  size_t size;
+  struct hash_node *new_node;
+  struct hash_node *p;
+  for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
+    if (strcmp (p->contents, string) == 0)
+      return p->contents;
+  size = strlen (string) + 1;
+  new_node =
+    (struct hash_node *)
+    malloc (offsetof (struct hash_node, contents[0]) + size);
+  if (new_node == NULL)
+    /* Out of memory.  Return a statically allocated string.  */
+    return "C";
+  memcpy (new_node->contents, string, size);
+  /* Lock while inserting new_node.  */
+  gl_lock_lock (struniq_lock);
+  /* Check whether another thread already added the string while we were
+     waiting on the lock.  */
+  for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
+    if (strcmp (p->contents, string) == 0)
+      {
+        free (new_node);
+        new_node = p;
+        goto done;
+      }
+  /* Really insert new_node into the hash table.  Fill new_node entirely first,
+     because other threads may be iterating over the linked list.  */
+  new_node->next = struniq_hash_table[slot];
+  struniq_hash_table[slot] = new_node;
+ done:
+  /* Unlock after new_node is inserted.  */
+  gl_lock_unlock (struniq_lock);
+  return new_node->contents;
+}
+
+#endif
+
+
+#if defined IN_LIBINTL || HAVE_USELOCALE
+
+/* Like gl_locale_name_thread, except that the result is not in storage of
+   indefinite extent.  */
+# if !defined IN_LIBINTL
+static
+# endif
+const char *
+gl_locale_name_thread_unsafe (int category, const char *categoryname)
+{
+# if HAVE_USELOCALE
+  {
+    locale_t thread_locale = uselocale (NULL);
+    if (thread_locale != LC_GLOBAL_LOCALE)
+      {
+#  if __GLIBC__ >= 2 && !defined __UCLIBC__
+        /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+           glibc < 2.12.
+           See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>.  */
+        const char *name =
+          nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
+        if (name[0] == '\0')
+          /* Fallback code for glibc < 2.4, which did not implement
+             nl_langinfo (_NL_LOCALE_NAME (category)).  */
+          name = thread_locale->__names[category];
+        return name;
+#  endif
+#  if defined __APPLE__ && defined __MACH__ /* MacOS X */
+        /* The locale name is found deep in an undocumented data structure.
+           Since it's stored in a buffer of size 32 and newlocale() rejects
+           locale names of length > 31, we can assume that it is NUL terminated
+           in this buffer. But we need to make a copy of the locale name, of
+           indefinite extent.  */
+        struct _xlocale_part1_v0 /* used in MacOS X 10.5 */
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            __darwin_mbstate_t __mbs[10];
+            int64_t __magic;
+          };
+        struct _xlocale_part1_v1 /* used in MacOS X >= 10.6.0 */
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            __darwin_mbstate_t __mbs[10];
+            /*pthread_lock_t*/ int __lock;
+            int64_t __magic;
+          };
+        struct _xlocale_part2
+          {
+            int64_t __magic;
+            unsigned char __collate_load_error;
+            unsigned char __collate_substitute_nontrivial;
+            unsigned char _messages_using_locale;
+            unsigned char _monetary_using_locale;
+            unsigned char _numeric_using_locale;
+            unsigned char _time_using_locale;
+            unsigned char __mlocale_changed;
+            unsigned char __nlocale_changed;
+            unsigned char __numeric_fp_cvt;
+            struct __xlocale_st_collate *__lc_collate;
+            struct __xlocale_st_runelocale *__lc_ctype;
+            struct __xlocale_st_messages *__lc_messages;
+            struct __xlocale_st_monetary *__lc_monetary;
+            struct __xlocale_st_numeric *__lc_numeric;
+            struct _xlocale *__lc_numeric_loc;
+            struct __xlocale_st_time *__lc_time;
+            /* more */
+          };
+        struct __xlocale_st_collate
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char __encoding[32];
+            /* more */
+          };
+        struct __xlocale_st_runelocale
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char __ctype_encoding[32];
+            /* more */
+          };
+        struct __xlocale_st_messages
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char *_messages_locale_buf;
+            /* more */
+          };
+        struct __xlocale_st_monetary
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char *_monetary_locale_buf;
+            /* more */
+          };
+        struct __xlocale_st_numeric {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char *_numeric_locale_buf;
+            /* more */
+          };
+        struct __xlocale_st_time {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            char *_time_locale_buf;
+            /* more */
+          };
+        struct _xlocale_part2 *tlp;
+        if (((struct _xlocale_part1_v0 *) thread_locale)->__magic
+            == 0x786C6F63616C6530LL)
+          /* MacOS X 10.5 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v0 *) thread_locale)->__magic;
+        else if (((struct _xlocale_part1_v1 *) thread_locale)->__magic
+                 == 0x786C6F63616C6530LL)
+          /* MacOS X >= 10.6.0 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v1 *) thread_locale)->__magic;
+        else
+          /* Unsupported version of MacOS X: The internals of 'struct _xlocale'
+             have changed again.  */
+          return "";
+        switch (category)
+          {
+          case LC_CTYPE:
+            return tlp->__lc_ctype->__ctype_encoding;
+          case LC_NUMERIC:
+            return tlp->_numeric_using_locale
+                   ? tlp->__lc_numeric->_numeric_locale_buf
+                   : "C";
+          case LC_TIME:
+            return tlp->_time_using_locale
+                   ? tlp->__lc_time->_time_locale_buf
+                   : "C";
+          case LC_COLLATE:
+            return !tlp->__collate_load_error
+                   ? tlp->__lc_collate->__encoding
+                   : "C";
+          case LC_MONETARY:
+            return tlp->_monetary_using_locale
+                   ? tlp->__lc_monetary->_monetary_locale_buf
+                   : "C";
+          case LC_MESSAGES:
+            return tlp->_messages_using_locale
+                   ? tlp->__lc_messages->_messages_locale_buf
+                   : "C";
+          default: /* We shouldn't get here.  */
+            return "";
+          }
+#  endif
+      }
+  }
+# endif
+  return NULL;
+}
+
+#endif
+
+const char *
+gl_locale_name_thread (int category, const char *categoryname)
+{
+#if HAVE_USELOCALE
+  const char *name = gl_locale_name_thread_unsafe (category, categoryname);
+  if (name != NULL)
+    return struniq (name);
+#endif
+  return NULL;
+}
+
+/* XPG3 defines the result of 'setlocale (category, NULL)' as:
+   "Directs 'setlocale()' to query 'category' and return the current
+    setting of 'local'."
+   However it does not specify the exact format.  Neither do SUSV2 and
+   ISO C 99.  So we can use this feature only on selected systems (e.g.
+   those using GNU C Library).  */
+#if defined _LIBC || ((defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__)
+# define HAVE_LOCALE_NULL
+#endif
+
+const char *
+gl_locale_name_posix (int category, const char *categoryname)
+{
+  /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
+     On some systems this can be done by the 'setlocale' function itself.  */
+#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
+  return setlocale (category, NULL);
+#else
+  /* On other systems we ignore what setlocale reports and instead look at the
+     environment variables directly.  This is necessary
+       1. on systems which have a facility for customizing the default locale
+          (MacOS X, native Windows, Cygwin) and where the system's setlocale()
+          function ignores this default locale (MacOS X, Cygwin), in two cases:
+          a. when the user missed to use the setlocale() override from libintl
+             (for example by not including <libintl.h>),
+          b. when setlocale supports only the "C" locale, such as on Cygwin
+             1.5.x.  In this case even the override from libintl cannot help.
+       2. on all systems where setlocale supports only the "C" locale.  */
+  /* Strictly speaking, it is a POSIX violation to look at the environment
+     variables regardless whether setlocale has been called or not.  POSIX
+     says:
+         "For C-language programs, the POSIX locale shall be the
+          default locale when the setlocale() function is not called."
+     But we assume that all programs that use internationalized APIs call
+     setlocale (LC_ALL, "").  */
+  return gl_locale_name_environ (category, categoryname);
+#endif
+}
+
+const char *
+gl_locale_name_environ (int category, const char *categoryname)
+{
+  const char *retval;
+
+  /* Setting of LC_ALL overrides all other.  */
+  retval = getenv ("LC_ALL");
+  if (retval != NULL && retval[0] != '\0')
+    return retval;
+  /* Next comes the name of the desired category.  */
+  retval = getenv (categoryname);
+  if (retval != NULL && retval[0] != '\0')
+    return retval;
+  /* Last possibility is the LANG environment variable.  */
+  retval = getenv ("LANG");
+  if (retval != NULL && retval[0] != '\0')
+    {
+#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
+      /* MacOS X 10.2 or newer.
+         Ignore invalid LANG value set by the Terminal application.  */
+      if (strcmp (retval, "UTF-8") != 0)
+#endif
+#if defined __CYGWIN__
+      /* Cygwin.
+         Ignore dummy LANG value set by ~/.profile.  */
+      if (strcmp (retval, "C.UTF-8") != 0)
+#endif
+        return retval;
+    }
+
+  return NULL;
+}
+
+const char *
+gl_locale_name_default (void)
+{
+  /* POSIX:2001 says:
+     "All implementations shall define a locale as the default locale, to be
+      invoked when no environment variables are set, or set to the empty
+      string.  This default locale can be the POSIX locale or any other
+      implementation-defined locale.  Some implementations may provide
+      facilities for local installation administrators to set the default
+      locale, customizing it for each location.  POSIX:2001 does not require
+      such a facility.
+
+     The systems with such a facility are MacOS X and Windows: They provide a
+     GUI that allows the user to choose a locale.
+       - On MacOS X, by default, none of LC_* or LANG are set.  Starting with
+         MacOS X 10.4 or 10.5, LANG is set for processes launched by the
+         'Terminal' application (but sometimes to an incorrect value "UTF-8").
+         When no environment variable is set, setlocale (LC_ALL, "") uses the
+         "C" locale.
+       - On native Windows, by default, none of LC_* or LANG are set.
+         When no environment variable is set, setlocale (LC_ALL, "") uses the
+         locale chosen by the user.
+       - On Cygwin 1.5.x, by default, none of LC_* or LANG are set.
+         When no environment variable is set, setlocale (LC_ALL, "") uses the
+         "C" locale.
+       - On Cygwin 1.7, by default, LANG is set to "C.UTF-8" when the default
+         ~/.profile is executed.
+         When no environment variable is set, setlocale (LC_ALL, "") uses the
+         "C.UTF-8" locale, which operates in the same way as the "C" locale.
+  */
+
+#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined WIN32_NATIVE || defined __CYGWIN__)
+
+  /* The system does not have a way of setting the locale, other than the
+     POSIX specified environment variables.  We use C as default locale.  */
+  return "C";
+
+#else
+
+  /* Return an XPG style locale name language[_territory][@modifier].
+     Don't even bother determining the codeset; it's not useful in this
+     context, because message catalogs are not specific to a single
+     codeset.  */
+
+# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
+  /* MacOS X 10.2 or newer */
+  {
+    /* Cache the locale name, since CoreFoundation calls are expensive.  */
+    static const char *cached_localename;
+
+    if (cached_localename == NULL)
+      {
+        char namebuf[256];
+#  if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */
+        CFLocaleRef locale = CFLocaleCopyCurrent ();
+        CFStringRef name = CFLocaleGetIdentifier (locale);
+
+        if (CFStringGetCString (name, namebuf, sizeof (namebuf),
+                                kCFStringEncodingASCII))
+          {
+            gl_locale_name_canonicalize (namebuf);
+            cached_localename = strdup (namebuf);
+          }
+        CFRelease (locale);
+#  elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */
+        CFTypeRef value =
+          CFPreferencesCopyAppValue (CFSTR ("AppleLocale"),
+                                     kCFPreferencesCurrentApplication);
+        if (value != NULL
+            && CFGetTypeID (value) == CFStringGetTypeID ()
+            && CFStringGetCString ((CFStringRef)value,
+                                   namebuf, sizeof (namebuf),
+                                   kCFStringEncodingASCII))
+          {
+            gl_locale_name_canonicalize (namebuf);
+            cached_localename = strdup (namebuf);
+          }
+#  endif
+        if (cached_localename == NULL)
+          cached_localename = "C";
+      }
+    return cached_localename;
+  }
+
+# endif
+
+# if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
+  {
+    LCID lcid;
+
+    /* Use native Win32 API locale ID.  */
+    lcid = GetThreadLocale ();
+
+    return gl_locale_name_from_win32_LCID (lcid);
+  }
+# endif
+#endif
+}
+
+/* Determine the current locale's name, and canonicalize it into XPG syntax
+     language[_territory][.codeset][@modifier]
+   The codeset part in the result is not reliable; the locale_charset()
+   should be used for codeset information instead.
+   The result must not be freed; it is statically allocated.  */
+
+const char *
+gl_locale_name (int category, const char *categoryname)
+{
+  const char *retval;
+
+  retval = gl_locale_name_thread (category, categoryname);
+  if (retval != NULL)
+    return retval;
+
+  retval = gl_locale_name_posix (category, categoryname);
+  if (retval != NULL)
+    return retval;
+
+  return gl_locale_name_default ();
+}
diff --git a/gnulib/tests/localename.h b/gnulib/tests/localename.h
new file mode 100644 (file)
index 0000000..e754853
--- /dev/null
@@ -0,0 +1,97 @@
+/* Determine name of the currently selected locale.
+   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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+#ifndef _GL_LOCALENAME_H
+#define _GL_LOCALENAME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Determine the current locale's name.
+   It considers both the POSIX notion of locale name (see functions
+   gl_locale_name_thread and gl_locale_name_posix) and the system notion
+   of locale name (see function gl_locale_name_default).
+   CATEGORY is a locale category abbreviation, as defined in <locale.h>,
+   but not LC_ALL. E.g. LC_MESSAGES.
+   CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
+   Return the locale category's name, canonicalized into XPG syntax
+     language[_territory][.codeset][@modifier]
+   The codeset part in the result is not reliable; the locale_charset()
+   should be used for codeset information instead.
+   The result must not be freed; it is statically allocated.  */
+extern const char * gl_locale_name (int category, const char *categoryname);
+
+/* Determine the current per-thread locale's name, as specified by uselocale()
+   calls.
+   CATEGORY is a locale category abbreviation, as defined in <locale.h>,
+   but not LC_ALL. E.g. LC_MESSAGES.
+   CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
+   Return the locale category's name, canonicalized into XPG syntax
+     language[_territory][.codeset][@modifier]
+   or NULL if no locale has been specified for the current thread.
+   The codeset part in the result is not reliable; the locale_charset()
+   should be used for codeset information instead.
+   The result must not be freed; it is statically allocated.  */
+extern const char * gl_locale_name_thread (int category, const char *categoryname);
+
+/* Determine the thread-independent current locale's name, as specified by
+   setlocale() calls or by environment variables.
+   CATEGORY is a locale category abbreviation, as defined in <locale.h>,
+   but not LC_ALL. E.g. LC_MESSAGES.
+   CATEGORYNAME is the name of CATEGORY as a string, e.g. "LC_MESSAGES".
+   Return the locale category's name, canonicalized into XPG syntax
+     language[_territory][.codeset][@modifier]
+   or NULL if no locale has been specified to setlocale() or by environment
+   variables.
+   The codeset part in the result is not reliable; the locale_charset()
+   should be used for codeset information instead.
+   The result must not be freed; it is statically allocated.  */
+extern const char * gl_locale_name_posix (int category, const char *categoryname);
+
+/* Determine the default locale's name, as specified by environment
+   variables.
+   Return the locale category's name, or NULL if no locale has been specified
+   by environment variables.
+   The result must not be freed; it is statically allocated.  */
+extern const char * gl_locale_name_environ (int category, const char *categoryname);
+
+/* Determine the default locale's name.  This is the current locale's name,
+   if not specified by uselocale() calls, by setlocale() calls, or by
+   environment variables.  This locale name is usually determined by systems
+   settings that the user can manipulate through a GUI.
+
+   Quoting POSIX:2001:
+     "All implementations shall define a locale as the default locale,
+      to be invoked when no environment variables are set, or set to the
+      empty string.  This default locale can be the C locale or any other
+      implementation-defined locale.  Some implementations may provide
+      facilities for local installation administrators to set the default
+      locale, customizing it for each location.  IEEE Std 1003.1-2001 does
+      not require such a facility."
+
+   The result must not be freed; it is statically allocated.  */
+extern const char * gl_locale_name_default (void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GL_LOCALENAME_H */
diff --git a/gnulib/tests/macros.h b/gnulib/tests/macros.h
new file mode 100644 (file)
index 0000000..8922675
--- /dev/null
@@ -0,0 +1,64 @@
+/* Common macros used by gnulib tests.
+   Copyright (C) 2006-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/>.  */
+
+
+/* This file contains macros that are used by many gnulib tests.
+   Put here only frequently used macros, say, used by 10 tests or more.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Define ASSERT_STREAM before including this file if ASSERT must
+   target a stream other than stderr.  */
+#ifndef ASSERT_STREAM
+# define ASSERT_STREAM stderr
+#endif
+
+/* ASSERT (condition);
+   verifies that the specified condition is fulfilled.  If not, a message
+   is printed to ASSERT_STREAM if defined (defaulting to stderr if
+   undefined) and the program is terminated with an error code.
+
+   This macro has the following properties:
+     - The programmer specifies the expected condition, not the failure
+       condition.  This simplifies thinking.
+     - The condition is tested always, regardless of compilation flags.
+       (Unlike the macro from <assert.h>.)
+     - On Unix platforms, the tester can debug the test program with a
+       debugger (provided core dumps are enabled: "ulimit -c unlimited").
+     - For the sake of platforms where no debugger is available (such as
+       some mingw systems), an error message is printed on the error
+       stream that includes the source location of the ASSERT invocation.
+ */
+#define ASSERT(expr) \
+  do                                                                         \
+    {                                                                        \
+      if (!(expr))                                                           \
+        {                                                                    \
+          fprintf (ASSERT_STREAM, "%s:%d: assertion failed\n",               \
+                   __FILE__, __LINE__);                                      \
+          fflush (ASSERT_STREAM);                                            \
+          abort ();                                                          \
+        }                                                                    \
+    }                                                                        \
+  while (0)
+
+/* SIZEOF (array)
+   returns the number of elements of an array.  It works for arrays that are
+   declared outside functions and for local variables of array type.  It does
+   *not* work for function parameters of array type, because they are actually
+   parameters of pointer type.  */
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
diff --git a/gnulib/tests/open.c b/gnulib/tests/open.c
new file mode 100644 (file)
index 0000000..2e2cc74
--- /dev/null
@@ -0,0 +1,167 @@
+/* Open a descriptor to a file.
+   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>
+
+/* Get the original definition of open.  It might be defined as a macro.  */
+#define __need_system_fcntl_h
+#include <fcntl.h>
+#undef __need_system_fcntl_h
+#include <sys/types.h>
+
+static inline int
+orig_open (const char *filename, int flags, mode_t mode)
+{
+  return open (filename, flags, mode);
+}
+
+/* Specification.  */
+#include <fcntl.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#ifndef REPLACE_OPEN_DIRECTORY
+# define REPLACE_OPEN_DIRECTORY 0
+#endif
+
+int
+open (const char *filename, int flags, ...)
+{
+  mode_t mode;
+  int fd;
+
+  mode = 0;
+  if (flags & O_CREAT)
+    {
+      va_list arg;
+      va_start (arg, flags);
+
+      /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
+         creates crashing code when 'mode_t' is smaller than 'int'.  */
+      mode = va_arg (arg, PROMOTED_MODE_T);
+
+      va_end (arg);
+    }
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  if (strcmp (filename, "/dev/null") == 0)
+    filename = "NUL";
+#endif
+
+#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>
+     says that
+       "A pathname that contains at least one non-slash character and that
+        ends with one or more trailing slashes shall be resolved as if a
+        single dot character ( '.' ) were appended to the pathname."
+     and
+       "The special filename dot shall refer to the directory specified by
+        its predecessor."
+     If the named file already exists as a directory, then
+       - if O_CREAT is specified, open() must fail because of the semantics
+         of O_CREAT,
+       - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
+         <http://www.opengroup.org/susv3/functions/open.html> says that it
+         fails with errno = EISDIR in this case.
+     If the named file does not exist or does not name a directory, then
+       - if O_CREAT is specified, open() must fail since open() cannot create
+         directories,
+       - if O_WRONLY or O_RDWR is specified, open() must fail because the
+         file does not contain a '.' directory.  */
+  if (flags & (O_CREAT | O_WRONLY | O_RDWR))
+    {
+      size_t len = strlen (filename);
+      if (len > 0 && filename[len - 1] == '/')
+        {
+          errno = EISDIR;
+          return -1;
+        }
+    }
+#endif
+
+  fd = orig_open (filename, flags, mode);
+
+#if REPLACE_FCHDIR
+  /* Implementing fchdir and fdopendir requires the ability to open a
+     directory file descriptor.  If open doesn't support that (as on
+     mingw), we use a dummy file that behaves the same as directories
+     on Linux (ie. always reports EOF on attempts to read()), and
+     override fstat() in fchdir.c to hide the fact that we have a
+     dummy.  */
+  if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
+      && ((flags & O_ACCMODE) == O_RDONLY
+          || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH)))
+    {
+      struct stat statbuf;
+      if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
+        {
+          /* Maximum recursion depth of 1.  */
+          fd = open ("/dev/null", flags, mode);
+          if (0 <= fd)
+            fd = _gl_register_fd (fd, filename);
+        }
+      else
+        errno = EACCES;
+    }
+#endif
+
+#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>
+     says that
+       "A pathname that contains at least one non-slash character and that
+        ends with one or more trailing slashes shall be resolved as if a
+        single dot character ( '.' ) were appended to the pathname."
+     and
+       "The special filename dot shall refer to the directory specified by
+        its predecessor."
+     If the named file without the slash is not a directory, open() must fail
+     with ENOTDIR.  */
+  if (fd >= 0)
+    {
+      /* We know len is positive, since open did not fail with ENOENT.  */
+      size_t len = strlen (filename);
+      if (filename[len - 1] == '/')
+        {
+          struct stat statbuf;
+
+          if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
+            {
+              close (fd);
+              errno = ENOTDIR;
+              return -1;
+            }
+        }
+    }
+#endif
+
+#if REPLACE_FCHDIR
+  if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
+    fd = _gl_register_fd (fd, filename);
+#endif
+
+  return fd;
+}
diff --git a/gnulib/tests/putenv.c b/gnulib/tests/putenv.c
new file mode 100644 (file)
index 0000000..68e5fec
--- /dev/null
@@ -0,0 +1,132 @@
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2011 Free Software
+   Foundation, Inc.
+
+   NOTE: The canonical source of this file is maintained with the GNU C
+   Library.  Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+   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 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 <stdlib.h>
+
+#include <stddef.h>
+
+/* Include errno.h *after* sys/types.h to work around header problems
+   on AIX 3.2.5.  */
+#include <errno.h>
+#ifndef __set_errno
+# define __set_errno(ev) ((errno) = (ev))
+#endif
+
+#include <string.h>
+#include <unistd.h>
+
+#if HAVE_GNU_LD
+# define environ __environ
+#else
+extern char **environ;
+#endif
+
+#if _LIBC
+/* This lock protects against simultaneous modifications of `environ'.  */
+# include <bits/libc-lock.h>
+__libc_lock_define_initialized (static, envlock)
+# define LOCK   __libc_lock_lock (envlock)
+# define UNLOCK __libc_lock_unlock (envlock)
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+static int
+_unsetenv (const char *name)
+{
+  size_t len;
+  char **ep;
+
+  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  len = strlen (name);
+
+  LOCK;
+
+  ep = environ;
+  while (*ep != NULL)
+    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+      {
+        /* Found it.  Remove this pointer by moving later ones back.  */
+        char **dp = ep;
+
+        do
+          dp[0] = dp[1];
+        while (*dp++);
+        /* Continue the loop in case NAME appears again.  */
+      }
+    else
+      ++ep;
+
+  UNLOCK;
+
+  return 0;
+}
+
+
+/* Put STRING, which is of the form "NAME=VALUE", in the environment.
+   If STRING contains no `=', then remove STRING from the environment.  */
+int
+putenv (char *string)
+{
+  const char *const name_end = strchr (string, '=');
+  register size_t size;
+  register char **ep;
+
+  if (name_end == NULL)
+    {
+      /* Remove the variable from the environment.  */
+      return _unsetenv (string);
+    }
+
+  size = 0;
+  for (ep = environ; *ep != NULL; ++ep)
+    if (!strncmp (*ep, string, name_end - string) &&
+        (*ep)[name_end - string] == '=')
+      break;
+    else
+      ++size;
+
+  if (*ep == NULL)
+    {
+      static char **last_environ = NULL;
+      char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
+      if (new_environ == NULL)
+        return -1;
+      (void) memcpy ((void *) new_environ, (void *) environ,
+                     size * sizeof (char *));
+      new_environ[size] = (char *) string;
+      new_environ[size + 1] = NULL;
+      free (last_environ);
+      last_environ = new_environ;
+      environ = new_environ;
+    }
+  else
+    *ep = string;
+
+  return 0;
+}
diff --git a/gnulib/tests/same-inode.h b/gnulib/tests/same-inode.h
new file mode 100644 (file)
index 0000000..d434b94
--- /dev/null
@@ -0,0 +1,25 @@
+/* Determine whether two stat buffers refer to the same file.
+
+   Copyright (C) 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/>.  */
+
+#ifndef SAME_INODE_H
+# define SAME_INODE_H 1
+
+# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
+   ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
+    && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
+
+#endif
diff --git a/gnulib/tests/setenv.c b/gnulib/tests/setenv.c
new file mode 100644 (file)
index 0000000..7c06192
--- /dev/null
@@ -0,0 +1,390 @@
+/* Copyright (C) 1992, 1995-2003, 2005-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   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/>.  */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the name == NULL test below.  */
+#define _GL_ARG_NONNULL(params)
+
+#include <alloca.h>
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <errno.h>
+#ifndef __set_errno
+# define __set_errno(ev) ((errno) = (ev))
+#endif
+
+#include <string.h>
+#if _LIBC || HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if !_LIBC
+# include "malloca.h"
+#endif
+
+#if _LIBC || !HAVE_SETENV
+
+#if !_LIBC
+# define __environ      environ
+#endif
+
+#if _LIBC
+/* This lock protects against simultaneous modifications of `environ'.  */
+# include <bits/libc-lock.h>
+__libc_lock_define_initialized (static, envlock)
+# define LOCK   __libc_lock_lock (envlock)
+# define UNLOCK __libc_lock_unlock (envlock)
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+/* In the GNU C library we must keep the namespace clean.  */
+#ifdef _LIBC
+# define setenv __setenv
+# define clearenv __clearenv
+# define tfind __tfind
+# define tsearch __tsearch
+#else
+/* Use the system functions, not the gnulib overrides in this file.  */
+# undef malloc
+# undef realloc
+#endif
+
+/* In the GNU C library implementation we try to be more clever and
+   allow arbitrarily many changes of the environment given that the used
+   values are from a small set.  Outside glibc this will eat up all
+   memory after a while.  */
+#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
+                      && defined __GNUC__)
+# define USE_TSEARCH    1
+# include <search.h>
+typedef int (*compar_fn_t) (const void *, const void *);
+
+/* This is a pointer to the root of the search tree with the known
+   values.  */
+static void *known_values;
+
+# define KNOWN_VALUE(Str) \
+  ({                                                                          \
+    void *value = tfind (Str, &known_values, (compar_fn_t) strcmp);           \
+    value != NULL ? *(char **) value : NULL;                                  \
+  })
+# define STORE_VALUE(Str) \
+  tsearch (Str, &known_values, (compar_fn_t) strcmp)
+
+#else
+# undef USE_TSEARCH
+
+# define KNOWN_VALUE(Str) NULL
+# define STORE_VALUE(Str) do { } while (0)
+
+#endif
+
+
+/* If this variable is not a null pointer we allocated the current
+   environment.  */
+static char **last_environ;
+
+
+/* This function is used by `setenv' and `putenv'.  The difference between
+   the two functions is that for the former must create a new string which
+   is then placed in the environment, while the argument of `putenv'
+   must be used directly.  This is all complicated by the fact that we try
+   to reuse values once generated for a `setenv' call since we can never
+   free the strings.  */
+int
+__add_to_environ (const char *name, const char *value, const char *combined,
+                  int replace)
+{
+  char **ep;
+  size_t size;
+  const size_t namelen = strlen (name);
+  const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
+
+  LOCK;
+
+  /* We have to get the pointer now that we have the lock and not earlier
+     since another thread might have created a new environment.  */
+  ep = __environ;
+
+  size = 0;
+  if (ep != NULL)
+    {
+      for (; *ep != NULL; ++ep)
+        if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+          break;
+        else
+          ++size;
+    }
+
+  if (ep == NULL || *ep == NULL)
+    {
+      char **new_environ;
+#ifdef USE_TSEARCH
+      char *new_value;
+#endif
+
+      /* We allocated this space; we can extend it.  */
+      new_environ =
+        (char **) (last_environ == NULL
+                   ? malloc ((size + 2) * sizeof (char *))
+                   : realloc (last_environ, (size + 2) * sizeof (char *)));
+      if (new_environ == NULL)
+        {
+          /* It's easier to set errno to ENOMEM than to rely on the
+             'malloc-posix' and 'realloc-posix' gnulib modules.  */
+          __set_errno (ENOMEM);
+          UNLOCK;
+          return -1;
+        }
+
+      /* If the whole entry is given add it.  */
+      if (combined != NULL)
+        /* We must not add the string to the search tree since it belongs
+           to the user.  */
+        new_environ[size] = (char *) combined;
+      else
+        {
+          /* See whether the value is already known.  */
+#ifdef USE_TSEARCH
+# ifdef _LIBC
+          new_value = (char *) alloca (namelen + 1 + vallen);
+          __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+                     value, vallen);
+# else
+          new_value = (char *) malloca (namelen + 1 + vallen);
+          if (new_value == NULL)
+            {
+              __set_errno (ENOMEM);
+              UNLOCK;
+              return -1;
+            }
+          memcpy (new_value, name, namelen);
+          new_value[namelen] = '=';
+          memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+          new_environ[size] = KNOWN_VALUE (new_value);
+          if (new_environ[size] == NULL)
+#endif
+            {
+              new_environ[size] = (char *) malloc (namelen + 1 + vallen);
+              if (new_environ[size] == NULL)
+                {
+#if defined USE_TSEARCH && !defined _LIBC
+                  freea (new_value);
+#endif
+                  __set_errno (ENOMEM);
+                  UNLOCK;
+                  return -1;
+                }
+
+#ifdef USE_TSEARCH
+              memcpy (new_environ[size], new_value, namelen + 1 + vallen);
+#else
+              memcpy (new_environ[size], name, namelen);
+              new_environ[size][namelen] = '=';
+              memcpy (&new_environ[size][namelen + 1], value, vallen);
+#endif
+              /* And save the value now.  We cannot do this when we remove
+                 the string since then we cannot decide whether it is a
+                 user string or not.  */
+              STORE_VALUE (new_environ[size]);
+            }
+#if defined USE_TSEARCH && !defined _LIBC
+          freea (new_value);
+#endif
+        }
+
+      if (__environ != last_environ)
+        memcpy ((char *) new_environ, (char *) __environ,
+                size * sizeof (char *));
+
+      new_environ[size + 1] = NULL;
+
+      last_environ = __environ = new_environ;
+    }
+  else if (replace)
+    {
+      char *np;
+
+      /* Use the user string if given.  */
+      if (combined != NULL)
+        np = (char *) combined;
+      else
+        {
+#ifdef USE_TSEARCH
+          char *new_value;
+# ifdef _LIBC
+          new_value = alloca (namelen + 1 + vallen);
+          __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+                     value, vallen);
+# else
+          new_value = malloca (namelen + 1 + vallen);
+          if (new_value == NULL)
+            {
+              __set_errno (ENOMEM);
+              UNLOCK;
+              return -1;
+            }
+          memcpy (new_value, name, namelen);
+          new_value[namelen] = '=';
+          memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+          np = KNOWN_VALUE (new_value);
+          if (np == NULL)
+#endif
+            {
+              np = (char *) malloc (namelen + 1 + vallen);
+              if (np == NULL)
+                {
+#if defined USE_TSEARCH && !defined _LIBC
+                  freea (new_value);
+#endif
+                  __set_errno (ENOMEM);
+                  UNLOCK;
+                  return -1;
+                }
+
+#ifdef USE_TSEARCH
+              memcpy (np, new_value, namelen + 1 + vallen);
+#else
+              memcpy (np, name, namelen);
+              np[namelen] = '=';
+              memcpy (&np[namelen + 1], value, vallen);
+#endif
+              /* And remember the value.  */
+              STORE_VALUE (np);
+            }
+#if defined USE_TSEARCH && !defined _LIBC
+          freea (new_value);
+#endif
+        }
+
+      *ep = np;
+    }
+
+  UNLOCK;
+
+  return 0;
+}
+
+int
+setenv (const char *name, const char *value, int replace)
+{
+  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return __add_to_environ (name, value, NULL, replace);
+}
+
+/* The `clearenv' was planned to be added to POSIX.1 but probably
+   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings
+   for Fortran 77) requires this function.  */
+int
+clearenv (void)
+{
+  LOCK;
+
+  if (__environ == last_environ && __environ != NULL)
+    {
+      /* We allocated this environment so we can free it.  */
+      free (__environ);
+      last_environ = NULL;
+    }
+
+  /* Clear the environment pointer removes the whole environment.  */
+  __environ = NULL;
+
+  UNLOCK;
+
+  return 0;
+}
+
+#ifdef _LIBC
+static void
+free_mem (void)
+{
+  /* Remove all traces.  */
+  clearenv ();
+
+  /* Now remove the search tree.  */
+  __tdestroy (known_values, free);
+  known_values = NULL;
+}
+text_set_element (__libc_subfreeres, free_mem);
+
+
+# undef setenv
+# undef clearenv
+weak_alias (__setenv, setenv)
+weak_alias (__clearenv, clearenv)
+#endif
+
+#endif /* _LIBC || !HAVE_SETENV */
+
+/* The rest of this file is called into use when replacing an existing
+   but buggy setenv.  Known bugs include failure to diagnose invalid
+   name, and consuming a leading '=' from value.  */
+#if HAVE_SETENV
+
+# undef setenv
+# define STREQ(a, b) (strcmp (a, b) == 0)
+
+int
+rpl_setenv (const char *name, const char *value, int replace)
+{
+  int result;
+  if (!name || !*name || strchr (name, '='))
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  /* Call the real setenv even if replace is 0, in case implementation
+     has underlying data to update, such as when environ changes.  */
+  result = setenv (name, value, replace);
+  if (result == 0 && replace && *value == '=')
+    {
+      char *tmp = getenv (name);
+      if (!STREQ (tmp, value))
+        {
+          int saved_errno;
+          size_t len = strlen (value);
+          tmp = malloca (len + 2);
+          /* Since leading '=' is eaten, double it up.  */
+          *tmp = '=';
+          memcpy (tmp + 1, value, len + 1);
+          result = setenv (name, tmp, replace);
+          saved_errno = errno;
+          freea (tmp);
+          errno = saved_errno;
+        }
+    }
+  return result;
+}
+
+#endif /* HAVE_SETENV */
diff --git a/gnulib/tests/setlocale.c b/gnulib/tests/setlocale.c
new file mode 100644 (file)
index 0000000..0cef00f
--- /dev/null
@@ -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
diff --git a/gnulib/tests/signature.h b/gnulib/tests/signature.h
new file mode 100644 (file)
index 0000000..8256989
--- /dev/null
@@ -0,0 +1,48 @@
+/* Macro for checking that a function declaration is compliant.
+   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/>.  */
+
+#ifndef SIGNATURE_CHECK
+
+/* Check that the function FN takes the specified arguments ARGS with
+   a return type of RET.  This header is designed to be included after
+   <config.h> and the one system header that is supposed to contain
+   the function being checked, but prior to any other system headers
+   that are necessary for the unit test.  Therefore, this file does
+   not include any system headers, nor reference anything outside of
+   the macro arguments.  For an example, if foo.h should provide:
+
+   extern int foo (char, float);
+
+   then the unit test named test-foo.c would start out with:
+
+   #include <config.h>
+   #include <foo.h>
+   #include "signature.h"
+   SIGNATURE_CHECK (foo, int, (char, float));
+   #include <other.h>
+   ...
+*/
+# define SIGNATURE_CHECK(fn, ret, args) \
+  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
+
+/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test.
+   Note that the checks must not occupy the same line.  */
+# define SIGNATURE_CHECK1(fn, ret, args, id) \
+  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
+# define SIGNATURE_CHECK2(fn, ret, args, id) \
+  static ret (* _GL_UNUSED signature_check ## id) args = fn
+
+#endif /* SIGNATURE_CHECK */
diff --git a/gnulib/tests/symlink.c b/gnulib/tests/symlink.c
new file mode 100644 (file)
index 0000000..2896cc9
--- /dev/null
@@ -0,0 +1,57 @@
+/* Stub for symlink().
+   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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+
+#if HAVE_SYMLINK
+
+# undef symlink
+
+/* Create a symlink, but reject trailing slash.  */
+int
+rpl_symlink (char const *contents, char const *name)
+{
+  size_t len = strlen (name);
+  if (len && name[len - 1] == '/')
+    {
+      struct stat st;
+      if (lstat (name, &st) == 0)
+        errno = EEXIST;
+      return -1;
+    }
+  return symlink (contents, name);
+}
+
+#else /* !HAVE_SYMLINK */
+
+/* The system does not support symlinks.  */
+int
+symlink (char const *contents _GL_UNUSED,
+         char const *name _GL_UNUSED)
+{
+  errno = ENOSYS;
+  return -1;
+}
+
+#endif /* !HAVE_SYMLINK */
diff --git a/gnulib/tests/test-alloca-opt.c b/gnulib/tests/test-alloca-opt.c
new file mode 100644 (file)
index 0000000..5aa1645
--- /dev/null
@@ -0,0 +1,62 @@
+/* Test of optional automatic memory allocation.
+   Copyright (C) 2005, 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <alloca.h>
+
+#if HAVE_ALLOCA
+
+static void
+do_allocation (int n)
+{
+  void *ptr = alloca (n);
+  (void) ptr;
+}
+
+void (*func) (int) = do_allocation;
+
+#endif
+
+int
+main ()
+{
+#if HAVE_ALLOCA
+  int i;
+
+  /* Repeat a lot of times, to make sure there's no memory leak.  */
+  for (i = 0; i < 100000; i++)
+    {
+      /* Try various values.
+         n = 0 gave a crash on Alpha with gcc-2.5.8.
+         Some versions of MacOS X have a stack size limit of 512 KB.  */
+      func (34);
+      func (134);
+      func (399);
+      func (510823);
+      func (129321);
+      func (0);
+      func (4070);
+      func (4095);
+      func (1);
+      func (16582);
+    }
+#endif
+
+  return 0;
+}
diff --git a/gnulib/tests/test-binary-io.c b/gnulib/tests/test-binary-io.c
new file mode 100644 (file)
index 0000000..8e5d193
--- /dev/null
@@ -0,0 +1,64 @@
+/* Test of binary mode I/O.
+   Copyright (C) 2005, 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>, 2005.  */
+
+#include <config.h>
+
+#include "binary-io.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* Test the O_BINARY macro.  */
+  {
+    int fd =
+      open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600);
+    if (write (fd, "Hello\n", 6) < 0)
+      exit (1);
+    close (fd);
+  }
+  {
+    struct stat statbuf;
+    if (stat ("t-bin-out2.tmp", &statbuf) < 0)
+      exit (1);
+    ASSERT (statbuf.st_size == 6);
+  }
+  unlink ("t-bin-out2.tmp");
+
+  /* Test the SET_BINARY macro.  */
+  SET_BINARY (1);
+  fputs ("Hello\n", stdout);
+  fclose (stdout);
+  fclose (stderr);
+  {
+    struct stat statbuf;
+    if (stat ("t-bin-out1.tmp", &statbuf) < 0)
+      exit (1);
+    ASSERT (statbuf.st_size == 6);
+  }
+
+  return 0;
+}
diff --git a/gnulib/tests/test-binary-io.sh b/gnulib/tests/test-binary-io.sh
new file mode 100755 (executable)
index 0000000..33e128c
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp"
+./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/gnulib/tests/test-btowc.c b/gnulib/tests/test-btowc.c
new file mode 100644 (file)
index 0000000..7907cbe
--- /dev/null
@@ -0,0 +1,63 @@
+/* Test of conversion of unibyte 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (btowc, wint_t, (int));
+
+#include <locale.h>
+#include <stdio.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  int c;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  ASSERT (btowc (EOF) == WEOF);
+
+  if (argc > 1)
+    switch (argv[1][0])
+      {
+      case '1':
+        /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+        for (c = 0; c < 0x80; c++)
+          ASSERT (btowc (c) == c);
+        for (c = 0xA0; c < 0x100; c++)
+          ASSERT (btowc (c) != WEOF);
+        return 0;
+
+      case '2':
+        /* Locale encoding is UTF-8.  */
+        for (c = 0; c < 0x80; c++)
+          ASSERT (btowc (c) == c);
+        for (c = 0x80; c < 0x100; c++)
+          ASSERT (btowc (c) == WEOF);
+        return 0;
+      }
+
+  return 1;
+}
diff --git a/gnulib/tests/test-btowc1.sh b/gnulib/tests/test-btowc1.sh
new file mode 100755 (executable)
index 0000000..aaef48d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+./test-btowc${EXEEXT} 1
diff --git a/gnulib/tests/test-btowc2.sh b/gnulib/tests/test-btowc2.sh
new file mode 100755 (executable)
index 0000000..2e06038
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-btowc${EXEEXT} 2
diff --git a/gnulib/tests/test-c-ctype.c b/gnulib/tests/test-c-ctype.c
new file mode 100644 (file)
index 0000000..9d748ff
--- /dev/null
@@ -0,0 +1,386 @@
+/* Test of character handling in C locale.
+   Copyright (C) 2005, 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>, 2005.  */
+
+#include <config.h>
+
+#include "c-ctype.h"
+
+#include <locale.h>
+
+#include "macros.h"
+
+static void
+test_all (void)
+{
+  int c;
+
+  for (c = -0x80; c < 0x100; c++)
+    {
+      ASSERT (c_isascii (c) == (c >= 0 && c < 0x80));
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+          ASSERT (c_isalnum (c) == 1);
+          break;
+        default:
+          ASSERT (c_isalnum (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+          ASSERT (c_isalpha (c) == 1);
+          break;
+        default:
+          ASSERT (c_isalpha (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case '\t': case ' ':
+          ASSERT (c_isblank (c) == 1);
+          break;
+        default:
+          ASSERT (c_isblank (c) == 0);
+          break;
+        }
+
+      ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f));
+
+      switch (c)
+        {
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+          ASSERT (c_isdigit (c) == 1);
+          break;
+        default:
+          ASSERT (c_isdigit (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+          ASSERT (c_islower (c) == 1);
+          break;
+        default:
+          ASSERT (c_islower (c) == 0);
+          break;
+        }
+
+      ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' '));
+
+      ASSERT (c_isprint (c) == (c >= 0x20 && c < 0x7f));
+
+      ASSERT (c_ispunct (c) == (c_isgraph (c) && !c_isalnum (c)));
+
+      switch (c)
+        {
+        case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
+          ASSERT (c_isspace (c) == 1);
+          break;
+        default:
+          ASSERT (c_isspace (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+          ASSERT (c_isupper (c) == 1);
+          break;
+        default:
+          ASSERT (c_isupper (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+          ASSERT (c_isxdigit (c) == 1);
+          break;
+        default:
+          ASSERT (c_isxdigit (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A':
+          ASSERT (c_tolower (c) == 'a');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'B':
+          ASSERT (c_tolower (c) == 'b');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'C':
+          ASSERT (c_tolower (c) == 'c');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'D':
+          ASSERT (c_tolower (c) == 'd');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'E':
+          ASSERT (c_tolower (c) == 'e');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'F':
+          ASSERT (c_tolower (c) == 'f');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'G':
+          ASSERT (c_tolower (c) == 'g');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'H':
+          ASSERT (c_tolower (c) == 'h');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'I':
+          ASSERT (c_tolower (c) == 'i');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'J':
+          ASSERT (c_tolower (c) == 'j');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'K':
+          ASSERT (c_tolower (c) == 'k');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'L':
+          ASSERT (c_tolower (c) == 'l');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'M':
+          ASSERT (c_tolower (c) == 'm');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'N':
+          ASSERT (c_tolower (c) == 'n');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'O':
+          ASSERT (c_tolower (c) == 'o');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'P':
+          ASSERT (c_tolower (c) == 'p');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Q':
+          ASSERT (c_tolower (c) == 'q');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'R':
+          ASSERT (c_tolower (c) == 'r');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'S':
+          ASSERT (c_tolower (c) == 's');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'T':
+          ASSERT (c_tolower (c) == 't');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'U':
+          ASSERT (c_tolower (c) == 'u');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'V':
+          ASSERT (c_tolower (c) == 'v');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'W':
+          ASSERT (c_tolower (c) == 'w');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'X':
+          ASSERT (c_tolower (c) == 'x');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Y':
+          ASSERT (c_tolower (c) == 'y');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Z':
+          ASSERT (c_tolower (c) == 'z');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'a':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'A');
+          break;
+        case 'b':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'B');
+          break;
+        case 'c':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'C');
+          break;
+        case 'd':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'D');
+          break;
+        case 'e':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'E');
+          break;
+        case 'f':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'F');
+          break;
+        case 'g':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'G');
+          break;
+        case 'h':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'H');
+          break;
+        case 'i':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'I');
+          break;
+        case 'j':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'J');
+          break;
+        case 'k':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'K');
+          break;
+        case 'l':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'L');
+          break;
+        case 'm':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'M');
+          break;
+        case 'n':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'N');
+          break;
+        case 'o':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'O');
+          break;
+        case 'p':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'P');
+          break;
+        case 'q':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Q');
+          break;
+        case 'r':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'R');
+          break;
+        case 's':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'S');
+          break;
+        case 't':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'T');
+          break;
+        case 'u':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'U');
+          break;
+        case 'v':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'V');
+          break;
+        case 'w':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'W');
+          break;
+        case 'x':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'X');
+          break;
+        case 'y':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Y');
+          break;
+        case 'z':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Z');
+          break;
+        default:
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == c);
+          break;
+        }
+    }
+}
+
+int
+main ()
+{
+  test_all ();
+
+  setlocale (LC_ALL, "de_DE");
+  test_all ();
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  test_all ();
+
+  return 0;
+}
diff --git a/gnulib/tests/test-c-strcase.sh b/gnulib/tests/test-c-strcase.sh
new file mode 100755 (executable)
index 0000000..5fcf906
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Test in the C locale.
+./test-c-strcasecmp${EXEEXT} || exit 1
+./test-c-strncasecmp${EXEEXT} || exit 1
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR ./test-c-strcasecmp${EXEEXT} locale || exit 1
+  LC_ALL=$LOCALE_FR ./test-c-strncasecmp${EXEEXT} locale || exit 1
+fi
+
+# Test in a Turkish UTF-8 locale.
+: ${LOCALE_TR_UTF8=tr_TR.UTF-8}
+if test $LOCALE_TR_UTF8 != none; then
+  LC_ALL=$LOCALE_TR_UTF8 ./test-c-strcasecmp${EXEEXT} locale || exit 1
+  LC_ALL=$LOCALE_TR_UTF8 ./test-c-strncasecmp${EXEEXT} locale || exit 1
+fi
+
+exit 0
diff --git a/gnulib/tests/test-c-strcasecmp.c b/gnulib/tests/test-c-strcasecmp.c
new file mode 100644 (file)
index 0000000..faa3001
--- /dev/null
@@ -0,0 +1,65 @@
+/* Test of case-insensitive string comparison 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include "c-strcase.h"
+
+#include <locale.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  if (argc > 1)
+    {
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+        return 1;
+    }
+
+  ASSERT (c_strcasecmp ("paragraph", "Paragraph") == 0);
+
+  ASSERT (c_strcasecmp ("paragrapH", "parAgRaph") == 0);
+
+  ASSERT (c_strcasecmp ("paragraph", "paraLyzed") < 0);
+  ASSERT (c_strcasecmp ("paraLyzed", "paragraph") > 0);
+
+  ASSERT (c_strcasecmp ("para", "paragraph") < 0);
+  ASSERT (c_strcasecmp ("paragraph", "para") > 0);
+
+  /* The following tests shows how c_strcasecmp() is different from
+     strcasecmp().  */
+
+  ASSERT (c_strcasecmp ("\311mile", "\351mile") < 0);
+  ASSERT (c_strcasecmp ("\351mile", "\311mile") > 0);
+
+  /* The following tests shows how c_strcasecmp() is different from
+     mbscasecmp().  */
+
+  ASSERT (c_strcasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") > 0); /* Ã¶zgür */
+  ASSERT (c_strcasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") < 0); /* Ã¶zgür */
+
+  /* This test shows how strings of different size cannot compare equal.  */
+  ASSERT (c_strcasecmp ("turkish", "TURK\304\260SH") < 0);
+  ASSERT (c_strcasecmp ("TURK\304\260SH", "turkish") > 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-c-strncasecmp.c b/gnulib/tests/test-c-strncasecmp.c
new file mode 100644 (file)
index 0000000..6a225c7
--- /dev/null
@@ -0,0 +1,79 @@
+/* Test of case-insensitive string comparison 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include "c-strcase.h"
+
+#include <locale.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  if (argc > 1)
+    {
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+        return 1;
+    }
+
+  ASSERT (c_strncasecmp ("paragraph", "Paragraph", 1000000) == 0);
+  ASSERT (c_strncasecmp ("paragraph", "Paragraph", 9) == 0);
+
+  ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 1000000) == 0);
+  ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 9) == 0);
+
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 10) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 9) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 5) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 4) == 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 10) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 9) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 5) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 4) == 0);
+
+  ASSERT (c_strncasecmp ("para", "paragraph", 10) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 9) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 5) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 4) == 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 10) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 9) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 5) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 4) == 0);
+
+  /* The following tests shows how c_strncasecmp() is different from
+     strncasecmp().  */
+
+  ASSERT (c_strncasecmp ("\311mily", "\351mile", 4) < 0);
+  ASSERT (c_strncasecmp ("\351mile", "\311mily", 4) > 0);
+
+  /* The following tests shows how c_strncasecmp() is different from
+     mbsncasecmp().  */
+
+  ASSERT (c_strncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) > 0); /* Ã¶zgür */
+  ASSERT (c_strncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) < 0); /* Ã¶zgür */
+
+  /* This test shows how strings of different size cannot compare equal.  */
+  ASSERT (c_strncasecmp ("turkish", "TURK\304\260SH", 7) < 0);
+  ASSERT (c_strncasecmp ("TURK\304\260SH", "turkish", 7) > 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-canonicalize-lgpl.c b/gnulib/tests/test-canonicalize-lgpl.c
new file mode 100644 (file)
index 0000000..17cdff0
--- /dev/null
@@ -0,0 +1,222 @@
+/* Test of execution of program termination handlers.
+   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 <stdlib.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (realpath, char *, (const char *, char *));
+SIGNATURE_CHECK (canonicalize_file_name, char *, (const char *));
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "same-inode.h"
+#include "ignore-value.h"
+#include "macros.h"
+
+#define BASE "t-can-lgpl.tmp"
+
+static void *
+null_ptr (void)
+{
+  return NULL;
+}
+
+int
+main (void)
+{
+#if GNULIB_TEST_CANONICALIZE
+  /* No need to test canonicalize-lgpl module if canonicalize is also
+     in use.  */
+  return 0;
+#endif
+
+  /* Setup some hierarchy to be used by this test.  Start by removing
+     any leftovers from a previous partial run.  */
+  {
+    int fd;
+    ignore_value (system ("rm -rf " BASE " ise"));
+    ASSERT (mkdir (BASE, 0700) == 0);
+    fd = creat (BASE "/tra", 0600);
+    ASSERT (0 <= fd);
+    ASSERT (close (fd) == 0);
+  }
+
+  /* Check for ., .., intermediate // handling, and for error cases.  */
+  {
+    char *result = canonicalize_file_name (BASE "//./..//" BASE "/tra");
+    ASSERT (result != NULL);
+    ASSERT (strstr (result, "/" BASE "/tra")
+            == result + strlen (result) - strlen ("/" BASE "/tra"));
+    free (result);
+    errno = 0;
+    result = canonicalize_file_name ("");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOENT);
+    errno = 0;
+    result = canonicalize_file_name (null_ptr ());
+    ASSERT (result == NULL);
+    ASSERT (errno == EINVAL);
+  }
+
+  /* Check that a non-directory with trailing slash yields NULL.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name (BASE "/tra/");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOTDIR);
+  }
+
+  /* Check that a missing directory yields NULL.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name (BASE "/zzz/..");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOENT);
+  }
+
+  /* From here on out, tests involve symlinks.  */
+  if (symlink (BASE "/ket", "ise") != 0)
+    {
+      ASSERT (remove (BASE "/tra") == 0);
+      ASSERT (rmdir (BASE) == 0);
+      fputs ("skipping test: symlinks not supported on this file system\n",
+             stderr);
+      return 77;
+    }
+  ASSERT (symlink ("bef", BASE "/plo") == 0);
+  ASSERT (symlink ("tra", BASE "/huk") == 0);
+  ASSERT (symlink ("lum", BASE "/bef") == 0);
+  ASSERT (symlink ("wum", BASE "/ouk") == 0);
+  ASSERT (symlink ("../ise", BASE "/ket") == 0);
+  ASSERT (mkdir (BASE "/lum", 0700) == 0);
+  ASSERT (symlink ("//.//../..", BASE "/droot") == 0);
+
+  /* Check that the symbolic link to a file can be resolved.  */
+  {
+    char *result1 = canonicalize_file_name (BASE "/huk");
+    char *result2 = canonicalize_file_name (BASE "/tra");
+    ASSERT (result1 != NULL);
+    ASSERT (result2 != NULL);
+    ASSERT (strcmp (result1, result2) == 0);
+    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/tra"),
+                    "/" BASE "/tra") == 0);
+    free (result1);
+    free (result2);
+  }
+
+  /* Check that the symbolic link to a directory can be resolved.  */
+  {
+    char *result1 = canonicalize_file_name (BASE "/plo");
+    char *result2 = canonicalize_file_name (BASE "/bef");
+    char *result3 = canonicalize_file_name (BASE "/lum");
+    ASSERT (result1 != NULL);
+    ASSERT (result2 != NULL);
+    ASSERT (result3 != NULL);
+    ASSERT (strcmp (result1, result2) == 0);
+    ASSERT (strcmp (result2, result3) == 0);
+    ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/lum"),
+                    "/" BASE "/lum") == 0);
+    free (result1);
+    free (result2);
+    free (result3);
+  }
+
+  /* Check that a symbolic link to a nonexistent file yields NULL.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name (BASE "/ouk");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOENT);
+  }
+
+  /* Check that a non-directory symlink with trailing slash yields NULL.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name (BASE "/huk/");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOTDIR);
+  }
+
+  /* Check that a missing directory via symlink yields NULL.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name (BASE "/ouk/..");
+    ASSERT (result == NULL);
+    ASSERT (errno == ENOENT);
+  }
+
+  /* Check that a loop of symbolic links is detected.  */
+  {
+    char *result;
+    errno = 0;
+    result = canonicalize_file_name ("ise");
+    ASSERT (result == NULL);
+    ASSERT (errno == ELOOP);
+  }
+
+  /* Check that leading // is honored correctly.  */
+  {
+    struct stat st1;
+    struct stat st2;
+    char *result1 = canonicalize_file_name ("//.");
+    char *result2 = canonicalize_file_name (BASE "/droot");
+    ASSERT (result1);
+    ASSERT (result2);
+    ASSERT (stat ("/", &st1) == 0);
+    ASSERT (stat ("//", &st2) == 0);
+    if (SAME_INODE (st1, st2))
+      {
+        ASSERT (strcmp (result1, "/") == 0);
+        ASSERT (strcmp (result2, "/") == 0);
+      }
+    else
+      {
+        ASSERT (strcmp (result1, "//") == 0);
+        ASSERT (strcmp (result2, "//") == 0);
+      }
+    free (result1);
+    free (result2);
+  }
+
+
+  /* Cleanup.  */
+  ASSERT (remove (BASE "/droot") == 0);
+  ASSERT (remove (BASE "/plo") == 0);
+  ASSERT (remove (BASE "/huk") == 0);
+  ASSERT (remove (BASE "/bef") == 0);
+  ASSERT (remove (BASE "/ouk") == 0);
+  ASSERT (remove (BASE "/ket") == 0);
+  ASSERT (remove (BASE "/lum") == 0);
+  ASSERT (remove (BASE "/tra") == 0);
+  ASSERT (remove (BASE) == 0);
+  ASSERT (remove ("ise") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-ctype.c b/gnulib/tests/test-ctype.c
new file mode 100644 (file)
index 0000000..0a5cb19
--- /dev/null
@@ -0,0 +1,27 @@
+/* Test of <ctype.h> substitute.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <ctype.h>
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-dup2.c b/gnulib/tests/test-dup2.c
new file mode 100644 (file)
index 0000000..e2ad88b
--- /dev/null
@@ -0,0 +1,198 @@
+/* Test duplicating file descriptors.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (dup2, int, (int, int));
+
+#include <errno.h>
+#include <fcntl.h>
+
+#include "binary-io.h"
+
+#if GNULIB_TEST_CLOEXEC
+# include "cloexec.h"
+#endif
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Get declarations of the Win32 API functions.  */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
+#include "macros.h"
+
+/* Return non-zero if FD is open.  */
+static int
+is_open (int fd)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  /* On Win32, the initial state of unassigned standard file
+     descriptors is that they are open but point to an
+     INVALID_HANDLE_VALUE, and there is no fcntl.  */
+  return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
+#else
+# ifndef F_GETFL
+#  error Please port fcntl to your platform
+# endif
+  return 0 <= fcntl (fd, F_GETFL);
+#endif
+}
+
+#if GNULIB_TEST_CLOEXEC
+/* Return non-zero if FD is open and inheritable across exec/spawn.  */
+static int
+is_inheritable (int fd)
+{
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  /* On Win32, the initial state of unassigned standard file
+     descriptors is that they are open but point to an
+     INVALID_HANDLE_VALUE, and there is no fcntl.  */
+  HANDLE h = (HANDLE) _get_osfhandle (fd);
+  DWORD flags;
+  if (h == INVALID_HANDLE_VALUE || GetHandleInformation (h, &flags) == 0)
+    return 0;
+  return (flags & HANDLE_FLAG_INHERIT) != 0;
+# else
+#  ifndef F_GETFD
+#   error Please port fcntl to your platform
+#  endif
+  int i = fcntl (fd, F_GETFD);
+  return 0 <= i && (i & FD_CLOEXEC) == 0;
+# endif
+}
+#endif /* GNULIB_TEST_CLOEXEC */
+
+#if !O_BINARY
+# define setmode(f,m) zero ()
+static int zero (void) { return 0; }
+#endif
+
+/* Return non-zero if FD is open in the given MODE, which is either
+   O_TEXT or O_BINARY.  */
+static int
+is_mode (int fd, int mode)
+{
+  int value = setmode (fd, O_BINARY);
+  setmode (fd, value);
+  return mode == value;
+}
+
+int
+main (void)
+{
+  const char *file = "test-dup2.tmp";
+  char buffer[1];
+  int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600);
+
+  /* Assume std descriptors were provided by invoker.  */
+  ASSERT (STDERR_FILENO < fd);
+  ASSERT (is_open (fd));
+  /* Ignore any other fd's leaked into this process.  */
+  close (fd + 1);
+  close (fd + 2);
+  ASSERT (!is_open (fd + 1));
+  ASSERT (!is_open (fd + 2));
+
+  /* Assigning to self must be a no-op.  */
+  ASSERT (dup2 (fd, fd) == fd);
+  ASSERT (is_open (fd));
+
+  /* The source must be valid.  */
+  errno = 0;
+  ASSERT (dup2 (-1, fd) == -1);
+  ASSERT (errno == EBADF);
+  errno = 0;
+  ASSERT (dup2 (AT_FDCWD, fd) == -1);
+  ASSERT (errno == EBADF);
+  ASSERT (is_open (fd));
+
+  /* If the source is not open, then the destination is unaffected.  */
+  errno = 0;
+  ASSERT (dup2 (fd + 1, fd + 1) == -1);
+  ASSERT (errno == EBADF);
+  ASSERT (!is_open (fd + 1));
+  errno = 0;
+  ASSERT (dup2 (fd + 1, fd) == -1);
+  ASSERT (errno == EBADF);
+  ASSERT (is_open (fd));
+
+  /* The destination must be valid.  */
+  errno = 0;
+  ASSERT (dup2 (fd, -2) == -1);
+  ASSERT (errno == EBADF);
+  errno = 0;
+  ASSERT (dup2 (fd, 10000000) == -1);
+  ASSERT (errno == EBADF);
+
+  /* Using dup2 can skip fds.  */
+  ASSERT (dup2 (fd, fd + 2) == fd + 2);
+  ASSERT (is_open (fd));
+  ASSERT (!is_open (fd + 1));
+  ASSERT (is_open (fd + 2));
+
+  /* Verify that dup2 closes the previous occupant of a fd.  */
+  ASSERT (open ("/dev/null", O_WRONLY, 0600) == fd + 1);
+  ASSERT (dup2 (fd + 1, fd) == fd);
+  ASSERT (close (fd + 1) == 0);
+  ASSERT (write (fd, "1", 1) == 1);
+  ASSERT (dup2 (fd + 2, fd) == fd);
+  ASSERT (lseek (fd, 0, SEEK_END) == 0);
+  ASSERT (write (fd + 2, "2", 1) == 1);
+  ASSERT (lseek (fd, 0, SEEK_SET) == 0);
+  ASSERT (read (fd, buffer, 1) == 1);
+  ASSERT (*buffer == '2');
+
+#if GNULIB_TEST_CLOEXEC
+  /* Any new fd created by dup2 must not be cloexec.  */
+  ASSERT (close (fd + 2) == 0);
+  ASSERT (dup_cloexec (fd) == fd + 1);
+  ASSERT (!is_inheritable (fd + 1));
+  ASSERT (dup2 (fd + 1, fd + 1) == fd + 1);
+  ASSERT (!is_inheritable (fd + 1));
+  ASSERT (dup2 (fd + 1, fd + 2) == fd + 2);
+  ASSERT (!is_inheritable (fd + 1));
+  ASSERT (is_inheritable (fd + 2));
+  errno = 0;
+  ASSERT (dup2 (fd + 1, -1) == -1);
+  ASSERT (errno == EBADF);
+  ASSERT (!is_inheritable (fd + 1));
+#endif
+
+  /* On systems that distinguish between text and binary mode, dup2
+     reuses the mode of the source.  */
+  setmode (fd, O_BINARY);
+  ASSERT (is_mode (fd, O_BINARY));
+  ASSERT (dup2 (fd, fd + 1) == fd + 1);
+  ASSERT (is_mode (fd + 1, O_BINARY));
+  setmode (fd, O_TEXT);
+  ASSERT (is_mode (fd, O_TEXT));
+  ASSERT (dup2 (fd, fd + 1) == fd + 1);
+  ASSERT (is_mode (fd + 1, O_TEXT));
+
+  /* Clean up.  */
+  ASSERT (close (fd + 2) == 0);
+  ASSERT (close (fd + 1) == 0);
+  ASSERT (close (fd) == 0);
+  ASSERT (unlink (file) == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-environ.c b/gnulib/tests/test-environ.c
new file mode 100644 (file)
index 0000000..11df789
--- /dev/null
@@ -0,0 +1,44 @@
+/* Test of environ variable.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include <string.h>
+
+int
+main ()
+{
+  /* The environment variables that are set even in the weirdest situations
+     are HOME and PATH.
+     POSIX says that HOME is initialized by the system, and that PATH may be
+     unset.  But in practice it's more frequent to see HOME unset and PATH
+     set.  So we test the presence of PATH.  */
+  char **remaining_variables = environ;
+  char *string;
+
+  for (; (string = *remaining_variables) != NULL; remaining_variables++)
+    {
+      if (strncmp (string, "PATH=", 5) == 0)
+        /* Found the PATH environment variable.  */
+        return 0;
+    }
+  /* Failed to find the PATH environment variable.  */
+  return 1;
+}
diff --git a/gnulib/tests/test-errno.c b/gnulib/tests/test-errno.c
new file mode 100644 (file)
index 0000000..7851c22
--- /dev/null
@@ -0,0 +1,117 @@
+/* Test of <errno.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <errno.h>
+
+/* Verify that the POSIX mandated errno values exist and can be used as
+   initializers outside of a function.
+   The variable names happen to match the Linux/x86 error numbers.  */
+int e1 = EPERM;
+int e2 = ENOENT;
+int e3 = ESRCH;
+int e4 = EINTR;
+int e5 = EIO;
+int e6 = ENXIO;
+int e7 = E2BIG;
+int e8 = ENOEXEC;
+int e9 = EBADF;
+int e10 = ECHILD;
+int e11 = EAGAIN;
+int e11a = EWOULDBLOCK;
+int e12 = ENOMEM;
+int e13 = EACCES;
+int e14 = EFAULT;
+int e16 = EBUSY;
+int e17 = EEXIST;
+int e18 = EXDEV;
+int e19 = ENODEV;
+int e20 = ENOTDIR;
+int e21 = EISDIR;
+int e22 = EINVAL;
+int e23 = ENFILE;
+int e24 = EMFILE;
+int e25 = ENOTTY;
+int e26 = ETXTBSY;
+int e27 = EFBIG;
+int e28 = ENOSPC;
+int e29 = ESPIPE;
+int e30 = EROFS;
+int e31 = EMLINK;
+int e32 = EPIPE;
+int e33 = EDOM;
+int e34 = ERANGE;
+int e35 = EDEADLK;
+int e36 = ENAMETOOLONG;
+int e37 = ENOLCK;
+int e38 = ENOSYS;
+int e39 = ENOTEMPTY;
+int e40 = ELOOP;
+int e42 = ENOMSG;
+int e43 = EIDRM;
+int e67 = ENOLINK;
+int e71 = EPROTO;
+int e72 = EMULTIHOP;
+int e74 = EBADMSG;
+int e75 = EOVERFLOW;
+int e84 = EILSEQ;
+int e88 = ENOTSOCK;
+int e89 = EDESTADDRREQ;
+int e90 = EMSGSIZE;
+int e91 = EPROTOTYPE;
+int e92 = ENOPROTOOPT;
+int e93 = EPROTONOSUPPORT;
+int e95 = EOPNOTSUPP;
+int e95a = ENOTSUP;
+int e97 = EAFNOSUPPORT;
+int e98 = EADDRINUSE;
+int e99 = EADDRNOTAVAIL;
+int e100 = ENETDOWN;
+int e101 = ENETUNREACH;
+int e102 = ENETRESET;
+int e103 = ECONNABORTED;
+int e104 = ECONNRESET;
+int e105 = ENOBUFS;
+int e106 = EISCONN;
+int e107 = ENOTCONN;
+int e110 = ETIMEDOUT;
+int e111 = ECONNREFUSED;
+int e113 = EHOSTUNREACH;
+int e114 = EALREADY;
+int e115 = EINPROGRESS;
+int e116 = ESTALE;
+int e122 = EDQUOT;
+int e125 = ECANCELED;
+
+/* Don't verify that these errno values are all different, except for possibly
+   EWOULDBLOCK == EAGAIN.  Even Linux/x86 does not pass this check: it has
+   ENOTSUP == EOPNOTSUPP.  */
+
+int
+main ()
+{
+  /* Verify that errno can be assigned.  */
+  errno = EOVERFLOW;
+
+  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
+  if (errno == EINVAL)
+    return 1;
+
+  return 0;
+}
diff --git a/gnulib/tests/test-fcntl-h.c b/gnulib/tests/test-fcntl-h.c
new file mode 100644 (file)
index 0000000..dd20fbb
--- /dev/null
@@ -0,0 +1,38 @@
+/* Test of <fcntl.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <fcntl.h>
+
+/* Check that the various O_* macros are defined.  */
+int o = O_DIRECT | O_DIRECTORY | O_DSYNC | O_NDELAY | O_NOATIME | O_NONBLOCK
+        | O_NOCTTY | O_NOFOLLOW | O_NOLINKS | O_RSYNC | O_SYNC | O_TTY_INIT
+        | O_BINARY | O_TEXT;
+
+/* Check that the various SEEK_* macros are defined.  */
+int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
+
+/* Check that the FD_* macros are defined.  */
+int fd = FD_CLOEXEC;
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-fnmatch.c b/gnulib/tests/test-fnmatch.c
new file mode 100644 (file)
index 0000000..66f9b1c
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test of fnmatch string matching function.
+   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 Simon Josefsson <simon@josefsson.org>, 2009.  */
+
+#include <config.h>
+
+#include <fnmatch.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int));
+
+#include "macros.h"
+
+int
+main ()
+{
+  int res;
+
+  ASSERT (res = fnmatch ("", "", 0) == 0);
+
+  ASSERT (res = fnmatch ("*", "", 0) == 0);
+  ASSERT (res = fnmatch ("*", "foo", 0) == 0);
+  ASSERT (res = fnmatch ("*", "bar", 0) == 0);
+  ASSERT (res = fnmatch ("*", "*", 0) == 0);
+  ASSERT (res = fnmatch ("**", "f", 0) == 0);
+  ASSERT (res = fnmatch ("**", "foo.txt", 0) == 0);
+  ASSERT (res = fnmatch ("*.*", "foo.txt", 0) == 0);
+
+  ASSERT (res = fnmatch ("foo*.txt", "foobar.txt", 0) == 0);
+
+  ASSERT (res = fnmatch ("foo.txt", "foo.txt", 0) == 0);
+  ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", 0) == 0);
+  ASSERT (res = fnmatch ("foo\\.txt", "foo.txt", FNM_NOESCAPE) == FNM_NOMATCH);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-getdelim.c b/gnulib/tests/test-getdelim.c
new file mode 100644 (file)
index 0000000..f4d1c9d
--- /dev/null
@@ -0,0 +1,95 @@
+/* Test of getdelim() 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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2007.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (getdelim, ssize_t, (char **, size_t *, int, FILE *));
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  FILE *f;
+  char *line;
+  size_t len;
+  ssize_t result;
+
+  /* Create test file.  */
+  f = fopen ("test-getdelim.txt", "wb");
+  if (!f || fwrite ("anAnbcnd\0f", 1, 10, f) != 10 || fclose (f) != 0)
+    {
+      fputs ("Failed to create sample file.\n", stderr);
+      remove ("test-getdelim.txt");
+      return 1;
+    }
+  f = fopen ("test-getdelim.txt", "rb");
+  if (!f)
+    {
+      fputs ("Failed to reopen sample file.\n", stderr);
+      remove ("test-getdelim.txt");
+      return 1;
+    }
+
+  /* Test initial allocation, which must include trailing NUL.  */
+  line = NULL;
+  len = 0;
+  result = getdelim (&line, &len, 'n', f);
+  ASSERT (result == 2);
+  ASSERT (strcmp (line, "an") == 0);
+  ASSERT (2 < len);
+  free (line);
+
+  /* Test initial allocation again, with line = NULL and len != 0.  */
+  line = NULL;
+  len = (size_t)(~0) / 4;
+  result = getdelim (&line, &len, 'n', f);
+  ASSERT (result == 2);
+  ASSERT (strcmp (line, "An") == 0);
+  ASSERT (2 < len);
+  free (line);
+
+  /* Test growth of buffer.  */
+  line = malloc (1);
+  len = 1;
+  result = getdelim (&line, &len, 'n', f);
+  ASSERT (result == 3);
+  ASSERT (strcmp (line, "bcn") == 0);
+  ASSERT (3 < len);
+
+  /* Test embedded NULs and EOF behavior.  */
+  result = getdelim (&line, &len, 'n', f);
+  ASSERT (result == 3);
+  ASSERT (memcmp (line, "d\0f", 4) == 0);
+  ASSERT (3 < len);
+
+  result = getdelim (&line, &len, 'n', f);
+  ASSERT (result == -1);
+
+  free (line);
+  fclose (f);
+  remove ("test-getdelim.txt");
+  return 0;
+}
diff --git a/gnulib/tests/test-getline.c b/gnulib/tests/test-getline.c
new file mode 100644 (file)
index 0000000..bead4b6
--- /dev/null
@@ -0,0 +1,95 @@
+/* Test of getline() 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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2007.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (getline, ssize_t, (char **, size_t *, FILE *));
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  FILE *f;
+  char *line;
+  size_t len;
+  ssize_t result;
+
+  /* Create test file.  */
+  f = fopen ("test-getline.txt", "wb");
+  if (!f || fwrite ("a\nA\nbc\nd\0f", 1, 10, f) != 10 || fclose (f) != 0)
+    {
+      fputs ("Failed to create sample file.\n", stderr);
+      remove ("test-getline.txt");
+      return 1;
+    }
+  f = fopen ("test-getline.txt", "rb");
+  if (!f)
+    {
+      fputs ("Failed to reopen sample file.\n", stderr);
+      remove ("test-getline.txt");
+      return 1;
+    }
+
+  /* Test initial allocation, which must include trailing NUL.  */
+  line = NULL;
+  len = 0;
+  result = getline (&line, &len, f);
+  ASSERT (result == 2);
+  ASSERT (strcmp (line, "a\n") == 0);
+  ASSERT (2 < len);
+  free (line);
+
+  /* Test initial allocation again, with line = NULL and len != 0.  */
+  line = NULL;
+  len = (size_t)(~0) / 4;
+  result = getline (&line, &len, f);
+  ASSERT (result == 2);
+  ASSERT (strcmp (line, "A\n") == 0);
+  ASSERT (2 < len);
+  free (line);
+
+  /* Test growth of buffer, must not leak.  */
+  line = malloc (1);
+  len = 0;
+  result = getline (&line, &len, f);
+  ASSERT (result == 3);
+  ASSERT (strcmp (line, "bc\n") == 0);
+  ASSERT (3 < len);
+
+  /* Test embedded NULs and EOF behavior.  */
+  result = getline (&line, &len, f);
+  ASSERT (result == 3);
+  ASSERT (memcmp (line, "d\0f", 4) == 0);
+  ASSERT (3 < len);
+
+  result = getline (&line, &len, f);
+  ASSERT (result == -1);
+
+  free (line);
+  fclose (f);
+  remove ("test-getline.txt");
+  return 0;
+}
diff --git a/gnulib/tests/test-getopt.c b/gnulib/tests/test-getopt.c
new file mode 100644 (file)
index 0000000..69f2cfa
--- /dev/null
@@ -0,0 +1,99 @@
+/* Test of command line argument processing.
+   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>
+
+/* None of the files accessed by this test are large, so disable the
+   ftell link warning if we are not using the gnulib ftell module.  */
+#define _GL_NO_LARGE_FILES
+
+#if GNULIB_TEST_GETOPT_GNU
+# include <getopt.h>
+
+# ifndef __getopt_argv_const
+#  define __getopt_argv_const const
+# endif
+# include "signature.h"
+SIGNATURE_CHECK (getopt_long, int, (int, char *__getopt_argv_const *,
+                                    char const *, struct option const *,
+                                    int *));
+SIGNATURE_CHECK (getopt_long_only, int, (int, char *__getopt_argv_const *,
+                                         char const *, struct option const *,
+                                         int *));
+
+#endif
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (getopt, int, (int, char * const[], char const *));
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* This test intentionally remaps stderr.  So, we arrange to have fd 10
+   (outside the range of interesting fd's during the test) set up to
+   duplicate the original stderr.  */
+
+#define BACKUP_STDERR_FILENO 10
+#define ASSERT_STREAM myerr
+#include "macros.h"
+
+static FILE *myerr;
+
+#include "test-getopt.h"
+#if GNULIB_TEST_GETOPT_GNU
+# include "test-getopt_long.h"
+#endif
+
+int
+main (void)
+{
+   /* This test validates that stderr is used correctly, so move the
+      original into fd 10.  */
+  if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO
+      || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL)
+    return 2;
+
+  ASSERT (freopen ("test-getopt.tmp", "w", stderr) == stderr);
+
+  /* These default values are required by POSIX.  */
+  ASSERT (optind == 1);
+  ASSERT (opterr != 0);
+
+  setenv ("POSIXLY_CORRECT", "1", 1);
+  test_getopt ();
+
+#if GNULIB_TEST_GETOPT_GNU
+  test_getopt_long_posix ();
+#endif
+
+  unsetenv ("POSIXLY_CORRECT");
+  test_getopt ();
+
+#if GNULIB_TEST_GETOPT_GNU
+  test_getopt_long ();
+  test_getopt_long_only ();
+#endif
+
+  ASSERT (fclose (stderr) == 0);
+  ASSERT (remove ("test-getopt.tmp") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-getopt.h b/gnulib/tests/test-getopt.h
new file mode 100644 (file)
index 0000000..9c877b3
--- /dev/null
@@ -0,0 +1,1369 @@
+/* Test of command line argument processing.
+   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 <stdbool.h>
+
+/* The glibc/gnulib implementation of getopt supports setting optind =
+   0, but not all other implementations do.  This matters for getopt.
+   But for getopt_long, we require GNU compatibility.  */
+#if defined __GETOPT_PREFIX || (__GLIBC__ >= 2 && !defined __UCLIBC__)
+# define OPTIND_MIN 0
+#elif HAVE_DECL_OPTRESET
+# define OPTIND_MIN (optreset = 1)
+#else
+# define OPTIND_MIN 1
+#endif
+
+static void
+getopt_loop (int argc, const char **argv,
+             const char *options,
+             int *a_seen, int *b_seen,
+             const char **p_value, const char **q_value,
+             int *non_options_count, const char **non_options,
+             int *unrecognized, bool *message_issued)
+{
+  int c;
+  int pos = ftell (stderr);
+
+  while ((c = getopt (argc, (char **) argv, options)) != -1)
+    {
+      switch (c)
+        {
+        case 'a':
+          (*a_seen)++;
+          break;
+        case 'b':
+          (*b_seen)++;
+          break;
+        case 'p':
+          *p_value = optarg;
+          break;
+        case 'q':
+          *q_value = optarg;
+          break;
+        case '\1':
+          /* Must only happen with option '-' at the beginning.  */
+          ASSERT (options[0] == '-');
+          non_options[(*non_options_count)++] = optarg;
+          break;
+        case ':':
+          /* Must only happen with option ':' at the beginning.  */
+          ASSERT (options[0] == ':'
+                  || ((options[0] == '-' || options[0] == '+')
+                      && options[1] == ':'));
+          /* fall through */
+        case '?':
+          *unrecognized = optopt;
+          break;
+        default:
+          *unrecognized = c;
+          break;
+        }
+    }
+
+  *message_issued = pos < ftell (stderr);
+}
+
+static void
+test_getopt (void)
+{
+  int start;
+  bool posixly = !!getenv ("POSIXLY_CORRECT");
+  /* See comment in getopt.c:
+     glibc gets a LSB-compliant getopt.
+     Standalone applications get a POSIX-compliant getopt.  */
+#if defined __GETOPT_PREFIX || !(__GLIBC__ >= 2 || defined __MINGW32__)
+  /* Using getopt from gnulib or from a non-glibc system.  */
+  posixly = true;
+#endif
+
+  /* Test processing of boolean options.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "ab",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-b";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "ab",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ba";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "ab",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "ab",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 2);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+      ASSERT (!output);
+    }
+
+  /* Test processing of options with arguments.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "p:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "p:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "-q";
+      argv[argc++] = "baz";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+      ASSERT (!output);
+    }
+
+#if GNULIB_TEST_GETOPT_GNU
+  /* Test processing of options with optional arguments.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "p::q::",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "p::q::",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp::q::",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+      ASSERT (!output);
+    }
+#endif /* GNULIB_TEST_GETOPT_GNU */
+
+  /* Check that invalid options are recognized; and that both opterr
+     and leading ':' can silence output.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-x";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 42;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'x');
+      ASSERT (optind == 5);
+      ASSERT (output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-x";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 0;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'x');
+      ASSERT (optind == 5);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-x";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, ":abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'x');
+      ASSERT (optind == 5);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-:";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 42;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == ':');
+      ASSERT (optind == 5);
+      ASSERT (output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-:";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 0;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == ':');
+      ASSERT (optind == 5);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-:";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, ":abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == ':');
+      ASSERT (optind == 5);
+      ASSERT (!output);
+    }
+
+  /* Check for missing argument behavior.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ap";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'p');
+      ASSERT (optind == 2);
+      ASSERT (output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ap";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 0;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'p');
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ap";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, ":abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'p');
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+
+  /* Check that by default, non-options arguments are moved to the end.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      if (posixly)
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "donald") == 0);
+          ASSERT (strcmp (argv[2], "-p") == 0);
+          ASSERT (strcmp (argv[3], "billy") == 0);
+          ASSERT (strcmp (argv[4], "duck") == 0);
+          ASSERT (strcmp (argv[5], "-a") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 0);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value == NULL);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 1);
+          ASSERT (!output);
+        }
+      else
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "-p") == 0);
+          ASSERT (strcmp (argv[2], "billy") == 0);
+          ASSERT (strcmp (argv[3], "-a") == 0);
+          ASSERT (strcmp (argv[4], "donald") == 0);
+          ASSERT (strcmp (argv[5], "duck") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 1);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 4);
+          ASSERT (!output);
+        }
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[20];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      if (posixly)
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "donald") == 0);
+          ASSERT (strcmp (argv[2], "-p") == 0);
+          ASSERT (strcmp (argv[3], "billy") == 0);
+          ASSERT (strcmp (argv[4], "duck") == 0);
+          ASSERT (strcmp (argv[5], "-a") == 0);
+          ASSERT (strcmp (argv[6], "--") == 0);
+          ASSERT (strcmp (argv[7], "-b") == 0);
+          ASSERT (strcmp (argv[8], "foo") == 0);
+          ASSERT (strcmp (argv[9], "-q") == 0);
+          ASSERT (strcmp (argv[10], "johnny") == 0);
+          ASSERT (strcmp (argv[11], "bar") == 0);
+          ASSERT (argv[12] == NULL);
+          ASSERT (a_seen == 0);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value == NULL);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 1);
+          ASSERT (!output);
+        }
+      else
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "-p") == 0);
+          ASSERT (strcmp (argv[2], "billy") == 0);
+          ASSERT (strcmp (argv[3], "-a") == 0);
+          ASSERT (strcmp (argv[4], "--") == 0);
+          ASSERT (strcmp (argv[5], "donald") == 0);
+          ASSERT (strcmp (argv[6], "duck") == 0);
+          ASSERT (strcmp (argv[7], "-b") == 0);
+          ASSERT (strcmp (argv[8], "foo") == 0);
+          ASSERT (strcmp (argv[9], "-q") == 0);
+          ASSERT (strcmp (argv[10], "johnny") == 0);
+          ASSERT (strcmp (argv[11], "bar") == 0);
+          ASSERT (argv[12] == NULL);
+          ASSERT (a_seen == 1);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 5);
+          ASSERT (!output);
+        }
+    }
+
+#if GNULIB_TEST_GETOPT_GNU
+  /* Check that the '-' flag causes non-options to be returned in order.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "-abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 3);
+      ASSERT (strcmp (non_options[0], "donald") == 0);
+      ASSERT (strcmp (non_options[1], "duck") == 0);
+      ASSERT (strcmp (non_options[2], "bar") == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 7);
+      ASSERT (!output);
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[20];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "-abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "--") == 0);
+      ASSERT (strcmp (argv[7], "-b") == 0);
+      ASSERT (strcmp (argv[8], "foo") == 0);
+      ASSERT (strcmp (argv[9], "-q") == 0);
+      ASSERT (strcmp (argv[10], "johnny") == 0);
+      ASSERT (strcmp (argv[11], "bar") == 0);
+      ASSERT (argv[12] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (!output);
+      if (non_options_count == 2)
+        {
+          /* glibc behaviour.  */
+          ASSERT (non_options_count == 2);
+          ASSERT (strcmp (non_options[0], "donald") == 0);
+          ASSERT (strcmp (non_options[1], "duck") == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 7);
+        }
+      else
+        {
+          /* Another valid behaviour.  */
+          ASSERT (non_options_count == 7);
+          ASSERT (strcmp (non_options[0], "donald") == 0);
+          ASSERT (strcmp (non_options[1], "duck") == 0);
+          ASSERT (strcmp (non_options[2], "-b") == 0);
+          ASSERT (strcmp (non_options[3], "foo") == 0);
+          ASSERT (strcmp (non_options[4], "-q") == 0);
+          ASSERT (strcmp (non_options[5], "johnny") == 0);
+          ASSERT (strcmp (non_options[6], "bar") == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 12);
+        }
+    }
+
+  /* Check that the '-' flag has to come first.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:-",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      if (posixly)
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "donald") == 0);
+          ASSERT (strcmp (argv[2], "-p") == 0);
+          ASSERT (strcmp (argv[3], "billy") == 0);
+          ASSERT (strcmp (argv[4], "duck") == 0);
+          ASSERT (strcmp (argv[5], "-a") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 0);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value == NULL);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 1);
+          ASSERT (!output);
+        }
+      else
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "-p") == 0);
+          ASSERT (strcmp (argv[2], "billy") == 0);
+          ASSERT (strcmp (argv[3], "-a") == 0);
+          ASSERT (strcmp (argv[4], "donald") == 0);
+          ASSERT (strcmp (argv[5], "duck") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 1);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 4);
+          ASSERT (!output);
+        }
+    }
+
+  /* Check that the '+' flag causes the first non-option to terminate the
+     loop.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "+abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-+";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_loop (argc, argv, "+abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == '+');
+      ASSERT (optind == 2);
+      ASSERT (output);
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[20];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "+abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "--") == 0);
+      ASSERT (strcmp (argv[7], "-b") == 0);
+      ASSERT (strcmp (argv[8], "foo") == 0);
+      ASSERT (strcmp (argv[9], "-q") == 0);
+      ASSERT (strcmp (argv[10], "johnny") == 0);
+      ASSERT (strcmp (argv[11], "bar") == 0);
+      ASSERT (argv[12] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+      ASSERT (!output);
+    }
+#endif /* GNULIB_TEST_GETOPT_GNU */
+
+  /* Check that the '+' flag has to come first.  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "abp:q:+",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      if (posixly)
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "donald") == 0);
+          ASSERT (strcmp (argv[2], "-p") == 0);
+          ASSERT (strcmp (argv[3], "billy") == 0);
+          ASSERT (strcmp (argv[4], "duck") == 0);
+          ASSERT (strcmp (argv[5], "-a") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 0);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value == NULL);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 1);
+          ASSERT (!output);
+        }
+      else
+        {
+          ASSERT (strcmp (argv[0], "program") == 0);
+          ASSERT (strcmp (argv[1], "-p") == 0);
+          ASSERT (strcmp (argv[2], "billy") == 0);
+          ASSERT (strcmp (argv[3], "-a") == 0);
+          ASSERT (strcmp (argv[4], "donald") == 0);
+          ASSERT (strcmp (argv[5], "duck") == 0);
+          ASSERT (strcmp (argv[6], "bar") == 0);
+          ASSERT (argv[7] == NULL);
+          ASSERT (a_seen == 1);
+          ASSERT (b_seen == 0);
+          ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+          ASSERT (q_value == NULL);
+          ASSERT (non_options_count == 0);
+          ASSERT (unrecognized == 0);
+          ASSERT (optind == 4);
+          ASSERT (!output);
+        }
+    }
+
+#if GNULIB_TEST_GETOPT_GNU
+  /* If GNU extensions are supported, require compliance with POSIX
+     interpretation on leading '+' behavior.
+     http://austingroupbugs.net/view.php?id=191  */
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      opterr = 1;
+      getopt_loop (argc, argv, "+:abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_loop (argc, argv, "+:abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'p');
+      ASSERT (optind == 2);
+      ASSERT (!output);
+    }
+  for (start = OPTIND_MIN; start <= 1; start++)
+    {
+      int a_seen = 0;
+      int b_seen = 0;
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      bool output;
+      int argc = 0;
+      const char *argv[10];
+
+      argv[argc++] = "program";
+      argv[argc++] = "-b";
+      argv[argc++] = "-p";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_loop (argc, argv, "+:abp:q:",
+                   &a_seen, &b_seen, &p_value, &q_value,
+                   &non_options_count, non_options, &unrecognized, &output);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'p');
+      ASSERT (optind == 3);
+      ASSERT (!output);
+    }
+#endif /* GNULIB_TEST_GETOPT_GNU */
+}
diff --git a/gnulib/tests/test-getopt_long.h b/gnulib/tests/test-getopt_long.h
new file mode 100644 (file)
index 0000000..7a74867
--- /dev/null
@@ -0,0 +1,2125 @@
+/* Test of command line argument processing.
+   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.  */
+
+static int a_seen;
+static int b_seen;
+static int q_seen;
+
+static const struct option long_options_required[] =
+  {
+    { "alpha",    no_argument,       NULL, 'a' },
+    { "beta",     no_argument,       &b_seen, 1 },
+    { "prune",    required_argument, NULL, 'p' },
+    { "quetsche", required_argument, &q_seen, 1 },
+    { "xtremely-",no_argument,       NULL, 1003 },
+    { "xtra",     no_argument,       NULL, 1001 },
+    { "xtreme",   no_argument,       NULL, 1002 },
+    { "xtremely", no_argument,       NULL, 1003 },
+    { NULL,       0,                 NULL, 0 }
+  };
+
+static const struct option long_options_optional[] =
+  {
+    { "alpha",    no_argument,       NULL, 'a' },
+    { "beta",     no_argument,       &b_seen, 1 },
+    { "prune",    optional_argument, NULL, 'p' },
+    { "quetsche", optional_argument, &q_seen, 1 },
+    { NULL,       0,                 NULL, 0 }
+  };
+
+static void
+getopt_long_loop (int argc, const char **argv,
+                  const char *options, const struct option *long_options,
+                  const char **p_value, const char **q_value,
+                  int *non_options_count, const char **non_options,
+                  int *unrecognized)
+{
+  int option_index = -1;
+  int c;
+
+  opterr = 0;
+  q_seen = 0;
+  while ((c = getopt_long (argc, (char **) argv, options, long_options,
+                           &option_index))
+         != -1)
+    {
+      switch (c)
+        {
+        case 0:
+          /* An option with a non-NULL flag pointer was processed.  */
+          if (q_seen)
+            *q_value = optarg;
+          break;
+        case 'a':
+          a_seen++;
+          break;
+        case 'b':
+          b_seen = 1;
+          break;
+        case 'p':
+          *p_value = optarg;
+          break;
+        case 'q':
+          *q_value = optarg;
+          break;
+        case '\1':
+          /* Must only happen with option '-' at the beginning.  */
+          ASSERT (options[0] == '-');
+          non_options[(*non_options_count)++] = optarg;
+          break;
+        case ':':
+          /* Must only happen with option ':' at the beginning.  */
+          ASSERT (options[0] == ':'
+                  || ((options[0] == '-' || options[0] == '+')
+                      && options[1] == ':'));
+          /* fall through */
+        case '?':
+          *unrecognized = optopt;
+          break;
+        default:
+          *unrecognized = c;
+          break;
+        }
+    }
+}
+
+/* Reduce casting, so we can use string literals elsewhere.
+   getopt_long takes an array of char*, but luckily does not modify
+   those elements, so we can pass const char*.  */
+static int
+do_getopt_long (int argc, const char **argv, const char *shortopts,
+                const struct option *longopts, int *longind)
+{
+  return getopt_long (argc, (char **) argv, shortopts, longopts, longind);
+}
+
+static void
+test_getopt_long (void)
+{
+  int start;
+
+  /* Test disambiguation of options.  */
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--x";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xt";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtr";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtra";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == 1001);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtre";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtrem";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtreme";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == 1002);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtremel";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == 1003);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--xtremely";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "ab", long_options_required, &option_index);
+    ASSERT (c == 1003);
+  }
+
+  /* Check that -W handles unknown options.  */
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-W";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 'W');
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-Wunknown";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index);
+    /* glibc and BSD behave differently here, but for now, we allow
+       both behaviors since W support is not frequently used.  */
+    if (c == '?')
+      {
+        ASSERT (optopt == 0);
+        ASSERT (optarg == NULL);
+      }
+    else
+      {
+        ASSERT (c == 'W');
+        ASSERT (strcmp (optarg, "unknown") == 0);
+      }
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-W";
+    argv[argc++] = "unknown";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long (argc, argv, "W;", long_options_required, &option_index);
+    /* glibc and BSD behave differently here, but for now, we allow
+       both behaviors since W support is not frequently used.  */
+    if (c == '?')
+      {
+        ASSERT (optopt == 0);
+        ASSERT (optarg == NULL);
+      }
+    else
+      {
+        ASSERT (c == 'W');
+        ASSERT (strcmp (optarg, "unknown") == 0);
+      }
+  }
+
+  /* Test processing of boolean short options.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-b";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ba";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "-a";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 2);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+
+  /* Test processing of boolean long options.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--alpha";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--beta";
+      argv[argc++] = "--alpha";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--alpha";
+      argv[argc++] = "--beta";
+      argv[argc++] = "--alpha";
+      argv[argc++] = "--beta";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 2);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+
+  /* Test processing of boolean long options via -W.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Walpha";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abW;", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-W";
+      argv[argc++] = "beta";
+      argv[argc++] = "-W";
+      argv[argc++] = "alpha";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "aW;b", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Walpha";
+      argv[argc++] = "-Wbeta";
+      argv[argc++] = "-Walpha";
+      argv[argc++] = "-Wbeta";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "W;ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 2);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+
+  /* Test processing of short options with arguments.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "-q";
+      argv[argc++] = "baz";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+
+  /* Test processing of long options with arguments.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "--q";
+      argv[argc++] = "baz";
+      argv[argc++] = "--p=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+
+  /* Test processing of long options with arguments via -W.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Wp=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:q:W;", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-W";
+      argv[argc++] = "p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p:W;q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-ab";
+      argv[argc++] = "-Wq";
+      argv[argc++] = "baz";
+      argv[argc++] = "-W";
+      argv[argc++] = "p=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "W;abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value != NULL && strcmp (q_value, "baz") == 0);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 6);
+    }
+
+  /* Test processing of short options with optional arguments.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-pfoo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+
+  /* Test processing of long options with optional arguments.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p=";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && *p_value == '\0');
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "--p";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+
+  /* Test processing of long options with optional arguments via -W.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Wp=foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::W;", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Wp";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::q::W;", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-Wp=";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "W;p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && *p_value == '\0');
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-W";
+      argv[argc++] = "p=";
+      argv[argc++] = "foo";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "W;p::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && *p_value == '\0');
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 3);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-W";
+      argv[argc++] = "p";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "W;abp::q::", long_options_optional,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      /* ASSERT (p_value == NULL); */
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+
+  /* Check that invalid options are recognized.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-x";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'x');
+      ASSERT (optind == 5);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "-:";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == ':');
+      ASSERT (optind == 5);
+    }
+
+  /* Check that unexpected arguments are recognized.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "--a=";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 'a');
+      ASSERT (optind == 4);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "foo";
+      argv[argc++] = "--b=";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "foo") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      /* When flag is non-zero, glibc sets optopt anyway, but BSD
+         leaves optopt unchanged.  */
+      ASSERT (unrecognized == 1 || unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+
+  /* Check that by default, non-options arguments are moved to the end.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "-p") == 0);
+      ASSERT (strcmp (argv[2], "billy") == 0);
+      ASSERT (strcmp (argv[3], "-a") == 0);
+      ASSERT (strcmp (argv[4], "donald") == 0);
+      ASSERT (strcmp (argv[5], "duck") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[20];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "-p") == 0);
+      ASSERT (strcmp (argv[2], "billy") == 0);
+      ASSERT (strcmp (argv[3], "-a") == 0);
+      ASSERT (strcmp (argv[4], "--") == 0);
+      ASSERT (strcmp (argv[5], "donald") == 0);
+      ASSERT (strcmp (argv[6], "duck") == 0);
+      ASSERT (strcmp (argv[7], "-b") == 0);
+      ASSERT (strcmp (argv[8], "foo") == 0);
+      ASSERT (strcmp (argv[9], "-q") == 0);
+      ASSERT (strcmp (argv[10], "johnny") == 0);
+      ASSERT (strcmp (argv[11], "bar") == 0);
+      ASSERT (argv[12] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 5);
+    }
+
+  /* Check that the '-' flag causes non-options to be returned in order.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "-abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 3);
+      ASSERT (strcmp (non_options[0], "donald") == 0);
+      ASSERT (strcmp (non_options[1], "duck") == 0);
+      ASSERT (strcmp (non_options[2], "bar") == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 7);
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[20];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "-abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "--") == 0);
+      ASSERT (strcmp (argv[7], "-b") == 0);
+      ASSERT (strcmp (argv[8], "foo") == 0);
+      ASSERT (strcmp (argv[9], "-q") == 0);
+      ASSERT (strcmp (argv[10], "johnny") == 0);
+      ASSERT (strcmp (argv[11], "bar") == 0);
+      ASSERT (argv[12] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      if (non_options_count == 2)
+      {
+        /* glibc behaviour.  */
+        ASSERT (non_options_count == 2);
+        ASSERT (strcmp (non_options[0], "donald") == 0);
+        ASSERT (strcmp (non_options[1], "duck") == 0);
+        ASSERT (unrecognized == 0);
+        ASSERT (optind == 7);
+      }
+      else
+      {
+        /* Another valid behaviour.  */
+        ASSERT (non_options_count == 7);
+        ASSERT (strcmp (non_options[0], "donald") == 0);
+        ASSERT (strcmp (non_options[1], "duck") == 0);
+        ASSERT (strcmp (non_options[2], "-b") == 0);
+        ASSERT (strcmp (non_options[3], "foo") == 0);
+        ASSERT (strcmp (non_options[4], "-q") == 0);
+        ASSERT (strcmp (non_options[5], "johnny") == 0);
+        ASSERT (strcmp (non_options[6], "bar") == 0);
+        ASSERT (unrecognized == 0);
+        ASSERT (optind == 12);
+      }
+    }
+
+  /* Check that the '-' flag has to come first.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:-", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "-p") == 0);
+      ASSERT (strcmp (argv[2], "billy") == 0);
+      ASSERT (strcmp (argv[3], "-a") == 0);
+      ASSERT (strcmp (argv[4], "donald") == 0);
+      ASSERT (strcmp (argv[5], "duck") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+
+  /* Check that the '+' flag causes the first non-option to terminate the
+     loop.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "+abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+    }
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-+";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "+abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == '+');
+      ASSERT (optind == 2);
+    }
+
+  /* Check that '--' ends the argument processing.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[20];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "--";
+      argv[argc++] = "-b";
+      argv[argc++] = "foo";
+      argv[argc++] = "-q";
+      argv[argc++] = "johnny";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "+abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "--") == 0);
+      ASSERT (strcmp (argv[7], "-b") == 0);
+      ASSERT (strcmp (argv[8], "foo") == 0);
+      ASSERT (strcmp (argv[9], "-q") == 0);
+      ASSERT (strcmp (argv[10], "johnny") == 0);
+      ASSERT (strcmp (argv[11], "bar") == 0);
+      ASSERT (argv[12] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+    }
+
+  /* Check that the '+' flag has to come first.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:+", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "-p") == 0);
+      ASSERT (strcmp (argv[2], "billy") == 0);
+      ASSERT (strcmp (argv[3], "-a") == 0);
+      ASSERT (strcmp (argv[4], "donald") == 0);
+      ASSERT (strcmp (argv[5], "duck") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value != NULL && strcmp (p_value, "billy") == 0);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+}
+
+/* Test behavior of getopt_long when POSIXLY_CORRECT is set in the
+   environment.  Options with optional arguments should not change
+   behavior just because of an environment variable.
+   http://lists.gnu.org/archive/html/bug-m4/2006-09/msg00028.html  */
+static void
+test_getopt_long_posix (void)
+{
+  int start;
+
+  /* Check that POSIXLY_CORRECT stops parsing the same as leading '+'.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "donald";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc++] = "duck";
+      argv[argc++] = "-a";
+      argv[argc++] = "bar";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "abp:q:", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (strcmp (argv[0], "program") == 0);
+      ASSERT (strcmp (argv[1], "donald") == 0);
+      ASSERT (strcmp (argv[2], "-p") == 0);
+      ASSERT (strcmp (argv[3], "billy") == 0);
+      ASSERT (strcmp (argv[4], "duck") == 0);
+      ASSERT (strcmp (argv[5], "-a") == 0);
+      ASSERT (strcmp (argv[6], "bar") == 0);
+      ASSERT (argv[7] == NULL);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 1);
+    }
+
+  /* Check that POSIXLY_CORRECT doesn't change optional arguments.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-p";
+      argv[argc++] = "billy";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "p::", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 0);
+      ASSERT (b_seen == 0);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 2);
+    }
+
+  /* Check that leading - still sees options after non-options.  */
+  for (start = 0; start <= 1; start++)
+    {
+      const char *p_value = NULL;
+      const char *q_value = NULL;
+      int non_options_count = 0;
+      const char *non_options[10];
+      int unrecognized = 0;
+      int argc = 0;
+      const char *argv[10];
+      a_seen = 0;
+      b_seen = 0;
+
+      argv[argc++] = "program";
+      argv[argc++] = "-a";
+      argv[argc++] = "billy";
+      argv[argc++] = "-b";
+      argv[argc] = NULL;
+      optind = start;
+      getopt_long_loop (argc, argv, "-ab", long_options_required,
+                        &p_value, &q_value,
+                        &non_options_count, non_options, &unrecognized);
+      ASSERT (a_seen == 1);
+      ASSERT (b_seen == 1);
+      ASSERT (p_value == NULL);
+      ASSERT (q_value == NULL);
+      ASSERT (non_options_count == 1);
+      ASSERT (strcmp (non_options[0], "billy") == 0);
+      ASSERT (unrecognized == 0);
+      ASSERT (optind == 4);
+    }
+}
+
+/* Reduce casting, so we can use string literals elsewhere.
+   getopt_long_only takes an array of char*, but luckily does not
+   modify those elements, so we can pass const char*.  */
+static int
+do_getopt_long_only (int argc, const char **argv, const char *shortopts,
+                     const struct option *longopts, int *longind)
+{
+  return getopt_long_only (argc, (char **) argv, shortopts, longopts, longind);
+}
+
+static void
+test_getopt_long_only (void)
+{
+  /* Test disambiguation of options.  */
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-x";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "ab", long_options_required,
+                             &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-x";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx", long_options_required,
+                             &option_index);
+    ASSERT (c == 'x');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--x";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx", long_options_required,
+                             &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-b";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    b_seen = 0;
+    c = do_getopt_long_only (argc, argv, "abx", long_options_required,
+                             &option_index);
+    ASSERT (c == 'b');
+    ASSERT (b_seen == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "--b";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    b_seen = 0;
+    c = do_getopt_long_only (argc, argv, "abx", long_options_required,
+                             &option_index);
+    ASSERT (c == 0);
+    ASSERT (b_seen == 1);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xt";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "ab", long_options_required,
+                             &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xt";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx", long_options_required,
+                             &option_index);
+    ASSERT (c == '?');
+    ASSERT (optopt == 0);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xtra";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "ab", long_options_required,
+                             &option_index);
+    ASSERT (c == 1001);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xtreme";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx:", long_options_required,
+                             &option_index);
+    ASSERT (c == 1002);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xtremel";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "ab", long_options_required,
+                             &option_index);
+    /* glibc getopt_long_only is intentionally different from
+       getopt_long when handling a prefix that is common to two
+       spellings, when both spellings have the same option directives.
+       BSD getopt_long_only treats both cases the same.  */
+    ASSERT (c == 1003 || c == '?');
+    ASSERT (optind == 2);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xtremel";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx::", long_options_required,
+                             &option_index);
+    /* glibc getopt_long_only is intentionally different from
+       getopt_long when handling a prefix that is common to two
+       spellings, when both spellings have the same option directives.
+       BSD getopt_long_only treats both cases the same.  */
+    ASSERT (c == 1003 || c == '?');
+    ASSERT (optind == 2);
+    ASSERT (optarg == NULL);
+  }
+  {
+    int argc = 0;
+    const char *argv[10];
+    int option_index;
+    int c;
+
+    argv[argc++] = "program";
+    argv[argc++] = "-xtras";
+    argv[argc] = NULL;
+    optind = 1;
+    opterr = 0;
+    c = do_getopt_long_only (argc, argv, "abx::", long_options_required,
+                             &option_index);
+    ASSERT (c == 'x');
+    ASSERT (strcmp (optarg, "tras") == 0);
+  }
+}
diff --git a/gnulib/tests/test-ignore-value.c b/gnulib/tests/test-ignore-value.c
new file mode 100644 (file)
index 0000000..501f79c
--- /dev/null
@@ -0,0 +1,84 @@
+/* Test the "ignore-value" module.
+
+   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.  */
+
+#include <config.h>
+
+#include "ignore-value.h"
+
+#include <stdio.h>
+
+#ifndef _GL_ATTRIBUTE_RETURN_CHECK
+# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
+#  define _GL_ATTRIBUTE_RETURN_CHECK
+# else
+#  define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+# endif
+#endif
+
+struct s { int i; };
+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)
+{
+  return 0;
+}
+
+static int
+doInt (void)
+{
+  return 0;
+}
+
+static off_t
+doOff (void)
+{
+  return 0;
+}
+
+static void *
+doPtr (void)
+{
+  return NULL;
+}
+
+static struct s
+doStruct (void)
+{
+  static struct s s1;
+  return s1;
+}
+
+int
+main (void)
+{
+  /* If this test can compile with -Werror and the same warnings as
+     the rest of the project, then we are properly silencing warnings
+     about ignored return values.  */
+  ignore_value (doChar ());
+  ignore_value (doInt ());
+  ignore_value (doOff ());
+  ignore_value (doPtr ());
+  ignore_value (doStruct ());
+  return 0;
+}
diff --git a/gnulib/tests/test-isblank.c b/gnulib/tests/test-isblank.c
new file mode 100644 (file)
index 0000000..229d8d6
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test of isblank() function.
+   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>
+
+#include <ctype.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (isblank, int, (int));
+
+#include <limits.h>
+#include <stdio.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  unsigned int c;
+
+  /* Verify the property in the "C" locale.
+     POSIX specifies in
+       <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
+     that
+       - in all locales, the blank characters include the <space> and <tab>
+         characters,
+       - in the "POSIX" locale (which is usually the same as the "C" locale),
+         the blank characters include only the ASCII <space> and <tab>
+         characters.  */
+  for (c = 0; c <= UCHAR_MAX; c++)
+    ASSERT (!isblank (c) == !(c == ' ' || c == '\t'));
+  ASSERT (!isblank (EOF));
+
+  return 0;
+}
diff --git a/gnulib/tests/test-langinfo.c b/gnulib/tests/test-langinfo.c
new file mode 100644 (file)
index 0000000..ade807c
--- /dev/null
@@ -0,0 +1,92 @@
+/* Test of <langinfo.h> substitute.
+   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>
+
+#include <langinfo.h>
+
+/* Check that all the nl_item values are defined.  */
+int items[] =
+  {
+    /* nl_langinfo items of the LC_CTYPE category */
+    CODESET,
+    /* nl_langinfo items of the LC_NUMERIC category */
+    RADIXCHAR,
+    THOUSEP,
+    /* nl_langinfo items of the LC_TIME category */
+    D_T_FMT,
+    D_FMT,
+    T_FMT,
+    T_FMT_AMPM,
+    AM_STR,
+    PM_STR,
+    DAY_1,
+    DAY_2,
+    DAY_3,
+    DAY_4,
+    DAY_5,
+    DAY_6,
+    DAY_7,
+    ABDAY_1,
+    ABDAY_2,
+    ABDAY_3,
+    ABDAY_4,
+    ABDAY_5,
+    ABDAY_6,
+    ABDAY_7,
+    MON_1,
+    MON_2,
+    MON_3,
+    MON_4,
+    MON_5,
+    MON_6,
+    MON_7,
+    MON_8,
+    MON_9,
+    MON_10,
+    MON_11,
+    MON_12,
+    ABMON_1,
+    ABMON_2,
+    ABMON_3,
+    ABMON_4,
+    ABMON_5,
+    ABMON_6,
+    ABMON_7,
+    ABMON_8,
+    ABMON_9,
+    ABMON_10,
+    ABMON_11,
+    ABMON_12,
+    ERA,
+    ERA_D_FMT,
+    ERA_D_T_FMT,
+    ERA_T_FMT,
+    ALT_DIGITS,
+    /* nl_langinfo items of the LC_MONETARY category */
+    CRNCYSTR,
+    /* nl_langinfo items of the LC_MESSAGES category */
+    YESEXPR,
+    NOEXPR
+  };
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-locale.c b/gnulib/tests/test-locale.c
new file mode 100644 (file)
index 0000000..9b55e37
--- /dev/null
@@ -0,0 +1,49 @@
+/* Test of <locale.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <locale.h>
+
+#include "verify.h"
+
+int a[] =
+  {
+    LC_ALL,
+    LC_COLLATE,
+    LC_CTYPE,
+    LC_MESSAGES,
+    LC_MONETARY,
+    LC_NUMERIC,
+    LC_TIME
+  };
+
+#if HAVE_NEWLOCALE
+/* Check that the locale_t type and the LC_GLOBAL_LOCALE macro are defined.  */
+locale_t b = LC_GLOBAL_LOCALE;
+#endif
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-localename.c b/gnulib/tests/test-localename.c
new file mode 100644 (file)
index 0000000..09f002c
--- /dev/null
@@ -0,0 +1,747 @@
+/* Test of gl_locale_name function and its variants.
+   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 "localename.h"
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+
+#if HAVE_NEWLOCALE
+
+static struct { int cat; int mask; const char *string; } const categories[] =
+  {
+      { LC_CTYPE,          LC_CTYPE_MASK,          "LC_CTYPE" },
+      { LC_NUMERIC,        LC_NUMERIC_MASK,        "LC_NUMERIC" },
+      { LC_TIME,           LC_TIME_MASK,           "LC_TIME" },
+      { LC_COLLATE,        LC_COLLATE_MASK,        "LC_COLLATE" },
+      { LC_MONETARY,       LC_MONETARY_MASK,       "LC_MONETARY" },
+      { LC_MESSAGES,       LC_MESSAGES_MASK,       "LC_MESSAGES" }
+# ifdef LC_PAPER
+    , { LC_PAPER,          LC_PAPER_MASK,          "LC_PAPER" }
+# endif
+# ifdef LC_NAME
+    , { LC_NAME,           LC_NAME_MASK,           "LC_NAME" }
+# endif
+# ifdef LC_ADDRESS
+    , { LC_ADDRESS,        LC_ADDRESS_MASK,        "LC_ADDRESS" }
+# endif
+# ifdef LC_TELEPHONE
+    , { LC_TELEPHONE,      LC_TELEPHONE_MASK,      "LC_TELEPHONE" }
+# endif
+# ifdef LC_MEASUREMENT
+    , { LC_MEASUREMENT,    LC_MEASUREMENT_MASK,    "LC_MEASUREMENT" }
+# endif
+# ifdef LC_IDENTIFICATION
+    , { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK, "LC_IDENTIFICATION" }
+# endif
+  };
+
+#endif
+
+/* Test the gl_locale_name() function.  */
+static void
+test_locale_name (void)
+{
+  const char *name;
+
+  /* Check that gl_locale_name returns non-NULL.  */
+  ASSERT (gl_locale_name (LC_MESSAGES, "LC_MESSAGES") != NULL);
+
+  /* Get into a defined state,  */
+  setlocale (LC_ALL, "en_US.UTF-8");
+#if HAVE_NEWLOCALE
+  uselocale (LC_GLOBAL_LOCALE);
+#endif
+
+  /* Check that when all environment variables are unset,
+     gl_locale_name returns the default locale.  */
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LC_NUMERIC");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"),
+                  gl_locale_name_default ()) == 0);
+  ASSERT (strcmp (gl_locale_name (LC_NUMERIC, "LC_NUMERIC"),
+                  gl_locale_name_default ()) == 0);
+
+  /* Check that an empty environment variable is treated like an unset
+     environment variable.  */
+
+  setenv ("LC_ALL", "", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"),
+                  gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "", 1);
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"),
+                  gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "", 1);
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"),
+                  gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "", 1);
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"),
+                  gl_locale_name_default ()) == 0);
+
+  /* Check that LC_ALL overrides the others, and LANG is overridden by the
+     others.  */
+
+  setenv ("LC_ALL", "C", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "C", 1);
+  setenv ("LC_MESSAGES", "C", 1);
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "C", 1);
+  setlocale (LC_ALL, "");
+  ASSERT (strcmp (gl_locale_name (LC_MESSAGES, "LC_MESSAGES"), "C") == 0);
+
+  /* Check mixed situations.  */
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  setenv ("LANG", "de_DE.UTF-8", 1);
+  if (setlocale (LC_ALL, "") != NULL)
+    {
+      name = gl_locale_name (LC_CTYPE, "LC_CTYPE");
+      ASSERT (strcmp (name, "de_DE.UTF-8") == 0);
+      name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES");
+      ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+    }
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  unsetenv ("LANG");
+  if (setlocale (LC_ALL, "") != NULL)
+    {
+      name = gl_locale_name (LC_CTYPE, "LC_CTYPE");
+      ASSERT (strcmp (name, gl_locale_name_default ()) == 0);
+      name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES");
+      ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+    }
+
+#if HAVE_NEWLOCALE
+  /* Check that gl_locale_name considers the thread locale.  */
+  {
+    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+    if (locale != NULL)
+      {
+        uselocale (locale);
+        name = gl_locale_name (LC_CTYPE, "LC_CTYPE");
+        ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+        name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES");
+        ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+      }
+  }
+
+  /* Check that gl_locale_name distinguishes different categories of the
+     thread locale, and that the name is the right one for each.  */
+  {
+    unsigned int i;
+
+    for (i = 0; i < SIZEOF (categories); i++)
+      {
+        int category_mask = categories[i].mask;
+        locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+        if (locale != NULL)
+          {
+            locale = newlocale (category_mask, "de_DE.UTF-8", locale);
+            if (locale != NULL)
+              {
+                unsigned int j;
+
+                uselocale (locale);
+                for (j = 0; j < SIZEOF (categories); j++)
+                  {
+                    const char *name_j =
+                      gl_locale_name (categories[j].cat, categories[j].string);
+                    if (j == i)
+                      ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+                    else
+                      ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+                  }
+              }
+          }
+      }
+  }
+#endif
+}
+
+/* Test the gl_locale_name_thread() function.  */
+static void
+test_locale_name_thread (void)
+{
+  /* Get into a defined state,  */
+  setlocale (LC_ALL, "en_US.UTF-8");
+
+#if HAVE_NEWLOCALE
+  /* Check that gl_locale_name_thread returns NULL when no thread locale is
+     set.  */
+  uselocale (LC_GLOBAL_LOCALE);
+  ASSERT (gl_locale_name_thread (LC_CTYPE, "LC_CTYPE") == NULL);
+  ASSERT (gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES") == NULL);
+
+  /* Check that gl_locale_name_thread considers the thread locale.  */
+  {
+    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+    if (locale != NULL)
+      {
+        const char *name;
+
+        uselocale (locale);
+        name = gl_locale_name_thread (LC_CTYPE, "LC_CTYPE");
+        ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+        name = gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES");
+        ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+      }
+  }
+
+  /* Check that gl_locale_name_thread distinguishes different categories of the
+     thread locale, and that the name is the right one for each.  */
+  {
+    unsigned int i;
+
+    for (i = 0; i < SIZEOF (categories); i++)
+      {
+        int category_mask = categories[i].mask;
+        locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+        if (locale != NULL)
+          {
+            locale = newlocale (category_mask, "de_DE.UTF-8", locale);
+            if (locale != NULL)
+              {
+                unsigned int j;
+
+                uselocale (locale);
+                for (j = 0; j < SIZEOF (categories); j++)
+                  {
+                    const char *name_j =
+                      gl_locale_name_thread (categories[j].cat,
+                                             categories[j].string);
+                    if (j == i)
+                      ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+                    else
+                      ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+                  }
+              }
+          }
+      }
+  }
+
+  /* Check that gl_locale_name_thread returns a string that is allocated with
+     indefinite extent.  */
+  {
+    /* Try many locale names in turn, in order to defeat possible caches.  */
+    static const char * const choices[] =
+      {
+        "C",
+        "POSIX",
+        "af_ZA",
+        "af_ZA.UTF-8",
+        "am_ET",
+        "am_ET.UTF-8",
+        "be_BY",
+        "be_BY.UTF-8",
+        "bg_BG",
+        "bg_BG.UTF-8",
+        "ca_ES",
+        "ca_ES.UTF-8",
+        "cs_CZ",
+        "cs_CZ.UTF-8",
+        "da_DK",
+        "da_DK.UTF-8",
+        "de_AT",
+        "de_AT.UTF-8",
+        "de_CH",
+        "de_CH.UTF-8",
+        "de_DE",
+        "de_DE.UTF-8",
+        "el_GR",
+        "el_GR.UTF-8",
+        "en_AU",
+        "en_AU.UTF-8",
+        "en_CA",
+        "en_CA.UTF-8",
+        "en_GB",
+        "en_GB.UTF-8",
+        "en_IE",
+        "en_IE.UTF-8",
+        "en_NZ",
+        "en_NZ.UTF-8",
+        "en_US",
+        "en_US.UTF-8",
+        "es_ES",
+        "es_ES.UTF-8",
+        "et_EE",
+        "et_EE.UTF-8",
+        "eu_ES",
+        "eu_ES.UTF-8",
+        "fi_FI",
+        "fi_FI.UTF-8",
+        "fr_BE",
+        "fr_BE.UTF-8",
+        "fr_CA",
+        "fr_CA.UTF-8",
+        "fr_CH",
+        "fr_CH.UTF-8",
+        "fr_FR",
+        "fr_FR.UTF-8",
+        "he_IL",
+        "he_IL.UTF-8",
+        "hr_HR",
+        "hr_HR.UTF-8",
+        "hu_HU",
+        "hu_HU.UTF-8",
+        "hy_AM",
+        "is_IS",
+        "is_IS.UTF-8",
+        "it_CH",
+        "it_CH.UTF-8",
+        "it_IT",
+        "it_IT.UTF-8",
+        "ja_JP.UTF-8",
+        "kk_KZ",
+        "kk_KZ.UTF-8",
+        "ko_KR.UTF-8",
+        "lt_LT",
+        "lt_LT.UTF-8",
+        "nl_BE",
+        "nl_BE.UTF-8",
+        "nl_NL",
+        "nl_NL.UTF-8",
+        "no_NO",
+        "no_NO.UTF-8",
+        "pl_PL",
+        "pl_PL.UTF-8",
+        "pt_BR",
+        "pt_BR.UTF-8",
+        "pt_PT",
+        "pt_PT.UTF-8",
+        "ro_RO",
+        "ro_RO.UTF-8",
+        "ru_RU",
+        "ru_RU.UTF-8",
+        "sk_SK",
+        "sk_SK.UTF-8",
+        "sl_SI",
+        "sl_SI.UTF-8",
+        "sv_SE",
+        "sv_SE.UTF-8",
+        "tr_TR",
+        "tr_TR.UTF-8",
+        "uk_UA",
+        "uk_UA.UTF-8",
+        "zh_CN",
+        "zh_CN.UTF-8",
+        "zh_HK",
+        "zh_HK.UTF-8",
+        "zh_TW",
+        "zh_TW.UTF-8"
+      };
+    /* Remember which locales are available.  */
+    unsigned char /* bool */ available[SIZEOF (choices)];
+    /* Array of remembered results of gl_locale_name_thread.  */
+    const char *unsaved_names[SIZEOF (choices)][SIZEOF (categories)];
+    /* Array of remembered results of gl_locale_name_thread, stored in safe
+       memory.  */
+    char *saved_names[SIZEOF (choices)][SIZEOF (categories)];
+    unsigned int j;
+
+    for (j = 0; j < SIZEOF (choices); j++)
+      {
+        locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
+        available[j] = (locale != NULL);
+        if (locale != NULL)
+          {
+            unsigned int i;
+
+            uselocale (locale);
+            for (i = 0; i < SIZEOF (categories); i++)
+              {
+                unsaved_names[j][i] = gl_locale_name_thread (categories[i].cat, categories[i].string);
+                saved_names[j][i] = strdup (unsaved_names[j][i]);
+              }
+            uselocale (LC_GLOBAL_LOCALE);
+            freelocale (locale);
+          }
+      }
+    /* Verify the unsaved_names are still valid.  */
+    for (j = 0; j < SIZEOF (choices); j++)
+      if (available[j])
+        {
+          unsigned int i;
+
+          for (i = 0; i < SIZEOF (categories); i++)
+            ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
+        }
+    /* Allocate many locales, without freeing them.  This is an attempt at
+       overwriting as much of the previously allocated memory as possible.  */
+    for (j = SIZEOF (choices); j > 0; )
+      {
+        j--;
+        if (available[j])
+          {
+            locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
+            unsigned int i;
+
+            ASSERT (locale != NULL);
+            uselocale (locale);
+            for (i = 0; i < SIZEOF (categories); i++)
+              {
+                const char *name = gl_locale_name_thread (categories[i].cat, categories[i].string);
+                ASSERT (strcmp (unsaved_names[j][i], name) == 0);
+              }
+            uselocale (LC_GLOBAL_LOCALE);
+          }
+      }
+    /* Verify the unsaved_names are still valid.  */
+    for (j = 0; j < SIZEOF (choices); j++)
+      if (available[j])
+        {
+          unsigned int i;
+
+          for (i = 0; i < SIZEOF (categories); i++)
+            ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
+        }
+  }
+#else
+  /* Check that gl_locale_name_thread always returns NULL.  */
+  ASSERT (gl_locale_name_thread (LC_CTYPE, "LC_CTYPE") == NULL);
+  ASSERT (gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES") == NULL);
+#endif
+}
+
+/* Test the gl_locale_name_posix() function.  */
+static void
+test_locale_name_posix (void)
+{
+  const char *name;
+
+  /* Get into a defined state,  */
+  setlocale (LC_ALL, "en_US.UTF-8");
+#if HAVE_NEWLOCALE
+  uselocale (LC_GLOBAL_LOCALE);
+#endif
+
+  /* Check that when all environment variables are unset,
+     gl_locale_name_posix returns either NULL or the default locale.  */
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LC_NUMERIC");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+  name = gl_locale_name_posix (LC_NUMERIC, "LC_NUMERIC");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+
+  /* Check that an empty environment variable is treated like an unset
+     environment variable.  */
+
+  setenv ("LC_ALL", "", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "", 1);
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "", 1);
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "", 1);
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+
+  /* Check that LC_ALL overrides the others, and LANG is overridden by the
+     others.  */
+
+  setenv ("LC_ALL", "C", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "C", 1);
+  setenv ("LC_MESSAGES", "C", 1);
+  unsetenv ("LANG");
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "C", 1);
+  setlocale (LC_ALL, "");
+  name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  /* Check mixed situations.  */
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  setenv ("LANG", "de_DE.UTF-8", 1);
+  if (setlocale (LC_ALL, "") != NULL)
+    {
+      name = gl_locale_name_posix (LC_CTYPE, "LC_CTYPE");
+      ASSERT (strcmp (name, "de_DE.UTF-8") == 0);
+      name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+      ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+    }
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  unsetenv ("LANG");
+  if (setlocale (LC_ALL, "") != NULL)
+    {
+      name = gl_locale_name_posix (LC_CTYPE, "LC_CTYPE");
+      ASSERT (name == NULL || strcmp (name, gl_locale_name_default ()) == 0);
+      name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+      ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+    }
+
+#if HAVE_NEWLOCALE
+  /* Check that gl_locale_name_posix ignores the thread locale.  */
+  {
+    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+    if (locale != NULL)
+      {
+        unsetenv ("LC_ALL");
+        unsetenv ("LC_CTYPE");
+        unsetenv ("LC_MESSAGES");
+        setenv ("LANG", "C", 1);
+        setlocale (LC_ALL, "");
+        uselocale (locale);
+        name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES");
+        ASSERT (strcmp (name, "C") == 0);
+      }
+  }
+#endif
+}
+
+/* Test the gl_locale_name_environ() function.  */
+static void
+test_locale_name_environ (void)
+{
+  const char *name;
+
+  /* Get into a defined state,  */
+  setlocale (LC_ALL, "en_US.UTF-8");
+#if HAVE_NEWLOCALE
+  uselocale (LC_GLOBAL_LOCALE);
+#endif
+
+  /* Check that when all environment variables are unset,
+     gl_locale_name_environ returns NULL.  */
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LC_NUMERIC");
+  unsetenv ("LANG");
+  ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL);
+  ASSERT (gl_locale_name_environ (LC_NUMERIC, "LC_NUMERIC") == NULL);
+
+  /* Check that an empty environment variable is treated like an unset
+     environment variable.  */
+
+  setenv ("LC_ALL", "", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "", 1);
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "", 1);
+  unsetenv ("LANG");
+  ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "", 1);
+  ASSERT (gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES") == NULL);
+
+  /* Check that LC_ALL overrides the others, and LANG is overridden by the
+     others.  */
+
+  setenv ("LC_ALL", "C", 1);
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  unsetenv ("LANG");
+  name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  unsetenv ("LC_ALL");
+  setenv ("LC_CTYPE", "C", 1);
+  setenv ("LC_MESSAGES", "C", 1);
+  unsetenv ("LANG");
+  name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  unsetenv ("LC_MESSAGES");
+  setenv ("LANG", "C", 1);
+  name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "C") == 0);
+
+  /* Check mixed situations.  */
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  setenv ("LANG", "de_DE.UTF-8", 1);
+  name = gl_locale_name_environ (LC_CTYPE, "LC_CTYPE");
+  ASSERT (strcmp (name, "de_DE.UTF-8") == 0);
+  name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+
+  unsetenv ("LC_ALL");
+  unsetenv ("LC_CTYPE");
+  setenv ("LC_MESSAGES", "fr_FR.UTF-8", 1);
+  unsetenv ("LANG");
+  name = gl_locale_name_environ (LC_CTYPE, "LC_CTYPE");
+  ASSERT (name == NULL);
+  name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+  ASSERT (strcmp (name, "fr_FR.UTF-8") == 0);
+
+#if HAVE_NEWLOCALE
+  /* Check that gl_locale_name_environ ignores the thread locale.  */
+  {
+    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+    if (locale != NULL)
+      {
+        unsetenv ("LC_ALL");
+        unsetenv ("LC_CTYPE");
+        unsetenv ("LC_MESSAGES");
+        setenv ("LANG", "C", 1);
+        setlocale (LC_ALL, "");
+        uselocale (locale);
+        name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES");
+        ASSERT (strcmp (name, "C") == 0);
+      }
+  }
+#endif
+}
+
+/* Test the gl_locale_name_default() function.  */
+static void
+test_locale_name_default (void)
+{
+  const char *name = gl_locale_name_default ();
+
+  ASSERT (name != NULL);
+
+  /* Only MacOS X and Windows have a facility for the user to set the default
+     locale.  */
+#if !((defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__ || defined __CYGWIN__))
+  ASSERT (strcmp (name, "C") == 0);
+#endif
+
+#if HAVE_NEWLOCALE
+  /* Check that gl_locale_name_default ignores the thread locale.  */
+  {
+    locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+    if (locale != NULL)
+      {
+        uselocale (locale);
+        ASSERT (strcmp (gl_locale_name_default (), name) == 0);
+      }
+  }
+#endif
+}
+
+int
+main ()
+{
+  test_locale_name ();
+  test_locale_name_thread ();
+  test_locale_name_posix ();
+  test_locale_name_environ ();
+  test_locale_name_default ();
+
+  return 0;
+}
diff --git a/gnulib/tests/test-lock.c b/gnulib/tests/test-lock.c
new file mode 100644 (file)
index 0000000..04ce076
--- /dev/null
@@ -0,0 +1,601 @@
+/* Test of locking in multithreaded situations.
+   Copyright (C) 2005, 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.  */
+
+#include <config.h>
+
+#if USE_POSIX_THREADS || USE_SOLARIS_THREADS || USE_PTH_THREADS || USE_WIN32_THREADS
+
+#if USE_POSIX_THREADS
+# define TEST_POSIX_THREADS 1
+#endif
+#if USE_SOLARIS_THREADS
+# define TEST_SOLARIS_THREADS 1
+#endif
+#if USE_PTH_THREADS
+# define TEST_PTH_THREADS 1
+#endif
+#if USE_WIN32_THREADS
+# define TEST_WIN32_THREADS 1
+#endif
+
+/* Whether to enable locking.
+   Uncomment this to get a test program without locking, to verify that
+   it crashes.  */
+#define ENABLE_LOCKING 1
+
+/* Which tests to perform.
+   Uncomment some of these, to verify that all tests crash if no locking
+   is enabled.  */
+#define DO_TEST_LOCK 1
+#define DO_TEST_RWLOCK 1
+#define DO_TEST_RECURSIVE_LOCK 1
+#define DO_TEST_ONCE 1
+
+/* Whether to help the scheduler through explicit yield().
+   Uncomment this to see if the operating system has a fair scheduler.  */
+#define EXPLICIT_YIELD 1
+
+/* Whether to print debugging messages.  */
+#define ENABLE_DEBUGGING 0
+
+/* Number of simultaneous threads.  */
+#define THREAD_COUNT 10
+
+/* Number of operations performed in each thread.
+   This is quite high, because with a smaller count, say 5000, we often get
+   an "OK" result even without ENABLE_LOCKING (on Linux/x86).  */
+#define REPEAT_COUNT 50000
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !ENABLE_LOCKING
+# undef USE_POSIX_THREADS
+# undef USE_SOLARIS_THREADS
+# undef USE_PTH_THREADS
+# undef USE_WIN32_THREADS
+#endif
+#include "glthread/lock.h"
+
+#if !ENABLE_LOCKING
+# if TEST_POSIX_THREADS
+#  define USE_POSIX_THREADS 1
+# endif
+# if TEST_SOLARIS_THREADS
+#  define USE_SOLARIS_THREADS 1
+# endif
+# if TEST_PTH_THREADS
+#  define USE_PTH_THREADS 1
+# endif
+# if TEST_WIN32_THREADS
+#  define USE_WIN32_THREADS 1
+# endif
+#endif
+
+#include "glthread/thread.h"
+#include "glthread/yield.h"
+
+#if ENABLE_DEBUGGING
+# define dbgprintf printf
+#else
+# define dbgprintf if (0) printf
+#endif
+
+#if EXPLICIT_YIELD
+# define yield() gl_thread_yield ()
+#else
+# define yield()
+#endif
+
+#define ACCOUNT_COUNT 4
+
+static int account[ACCOUNT_COUNT];
+
+static int
+random_account (void)
+{
+  return ((unsigned int) rand () >> 3) % ACCOUNT_COUNT;
+}
+
+static void
+check_accounts (void)
+{
+  int i, sum;
+
+  sum = 0;
+  for (i = 0; i < ACCOUNT_COUNT; i++)
+    sum += account[i];
+  if (sum != ACCOUNT_COUNT * 1000)
+    abort ();
+}
+
+
+/* ------------------- Test normal (non-recursive) locks ------------------- */
+
+/* Test normal locks by having several bank accounts and several threads
+   which shuffle around money between the accounts and another thread
+   checking that all the money is still there.  */
+
+gl_lock_define_initialized(static, my_lock)
+
+static void *
+lock_mutator_thread (void *arg)
+{
+  int repeat;
+
+  for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+    {
+      int i1, i2, value;
+
+      dbgprintf ("Mutator %p before lock\n", gl_thread_self ());
+      gl_lock_lock (my_lock);
+      dbgprintf ("Mutator %p after  lock\n", gl_thread_self ());
+
+      i1 = random_account ();
+      i2 = random_account ();
+      value = ((unsigned int) rand () >> 3) % 10;
+      account[i1] += value;
+      account[i2] -= value;
+
+      dbgprintf ("Mutator %p before unlock\n", gl_thread_self ());
+      gl_lock_unlock (my_lock);
+      dbgprintf ("Mutator %p after  unlock\n", gl_thread_self ());
+
+      dbgprintf ("Mutator %p before check lock\n", gl_thread_self ());
+      gl_lock_lock (my_lock);
+      check_accounts ();
+      gl_lock_unlock (my_lock);
+      dbgprintf ("Mutator %p after  check unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Mutator %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static volatile int lock_checker_done;
+
+static void *
+lock_checker_thread (void *arg)
+{
+  while (!lock_checker_done)
+    {
+      dbgprintf ("Checker %p before check lock\n", gl_thread_self ());
+      gl_lock_lock (my_lock);
+      check_accounts ();
+      gl_lock_unlock (my_lock);
+      dbgprintf ("Checker %p after  check unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Checker %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static void
+test_lock (void)
+{
+  int i;
+  gl_thread_t checkerthread;
+  gl_thread_t threads[THREAD_COUNT];
+
+  /* Initialization.  */
+  for (i = 0; i < ACCOUNT_COUNT; i++)
+    account[i] = 1000;
+  lock_checker_done = 0;
+
+  /* Spawn the threads.  */
+  checkerthread = gl_thread_create (lock_checker_thread, NULL);
+  for (i = 0; i < THREAD_COUNT; i++)
+    threads[i] = gl_thread_create (lock_mutator_thread, NULL);
+
+  /* Wait for the threads to terminate.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    gl_thread_join (threads[i], NULL);
+  lock_checker_done = 1;
+  gl_thread_join (checkerthread, NULL);
+  check_accounts ();
+}
+
+
+/* ----------------- Test read-write (non-recursive) locks ----------------- */
+
+/* Test read-write locks by having several bank accounts and several threads
+   which shuffle around money between the accounts and several other threads
+   that check that all the money is still there.  */
+
+gl_rwlock_define_initialized(static, my_rwlock)
+
+static void *
+rwlock_mutator_thread (void *arg)
+{
+  int repeat;
+
+  for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+    {
+      int i1, i2, value;
+
+      dbgprintf ("Mutator %p before wrlock\n", gl_thread_self ());
+      gl_rwlock_wrlock (my_rwlock);
+      dbgprintf ("Mutator %p after  wrlock\n", gl_thread_self ());
+
+      i1 = random_account ();
+      i2 = random_account ();
+      value = ((unsigned int) rand () >> 3) % 10;
+      account[i1] += value;
+      account[i2] -= value;
+
+      dbgprintf ("Mutator %p before unlock\n", gl_thread_self ());
+      gl_rwlock_unlock (my_rwlock);
+      dbgprintf ("Mutator %p after  unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Mutator %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static volatile int rwlock_checker_done;
+
+static void *
+rwlock_checker_thread (void *arg)
+{
+  while (!rwlock_checker_done)
+    {
+      dbgprintf ("Checker %p before check rdlock\n", gl_thread_self ());
+      gl_rwlock_rdlock (my_rwlock);
+      check_accounts ();
+      gl_rwlock_unlock (my_rwlock);
+      dbgprintf ("Checker %p after  check unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Checker %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static void
+test_rwlock (void)
+{
+  int i;
+  gl_thread_t checkerthreads[THREAD_COUNT];
+  gl_thread_t threads[THREAD_COUNT];
+
+  /* Initialization.  */
+  for (i = 0; i < ACCOUNT_COUNT; i++)
+    account[i] = 1000;
+  rwlock_checker_done = 0;
+
+  /* Spawn the threads.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    checkerthreads[i] = gl_thread_create (rwlock_checker_thread, NULL);
+  for (i = 0; i < THREAD_COUNT; i++)
+    threads[i] = gl_thread_create (rwlock_mutator_thread, NULL);
+
+  /* Wait for the threads to terminate.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    gl_thread_join (threads[i], NULL);
+  rwlock_checker_done = 1;
+  for (i = 0; i < THREAD_COUNT; i++)
+    gl_thread_join (checkerthreads[i], NULL);
+  check_accounts ();
+}
+
+
+/* -------------------------- Test recursive locks -------------------------- */
+
+/* Test recursive locks by having several bank accounts and several threads
+   which shuffle around money between the accounts (recursively) and another
+   thread checking that all the money is still there.  */
+
+gl_recursive_lock_define_initialized(static, my_reclock)
+
+static void
+recshuffle (void)
+{
+  int i1, i2, value;
+
+  dbgprintf ("Mutator %p before lock\n", gl_thread_self ());
+  gl_recursive_lock_lock (my_reclock);
+  dbgprintf ("Mutator %p after  lock\n", gl_thread_self ());
+
+  i1 = random_account ();
+  i2 = random_account ();
+  value = ((unsigned int) rand () >> 3) % 10;
+  account[i1] += value;
+  account[i2] -= value;
+
+  /* Recursive with probability 0.5.  */
+  if (((unsigned int) rand () >> 3) % 2)
+    recshuffle ();
+
+  dbgprintf ("Mutator %p before unlock\n", gl_thread_self ());
+  gl_recursive_lock_unlock (my_reclock);
+  dbgprintf ("Mutator %p after  unlock\n", gl_thread_self ());
+}
+
+static void *
+reclock_mutator_thread (void *arg)
+{
+  int repeat;
+
+  for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+    {
+      recshuffle ();
+
+      dbgprintf ("Mutator %p before check lock\n", gl_thread_self ());
+      gl_recursive_lock_lock (my_reclock);
+      check_accounts ();
+      gl_recursive_lock_unlock (my_reclock);
+      dbgprintf ("Mutator %p after  check unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Mutator %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static volatile int reclock_checker_done;
+
+static void *
+reclock_checker_thread (void *arg)
+{
+  while (!reclock_checker_done)
+    {
+      dbgprintf ("Checker %p before check lock\n", gl_thread_self ());
+      gl_recursive_lock_lock (my_reclock);
+      check_accounts ();
+      gl_recursive_lock_unlock (my_reclock);
+      dbgprintf ("Checker %p after  check unlock\n", gl_thread_self ());
+
+      yield ();
+    }
+
+  dbgprintf ("Checker %p dying.\n", gl_thread_self ());
+  return NULL;
+}
+
+static void
+test_recursive_lock (void)
+{
+  int i;
+  gl_thread_t checkerthread;
+  gl_thread_t threads[THREAD_COUNT];
+
+  /* Initialization.  */
+  for (i = 0; i < ACCOUNT_COUNT; i++)
+    account[i] = 1000;
+  reclock_checker_done = 0;
+
+  /* Spawn the threads.  */
+  checkerthread = gl_thread_create (reclock_checker_thread, NULL);
+  for (i = 0; i < THREAD_COUNT; i++)
+    threads[i] = gl_thread_create (reclock_mutator_thread, NULL);
+
+  /* Wait for the threads to terminate.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    gl_thread_join (threads[i], NULL);
+  reclock_checker_done = 1;
+  gl_thread_join (checkerthread, NULL);
+  check_accounts ();
+}
+
+
+/* ------------------------ Test once-only execution ------------------------ */
+
+/* Test once-only execution by having several threads attempt to grab a
+   once-only task simultaneously (triggered by releasing a read-write lock).  */
+
+gl_once_define(static, fresh_once)
+static int ready[THREAD_COUNT];
+static gl_lock_t ready_lock[THREAD_COUNT];
+#if ENABLE_LOCKING
+static gl_rwlock_t fire_signal[REPEAT_COUNT];
+#else
+static volatile int fire_signal_state;
+#endif
+static gl_once_t once_control;
+static int performed;
+gl_lock_define_initialized(static, performed_lock)
+
+static void
+once_execute (void)
+{
+  gl_lock_lock (performed_lock);
+  performed++;
+  gl_lock_unlock (performed_lock);
+}
+
+static void *
+once_contender_thread (void *arg)
+{
+  int id = (int) (long) arg;
+  int repeat;
+
+  for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+    {
+      /* Tell the main thread that we're ready.  */
+      gl_lock_lock (ready_lock[id]);
+      ready[id] = 1;
+      gl_lock_unlock (ready_lock[id]);
+
+      if (repeat == REPEAT_COUNT)
+        break;
+
+      dbgprintf ("Contender %p waiting for signal for round %d\n",
+                 gl_thread_self (), repeat);
+#if ENABLE_LOCKING
+      /* Wait for the signal to go.  */
+      gl_rwlock_rdlock (fire_signal[repeat]);
+      /* And don't hinder the others (if the scheduler is unfair).  */
+      gl_rwlock_unlock (fire_signal[repeat]);
+#else
+      /* Wait for the signal to go.  */
+      while (fire_signal_state <= repeat)
+        yield ();
+#endif
+      dbgprintf ("Contender %p got the     signal for round %d\n",
+                 gl_thread_self (), repeat);
+
+      /* Contend for execution.  */
+      gl_once (once_control, once_execute);
+    }
+
+  return NULL;
+}
+
+static void
+test_once (void)
+{
+  int i, repeat;
+  gl_thread_t threads[THREAD_COUNT];
+
+  /* Initialize all variables.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    {
+      ready[i] = 0;
+      gl_lock_init (ready_lock[i]);
+    }
+#if ENABLE_LOCKING
+  for (i = 0; i < REPEAT_COUNT; i++)
+    gl_rwlock_init (fire_signal[i]);
+#else
+  fire_signal_state = 0;
+#endif
+
+  /* Block all fire_signals.  */
+  for (i = REPEAT_COUNT-1; i >= 0; i--)
+    gl_rwlock_wrlock (fire_signal[i]);
+
+  /* Spawn the threads.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    threads[i] = gl_thread_create (once_contender_thread, (void *) (long) i);
+
+  for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+    {
+      /* Wait until every thread is ready.  */
+      dbgprintf ("Main thread before synchonizing for round %d\n", repeat);
+      for (;;)
+        {
+          int ready_count = 0;
+          for (i = 0; i < THREAD_COUNT; i++)
+            {
+              gl_lock_lock (ready_lock[i]);
+              ready_count += ready[i];
+              gl_lock_unlock (ready_lock[i]);
+            }
+          if (ready_count == THREAD_COUNT)
+            break;
+          yield ();
+        }
+      dbgprintf ("Main thread after  synchonizing for round %d\n", repeat);
+
+      if (repeat > 0)
+        {
+          /* Check that exactly one thread executed the once_execute()
+             function.  */
+          if (performed != 1)
+            abort ();
+        }
+
+      if (repeat == REPEAT_COUNT)
+        break;
+
+      /* Preparation for the next round: Initialize once_control.  */
+      memcpy (&once_control, &fresh_once, sizeof (gl_once_t));
+
+      /* Preparation for the next round: Reset the performed counter.  */
+      performed = 0;
+
+      /* Preparation for the next round: Reset the ready flags.  */
+      for (i = 0; i < THREAD_COUNT; i++)
+        {
+          gl_lock_lock (ready_lock[i]);
+          ready[i] = 0;
+          gl_lock_unlock (ready_lock[i]);
+        }
+
+      /* Signal all threads simultaneously.  */
+      dbgprintf ("Main thread giving signal for round %d\n", repeat);
+#if ENABLE_LOCKING
+      gl_rwlock_unlock (fire_signal[repeat]);
+#else
+      fire_signal_state = repeat + 1;
+#endif
+    }
+
+  /* Wait for the threads to terminate.  */
+  for (i = 0; i < THREAD_COUNT; i++)
+    gl_thread_join (threads[i], NULL);
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+int
+main ()
+{
+#if TEST_PTH_THREADS
+  if (!pth_init ())
+    abort ();
+#endif
+
+#if DO_TEST_LOCK
+  printf ("Starting test_lock ..."); fflush (stdout);
+  test_lock ();
+  printf (" OK\n"); fflush (stdout);
+#endif
+#if DO_TEST_RWLOCK
+  printf ("Starting test_rwlock ..."); fflush (stdout);
+  test_rwlock ();
+  printf (" OK\n"); fflush (stdout);
+#endif
+#if DO_TEST_RECURSIVE_LOCK
+  printf ("Starting test_recursive_lock ..."); fflush (stdout);
+  test_recursive_lock ();
+  printf (" OK\n"); fflush (stdout);
+#endif
+#if DO_TEST_ONCE
+  printf ("Starting test_once ..."); fflush (stdout);
+  test_once ();
+  printf (" OK\n"); fflush (stdout);
+#endif
+
+  return 0;
+}
+
+#else
+
+/* No multithreading available.  */
+
+#include <stdio.h>
+
+int
+main ()
+{
+  fputs ("Skipping test: multithreading not enabled\n", stderr);
+  return 77;
+}
+
+#endif
diff --git a/gnulib/tests/test-lstat.c b/gnulib/tests/test-lstat.c
new file mode 100644 (file)
index 0000000..372e056
--- /dev/null
@@ -0,0 +1,60 @@
+/* Test of lstat() function.
+   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/>.  */
+
+/* Written by Simon Josefsson, 2008; and Eric Blake, 2009.  */
+
+#include <config.h>
+
+#include <sys/stat.h>
+
+/* Caution: lstat may be a function-like macro.  Although this
+   signature check must pass, it may be the signature of the real (and
+   broken) lstat rather than rpl_lstat.  Most code should not use the
+   address of lstat.  */
+#include "signature.h"
+SIGNATURE_CHECK (lstat, int, (char const *, struct stat *));
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "same-inode.h"
+#include "ignore-value.h"
+#include "macros.h"
+
+#define BASE "test-lstat.t"
+
+#include "test-lstat.h"
+
+/* Wrapper around lstat, which works even if lstat is a function-like
+   macro, where test_lstat_func(lstat) would do the wrong thing.  */
+static int
+do_lstat (char const *name, struct stat *st)
+{
+  return lstat (name, st);
+}
+
+int
+main (void)
+{
+  /* Remove any leftovers from a previous partial run.  */
+  ignore_value (system ("rm -rf " BASE "*"));
+
+  return test_lstat_func (do_lstat, true);
+}
diff --git a/gnulib/tests/test-lstat.h b/gnulib/tests/test-lstat.h
new file mode 100644 (file)
index 0000000..883c4e8
--- /dev/null
@@ -0,0 +1,116 @@
+/* Test of lstat() function.
+   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/>.  */
+
+/* Written by Simon Josefsson, 2008; and Eric Blake, 2009.  */
+
+/* This file is designed to test both lstat(n,buf) and
+   fstatat(AT_FDCWD,n,buf,AT_SYMLINK_NOFOLLOW).  FUNC is the function
+   to test.  Assumes that BASE and ASSERT are already defined, and
+   that appropriate headers are already included.  If PRINT, warn
+   before skipping symlink tests with status 77.  */
+
+static int
+test_lstat_func (int (*func) (char const *, struct stat *), bool print)
+{
+  struct stat st1;
+  struct stat st2;
+
+  /* Test for common directories.  */
+  ASSERT (func (".", &st1) == 0);
+  ASSERT (func ("./", &st2) == 0);
+  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (S_ISDIR (st1.st_mode));
+  ASSERT (S_ISDIR (st2.st_mode));
+  ASSERT (func ("/", &st1) == 0);
+  ASSERT (func ("///", &st2) == 0);
+  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (S_ISDIR (st1.st_mode));
+  ASSERT (S_ISDIR (st2.st_mode));
+  ASSERT (func ("..", &st1) == 0);
+  ASSERT (S_ISDIR (st1.st_mode));
+
+  /* Test for error conditions.  */
+  errno = 0;
+  ASSERT (func ("", &st1) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("nosuch", &st1) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("nosuch/", &st1) == -1);
+  ASSERT (errno == ENOENT);
+
+  ASSERT (close (creat (BASE "file", 0600)) == 0);
+  ASSERT (func (BASE "file", &st1) == 0);
+  ASSERT (S_ISREG (st1.st_mode));
+  errno = 0;
+  ASSERT (func (BASE "file/", &st1) == -1);
+  ASSERT (errno == ENOTDIR);
+
+  /* Now for some symlink tests, where supported.  We set up:
+     link1 -> directory
+     link2 -> file
+     link3 -> dangling
+     link4 -> loop
+     then test behavior both with and without trailing slash.
+  */
+  if (symlink (".", BASE "link1") != 0)
+    {
+      ASSERT (unlink (BASE "file") == 0);
+      if (print)
+        fputs ("skipping test: symlinks not supported on this file system\n",
+               stderr);
+      return 77;
+    }
+  ASSERT (symlink (BASE "file", BASE "link2") == 0);
+  ASSERT (symlink (BASE "nosuch", BASE "link3") == 0);
+  ASSERT (symlink (BASE "link4", BASE "link4") == 0);
+
+  ASSERT (func (BASE "link1", &st1) == 0);
+  ASSERT (S_ISLNK (st1.st_mode));
+  ASSERT (func (BASE "link1/", &st1) == 0);
+  ASSERT (stat (BASE "link1", &st2) == 0);
+  ASSERT (S_ISDIR (st1.st_mode));
+  ASSERT (S_ISDIR (st2.st_mode));
+  ASSERT (SAME_INODE (st1, st2));
+
+  ASSERT (func (BASE "link2", &st1) == 0);
+  ASSERT (S_ISLNK (st1.st_mode));
+  errno = 0;
+  ASSERT (func (BASE "link2/", &st1) == -1);
+  ASSERT (errno == ENOTDIR);
+
+  ASSERT (func (BASE "link3", &st1) == 0);
+  ASSERT (S_ISLNK (st1.st_mode));
+  errno = 0;
+  ASSERT (func (BASE "link3/", &st1) == -1);
+  ASSERT (errno == ENOENT);
+
+  ASSERT (func (BASE "link4", &st1) == 0);
+  ASSERT (S_ISLNK (st1.st_mode));
+  errno = 0;
+  ASSERT (func (BASE "link4/", &st1) == -1);
+  ASSERT (errno == ELOOP);
+
+  /* Cleanup.  */
+  ASSERT (unlink (BASE "file") == 0);
+  ASSERT (unlink (BASE "link1") == 0);
+  ASSERT (unlink (BASE "link2") == 0);
+  ASSERT (unlink (BASE "link3") == 0);
+  ASSERT (unlink (BASE "link4") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-malloc-gnu.c b/gnulib/tests/test-malloc-gnu.c
new file mode 100644 (file)
index 0000000..c2a3d6b
--- /dev/null
@@ -0,0 +1,29 @@
+/* Test of malloc function.
+   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/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+int
+main ()
+{
+  /* Check that malloc (0) is not a NULL pointer.  */
+  if (malloc (0) == NULL)
+    return 1;
+
+  return 0;
+}
diff --git a/gnulib/tests/test-malloca.c b/gnulib/tests/test-malloca.c
new file mode 100644 (file)
index 0000000..92c86f2
--- /dev/null
@@ -0,0 +1,62 @@
+/* Test of safe automatic memory allocation.
+   Copyright (C) 2005, 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005.  */
+
+#include <config.h>
+
+#include "malloca.h"
+
+#include <stdlib.h>
+
+static void
+do_allocation (int n)
+{
+  void *ptr = malloca (n);
+  freea (ptr);
+  safe_alloca (n);
+}
+
+void (*func) (int) = do_allocation;
+
+int
+main ()
+{
+  int i;
+
+  /* This slows down malloc a lot.  */
+  unsetenv ("MALLOC_PERTURB_");
+
+  /* Repeat a lot of times, to make sure there's no memory leak.  */
+  for (i = 0; i < 50000; i++)
+    {
+      /* Try various values.
+         n = 0 gave a crash on Alpha with gcc-2.5.8.
+         Some versions of MacOS X have a stack size limit of 512 KB.  */
+      func (34);
+      func (134);
+      func (399);
+      func (510823);
+      func (129321);
+      func (0);
+      func (4070);
+      func (4095);
+      func (1);
+      func (16582);
+    }
+
+  return 0;
+}
diff --git a/gnulib/tests/test-mbrtowc-w32-1.sh b/gnulib/tests/test-mbrtowc-w32-1.sh
new file mode 100755 (executable)
index 0000000..3f12e44
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1252 locale.
+./test-mbrtowc-w32${EXEEXT} French_France 1252
diff --git a/gnulib/tests/test-mbrtowc-w32-2.sh b/gnulib/tests/test-mbrtowc-w32-2.sh
new file mode 100755 (executable)
index 0000000..9e1a765
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1256 locale.
+./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256
diff --git a/gnulib/tests/test-mbrtowc-w32-3.sh b/gnulib/tests/test-mbrtowc-w32-3.sh
new file mode 100755 (executable)
index 0000000..782c2d0
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP932 locale.
+./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932
diff --git a/gnulib/tests/test-mbrtowc-w32-4.sh b/gnulib/tests/test-mbrtowc-w32-4.sh
new file mode 100755 (executable)
index 0000000..0630f30
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP950 locale.
+./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950
diff --git a/gnulib/tests/test-mbrtowc-w32-5.sh b/gnulib/tests/test-mbrtowc-w32-5.sh
new file mode 100755 (executable)
index 0000000..7d7faa9
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP936 locale.
+./test-mbrtowc-w32${EXEEXT} Chinese_China 936
diff --git a/gnulib/tests/test-mbrtowc-w32.c b/gnulib/tests/test-mbrtowc-w32.c
new file mode 100644 (file)
index 0000000..ee8caf9
--- /dev/null
@@ -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
diff --git a/gnulib/tests/test-mbrtowc.c b/gnulib/tests/test-mbrtowc.c
new file mode 100644 (file)
index 0000000..727016a
--- /dev/null
@@ -0,0 +1,343 @@
+/* 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t,
+                                   mbstate_t *));
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  mbstate_t state;
+  wchar_t wc;
+  size_t ret;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  /* Test zero-length input.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, "x", 0, &state);
+    /* gnulib's implementation returns (size_t)(-2).
+       The AIX 5.1 implementation returns (size_t)(-1).
+       glibc's implementation returns 0.  */
+    ASSERT (ret == (size_t)(-2) || ret == (size_t)(-1) || ret == 0);
+    ASSERT (mbsinit (&state));
+  }
+
+  /* Test NUL byte input.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, "", 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == 0);
+    ASSERT (mbsinit (&state));
+    ret = mbrtowc (NULL, "", 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (mbsinit (&state));
+  }
+
+  /* Test single-byte input.  */
+  {
+    int c;
+    char buf[1];
+
+    memset (&state, '\0', sizeof (mbstate_t));
+    for (c = 0; c < 0x100; c++)
+      switch (c)
+        {
+        case '\t': case '\v': case '\f':
+        case ' ': case '!': case '"': case '#': case '%':
+        case '&': case '\'': case '(': case ')': case '*':
+        case '+': case ',': case '-': case '.': case '/':
+        case '0': case '1': case '2': case '3': case '4':
+        case '5': case '6': case '7': case '8': case '9':
+        case ':': case ';': case '<': case '=': case '>':
+        case '?':
+        case 'A': case 'B': case 'C': case 'D': case 'E':
+        case 'F': case 'G': case 'H': case 'I': case 'J':
+        case 'K': case 'L': case 'M': case 'N': case 'O':
+        case 'P': case 'Q': case 'R': case 'S': case 'T':
+        case 'U': case 'V': case 'W': case 'X': case 'Y':
+        case 'Z':
+        case '[': case '\\': case ']': case '^': case '_':
+        case 'a': case 'b': case 'c': case 'd': case 'e':
+        case 'f': case 'g': case 'h': case 'i': case 'j':
+        case 'k': case 'l': case 'm': case 'n': case 'o':
+        case 'p': case 'q': case 'r': case 's': case 't':
+        case 'u': case 'v': case 'w': case 'x': case 'y':
+        case 'z': case '{': case '|': case '}': case '~':
+          /* c is in the ISO C "basic character set".  */
+          buf[0] = c;
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, buf, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == c);
+          ASSERT (mbsinit (&state));
+          ret = mbrtowc (NULL, buf, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (mbsinit (&state));
+          break;
+        }
+  }
+
+  /* Test special calling convention, passing a NULL pointer.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, NULL, 5, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == (wchar_t) 0xBADFACE);
+    ASSERT (mbsinit (&state));
+  }
+
+  if (argc > 1)
+    switch (argv[1][0])
+      {
+      case '1':
+        /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+        {
+          char input[] = "B\374\337er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == (unsigned char) '\374');
+          ASSERT (mbsinit (&state));
+          input[1] = '\0';
+
+          /* 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 (mbsinit (&state));
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[3] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 4, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
+
+      case '2':
+        /* Locale encoding is UTF-8.  */
+        {
+          char input[] = "B\303\274\303\237er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[1] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 2, 5, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[2] = '\0';
+
+          /* 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 (mbsinit (&state));
+          input[3] = '\0';
+          input[4] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 5, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[5] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 6, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
+
+      case '3':
+        /* Locale encoding is EUC-JP.  */
+        {
+          char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == '<');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 2, &state);
+          ASSERT (ret == 2);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[1] = '\0';
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[3] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 4, 4, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[4] = '\0';
+
+          /* 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 (mbsinit (&state));
+          input[5] = '\0';
+          input[6] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 7, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == '>');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
+
+      case '4':
+        /* Locale encoding is GB18030.  */
+        {
+          char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[1] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 2, 7, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[2] = '\0';
+
+          /* 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 (mbsinit (&state));
+          input[3] = '\0';
+          input[4] = '\0';
+          input[5] = '\0';
+          input[6] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 7, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[5] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 8, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
+      }
+
+  return 1;
+}
diff --git a/gnulib/tests/test-mbrtowc1.sh b/gnulib/tests/test-mbrtowc1.sh
new file mode 100755 (executable)
index 0000000..3becba3
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+./test-mbrtowc${EXEEXT} 1
diff --git a/gnulib/tests/test-mbrtowc2.sh b/gnulib/tests/test-mbrtowc2.sh
new file mode 100755 (executable)
index 0000000..0405aba
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-mbrtowc${EXEEXT} 2
diff --git a/gnulib/tests/test-mbrtowc3.sh b/gnulib/tests/test-mbrtowc3.sh
new file mode 100755 (executable)
index 0000000..63a89a2
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific EUC-JP locale is installed.
+: ${LOCALE_JA=ja_JP}
+if test $LOCALE_JA = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional japanese locale is installed"
+  else
+    echo "Skipping test: no traditional japanese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_JA \
+./test-mbrtowc${EXEEXT} 3
diff --git a/gnulib/tests/test-mbrtowc4.sh b/gnulib/tests/test-mbrtowc4.sh
new file mode 100755 (executable)
index 0000000..b299a2c
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no transitional chinese locale is installed"
+  else
+    echo "Skipping test: no transitional chinese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+./test-mbrtowc${EXEEXT} 4
diff --git a/gnulib/tests/test-mbsinit.c b/gnulib/tests/test-mbsinit.c
new file mode 100644 (file)
index 0000000..2cc2924
--- /dev/null
@@ -0,0 +1,55 @@
+/* Test of test for initial conversion state.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (mbsinit, int, (const mbstate_t *));
+
+#include <locale.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  static mbstate_t state;
+
+  ASSERT (mbsinit (NULL));
+
+  ASSERT (mbsinit (&state));
+
+  if (argc > 1)
+    {
+      static const char input[1] = "\303";
+      wchar_t wc;
+      size_t ret;
+
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+        return 1;
+
+      ret = mbrtowc (&wc, input, 1, &state);
+      ASSERT (ret == (size_t)(-2));
+      ASSERT (!mbsinit (&state));
+    }
+
+  return 0;
+}
diff --git a/gnulib/tests/test-mbsinit.sh b/gnulib/tests/test-mbsinit.sh
new file mode 100755 (executable)
index 0000000..bbda48d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-mbsinit${EXEEXT}
diff --git a/gnulib/tests/test-mbsrtowcs.c b/gnulib/tests/test-mbsrtowcs.c
new file mode 100644 (file)
index 0000000..9a63ed9
--- /dev/null
@@ -0,0 +1,293 @@
+/* Test of conversion of string to wide string.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (mbsrtowcs, size_t, (wchar_t *, char const **, size_t,
+                                     mbstate_t *));
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  mbstate_t state;
+  wchar_t wc;
+  size_t ret;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  /* Test NUL byte input.  */
+  {
+    const char *src;
+
+    memset (&state, '\0', sizeof (mbstate_t));
+
+    src = "";
+    ret = mbsrtowcs (NULL, &src, 0, &state);
+    ASSERT (ret == 0);
+    ASSERT (mbsinit (&state));
+
+    src = "";
+    ret = mbsrtowcs (NULL, &src, 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (mbsinit (&state));
+
+    wc = (wchar_t) 0xBADFACE;
+    src = "";
+    ret = mbsrtowcs (&wc, &src, 0, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == (wchar_t) 0xBADFACE);
+    ASSERT (mbsinit (&state));
+
+    wc = (wchar_t) 0xBADFACE;
+    src = "";
+    ret = mbsrtowcs (&wc, &src, 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == 0);
+    ASSERT (mbsinit (&state));
+  }
+
+  if (argc > 1)
+    {
+      int unlimited;
+
+      for (unlimited = 0; unlimited < 2; unlimited++)
+        {
+          #define BUFSIZE 10
+          wchar_t buf[BUFSIZE];
+          const char *src;
+          mbstate_t temp_state;
+
+          {
+            size_t i;
+            for (i = 0; i < BUFSIZE; i++)
+              buf[i] = (wchar_t) 0xBADFACE;
+          }
+
+          switch (argv[1][0])
+            {
+            case '1':
+              /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+              {
+                char input[] = "B\374\337er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wctob (wc) == (unsigned char) '\374');
+                ASSERT (mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
+                ASSERT (ret == 3);
+                ASSERT (src == input + 2);
+                ASSERT (mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
+                ASSERT (ret == (unlimited ? 3 : 1));
+                ASSERT (src == (unlimited ? NULL : input + 3));
+                ASSERT (wctob (buf[0]) == (unsigned char) '\337');
+                if (unlimited)
+                  {
+                    ASSERT (buf[1] == 'e');
+                    ASSERT (buf[2] == 'r');
+                    ASSERT (buf[3] == 0);
+                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[1] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '2':
+              /* Locale encoding is UTF-8.  */
+              {
+                char input[] = "B\303\274\303\237er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 4);
+                ASSERT (src == input + 2);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 4 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 5));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == 'e');
+                    ASSERT (buf[3] == 'r');
+                    ASSERT (buf[4] == 0);
+                    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '3':
+              /* Locale encoding is EUC-JP.  */
+              {
+                char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == '<');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 2, &state);
+                ASSERT (ret == 2);
+                ASSERT (wctob (wc) == EOF);
+                ASSERT (mbsinit (&state));
+                input[1] = '\0';
+                input[2] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 3, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[3] = '\0';
+
+                src = input + 4;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 3);
+                ASSERT (src == input + 4);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 4;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 3 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 7));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == '>');
+                    ASSERT (buf[3] == 0);
+                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '4':
+              /* Locale encoding is GB18030.  */
+              {
+                char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 4);
+                ASSERT (src == input + 2);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 4 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 7));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == 'e');
+                    ASSERT (buf[3] == 'r');
+                    ASSERT (buf[4] == 0);
+                    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            default:
+              return 1;
+            }
+        }
+
+      return 0;
+    }
+
+  return 1;
+}
diff --git a/gnulib/tests/test-mbsrtowcs1.sh b/gnulib/tests/test-mbsrtowcs1.sh
new file mode 100755 (executable)
index 0000000..01916e7
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+./test-mbsrtowcs${EXEEXT} 1
diff --git a/gnulib/tests/test-mbsrtowcs2.sh b/gnulib/tests/test-mbsrtowcs2.sh
new file mode 100755 (executable)
index 0000000..f72ceb6
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-mbsrtowcs${EXEEXT} 2
diff --git a/gnulib/tests/test-mbsrtowcs3.sh b/gnulib/tests/test-mbsrtowcs3.sh
new file mode 100755 (executable)
index 0000000..b3c01d4
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific EUC-JP locale is installed.
+: ${LOCALE_JA=ja_JP}
+if test $LOCALE_JA = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional japanese locale is installed"
+  else
+    echo "Skipping test: no traditional japanese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_JA \
+./test-mbsrtowcs${EXEEXT} 3
diff --git a/gnulib/tests/test-mbsrtowcs4.sh b/gnulib/tests/test-mbsrtowcs4.sh
new file mode 100755 (executable)
index 0000000..226d6ff
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no transitional chinese locale is installed"
+  else
+    echo "Skipping test: no transitional chinese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+./test-mbsrtowcs${EXEEXT} 4
diff --git a/gnulib/tests/test-memchr.c b/gnulib/tests/test-memchr.c
new file mode 100644 (file)
index 0000000..a11f6cd
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ * Written by Eric Blake and Bruno Haible
+ *
+ * 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 <string.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (memchr, void *, (void const *, int, size_t));
+
+#include <stdlib.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+/* Calculating void * + int is not portable, so this wrapper converts
+   to char * to make the tests easier to write.  */
+#define MEMCHR (char *) memchr
+
+int
+main (void)
+{
+  size_t n = 0x100000;
+  char *input = malloc (n);
+  ASSERT (input);
+
+  input[0] = 'a';
+  input[1] = 'b';
+  memset (input + 2, 'c', 1024);
+  memset (input + 1026, 'd', n - 1028);
+  input[n - 2] = 'e';
+  input[n - 1] = 'a';
+
+  /* Basic behavior tests.  */
+  ASSERT (MEMCHR (input, 'a', n) == input);
+
+  ASSERT (MEMCHR (input, 'a', 0) == NULL);
+  ASSERT (MEMCHR (zerosize_ptr (), 'a', 0) == NULL);
+
+  ASSERT (MEMCHR (input, 'b', n) == input + 1);
+  ASSERT (MEMCHR (input, 'c', n) == input + 2);
+  ASSERT (MEMCHR (input, 'd', n) == input + 1026);
+
+  ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1);
+  ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2);
+  ASSERT (MEMCHR (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2);
+
+  ASSERT (MEMCHR (input, 'f', n) == NULL);
+  ASSERT (MEMCHR (input, '\0', n) == NULL);
+
+  /* Check that a very long haystack is handled quickly if the byte is
+     found near the beginning.  */
+  {
+    size_t repeat = 10000;
+    for (; repeat > 0; repeat--)
+      {
+        ASSERT (MEMCHR (input, 'c', n) == input + 2);
+      }
+  }
+
+  /* Alignment tests.  */
+  {
+    int i, j;
+    for (i = 0; i < 32; i++)
+      {
+        for (j = 0; j < 256; j++)
+          input[i + j] = j;
+        for (j = 0; j < 256; j++)
+          {
+            ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
+          }
+      }
+  }
+
+  /* Check that memchr() does not read past the first occurrence of the
+     byte being searched.  See the Austin Group's clarification
+     <http://www.opengroup.org/austin/docs/austin_454.txt>.
+     Test both '\0' and something else, since some implementations
+     special-case searching for NUL.
+  */
+  {
+    char *page_boundary = (char *) zerosize_ptr ();
+    /* Too small, and we miss cache line boundary tests; too large,
+       and the test takes cubically longer to complete.  */
+    int limit = 257;
+
+    if (page_boundary != NULL)
+      {
+        for (n = 1; n <= limit; n++)
+          {
+            char *mem = page_boundary - n;
+            memset (mem, 'X', n);
+            ASSERT (MEMCHR (mem, 'U', n) == NULL);
+            ASSERT (MEMCHR (mem, 0, n) == NULL);
+
+            {
+              size_t i;
+              size_t k;
+
+              for (i = 0; i < n; i++)
+                {
+                  mem[i] = 'U';
+                  for (k = i + 1; k < n + limit; k++)
+                    ASSERT (MEMCHR (mem, 'U', k) == mem + i);
+                  mem[i] = 0;
+                  for (k = i + 1; k < n + limit; k++)
+                    ASSERT (MEMCHR (mem, 0, k) == mem + i);
+                  mem[i] = 'X';
+                }
+            }
+          }
+      }
+  }
+
+  free (input);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-nl_langinfo.c b/gnulib/tests/test-nl_langinfo.c
new file mode 100644 (file)
index 0000000..964ea8d
--- /dev/null
@@ -0,0 +1,126 @@
+/* Test of nl_langinfo replacement.
+   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>
+
+#include <langinfo.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (nl_langinfo, char *, (nl_item));
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "c-strcase.h"
+#include "macros.h"
+
+/* For GCC >= 4.3, silence the warnings
+     "comparison of unsigned expression >= 0 is always true"
+   in this file.  */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
+int
+main (int argc, char *argv[])
+{
+  int pass = atoi (argv[1]);
+  /* pass    locale
+      0        C
+      1        traditional French locale
+      2        French UTF-8 locale
+   */
+
+  setlocale (LC_ALL, "");
+
+  /* nl_langinfo items of the LC_CTYPE category */
+  ASSERT (strlen (nl_langinfo (CODESET)) > 0);
+  if (pass == 2)
+    {
+      const char *codeset = nl_langinfo (CODESET);
+      ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0);
+    }
+  /* nl_langinfo items of the LC_NUMERIC category */
+  ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0);
+  ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0);
+  /* nl_langinfo items of the LC_TIME category */
+  ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (D_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (T_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (DAY_1)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_2)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_3)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_4)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_5)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_6)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_7)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_1)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_2)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_3)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_4)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_5)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_6)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_7)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_8)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_9)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_10)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_11)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_12)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_1)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_2)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_3)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_4)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_5)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_6)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_7)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_8)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_9)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
+  ASSERT (strlen (nl_langinfo (ERA)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0);
+  ASSERT (nl_langinfo (ALT_DIGITS) != NULL);
+  /* nl_langinfo items of the LC_MONETARY category */
+  {
+    const char *currency = nl_langinfo (CRNCYSTR);
+    ASSERT (strlen (currency) >= 0);
+#if !defined __NetBSD__
+    if (pass > 0)
+      ASSERT (strlen (currency) >= 1);
+#endif
+  }
+  /* nl_langinfo items of the LC_MESSAGES category */
+  ASSERT (strlen (nl_langinfo (YESEXPR)) > 0);
+  ASSERT (strlen (nl_langinfo (NOEXPR)) > 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-nl_langinfo.sh b/gnulib/tests/test-nl_langinfo.sh
new file mode 100755 (executable)
index 0000000..3168f42
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+LC_ALL=C ./test-nl_langinfo${EXEEXT} 0 || exit 1
+
+# Test whether a specific traditional locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR ./test-nl_langinfo${EXEEXT} 1 || exit 1
+fi
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+  LC_ALL=$LOCALE_FR_UTF8 ./test-nl_langinfo${EXEEXT} 2 || exit 1
+fi
+
+exit 0
diff --git a/gnulib/tests/test-open.c b/gnulib/tests/test-open.c
new file mode 100644 (file)
index 0000000..3c5b2ab
--- /dev/null
@@ -0,0 +1,41 @@
+/* Test of opening a file descriptor.
+   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 <fcntl.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (open, int, (char const *, int, ...));
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+#define BASE "test-open.t"
+
+#include "test-open.h"
+
+int
+main (void)
+{
+  return test_open (open, true);
+}
diff --git a/gnulib/tests/test-open.h b/gnulib/tests/test-open.h
new file mode 100644 (file)
index 0000000..3e5c5e1
--- /dev/null
@@ -0,0 +1,87 @@
+/* Test of opening a file descriptor.
+   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.  */
+
+/* This file is designed to test both open(n,buf[,mode]) and
+   openat(AT_FDCWD,n,buf[,mode]).  FUNC is the function to test.
+   Assumes that BASE and ASSERT are already defined, and that
+   appropriate headers are already included.  If PRINT, warn before
+   skipping symlink tests with status 77.  */
+
+static int
+test_open (int (*func) (char const *, int, ...), bool print)
+{
+  int fd;
+  /* Remove anything from prior partial run.  */
+  unlink (BASE "file");
+
+  /* Cannot create directory.  */
+  errno = 0;
+  ASSERT (func ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) == -1);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT
+          || errno == EINVAL);
+
+  /* Create a regular file.  */
+  fd = func (BASE "file", O_CREAT | O_RDONLY, 0600);
+  ASSERT (0 <= fd);
+  ASSERT (close (fd) == 0);
+
+  /* Trailing slash handling.  */
+  errno = 0;
+  ASSERT (func (BASE "file/", O_RDONLY) == -1);
+  ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL);
+
+  /* Directories cannot be opened for writing.  */
+  errno = 0;
+  ASSERT (func (".", O_WRONLY) == -1);
+  ASSERT (errno == EISDIR || errno == EACCES);
+
+  /* /dev/null must exist, and be writable.  */
+  fd = func ("/dev/null", O_RDONLY);
+  ASSERT (0 <= fd);
+  {
+    char c;
+    ASSERT (read (fd, &c, 1) == 0);
+  }
+  ASSERT (close (fd) == 0);
+  fd = func ("/dev/null", O_WRONLY);
+  ASSERT (0 <= fd);
+  ASSERT (write (fd, "c", 1) == 1);
+  ASSERT (close (fd) == 0);
+
+  /* Symlink handling, where supported.  */
+  if (symlink (BASE "file", BASE "link") != 0)
+    {
+      ASSERT (unlink (BASE "file") == 0);
+      if (print)
+        fputs ("skipping test: symlinks not supported on this file system\n",
+               stderr);
+      return 77;
+    }
+  errno = 0;
+  ASSERT (func (BASE "link/", O_RDONLY) == -1);
+  ASSERT (errno == ENOTDIR);
+  fd = func (BASE "link", O_RDONLY);
+  ASSERT (0 <= fd);
+  ASSERT (close (fd) == 0);
+
+  /* Cleanup.  */
+  ASSERT (unlink (BASE "file") == 0);
+  ASSERT (unlink (BASE "link") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-readlink.c b/gnulib/tests/test-readlink.c
new file mode 100644 (file)
index 0000000..3da5fbf
--- /dev/null
@@ -0,0 +1,48 @@
+/* Tests of readlink.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (readlink, ssize_t, (char const *, char *, size_t));
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "ignore-value.h"
+#include "macros.h"
+
+#define BASE "test-readlink.t"
+
+#include "test-readlink.h"
+
+int
+main (void)
+{
+  /* Remove any leftovers from a previous partial run.  */
+  ignore_value (system ("rm -rf " BASE "*"));
+
+  return test_readlink (readlink, true);
+}
diff --git a/gnulib/tests/test-readlink.h b/gnulib/tests/test-readlink.h
new file mode 100644 (file)
index 0000000..08d5662
--- /dev/null
@@ -0,0 +1,119 @@
+/* Tests of readlink.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+/* This file is designed to test both readlink(a,b,c) and
+   readlinkat(AT_FDCWD,a,b,c).  FUNC is the function to test.  Assumes
+   that BASE and ASSERT are already defined, and that appropriate
+   headers are already included.  If PRINT, warn before skipping
+   symlink tests with status 77.  */
+
+static int
+test_readlink (ssize_t (*func) (char const *, char *, size_t), bool print)
+{
+  char buf[80];
+
+  /* Sanity checks of failures.  Mingw lacks symlink, but readlink can
+     still distinguish between various errors.  */
+  memset (buf, 0xff, sizeof buf);
+  errno = 0;
+  ASSERT (func ("no_such", buf, sizeof buf) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("no_such/", buf, sizeof buf) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("", buf, sizeof buf) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func (".", buf, sizeof buf) == -1);
+  ASSERT (errno == EINVAL);
+  errno = 0;
+  ASSERT (func ("./", buf, sizeof buf) == -1);
+  ASSERT (errno == EINVAL);
+  ASSERT (close (creat (BASE "file", 0600)) == 0);
+  errno = 0;
+  ASSERT (func (BASE "file", buf, sizeof buf) == -1);
+  ASSERT (errno == EINVAL);
+  errno = 0;
+  ASSERT (func (BASE "file/", buf, sizeof buf) == -1);
+  ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */
+
+  /* Now test actual symlinks.  */
+  if (symlink (BASE "dir", BASE "link"))
+    {
+      ASSERT (unlink (BASE "file") == 0);
+      if (print)
+        fputs ("skipping test: symlinks not supported on this file system\n",
+               stderr);
+      return 77;
+    }
+  ASSERT (mkdir (BASE "dir", 0700) == 0);
+  errno = 0;
+  ASSERT (func (BASE "link/", buf, sizeof buf) == -1);
+  ASSERT (errno == EINVAL);
+  ASSERT (symlink (BASE "link", BASE "link2") == 0);
+  errno = 0;
+  ASSERT (func (BASE "link2/", buf, sizeof buf) == -1);
+  ASSERT (errno == EINVAL);
+  ASSERT (unlink (BASE "link2") == 0);
+  ASSERT (symlink (BASE "file", BASE "link2") == 0);
+  errno = 0;
+  ASSERT (func (BASE "link2/", buf, sizeof buf) == -1);
+  ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */
+  ASSERT (unlink (BASE "file") == 0);
+  ASSERT (unlink (BASE "link2") == 0);
+  {
+    /* Up till now, no readlink has been successful, so buf should be
+       unchanged.  */
+    int i;
+    for (i = 0; i < sizeof buf; i++)
+      ASSERT (buf[i] == (char) 0xff);
+  }
+  {
+    size_t len = strlen (BASE "dir");
+    /* When passing too small of a buffer, expect the truncated
+       length, or an ERANGE failure.  However, a size of 0 is not
+       portable enough to test.  */
+    ssize_t result;
+    errno = 0;
+    result = readlink (BASE "link", buf, 1);
+    if (result == -1)
+      {
+        ASSERT (errno == ERANGE);
+        ASSERT (buf[0] == (char) 0xff);
+      }
+    else
+      {
+        ASSERT (result == 1);
+        ASSERT (buf[0] == BASE[0]);
+      }
+    ASSERT (buf[1] == (char) 0xff);
+    ASSERT (func (BASE "link", buf, len) == len);
+    ASSERT (strncmp (buf, BASE "dir", len) == 0);
+    ASSERT (buf[len] == (char) 0xff);
+    ASSERT (func (BASE "link", buf, sizeof buf) == len);
+    ASSERT (strncmp (buf, BASE "dir", len) == 0);
+    /* POSIX says rest of buf is unspecified; but in practice, it is
+       either left alone, or NUL-terminated.  */
+    ASSERT (buf[len] == '\0' || buf[len] == (char) 0xff);
+  }
+  ASSERT (rmdir (BASE "dir") == 0);
+  ASSERT (unlink (BASE "link") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-safe-alloc.c b/gnulib/tests/test-safe-alloc.c
new file mode 100644 (file)
index 0000000..2cf61be
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Test the safe-alloc macros
+ *
+ * Copyright (C) 2009-2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "safe-alloc.h"
+
+#include "macros.h"
+
+int
+main ()
+{
+  struct tst
+  {
+    int a;
+    int b;
+  };
+
+  struct tst *p = NULL;
+  int r;
+
+  r = ALLOC (p);
+  ASSERT (r >= 0);
+
+  ASSERT (p->a == 0 && p->b == 0);
+
+  p->a = p->b = 42;
+  r = REALLOC_N (p, 5);
+
+  ASSERT (p[0].a == 42 && p[0].b == 42);
+
+  FREE (p);
+  ASSERT (p == NULL);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-setenv.c b/gnulib/tests/test-setenv.c
new file mode 100644 (file)
index 0000000..50eb71b
--- /dev/null
@@ -0,0 +1,56 @@
+/* Tests of setenv.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (setenv, int, (char const *, char const *, int));
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Test overwriting.  */
+  ASSERT (setenv ("a", "==", -1) == 0);
+  ASSERT (setenv ("a", "2", 0) == 0);
+  ASSERT (strcmp (getenv ("a"), "==") == 0);
+
+  /* Required to fail with EINVAL.  */
+  errno = 0;
+  ASSERT (setenv ("", "", 1) == -1);
+  ASSERT (errno == EINVAL);
+  errno = 0;
+  ASSERT (setenv ("a=b", "", 0) == -1);
+  ASSERT (errno == EINVAL);
+#if 0
+  /* glibc and gnulib's implementation guarantee this, but POSIX no
+     longer requires it: http://austingroupbugs.net/view.php?id=185  */
+  errno = 0;
+  ASSERT (setenv (NULL, "", 0) == -1);
+  ASSERT (errno == EINVAL);
+#endif
+
+  return 0;
+}
diff --git a/gnulib/tests/test-setlocale1.c b/gnulib/tests/test-setlocale1.c
new file mode 100644 (file)
index 0000000..ea7945c
--- /dev/null
@@ -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;
+}
diff --git a/gnulib/tests/test-setlocale1.sh b/gnulib/tests/test-setlocale1.sh
new file mode 100755 (executable)
index 0000000..59a0532
--- /dev/null
@@ -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
diff --git a/gnulib/tests/test-setlocale2.c b/gnulib/tests/test-setlocale2.c
new file mode 100644 (file)
index 0000000..7bfc42a
--- /dev/null
@@ -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;
+}
diff --git a/gnulib/tests/test-setlocale2.sh b/gnulib/tests/test-setlocale2.sh
new file mode 100755 (executable)
index 0000000..723e74e
--- /dev/null
@@ -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
diff --git a/gnulib/tests/test-stat.c b/gnulib/tests/test-stat.c
new file mode 100644 (file)
index 0000000..4cda089
--- /dev/null
@@ -0,0 +1,56 @@
+/* Tests of stat.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <sys/stat.h>
+
+/* Caution: stat may be a function-like macro.  Although this
+   signature check must pass, it may be the signature of the real (and
+   broken) stat rather than rpl_stat.  Most code should not use the
+   address of stat.  */
+#include "signature.h"
+SIGNATURE_CHECK (stat, int, (char const *, struct stat *));
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "pathmax.h"
+#include "same-inode.h"
+#include "macros.h"
+
+#define BASE "test-stat.t"
+
+#include "test-stat.h"
+
+/* Wrapper around stat, which works even if stat is a function-like
+   macro, where test_stat_func(stat) would do the wrong thing.  */
+static int
+do_stat (char const *name, struct stat *st)
+{
+  return stat (name, st);
+}
+
+int
+main (void)
+{
+  return test_stat_func (do_stat, true);
+}
diff --git a/gnulib/tests/test-stat.h b/gnulib/tests/test-stat.h
new file mode 100644 (file)
index 0000000..22552dc
--- /dev/null
@@ -0,0 +1,100 @@
+/* Tests of stat.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+/* This file is designed to test both stat(n,buf) and
+   fstatat(AT_FDCWD,n,buf,0).  FUNC is the function to test.  Assumes
+   that BASE and ASSERT are already defined, and that appropriate
+   headers are already included.  If PRINT, warn before skipping
+   symlink tests with status 77.  */
+
+static int
+test_stat_func (int (*func) (char const *, struct stat *), bool print)
+{
+  struct stat st1;
+  struct stat st2;
+  char cwd[PATH_MAX];
+
+  ASSERT (getcwd (cwd, PATH_MAX) == cwd);
+  ASSERT (func (".", &st1) == 0);
+  ASSERT (func ("./", &st2) == 0);
+  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (func (cwd, &st2) == 0);
+  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (func ("/", &st1) == 0);
+  ASSERT (func ("///", &st2) == 0);
+  ASSERT (SAME_INODE (st1, st2));
+
+  errno = 0;
+  ASSERT (func ("", &st1) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("nosuch", &st1) == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("nosuch/", &st1) == -1);
+  ASSERT (errno == ENOENT);
+
+  ASSERT (close (creat (BASE "file", 0600)) == 0);
+  ASSERT (func (BASE "file", &st1) == 0);
+  errno = 0;
+  ASSERT (func (BASE "file/", &st1) == -1);
+  ASSERT (errno == ENOTDIR);
+
+  /* Now for some symlink tests, where supported.  We set up:
+     link1 -> directory
+     link2 -> file
+     link3 -> dangling
+     link4 -> loop
+     then test behavior with trailing slash.
+  */
+  if (symlink (".", BASE "link1") != 0)
+    {
+      ASSERT (unlink (BASE "file") == 0);
+      if (print)
+        fputs ("skipping test: symlinks not supported on this file system\n",
+               stderr);
+      return 77;
+    }
+  ASSERT (symlink (BASE "file", BASE "link2") == 0);
+  ASSERT (symlink (BASE "nosuch", BASE "link3") == 0);
+  ASSERT (symlink (BASE "link4", BASE "link4") == 0);
+
+  ASSERT (func (BASE "link1/", &st1) == 0);
+  ASSERT (S_ISDIR (st1.st_mode));
+
+  errno = 0;
+  ASSERT (func (BASE "link2/", &st1) == -1);
+  ASSERT (errno == ENOTDIR);
+
+  errno = 0;
+  ASSERT (func (BASE "link3/", &st1) == -1);
+  ASSERT (errno == ENOENT);
+
+  errno = 0;
+  ASSERT (func (BASE "link4/", &st1) == -1);
+  ASSERT (errno == ELOOP);
+
+  /* Cleanup.  */
+  ASSERT (unlink (BASE "file") == 0);
+  ASSERT (unlink (BASE "link1") == 0);
+  ASSERT (unlink (BASE "link2") == 0);
+  ASSERT (unlink (BASE "link3") == 0);
+  ASSERT (unlink (BASE "link4") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-stdbool.c b/gnulib/tests/test-stdbool.c
new file mode 100644 (file)
index 0000000..e115ba2
--- /dev/null
@@ -0,0 +1,118 @@
+/* Test of <stdbool.h> substitute.
+   Copyright (C) 2002-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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+/* We want this test to succeed even when using gcc's -Werror; but to
+   do that requires a pragma that didn't exist before 4.3.0.  */
+#ifndef __GNUC__
+# define ADDRESS_CHECK_OKAY
+#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+/* No way to silence -Waddress.  */
+#else
+# pragma GCC diagnostic ignored "-Waddress"
+# define ADDRESS_CHECK_OKAY
+#endif
+
+#include <config.h>
+
+#include <stdbool.h>
+
+#ifndef bool
+ "error: bool is not defined"
+#endif
+#ifndef false
+ "error: false is not defined"
+#endif
+#if false
+ "error: false is not 0"
+#endif
+#ifndef true
+ "error: true is not defined"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+#ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+#endif
+
+/* Several tests cannot be guaranteed with gnulib's <stdbool.h>, at
+   least, not for all compilers and compiler options.  */
+#if HAVE_STDBOOL_H || 3 <= __GNUC__
+struct s { _Bool s: 1; _Bool t; } s;
+#endif
+
+char a[true == 1 ? 1 : -1];
+char b[false == 0 ? 1 : -1];
+char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above.  */
+char d[(bool) 0.5 == true ? 1 : -1];
+# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning.  */
+/* C99 may plausibly be interpreted as not requiring support for a cast from
+   a variable's address to bool in a static initializer.  So treat it like a
+   GCC extension.  */
+#  ifdef __GNUC__
+bool e = &s;
+#  endif
+# endif
+char f[(_Bool) 0.0 == false ? 1 : -1];
+#endif
+char g[true];
+char h[sizeof (_Bool)];
+#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above.  */
+char i[sizeof s.t];
+#endif
+enum { j = false, k = true, l = false * true, m = true * 256 };
+_Bool n[m];
+char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+/* Catch a bug in an HP-UX C compiler.  See
+   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+_Bool q = true;
+_Bool *pq = &q;
+
+int
+main ()
+{
+  int error = 0;
+
+#if HAVE_STDBOOL_H || 3 <= __GNUC__ /* See above.  */
+# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning.  */
+  /* A cast from a variable's address to bool is valid in expressions.  */
+  {
+    bool e1 = &s;
+    if (!e1)
+      error = 1;
+  }
+# endif
+#endif
+
+  /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+     reported by James Lemley on 2005-10-05; see
+     http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+     This is a runtime test, since a corresponding compile-time
+     test would rely on initializer extensions.  */
+  {
+    char digs[] = "0123456789";
+    if (&(digs + 5)[-2 + (bool) 1] != &digs[4])
+      error = 1;
+  }
+
+  return error;
+}
diff --git a/gnulib/tests/test-stddef.c b/gnulib/tests/test-stddef.c
new file mode 100644 (file)
index 0000000..c929af8
--- /dev/null
@@ -0,0 +1,52 @@
+/* Test of <stddef.h> substitute.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <stddef.h>
+
+#include "verify.h"
+
+/* Check that appropriate types are defined.  */
+wchar_t a = 'c';
+ptrdiff_t b = 1;
+size_t c = 2;
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+/* Check that offsetof produces integer constants with correct type.  */
+struct d
+{
+  char e;
+  char f;
+};
+/* Solaris 10 has a bug where offsetof is under-parenthesized, and
+   cannot be used as an arbitrary expression.  However, since it is
+   unlikely to bite real code, we ignore that short-coming.  */
+/* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */
+verify (sizeof (offsetof (struct d, e)) == sizeof (size_t));
+verify (offsetof (struct d, e) < -1); /* Must be unsigned.  */
+verify (offsetof (struct d, f) == 1);
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-stdint.c b/gnulib/tests/test-stdint.c
new file mode 100644 (file)
index 0000000..f606cc3
--- /dev/null
@@ -0,0 +1,361 @@
+/* Test of <stdint.h> substitute.
+   Copyright (C) 2006-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>, 2006.  */
+
+#include <config.h>
+
+/* Whether to enable pedantic checks. */
+#define DO_PEDANTIC 0
+
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* likewise */
+#include <stdint.h>
+
+#include "verify.h"
+#include "intprops.h"
+
+#if __GNUC__ >= 2 && DO_PEDANTIC
+# define verify_same_types(expr1,expr2)  \
+    extern void _verify_func(__LINE__) (__typeof__ (expr1) *); \
+    extern void _verify_func(__LINE__) (__typeof__ (expr2) *);
+# define _verify_func(line) _verify_func2(line)
+# define _verify_func2(line) verify_func_ ## line
+#else
+# define verify_same_types(expr1,expr2) extern void verify_func (int)
+#endif
+
+/* 7.18.1.1. Exact-width integer types */
+/* 7.18.2.1. Limits of exact-width integer types */
+
+int8_t a1[3] = { INT8_C (17), INT8_MIN, INT8_MAX };
+verify (TYPE_MINIMUM (int8_t) == INT8_MIN);
+verify (TYPE_MAXIMUM (int8_t) == INT8_MAX);
+verify_same_types (INT8_MIN, (int8_t) 0 + 0);
+verify_same_types (INT8_MAX, (int8_t) 0 + 0);
+
+int16_t a2[3] = { INT16_C (17), INT16_MIN, INT16_MAX };
+verify (TYPE_MINIMUM (int16_t) == INT16_MIN);
+verify (TYPE_MAXIMUM (int16_t) == INT16_MAX);
+verify_same_types (INT16_MIN, (int16_t) 0 + 0);
+verify_same_types (INT16_MAX, (int16_t) 0 + 0);
+
+int32_t a3[3] = { INT32_C (17), INT32_MIN, INT32_MAX };
+verify (TYPE_MINIMUM (int32_t) == INT32_MIN);
+verify (TYPE_MAXIMUM (int32_t) == INT32_MAX);
+verify_same_types (INT32_MIN, (int32_t) 0 + 0);
+verify_same_types (INT32_MAX, (int32_t) 0 + 0);
+
+#ifdef INT64_MAX
+int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX };
+verify (TYPE_MINIMUM (int64_t) == INT64_MIN);
+verify (TYPE_MAXIMUM (int64_t) == INT64_MAX);
+verify_same_types (INT64_MIN, (int64_t) 0 + 0);
+verify_same_types (INT64_MAX, (int64_t) 0 + 0);
+#endif
+
+uint8_t b1[2] = { UINT8_C (17), UINT8_MAX };
+verify (TYPE_MAXIMUM (uint8_t) == UINT8_MAX);
+verify_same_types (UINT8_MAX, (uint8_t) 0 + 0);
+
+uint16_t b2[2] = { UINT16_C (17), UINT16_MAX };
+verify (TYPE_MAXIMUM (uint16_t) == UINT16_MAX);
+verify_same_types (UINT16_MAX, (uint16_t) 0 + 0);
+
+uint32_t b3[2] = { UINT32_C (17), UINT32_MAX };
+verify (TYPE_MAXIMUM (uint32_t) == UINT32_MAX);
+verify_same_types (UINT32_MAX, (uint32_t) 0 + 0);
+
+#ifdef UINT64_MAX
+uint64_t b4[2] = { UINT64_C (17), UINT64_MAX };
+verify (TYPE_MAXIMUM (uint64_t) == UINT64_MAX);
+verify_same_types (UINT64_MAX, (uint64_t) 0 + 0);
+#endif
+
+#if INT8_MIN && INT8_MAX && INT16_MIN && INT16_MAX && INT32_MIN && INT32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+#if UINT8_MAX && UINT16_MAX && UINT32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+/* 7.18.1.2. Minimum-width integer types */
+/* 7.18.2.2. Limits of minimum-width integer types */
+
+int_least8_t c1[3] = { 17, INT_LEAST8_MIN, INT_LEAST8_MAX };
+verify (TYPE_MINIMUM (int_least8_t) == INT_LEAST8_MIN);
+verify (TYPE_MAXIMUM (int_least8_t) == INT_LEAST8_MAX);
+verify_same_types (INT_LEAST8_MIN, (int_least8_t) 0 + 0);
+verify_same_types (INT_LEAST8_MAX, (int_least8_t) 0 + 0);
+
+int_least16_t c2[3] = { 17, INT_LEAST16_MIN, INT_LEAST16_MAX };
+verify (TYPE_MINIMUM (int_least16_t) == INT_LEAST16_MIN);
+verify (TYPE_MAXIMUM (int_least16_t) == INT_LEAST16_MAX);
+verify_same_types (INT_LEAST16_MIN, (int_least16_t) 0 + 0);
+verify_same_types (INT_LEAST16_MAX, (int_least16_t) 0 + 0);
+
+int_least32_t c3[3] = { 17, INT_LEAST32_MIN, INT_LEAST32_MAX };
+verify (TYPE_MINIMUM (int_least32_t) == INT_LEAST32_MIN);
+verify (TYPE_MAXIMUM (int_least32_t) == INT_LEAST32_MAX);
+verify_same_types (INT_LEAST32_MIN, (int_least32_t) 0 + 0);
+verify_same_types (INT_LEAST32_MAX, (int_least32_t) 0 + 0);
+
+#ifdef INT_LEAST64_MAX
+int_least64_t c4[3] = { 17, INT_LEAST64_MIN, INT_LEAST64_MAX };
+verify (TYPE_MINIMUM (int_least64_t) == INT_LEAST64_MIN);
+verify (TYPE_MAXIMUM (int_least64_t) == INT_LEAST64_MAX);
+verify_same_types (INT_LEAST64_MIN, (int_least64_t) 0 + 0);
+verify_same_types (INT_LEAST64_MAX, (int_least64_t) 0 + 0);
+#endif
+
+uint_least8_t d1[2] = { 17, UINT_LEAST8_MAX };
+verify (TYPE_MAXIMUM (uint_least8_t) == UINT_LEAST8_MAX);
+verify_same_types (UINT_LEAST8_MAX, (uint_least8_t) 0 + 0);
+
+uint_least16_t d2[2] = { 17, UINT_LEAST16_MAX };
+verify (TYPE_MAXIMUM (uint_least16_t) == UINT_LEAST16_MAX);
+verify_same_types (UINT_LEAST16_MAX, (uint_least16_t) 0 + 0);
+
+uint_least32_t d3[2] = { 17, UINT_LEAST32_MAX };
+verify (TYPE_MAXIMUM (uint_least32_t) == UINT_LEAST32_MAX);
+verify_same_types (UINT_LEAST32_MAX, (uint_least32_t) 0 + 0);
+
+#ifdef UINT_LEAST64_MAX
+uint_least64_t d4[2] = { 17, UINT_LEAST64_MAX };
+verify (TYPE_MAXIMUM (uint_least64_t) == UINT_LEAST64_MAX);
+verify_same_types (UINT_LEAST64_MAX, (uint_least64_t) 0 + 0);
+#endif
+
+#if INT_LEAST8_MIN && INT_LEAST8_MAX && INT_LEAST16_MIN && INT_LEAST16_MAX && INT_LEAST32_MIN && INT_LEAST32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+#if UINT_LEAST8_MAX && UINT_LEAST16_MAX && UINT_LEAST32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+/* 7.18.1.3. Fastest minimum-width integer types */
+/* 7.18.2.3. Limits of fastest minimum-width integer types */
+
+int_fast8_t e1[3] = { 17, INT_FAST8_MIN, INT_FAST8_MAX };
+verify (TYPE_MINIMUM (int_fast8_t) == INT_FAST8_MIN);
+verify (TYPE_MAXIMUM (int_fast8_t) == INT_FAST8_MAX);
+verify_same_types (INT_FAST8_MIN, (int_fast8_t) 0 + 0);
+verify_same_types (INT_FAST8_MAX, (int_fast8_t) 0 + 0);
+
+int_fast16_t e2[3] = { 17, INT_FAST16_MIN, INT_FAST16_MAX };
+verify (TYPE_MINIMUM (int_fast16_t) == INT_FAST16_MIN);
+verify (TYPE_MAXIMUM (int_fast16_t) == INT_FAST16_MAX);
+verify_same_types (INT_FAST16_MIN, (int_fast16_t) 0 + 0);
+verify_same_types (INT_FAST16_MAX, (int_fast16_t) 0 + 0);
+
+int_fast32_t e3[3] = { 17, INT_FAST32_MIN, INT_FAST32_MAX };
+verify (TYPE_MINIMUM (int_fast32_t) == INT_FAST32_MIN);
+verify (TYPE_MAXIMUM (int_fast32_t) == INT_FAST32_MAX);
+verify_same_types (INT_FAST32_MIN, (int_fast32_t) 0 + 0);
+verify_same_types (INT_FAST32_MAX, (int_fast32_t) 0 + 0);
+
+#ifdef INT_FAST64_MAX
+int_fast64_t e4[3] = { 17, INT_FAST64_MIN, INT_FAST64_MAX };
+verify (TYPE_MINIMUM (int_fast64_t) == INT_FAST64_MIN);
+verify (TYPE_MAXIMUM (int_fast64_t) == INT_FAST64_MAX);
+verify_same_types (INT_FAST64_MIN, (int_fast64_t) 0 + 0);
+verify_same_types (INT_FAST64_MAX, (int_fast64_t) 0 + 0);
+#endif
+
+uint_fast8_t f1[2] = { 17, UINT_FAST8_MAX };
+verify (TYPE_MAXIMUM (uint_fast8_t) == UINT_FAST8_MAX);
+verify_same_types (UINT_FAST8_MAX, (uint_fast8_t) 0 + 0);
+
+uint_fast16_t f2[2] = { 17, UINT_FAST16_MAX };
+verify (TYPE_MAXIMUM (uint_fast16_t) == UINT_FAST16_MAX);
+verify_same_types (UINT_FAST16_MAX, (uint_fast16_t) 0 + 0);
+
+uint_fast32_t f3[2] = { 17, UINT_FAST32_MAX };
+verify (TYPE_MAXIMUM (uint_fast32_t) == UINT_FAST32_MAX);
+verify_same_types (UINT_FAST32_MAX, (uint_fast32_t) 0 + 0);
+
+#ifdef UINT_FAST64_MAX
+uint_fast64_t f4[2] = { 17, UINT_FAST64_MAX };
+verify (TYPE_MAXIMUM (uint_fast64_t) == UINT_FAST64_MAX);
+verify_same_types (UINT_FAST64_MAX, (uint_fast64_t) 0 + 0);
+#endif
+
+#if INT_FAST8_MIN && INT_FAST8_MAX && INT_FAST16_MIN && INT_FAST16_MAX && INT_FAST32_MIN && INT_FAST32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+#if UINT_FAST8_MAX && UINT_FAST16_MAX && UINT_FAST32_MAX
+/* ok */
+#else
+err or;
+#endif
+
+/* 7.18.1.4. Integer types capable of holding object pointers */
+/* 7.18.2.4. Limits of integer types capable of holding object pointers */
+
+intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX };
+verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN);
+verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX);
+verify_same_types (INTPTR_MIN, (intptr_t) 0 + 0);
+verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0);
+
+uintptr_t h[2] = { 17, UINTPTR_MAX };
+verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX);
+verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0);
+
+#if INTPTR_MIN && INTPTR_MAX && UINTPTR_MAX
+/* ok */
+#else
+err or;
+#endif
+
+/* 7.18.1.5. Greatest-width integer types */
+/* 7.18.2.5. Limits of greatest-width integer types */
+
+intmax_t i[3] = { INTMAX_C (17), INTMAX_MIN, INTMAX_MAX };
+verify (TYPE_MINIMUM (intmax_t) == INTMAX_MIN);
+verify (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX);
+verify_same_types (INTMAX_MIN, (intmax_t) 0 + 0);
+verify_same_types (INTMAX_MAX, (intmax_t) 0 + 0);
+
+uintmax_t j[2] = { UINTMAX_C (17), UINTMAX_MAX };
+verify (TYPE_MAXIMUM (uintmax_t) == UINTMAX_MAX);
+verify_same_types (UINTMAX_MAX, (uintmax_t) 0 + 0);
+
+/* As of 2007, Sun C and HP-UX 10.20 cc don't support 'long long' constants in
+   the preprocessor.  */
+#if !(defined __SUNPRO_C || (defined __hpux && !defined __GNUC__))
+#if INTMAX_MIN && INTMAX_MAX && UINTMAX_MAX
+/* ok */
+#else
+err or;
+#endif
+#endif
+
+/* 7.18.3. Limits of other integer types */
+
+#include <stddef.h>
+
+verify (TYPE_MINIMUM (ptrdiff_t) == PTRDIFF_MIN);
+verify (TYPE_MAXIMUM (ptrdiff_t) == PTRDIFF_MAX);
+verify_same_types (PTRDIFF_MIN, (ptrdiff_t) 0 + 0);
+verify_same_types (PTRDIFF_MAX, (ptrdiff_t) 0 + 0);
+
+#if PTRDIFF_MIN && PTRDIFF_MAX
+/* ok */
+#else
+err or;
+#endif
+
+#include <signal.h>
+
+verify (TYPE_MINIMUM (sig_atomic_t) == SIG_ATOMIC_MIN);
+verify (TYPE_MAXIMUM (sig_atomic_t) == SIG_ATOMIC_MAX);
+verify_same_types (SIG_ATOMIC_MIN, (sig_atomic_t) 0 + 0);
+verify_same_types (SIG_ATOMIC_MAX, (sig_atomic_t) 0 + 0);
+
+#if SIG_ATOMIC_MIN != 17 && SIG_ATOMIC_MAX
+/* ok */
+#else
+err or;
+#endif
+
+verify (TYPE_MAXIMUM (size_t) == SIZE_MAX);
+verify_same_types (SIZE_MAX, (size_t) 0 + 0);
+
+#if SIZE_MAX
+/* ok */
+#else
+err or;
+#endif
+
+#if HAVE_WCHAR_T
+verify (TYPE_MINIMUM (wchar_t) == WCHAR_MIN);
+verify (TYPE_MAXIMUM (wchar_t) == WCHAR_MAX);
+verify_same_types (WCHAR_MIN, (wchar_t) 0 + 0);
+verify_same_types (WCHAR_MAX, (wchar_t) 0 + 0);
+
+# if WCHAR_MIN != 17 && WCHAR_MAX
+/* ok */
+# else
+err or;
+# endif
+#endif
+
+#if HAVE_WINT_T
+# include <wchar.h>
+
+verify (TYPE_MINIMUM (wint_t) == WINT_MIN);
+verify (TYPE_MAXIMUM (wint_t) == WINT_MAX);
+verify_same_types (WINT_MIN, (wint_t) 0 + 0);
+verify_same_types (WINT_MAX, (wint_t) 0 + 0);
+
+# if WINT_MIN != 17 && WINT_MAX
+/* ok */
+# else
+err or;
+# endif
+#endif
+
+/* 7.18.4. Macros for integer constants */
+
+verify (INT8_C (17) == 17);
+verify_same_types (INT8_C (17), (int_least8_t)0 + 0);
+verify (UINT8_C (17) == 17);
+verify_same_types (UINT8_C (17), (uint_least8_t)0 + 0);
+
+verify (INT16_C (17) == 17);
+verify_same_types (INT16_C (17), (int_least16_t)0 + 0);
+verify (UINT16_C (17) == 17);
+verify_same_types (UINT16_C (17), (uint_least16_t)0 + 0);
+
+verify (INT32_C (17) == 17);
+verify_same_types (INT32_C (17), (int_least32_t)0 + 0);
+verify (UINT32_C (17) == 17);
+verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0);
+
+#ifdef INT64_C
+verify (INT64_C (17) == 17);
+verify_same_types (INT64_C (17), (int_least64_t)0 + 0);
+#endif
+#ifdef UINT64_C
+verify (UINT64_C (17) == 17);
+verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0);
+#endif
+
+verify (INTMAX_C (17) == 17);
+verify_same_types (INTMAX_C (17), (intmax_t)0 + 0);
+verify (UINTMAX_C (17) == 17);
+verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0);
+
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-stdio.c b/gnulib/tests/test-stdio.c
new file mode 100644 (file)
index 0000000..7e7a206
--- /dev/null
@@ -0,0 +1,43 @@
+/* Test of <stdio.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "verify.h"
+
+/* Check that the various SEEK_* macros are defined.  */
+int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+/* Check that the types are all defined.  */
+fpos_t t1;
+off_t t2;
+size_t t3;
+ssize_t t4;
+va_list t5;
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-stdlib.c b/gnulib/tests/test-stdlib.c
new file mode 100644 (file)
index 0000000..210aab4
--- /dev/null
@@ -0,0 +1,54 @@
+/* Test of <stdlib.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "verify.h"
+
+/* Check that EXIT_SUCCESS is 0, per POSIX.  */
+static int exitcode = EXIT_SUCCESS;
+#if EXIT_SUCCESS
+"oops"
+#endif
+
+/* Check for GNU value (not guaranteed by POSIX, but is guaranteed by
+   gnulib).  */
+#if EXIT_FAILURE != 1
+"oops"
+#endif
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+#if GNULIB_TEST_SYSTEM_POSIX
+# include "test-sys_wait.h"
+#else
+# define test_sys_wait_macros() 0
+#endif
+
+int
+main (void)
+{
+  if (test_sys_wait_macros ())
+    return 1;
+
+  return exitcode;
+}
diff --git a/gnulib/tests/test-string.c b/gnulib/tests/test-string.c
new file mode 100644 (file)
index 0000000..54c49a9
--- /dev/null
@@ -0,0 +1,33 @@
+/* Test of <string.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "verify.h"
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-strnlen.c b/gnulib/tests/test-strnlen.c
new file mode 100644 (file)
index 0000000..18d6fcd
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010-2011 Free Software Foundation, Inc.
+ * Written by Eric Blake
+ *
+ * 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 <string.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (strnlen, size_t, (char const *, size_t));
+
+#include <stdlib.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+int
+main (void)
+{
+  size_t i;
+  char *page_boundary = (char *) zerosize_ptr ();
+  if (!page_boundary)
+    {
+      page_boundary = malloc (0x1000);
+      ASSERT (page_boundary);
+      page_boundary += 0x1000;
+    }
+
+  /* Basic behavior tests.  */
+  ASSERT (strnlen ("a", 0) == 0);
+  ASSERT (strnlen ("a", 1) == 1);
+  ASSERT (strnlen ("a", 2) == 1);
+  ASSERT (strnlen ("", 0x100000) == 0);
+
+  /* Memory fence and alignment testing.  */
+  for (i = 0; i < 512; i++)
+    {
+      char *start = page_boundary - i;
+      size_t j = i;
+      memset (start, 'x', i);
+      do
+        {
+          if (i != j)
+            {
+              start[j] = 0;
+              ASSERT (strnlen (start, i + j) == j);
+            }
+          ASSERT (strnlen (start, i) == j);
+          ASSERT (strnlen (start, j) == j);
+        }
+      while (j--);
+    }
+
+  return 0;
+}
diff --git a/gnulib/tests/test-strstr.c b/gnulib/tests/test-strstr.c
new file mode 100644 (file)
index 0000000..d6d6639
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2004, 2007-2011 Free Software Foundation, Inc.
+ * Written by Bruno Haible and Eric Blake
+ *
+ * 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 <string.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (strstr, char *, (char const *, char const *));
+
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "zerosize-ptr.h"
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+#if HAVE_DECL_ALARM
+  /* Declare failure if test takes too long, by using default abort
+     caused by SIGALRM.  All known platforms that lack alarm also have
+     a quadratic strstr, and the replacement strstr is known to not
+     take too long.  */
+  signal (SIGALRM, SIG_DFL);
+  alarm (50);
+#endif
+
+  {
+    const char input[] = "foo";
+    const char *result = strstr (input, "");
+    ASSERT (result == input);
+  }
+
+  {
+    const char input[] = "foo";
+    const char *result = strstr (input, "o");
+    ASSERT (result == input + 1);
+  }
+
+  {
+    /* On some platforms, the memchr() functions reads past the first
+       occurrence of the byte to be searched, leading to an out-of-bounds
+       read access for strstr().
+       See <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737>.
+       This is a bug in memchr(), see the Austin Group's clarification
+       <http://www.opengroup.org/austin/docs/austin_454.txt>.  */
+    const char *fix = "aBaaaaaaaaaaax";
+    char *page_boundary = (char *) zerosize_ptr ();
+    size_t len = strlen (fix) + 1;
+    char *input = page_boundary ? page_boundary - len : malloc (len);
+    const char *result;
+
+    strcpy (input, fix);
+    result = strstr (input, "B1x");
+    ASSERT (result == NULL);
+    if (!page_boundary)
+      free (input);
+  }
+
+  {
+    const char input[] = "ABC ABCDAB ABCDABCDABDE";
+    const char *result = strstr (input, "ABCDABD");
+    ASSERT (result == input + 15);
+  }
+
+  {
+    const char input[] = "ABC ABCDAB ABCDABCDABDE";
+    const char *result = strstr (input, "ABCDABE");
+    ASSERT (result == NULL);
+  }
+
+  {
+    const char input[] = "ABC ABCDAB ABCDABCDABDE";
+    const char *result = strstr (input, "ABCDABCD");
+    ASSERT (result == input + 11);
+  }
+
+  /* Check that a long periodic needle does not cause false positives.  */
+  {
+    const char input[] = "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+                         "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+                         "_C3_A7_20_EF_BF_BD";
+    const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
+    const char *result = strstr (input, need);
+    ASSERT (result == NULL);
+  }
+  {
+    const char input[] = "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+                         "_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD"
+                         "_C3_A7_20_EF_BF_BD_DA_B5_C2_A6_20"
+                         "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
+    const char need[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
+    const char *result = strstr (input, need);
+    ASSERT (result == input + 115);
+  }
+
+  /* Check that a very long haystack is handled quickly if the needle is
+     short and occurs near the beginning.  */
+  {
+    size_t repeat = 10000;
+    size_t m = 1000000;
+    const char *needle =
+      "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+      "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+    char *haystack = (char *) malloc (m + 1);
+    if (haystack != NULL)
+      {
+        memset (haystack, 'A', m);
+        haystack[0] = 'B';
+        haystack[m] = '\0';
+
+        for (; repeat > 0; repeat--)
+          {
+            ASSERT (strstr (haystack, needle) == haystack + 1);
+          }
+
+        free (haystack);
+      }
+  }
+
+  /* Check that a very long needle is discarded quickly if the haystack is
+     short.  */
+  {
+    size_t repeat = 10000;
+    size_t m = 1000000;
+    const char *haystack =
+      "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+      "ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB";
+    char *needle = (char *) malloc (m + 1);
+    if (needle != NULL)
+      {
+        memset (needle, 'A', m);
+        needle[m] = '\0';
+
+        for (; repeat > 0; repeat--)
+          {
+            ASSERT (strstr (haystack, needle) == NULL);
+          }
+
+        free (needle);
+      }
+  }
+
+  /* Check that the asymptotic worst-case complexity is not quadratic.  */
+  {
+    size_t m = 1000000;
+    char *haystack = (char *) malloc (2 * m + 2);
+    char *needle = (char *) malloc (m + 2);
+    if (haystack != NULL && needle != NULL)
+      {
+        const char *result;
+
+        memset (haystack, 'A', 2 * m);
+        haystack[2 * m] = 'B';
+        haystack[2 * m + 1] = '\0';
+
+        memset (needle, 'A', m);
+        needle[m] = 'B';
+        needle[m + 1] = '\0';
+
+        result = strstr (haystack, needle);
+        ASSERT (result == haystack + m);
+      }
+    free (needle);
+    free (haystack);
+  }
+
+  /* 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;
+}
diff --git a/gnulib/tests/test-symlink.c b/gnulib/tests/test-symlink.c
new file mode 100644 (file)
index 0000000..367e045
--- /dev/null
@@ -0,0 +1,47 @@
+/* Tests of symlink.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (symlink, int, (char const *, char const *));
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#include "ignore-value.h"
+#include "macros.h"
+
+#define BASE "test-symlink.t"
+
+#include "test-symlink.h"
+
+int
+main (void)
+{
+  /* Remove any leftovers from a previous partial run.  */
+  ignore_value (system ("rm -rf " BASE "*"));
+
+  return test_symlink (symlink, true);
+}
diff --git a/gnulib/tests/test-symlink.h b/gnulib/tests/test-symlink.h
new file mode 100644 (file)
index 0000000..4d93929
--- /dev/null
@@ -0,0 +1,95 @@
+/* Tests of symlink.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+/* This file is designed to test both symlink(a,b) and
+   symlinkat(a,AT_FDCWD,b).  FUNC is the function to test.  Assumes
+   that BASE and ASSERT are already defined, and that appropriate
+   headers are already included.  If PRINT, warn before skipping
+   symlink tests with status 77.  */
+
+static int
+test_symlink (int (*func) (char const *, char const *), bool print)
+{
+  if (func ("nowhere", BASE "link1"))
+    {
+      if (print)
+        fputs ("skipping test: symlinks not supported on this file system\n",
+               stderr);
+      return 77;
+    }
+
+  /* Some systems allow the creation of 0-length symlinks as a synonym
+     for "."; but most reject it.  */
+  {
+    int status;
+    errno = 0;
+    status = func ("", BASE "link2");
+    if (status == -1)
+      ASSERT (errno == ENOENT || errno == EINVAL);
+    else
+      {
+        ASSERT (status == 0);
+        ASSERT (unlink (BASE "link2") == 0);
+      }
+  }
+
+  /* Sanity checks of failures.  */
+  errno = 0;
+  ASSERT (func ("nowhere", "") == -1);
+  ASSERT (errno == ENOENT);
+  errno = 0;
+  ASSERT (func ("nowhere", ".") == -1);
+  ASSERT (errno == EEXIST || errno == EINVAL);
+  errno = 0;
+  ASSERT (func ("somewhere", BASE "link1") == -1);
+  ASSERT (errno == EEXIST);
+  errno = 0;
+  ASSERT (func ("nowhere", BASE "link2/") == -1);
+  ASSERT (errno == ENOTDIR || errno == ENOENT);
+  ASSERT (mkdir (BASE "dir", 0700) == 0);
+  errno = 0;
+  ASSERT (func ("nowhere", BASE "dir") == -1);
+  ASSERT (errno == EEXIST);
+  errno = 0;
+  ASSERT (func ("nowhere", BASE "dir/") == -1);
+  ASSERT (errno == EEXIST || errno == EINVAL);
+  ASSERT (close (creat (BASE "file", 0600)) == 0);
+  errno = 0;
+  ASSERT (func ("nowhere", BASE "file") == -1);
+  ASSERT (errno == EEXIST);
+  errno = 0;
+  ASSERT (func ("nowhere", BASE "file/") == -1);
+  ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT);
+
+  /* Trailing slash must always be rejected.  */
+  ASSERT (unlink (BASE "link1") == 0);
+  ASSERT (func (BASE "link2", BASE "link1") == 0);
+  errno = 0;
+  ASSERT (func (BASE "nowhere", BASE "link1/") == -1);
+  ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT);
+  errno = 0;
+  ASSERT (unlink (BASE "link2") == -1);
+  ASSERT (errno == ENOENT);
+
+  /* Cleanup.  */
+  ASSERT (rmdir (BASE "dir") == 0);
+  ASSERT (unlink (BASE "file") == 0);
+  ASSERT (unlink (BASE "link1") == 0);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-sys_stat.c b/gnulib/tests/test-sys_stat.c
new file mode 100644 (file)
index 0000000..cd07d86
--- /dev/null
@@ -0,0 +1,288 @@
+/* Test of <sys/stat.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 <sys/stat.h>
+
+#include "verify.h"
+
+/* Check the existence of some macros.  */
+int a[] =
+  {
+    S_IFMT,
+    S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG,
+#ifdef S_IFLNK /* missing on mingw and djgpp */
+    S_IFLNK,
+#endif
+#ifdef S_IFSOCK /* missing on mingw and djgpp */
+    S_IFSOCK,
+#endif
+    S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR,
+    S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP,
+    S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH,
+    S_ISUID, S_ISGID, S_ISVTX,
+    S_ISBLK (S_IFREG),
+    S_ISCHR (S_IFREG),
+    S_ISDIR (S_IFREG),
+    S_ISFIFO (S_IFREG),
+    S_ISREG (S_IFREG),
+    S_ISLNK (S_IFREG),
+    S_ISSOCK (S_IFREG),
+    S_ISDOOR (S_IFREG),
+    S_ISMPB (S_IFREG),
+    S_ISNAM (S_IFREG),
+    S_ISNWK (S_IFREG),
+    S_ISPORT (S_IFREG),
+    S_ISCTG (S_IFREG),
+    S_ISOFD (S_IFREG),
+    S_ISOFL (S_IFREG),
+    S_ISWHT (S_IFREG)
+  };
+
+/* Sanity checks.  */
+
+verify (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR));
+verify (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP));
+verify (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH));
+
+verify (S_ISBLK (S_IFBLK));
+verify (!S_ISBLK (S_IFCHR));
+verify (!S_ISBLK (S_IFDIR));
+verify (!S_ISBLK (S_IFIFO));
+verify (!S_ISBLK (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISBLK (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISBLK (S_IFSOCK));
+#endif
+
+verify (!S_ISCHR (S_IFBLK));
+verify (S_ISCHR (S_IFCHR));
+verify (!S_ISCHR (S_IFDIR));
+verify (!S_ISCHR (S_IFIFO));
+verify (!S_ISCHR (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISCHR (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISCHR (S_IFSOCK));
+#endif
+
+verify (!S_ISDIR (S_IFBLK));
+verify (!S_ISDIR (S_IFCHR));
+verify (S_ISDIR (S_IFDIR));
+verify (!S_ISDIR (S_IFIFO));
+verify (!S_ISDIR (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISDIR (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISDIR (S_IFSOCK));
+#endif
+
+verify (!S_ISFIFO (S_IFBLK));
+verify (!S_ISFIFO (S_IFCHR));
+verify (!S_ISFIFO (S_IFDIR));
+verify (S_ISFIFO (S_IFIFO));
+verify (!S_ISFIFO (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISFIFO (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISFIFO (S_IFSOCK));
+#endif
+
+verify (!S_ISREG (S_IFBLK));
+verify (!S_ISREG (S_IFCHR));
+verify (!S_ISREG (S_IFDIR));
+verify (!S_ISREG (S_IFIFO));
+verify (S_ISREG (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISREG (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISREG (S_IFSOCK));
+#endif
+
+verify (!S_ISLNK (S_IFBLK));
+verify (!S_ISLNK (S_IFCHR));
+verify (!S_ISLNK (S_IFDIR));
+verify (!S_ISLNK (S_IFIFO));
+verify (!S_ISLNK (S_IFREG));
+#ifdef S_IFLNK
+verify (S_ISLNK (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISLNK (S_IFSOCK));
+#endif
+
+verify (!S_ISSOCK (S_IFBLK));
+verify (!S_ISSOCK (S_IFCHR));
+verify (!S_ISSOCK (S_IFDIR));
+verify (!S_ISSOCK (S_IFIFO));
+verify (!S_ISSOCK (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISSOCK (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (S_ISSOCK (S_IFSOCK));
+#endif
+
+verify (!S_ISDOOR (S_IFBLK));
+verify (!S_ISDOOR (S_IFCHR));
+verify (!S_ISDOOR (S_IFDIR));
+verify (!S_ISDOOR (S_IFIFO));
+verify (!S_ISDOOR (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISDOOR (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISDOOR (S_IFSOCK));
+#endif
+
+verify (!S_ISMPB (S_IFBLK));
+verify (!S_ISMPB (S_IFCHR));
+verify (!S_ISMPB (S_IFDIR));
+verify (!S_ISMPB (S_IFIFO));
+verify (!S_ISMPB (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISMPB (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISMPB (S_IFSOCK));
+#endif
+
+verify (!S_ISNAM (S_IFBLK));
+verify (!S_ISNAM (S_IFCHR));
+verify (!S_ISNAM (S_IFDIR));
+verify (!S_ISNAM (S_IFIFO));
+verify (!S_ISNAM (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISNAM (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISNAM (S_IFSOCK));
+#endif
+
+verify (!S_ISNWK (S_IFBLK));
+verify (!S_ISNWK (S_IFCHR));
+verify (!S_ISNWK (S_IFDIR));
+verify (!S_ISNWK (S_IFIFO));
+verify (!S_ISNWK (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISNWK (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISNWK (S_IFSOCK));
+#endif
+
+verify (!S_ISPORT (S_IFBLK));
+verify (!S_ISPORT (S_IFCHR));
+verify (!S_ISPORT (S_IFDIR));
+verify (!S_ISPORT (S_IFIFO));
+verify (!S_ISPORT (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISPORT (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISPORT (S_IFSOCK));
+#endif
+
+verify (!S_ISCTG (S_IFBLK));
+verify (!S_ISCTG (S_IFCHR));
+verify (!S_ISCTG (S_IFDIR));
+verify (!S_ISCTG (S_IFIFO));
+verify (!S_ISCTG (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISCTG (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISCTG (S_IFSOCK));
+#endif
+
+verify (!S_ISOFD (S_IFBLK));
+verify (!S_ISOFD (S_IFCHR));
+verify (!S_ISOFD (S_IFDIR));
+verify (!S_ISOFD (S_IFIFO));
+verify (!S_ISOFD (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISOFD (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISOFD (S_IFSOCK));
+#endif
+
+verify (!S_ISOFL (S_IFBLK));
+verify (!S_ISOFL (S_IFCHR));
+verify (!S_ISOFL (S_IFDIR));
+verify (!S_ISOFL (S_IFIFO));
+verify (!S_ISOFL (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISOFL (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISOFL (S_IFSOCK));
+#endif
+
+verify (!S_ISWHT (S_IFBLK));
+verify (!S_ISWHT (S_IFCHR));
+verify (!S_ISWHT (S_IFDIR));
+verify (!S_ISWHT (S_IFIFO));
+verify (!S_ISWHT (S_IFREG));
+#ifdef S_IFLNK
+verify (!S_ISWHT (S_IFLNK));
+#endif
+#ifdef S_IFSOCK
+verify (!S_ISWHT (S_IFSOCK));
+#endif
+
+/* POSIX 2008 requires traditional encoding of permission constants.  */
+verify (S_IRWXU == 00700);
+verify (S_IRUSR == 00400);
+verify (S_IWUSR == 00200);
+verify (S_IXUSR == 00100);
+verify (S_IRWXG == 00070);
+verify (S_IRGRP == 00040);
+verify (S_IWGRP == 00020);
+verify (S_IXGRP == 00010);
+verify (S_IRWXO == 00007);
+verify (S_IROTH == 00004);
+verify (S_IWOTH == 00002);
+verify (S_IXOTH == 00001);
+verify (S_ISUID == 04000);
+verify (S_ISGID == 02000);
+verify (S_ISVTX == 01000);
+
+#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000)           \
+     || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000)      \
+     || UTIME_NOW == UTIME_OMIT)
+invalid UTIME macros
+#endif
+
+/* Check the existence of some types.  */
+nlink_t t1;
+
+struct timespec t2;
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-sys_wait.c b/gnulib/tests/test-sys_wait.c
new file mode 100644 (file)
index 0000000..dce89c6
--- /dev/null
@@ -0,0 +1,47 @@
+/* Test of <sys/wait.h> substitute.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <sys/wait.h>
+
+/* Check for existence of required types.  */
+static pid_t a;
+
+#include "test-sys_wait.h"
+
+int
+main (void)
+{
+  if (test_sys_wait_macros ())
+    return 1;
+
+  switch (0)
+    {
+#if 0
+  /* Gnulib doesn't guarantee these, yet.  */
+    case WCONTINUED:
+    case WEXITED:
+    case WNOWAIT:
+    case WSTOPPED:
+#endif
+      break;
+    }
+
+  return a ? 1 : 0;
+}
diff --git a/gnulib/tests/test-sys_wait.h b/gnulib/tests/test-sys_wait.h
new file mode 100644 (file)
index 0000000..3c9b322
--- /dev/null
@@ -0,0 +1,53 @@
+/* Test of macros shared between <sys/wait.h> and <stdlib.h>.
+   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 Eric Blake <ebb9@byu.net>, 2010.  */
+
+static int
+test_sys_wait_macros (void)
+{
+  /* Check subset of <sys/wait.h> macros that must be visible here.
+     Note that some of these macros are only portable when operating
+     on an lvalue.  */
+  int i;
+  for (i = 0; i < 0x8000; i = (i ? i << 1 : 1))
+    {
+      /* POSIX requires that for all valid process statuses, that
+         exactly one of these three macros is true.  But not all
+         possible 16-bit values map to valid process status.
+         Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits
+         to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80
+         or 0x8000 to flag that core was also dumped.  Since we don't
+         know which byte is WIFEXITED, we skip the both possible bits
+         that can signal core dump.  */
+      if (i == 0x80)
+        continue;
+      if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1)
+        return 1;
+    }
+  i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i);
+
+  switch (i)
+    {
+#if 0
+  /* Gnulib doesn't guarantee these, yet.  */
+    case WNOHANG:
+    case WUNTRACED:
+#endif
+      break;
+    }
+  return 0;
+}
diff --git a/gnulib/tests/test-time.c b/gnulib/tests/test-time.c
new file mode 100644 (file)
index 0000000..0c78f36
--- /dev/null
@@ -0,0 +1,35 @@
+/* Test of <time.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <time.h>
+
+#include "verify.h"
+
+struct timespec a;
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-unistd.c b/gnulib/tests/test-unistd.c
new file mode 100644 (file)
index 0000000..be1ae06
--- /dev/null
@@ -0,0 +1,56 @@
+/* Test of <unistd.h> substitute.
+   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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "verify.h"
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+/* Check that the various SEEK_* macros are defined.  */
+int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
+
+/* Check that the various *_FILENO macros are defined.  */
+#if ! (defined STDIN_FILENO                                     \
+       && (STDIN_FILENO + STDOUT_FILENO + STDERR_FILENO == 3))
+missing or broken *_FILENO macros
+#endif
+
+/* Check that the types are all defined.  */
+size_t t1;
+ssize_t t2;
+#ifdef TODO /* Not implemented in gnulib yet */
+uid_t t3;
+gid_t t4;
+#endif
+off_t t5;
+pid_t t6;
+#ifdef TODO
+useconds_t t7;
+intptr_t t8;
+#endif
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-unsetenv.c b/gnulib/tests/test-unsetenv.c
new file mode 100644 (file)
index 0000000..9c9443b
--- /dev/null
@@ -0,0 +1,61 @@
+/* Tests of unsetenv.
+   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 Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (unsetenv, int, (char const *));
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  char entry[] = "b=2";
+
+  /* Test removal when multiple entries present.  */
+  ASSERT (putenv ((char *) "a=1") == 0);
+  ASSERT (putenv (entry) == 0);
+  entry[0] = 'a'; /* Unspecified what getenv("a") would be at this point.  */
+  ASSERT (unsetenv ("a") == 0); /* Both entries will be removed.  */
+  ASSERT (getenv ("a") == NULL);
+  ASSERT (unsetenv ("a") == 0);
+
+  /* Required to fail with EINVAL.  */
+  errno = 0;
+  ASSERT (unsetenv ("") == -1);
+  ASSERT (errno == EINVAL);
+  errno = 0;
+  ASSERT (unsetenv ("a=b") == -1);
+  ASSERT (errno == EINVAL);
+#if 0
+  /* glibc and gnulib's implementation guarantee this, but POSIX no
+     longer requires it: http://austingroupbugs.net/view.php?id=185  */
+  errno = 0;
+  ASSERT (unsetenv (NULL) == -1);
+  ASSERT (errno == EINVAL);
+#endif
+
+  return 0;
+}
diff --git a/gnulib/tests/test-vasnprintf.c b/gnulib/tests/test-vasnprintf.c
new file mode 100644 (file)
index 0000000..6b2a0ff
--- /dev/null
@@ -0,0 +1,94 @@
+/* Test of vasnprintf() and asnprintf() functions.
+   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 "vasnprintf.h"
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+static void
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
+{
+  char buf[8];
+  int size;
+
+  for (size = 0; size <= 8; size++)
+    {
+      size_t length = size;
+      char *result = my_asnprintf (NULL, &length, "%d", 12345);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "12345") == 0);
+      ASSERT (length == 5);
+      free (result);
+    }
+
+  for (size = 0; size <= 8; size++)
+    {
+      size_t length;
+      char *result;
+
+      memcpy (buf, "DEADBEEF", 8);
+      length = size;
+      result = my_asnprintf (buf, &length, "%d", 12345);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "12345") == 0);
+      ASSERT (length == 5);
+      if (size < 6)
+        ASSERT (result != buf);
+      ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+      if (result != buf)
+        free (result);
+    }
+}
+
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+  va_list args;
+  char *ret;
+
+  va_start (args, format);
+  ret = vasnprintf (resultbuf, lengthp, format, args);
+  va_end (args);
+  return ret;
+}
+
+static void
+test_vasnprintf ()
+{
+  test_function (my_asnprintf);
+}
+
+static void
+test_asnprintf ()
+{
+  test_function (asnprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+  test_vasnprintf ();
+  test_asnprintf ();
+  return 0;
+}
diff --git a/gnulib/tests/test-vasprintf.c b/gnulib/tests/test-vasprintf.c
new file mode 100644 (file)
index 0000000..6882d18
--- /dev/null
@@ -0,0 +1,103 @@
+/* Test of vasprintf() and asprintf() functions.
+   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 <stdio.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (asprintf, int, (char **, char const *, ...));
+SIGNATURE_CHECK (vasprintf, int, (char **, char const *, va_list));
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+static int
+my_asprintf (char **result, const char *format, ...)
+{
+  va_list args;
+  int ret;
+
+  va_start (args, format);
+  ret = vasprintf (result, format, args);
+  va_end (args);
+  return ret;
+}
+
+static void
+test_vasprintf ()
+{
+  int repeat;
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = my_asprintf (&result, "%d", 12345);
+      ASSERT (retval == 5);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "12345") == 0);
+      free (result);
+    }
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = my_asprintf (&result, "%08lx", 12345UL);
+      ASSERT (retval == 8);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "00003039") == 0);
+      free (result);
+    }
+}
+
+static void
+test_asprintf ()
+{
+  int repeat;
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = asprintf (&result, "%d", 12345);
+      ASSERT (retval == 5);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "12345") == 0);
+      free (result);
+    }
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = asprintf (&result, "%08lx", 12345UL);
+      ASSERT (retval == 8);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "00003039") == 0);
+      free (result);
+    }
+}
+
+int
+main (int argc, char *argv[])
+{
+  test_vasprintf ();
+  test_asprintf ();
+  return 0;
+}
diff --git a/gnulib/tests/test-verify.c b/gnulib/tests/test-verify.c
new file mode 100644 (file)
index 0000000..512c021
--- /dev/null
@@ -0,0 +1,69 @@
+/* Test the "verify" module.
+
+   Copyright (C) 2005, 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.  */
+
+#include <config.h>
+
+#include "verify.h"
+
+#ifndef EXP_FAIL
+# define EXP_FAIL 0
+#endif
+
+int x;
+enum { a, b, c };
+
+#if EXP_FAIL == 1
+verify (x >= 0);                  /* should give ERROR: non-constant expression */
+#endif
+verify (c == 2);                  /* should be ok */
+#if EXP_FAIL == 2
+verify (1 + 1 == 3);              /* should give ERROR */
+#endif
+verify (1 == 1); verify (1 == 1); /* should be ok */
+
+enum
+{
+  item = verify_true (1 == 1) * 0 + 17 /* should be ok */
+};
+
+static int
+function (int n)
+{
+#if EXP_FAIL == 3
+  verify (n >= 0);                  /* should give ERROR: non-constant expression */
+#endif
+  verify (c == 2);                  /* should be ok */
+#if EXP_FAIL == 4
+  verify (1 + 1 == 3);              /* should give ERROR */
+#endif
+  verify (1 == 1); verify (1 == 1); /* should be ok */
+
+  if (n)
+    return ((void) verify_true (1 == 1), verify_true (1 == 1) + 7); /* should be ok */
+#if EXP_FAIL == 5
+  return (verify_true (1 == 2), 5); /* should give ERROR */
+#endif
+  return 0;
+}
+
+int
+main (void)
+{
+  return !(function (0) == 0 && function (1) == 8);
+}
diff --git a/gnulib/tests/test-verify.sh b/gnulib/tests/test-verify.sh
new file mode 100755 (executable)
index 0000000..3e76761
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"
+
+# We are not interested in triggering bugs in the compilers and tools
+# (such as gcc 4.3.1 on openSUSE 11.0).
+unset MALLOC_PERTURB_
+
+# Rather than figure out how to invoke the compiler with the right
+# include path ourselves, we let make do it:
+(cd "$initial_cwd_" && rm -f test-verify.o \
+    && $MAKE test-verify.o >/dev/null 2>&1) \
+  || skip_ "cannot compile error-free"
+
+# Now, prove that we encounter all expected compilation failures:
+: >out
+: >err
+for i in 1 2 3 4 5; do
+  (cd "$initial_cwd_"
+   rm -f test-verify.o
+   $MAKE CFLAGS=-DEXP_FAIL=$i test-verify.o) >>out 2>>err \
+  && { warn_ "compiler didn't detect verification failure $i"; fail=1; }
+done
+
+Exit $fail
diff --git a/gnulib/tests/test-wchar.c b/gnulib/tests/test-wchar.c
new file mode 100644 (file)
index 0000000..2d3bad7
--- /dev/null
@@ -0,0 +1,37 @@
+/* Test of <wchar.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 <wchar.h>
+
+#include "verify.h"
+
+/* Check that the types wchar_t and wint_t are defined.  */
+wchar_t a = 'c';
+wint_t b = 'x';
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/gnulib/tests/test-wcrtomb-w32-1.sh b/gnulib/tests/test-wcrtomb-w32-1.sh
new file mode 100755 (executable)
index 0000000..50c82f5
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1252 locale.
+./test-wcrtomb-w32${EXEEXT} French_France 1252
diff --git a/gnulib/tests/test-wcrtomb-w32-2.sh b/gnulib/tests/test-wcrtomb-w32-2.sh
new file mode 100755 (executable)
index 0000000..783c70c
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1256 locale.
+./test-wcrtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256
diff --git a/gnulib/tests/test-wcrtomb-w32-3.sh b/gnulib/tests/test-wcrtomb-w32-3.sh
new file mode 100755 (executable)
index 0000000..619ea64
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP932 locale.
+./test-wcrtomb-w32${EXEEXT} Japanese_Japan 932
diff --git a/gnulib/tests/test-wcrtomb-w32-4.sh b/gnulib/tests/test-wcrtomb-w32-4.sh
new file mode 100755 (executable)
index 0000000..67b6803
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP950 locale.
+./test-wcrtomb-w32${EXEEXT} Chinese_Taiwan 950
diff --git a/gnulib/tests/test-wcrtomb-w32-5.sh b/gnulib/tests/test-wcrtomb-w32-5.sh
new file mode 100755 (executable)
index 0000000..9841fa9
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP936 locale.
+./test-wcrtomb-w32${EXEEXT} Chinese_China 936
diff --git a/gnulib/tests/test-wcrtomb-w32.c b/gnulib/tests/test-wcrtomb-w32.c
new file mode 100644 (file)
index 0000000..0b09498
--- /dev/null
@@ -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
diff --git a/gnulib/tests/test-wcrtomb.c b/gnulib/tests/test-wcrtomb.c
new file mode 100644 (file)
index 0000000..a50817f
--- /dev/null
@@ -0,0 +1,162 @@
+/* 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/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (wcrtomb, size_t, (char *, wchar_t, mbstate_t *));
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+/* Check the multibyte character s[0..n-1].  */
+static void
+check_character (const char *s, size_t n)
+{
+  wchar_t wc;
+  char buf[64];
+  int iret;
+  size_t ret;
+
+  wc = (wchar_t) 0xBADFACE;
+  iret = mbtowc (&wc, s, n);
+  ASSERT (iret == n);
+
+  ret = wcrtomb (buf, wc, NULL);
+  ASSERT (ret == n);
+  ASSERT (memcmp (buf, s, n) == 0);
+
+  /* Test special calling convention, passing a NULL pointer.  */
+  ret = wcrtomb (NULL, wc, NULL);
+  ASSERT (ret == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  char buf[64];
+  size_t ret;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  /* Test NUL character.  */
+  {
+    buf[0] = 'x';
+    ret = wcrtomb (buf, 0, NULL);
+    ASSERT (ret == 1);
+    ASSERT (buf[0] == '\0');
+  }
+
+  /* Test single bytes.  */
+  {
+    int c;
+
+    for (c = 0; c < 0x100; c++)
+      switch (c)
+        {
+        case '\t': case '\v': case '\f':
+        case ' ': case '!': case '"': case '#': case '%':
+        case '&': case '\'': case '(': case ')': case '*':
+        case '+': case ',': case '-': case '.': case '/':
+        case '0': case '1': case '2': case '3': case '4':
+        case '5': case '6': case '7': case '8': case '9':
+        case ':': case ';': case '<': case '=': case '>':
+        case '?':
+        case 'A': case 'B': case 'C': case 'D': case 'E':
+        case 'F': case 'G': case 'H': case 'I': case 'J':
+        case 'K': case 'L': case 'M': case 'N': case 'O':
+        case 'P': case 'Q': case 'R': case 'S': case 'T':
+        case 'U': case 'V': case 'W': case 'X': case 'Y':
+        case 'Z':
+        case '[': case '\\': case ']': case '^': case '_':
+        case 'a': case 'b': case 'c': case 'd': case 'e':
+        case 'f': case 'g': case 'h': case 'i': case 'j':
+        case 'k': case 'l': case 'm': case 'n': case 'o':
+        case 'p': case 'q': case 'r': case 's': case 't':
+        case 'u': case 'v': case 'w': case 'x': case 'y':
+        case 'z': case '{': case '|': case '}': case '~':
+          /* c is in the ISO C "basic character set".  */
+          ret = wcrtomb (buf, btowc (c), NULL);
+          ASSERT (ret == 1);
+          ASSERT (buf[0] == (char) c);
+          break;
+        }
+  }
+
+  /* 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])
+      {
+      case '1':
+        /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+        {
+          const char input[] = "B\374\337er"; /* "Büßer" */
+
+          check_character (input + 1, 1);
+          check_character (input + 2, 1);
+        }
+        return 0;
+
+      case '2':
+        /* Locale encoding is UTF-8.  */
+        {
+          const char input[] = "B\303\274\303\237er"; /* "Büßer" */
+
+          check_character (input + 1, 2);
+          check_character (input + 3, 2);
+        }
+        return 0;
+
+      case '3':
+        /* Locale encoding is EUC-JP.  */
+        {
+          const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+
+          check_character (input + 1, 2);
+          check_character (input + 3, 2);
+          check_character (input + 5, 2);
+        }
+        return 0;
+
+      case '4':
+        /* Locale encoding is GB18030.  */
+        {
+          const char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+
+          check_character (input + 1, 2);
+          check_character (input + 3, 4);
+        }
+        return 0;
+      }
+
+  return 1;
+}
diff --git a/gnulib/tests/test-wcrtomb.sh b/gnulib/tests/test-wcrtomb.sh
new file mode 100755 (executable)
index 0000000..3eda8f3
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR \
+  ./test-wcrtomb${EXEEXT} 1 \
+  || exit 1
+fi
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+  LC_ALL=$LOCALE_FR_UTF8 \
+  ./test-wcrtomb${EXEEXT} 2 \
+  || exit 1
+fi
+
+# Test whether a specific EUC-JP locale is installed.
+: ${LOCALE_JA=ja_JP}
+if test $LOCALE_JA != none; then
+  LC_ALL=$LOCALE_JA \
+  ./test-wcrtomb${EXEEXT} 3 \
+  || exit 1
+fi
+
+# Test whether a specific GB18030 locale is installed.
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+if test $LOCALE_ZH_CN != none; then
+  LC_ALL=$LOCALE_ZH_CN \
+  ./test-wcrtomb${EXEEXT} 4 \
+  || exit 1
+fi
+
+exit 0
diff --git a/gnulib/tests/test-wctype-h.c b/gnulib/tests/test-wctype-h.c
new file mode 100644 (file)
index 0000000..aed3b77
--- /dev/null
@@ -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;
+}
diff --git a/gnulib/tests/unsetenv.c b/gnulib/tests/unsetenv.c
new file mode 100644 (file)
index 0000000..215bba0
--- /dev/null
@@ -0,0 +1,120 @@
+/* Copyright (C) 1992, 1995-2002, 2005-2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software: you can redistribute it and/or modify
+   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>
+
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the name == NULL test below.  */
+#define _GL_ARG_NONNULL(params)
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <errno.h>
+#if !_LIBC
+# define __set_errno(ev) ((errno) = (ev))
+#endif
+
+#include <string.h>
+#include <unistd.h>
+
+#if !_LIBC
+# define __environ      environ
+#endif
+
+#if _LIBC
+/* This lock protects against simultaneous modifications of `environ'.  */
+# include <bits/libc-lock.h>
+__libc_lock_define_initialized (static, envlock)
+# define LOCK   __libc_lock_lock (envlock)
+# define UNLOCK __libc_lock_unlock (envlock)
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+/* In the GNU C library we must keep the namespace clean.  */
+#ifdef _LIBC
+# define unsetenv __unsetenv
+#endif
+
+#if _LIBC || !HAVE_UNSETENV
+
+int
+unsetenv (const char *name)
+{
+  size_t len;
+  char **ep;
+
+  if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  len = strlen (name);
+
+  LOCK;
+
+  ep = __environ;
+  while (*ep != NULL)
+    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+      {
+        /* Found it.  Remove this pointer by moving later ones back.  */
+        char **dp = ep;
+
+        do
+          dp[0] = dp[1];
+        while (*dp++);
+        /* Continue the loop in case NAME appears again.  */
+      }
+    else
+      ++ep;
+
+  UNLOCK;
+
+  return 0;
+}
+
+#ifdef _LIBC
+# undef unsetenv
+weak_alias (__unsetenv, unsetenv)
+#endif
+
+#else /* HAVE_UNSETENV */
+
+# undef unsetenv
+
+/* Call the underlying unsetenv, in case there is hidden bookkeeping
+   that needs updating beyond just modifying environ.  */
+int
+rpl_unsetenv (const char *name)
+{
+  int result = 0;
+  if (!name || !*name || strchr (name, '='))
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  while (getenv (name))
+# if !VOID_UNSETENV
+    result =
+# endif
+      unsetenv (name);
+  return result;
+}
+
+#endif /* HAVE_UNSETENV */
diff --git a/gnulib/tests/wctob.c b/gnulib/tests/wctob.c
new file mode 100644 (file)
index 0000000..cc26afc
--- /dev/null
@@ -0,0 +1,38 @@
+/* Convert wide character to unibyte character.
+   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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+wctob (wint_t wc)
+{
+  char buf[64];
+
+  if (!(MB_CUR_MAX <= sizeof (buf)))
+    abort ();
+  /* Handle the case where WEOF is a value that does not fit in a wchar_t.  */
+  if (wc == (wchar_t)wc)
+    if (wctomb (buf, (wchar_t)wc) == 1)
+      return (unsigned char) buf[0];
+  return EOF;
+}
diff --git a/gnulib/tests/wctomb-impl.h b/gnulib/tests/wctomb-impl.h
new file mode 100644 (file)
index 0000000..4e95de6
--- /dev/null
@@ -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;
+    }
+}
diff --git a/gnulib/tests/wctomb.c b/gnulib/tests/wctomb.c
new file mode 100644 (file)
index 0000000..889a3c6
--- /dev/null
@@ -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"
diff --git a/gnulib/tests/zerosize-ptr.h b/gnulib/tests/zerosize-ptr.h
new file mode 100644 (file)
index 0000000..beeb3da
--- /dev/null
@@ -0,0 +1,68 @@
+/* Return a pointer to a zero-size object in memory.
+   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/>.  */
+
+/* ISO C 99 does not allow memcmp(), memchr() etc. to be invoked with a NULL
+   argument.  Therefore this file produces a non-NULL pointer which cannot
+   be dereferenced, if possible.  */
+
+#include <stdlib.h>
+
+/* Test whether mmap() and mprotect() are available.
+   We don't use HAVE_MMAP, because AC_FUNC_MMAP would not define it on HP-UX.
+   HAVE_MPROTECT is not enough, because mingw does not have mmap() but has an
+   mprotect() function in libgcc.a.  */
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+# include <fcntl.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/mman.h>
+/* Define MAP_FILE when it isn't otherwise.  */
+# ifndef MAP_FILE
+#  define MAP_FILE 0
+# endif
+#endif
+
+/* Return a pointer to a zero-size object in memory (that is, actually, a
+   pointer to a page boundary where the previous page is readable and writable
+   and the next page is neither readable not writable), if possible.
+   Return NULL otherwise.  */
+
+static void *
+zerosize_ptr (void)
+{
+/* Use mmap and mprotect when they exist.  Don't test HAVE_MMAP, because it is
+   not defined on HP-UX 11 (since it does not support MAP_FIXED).  */
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+# if HAVE_MAP_ANONYMOUS
+  const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
+  const int fd = -1;
+# else /* !HAVE_MAP_ANONYMOUS */
+  const int flags = MAP_FILE | MAP_PRIVATE;
+  int fd = open ("/dev/zero", O_RDONLY, 0666);
+  if (fd >= 0)
+# endif
+    {
+      int pagesize = getpagesize ();
+      char *two_pages =
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
+      if (two_pages != (char *)(-1)
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        return two_pages + pagesize;
+    }
+#endif
+  return NULL;
+}
diff --git a/lenses/access.aug b/lenses/access.aug
new file mode 100644 (file)
index 0000000..2f85492
--- /dev/null
@@ -0,0 +1,110 @@
+(* 
+Module: Access
+  Parses /etc/security/access.conf
+
+Author: Lorenzo Dalrio <lorenzo.dalrio@gmail.com>
+
+About: Reference
+  Some examples of valid entries can be found in access.conf or "man access.conf"
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+  * Add a rule to permit login of all users from local sources (tty's, X, cron)
+  > set /files/etc/security/access.conf[0] +
+  > set /files/etc/security/access.conf[0]/user ALL
+  > set /files/etc/security/access.conf[0]/origin LOCAL
+
+About: Configuration files
+  This lens applies to /etc/security/access.conf. See <filter>.
+*)
+module Access =
+  autoload xfm
+
+(* Group: Comments and empty lines *)
+(* Variable: comment *)
+let comment   = Util.comment
+(* Variable: empty line *)
+let empty     = Util.empty
+(* Group: Useful primitives *)
+(* Variable: colon
+ *  this is the standard field separator " : "
+ *)
+let colon     = Sep.space . Sep.colon . Sep.space
+
+
+(************************************************************************
+ * Group:                     ENTRY LINE
+  *************************************************************************)
+(* View: access
+ * Allow (+) or deny (-) access
+ *)
+let access    = label "access" . store /[+-]/
+
+(* View: user_re
+ * Regex for user/netgroup fields
+ *)
+let user_re = Rx.word - /[Ee][Xx][Cc][Ee][Pp][Tt]/
+
+(* View: user
+ * user can be a username or a group
+ *)
+let user      = [ label "user" . store user_re ]
+
+(* View: netgroup
+ * Format is @NETGROUP[@@NISDOMAIN]
+ *)
+let netgroup =
+    [ label "netgroup" . Util.del_str "@" . store user_re
+      . [ label "nisdomain" . Util.del_str "@@" . store Rx.word ]? ]
+
+(* View: user_list
+ * A list of users or netgroups to apply the rule to
+ *)
+let user_list = Build.opt_list (user|netgroup) Sep.space
+
+(* View: origin_list
+ * origin_list can be a single ipaddr/originname/domain/fqdn or a list of those values
+ *)
+let origin_list = 
+   let origin_re = Rx.no_spaces - /[Ee][Xx][Cc][Ee][Pp][Tt]/
+   in Build.opt_list [ label "origin" . store origin_re ] Sep.space
+
+(* View: except
+ * The except operator makes it possible to write very compact rules. 
+ *)
+let except (lns:lens) = [ label "except" . Sep.space
+                        . del /[Ee][Xx][Cc][Ee][Pp][Tt]/ "EXCEPT"
+                        . Sep.space . lns ]
+
+(* View: entry 
+ * A valid entry line
+ * Definition:
+ *   > entry ::= access ':' user ':' origin_list
+ *)
+let entry     = [ access . colon
+                . user_list
+                . (except user_list)?
+                . colon
+                . origin_list
+                . (except origin_list)?
+                . Util.eol ]
+
+(************************************************************************
+ * Group:                        LENS & FILTER
+  *************************************************************************)
+(* View: lns
+    The access.conf lens, any amount of
+      * <empty> lines
+      * <comments>
+      * <entry>
+*)
+let lns       = (comment|empty|entry) *
+
+(* Variable: filter *)
+let filter    = incl "/etc/security/access.conf"
+
+let xfm       = transform lns filter
diff --git a/lenses/aliases.aug b/lenses/aliases.aug
new file mode 100644 (file)
index 0000000..44f83b9
--- /dev/null
@@ -0,0 +1,27 @@
+(* Parse mail aliases in /etc/aliases *)
+module Aliases =
+   autoload xfm
+
+   let word = /[^, \t\n]+/
+   let name = /([^ \t\n#:@]+|"[^"\n]*")/ (* " make emacs calm down *)
+
+   let colon = del /:[ \t]+/ ":\t"
+   let eol   = Util.eol
+
+   let comment = Util.comment
+   let empty   = Util.empty
+
+   let comma = del /,[ \t]*(\n[ \t]+)?/ ", "
+   let value_list = Build.opt_list ([ label "value" . store word]) comma
+   let alias = [ seq "alias" .
+                    [ label "name" . store name ] . colon .
+                    value_list
+                ] . eol
+
+  let lns = (comment | empty | alias)*
+
+  let xfm = transform lns (incl "/etc/aliases")
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/approx.aug b/lenses/approx.aug
new file mode 100644 (file)
index 0000000..1fed101
--- /dev/null
@@ -0,0 +1,20 @@
+module Approx =
+  autoload xfm
+
+  let eol = Util.eol
+  let indent = Util.indent
+  let key_re = /\$?[A-Za-z0-9_.-]+/
+  let sep = /[ \t]+/
+  let value_re = /[^ \t\n](.*[^ \t\n])?/
+
+  let comment = [ indent . label "#comment" . del /[#;][ \t]*/ "# "
+        . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
+
+  let empty = Util.empty
+
+  let kv = [ indent . key key_re . del sep " " . store value_re . eol ]
+
+  let lns = (empty | comment | kv) *
+
+  let filter = incl "/etc/approx/approx.conf"
+  let xfm = transform lns filter
diff --git a/lenses/aptpreferences.aug b/lenses/aptpreferences.aug
new file mode 100644 (file)
index 0000000..7bb8daf
--- /dev/null
@@ -0,0 +1,48 @@
+(* Apt/preferences module for Augeas          *)
+(* Author: Raphael Pinson <raphink@gmail.com> *)
+
+module AptPreferences =
+   autoload xfm
+
+   (* Define useful primitives *)
+   let colon        = del /:[ \t]*/ ": "
+   let eol          = del /[ \t]*\n/ "\n"
+   let value_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+   let value_to_spc = store /[^, \t\n]+/
+   let comma = del /,[ \t]*/ ", "
+   let equal = Util.del_str "="
+   let spc   = Util.del_ws_spc
+
+   (* Define empty *)
+   let empty = [ del /[ \t]*\n/ "\n" ]
+
+   (* Define record *)
+
+   let simple_entry (kw:string) = [ key kw . colon . value_to_eol . eol ]
+
+   let key_value (kw:string)    = [ key kw . equal . value_to_spc ]
+   let pin_keys = key_value "a"
+                | key_value "c"
+                | key_value "l"
+                | key_value "o"
+                | key_value "v"
+
+   let pin_options = store /(origin|release)/ . spc . pin_keys . ( comma . pin_keys )*
+   let version_pin = store /version/ . [ label "version" . spc . store /[^ \t\n]+/ ]
+
+   let pin = [ key "Pin" . colon . (pin_options | version_pin) . eol ]
+
+   let entries = simple_entry "Explanation"
+               | simple_entry "Package"
+               | simple_entry "Pin-Priority"
+               | pin
+
+   let record = [ seq "record" . entries+ ]
+
+   (* Define lens *)
+   let lns = (eol* . ( record . eol+ )* . record . eol* ) | eol
+
+   let filter = incl "/etc/apt/preferences"
+              . Util.stdexcl
+
+   let xfm = transform lns filter
diff --git a/lenses/aptsources.aug b/lenses/aptsources.aug
new file mode 100644 (file)
index 0000000..c3b03ef
--- /dev/null
@@ -0,0 +1,32 @@
+(* Parsing /etc/apt/sources.list *)
+
+module Aptsources =
+  autoload xfm
+
+  let sep_ws = del /[ \t]+/ " "
+
+  let eol = Util.del_str "\n"
+
+  let comment = Util.comment
+  let empty = Util.empty
+
+  let word = /[^# \n\t]+/
+
+  let record = [ Util.indent . seq "source" . [ label "type" . store word ] . sep_ws .
+                                [ label "uri"  . store word ] . sep_ws .
+                                [ label "distribution" . store word ]  .
+                                [ label "component" . sep_ws . store word ]* .
+                                del /[ \t]*(#.*)?/ ""
+                 . eol ]
+
+  let lns = ( comment | empty | record ) *
+
+  let filter = (incl "/etc/apt/sources.list")
+      . (incl "/etc/apt/sources.list.d/*")
+      . Util.stdexcl
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/bbhosts.aug b/lenses/bbhosts.aug
new file mode 100644 (file)
index 0000000..de30815
--- /dev/null
@@ -0,0 +1,89 @@
+(* BB-hosts module for Augeas                 *)
+(* Author: Raphael Pinson <raphink@gmail.com> *)
+(*                                            *)
+(* Supported :                                *)
+(*                                            *)
+(* Todo :                                     *)
+(*                                            *)
+
+module BBhosts =
+    autoload xfm
+
+    (* Define useful shortcuts *)
+
+    let eol = Util.eol
+    let eol_no_spc = Util.del_str "\n"
+    let sep_spc = Sep.space
+    let word  = store /[^|;# \n\t]+/
+    let value_to_eol = store /[^ \t][^\n]+/
+    let ip    = store Rx.ipv4
+    let url   = store /https?:[^;,# \n\t]+/
+
+    (* Define comments and empty lines *)
+    let comment = Util.comment
+    let empty   = Util.empty
+
+
+    (* Define host *)
+    let host_ip   = [ label "ip" . ip ]
+    let host_fqdn = [ label "fqdn" . sep_spc . word ]
+
+    let host_test_url  = [ label "url" . sep_spc . url ]
+    let host_test_cont (kw:string) = [ sep_spc . store /!?/ . key kw .
+                             (Util.del_str ";" .
+                                [ label "url" . word ] .
+                               (Util.del_str ";" . [ label "keyword" . word ])?
+                            )?
+                            ]
+
+
+    let host_test_flag (kw:string) = [ sep_spc . store /!?/ . key kw ]
+
+    let host_test = host_test_cont "cont"
+                  | host_test_cont "contInsecure"
+                  | host_test_cont "dns"
+                 | host_test_flag "noping"
+                 | host_test_flag "noconn"
+                 | host_test_flag "ssh"
+                 | host_test_flag "smtp"
+                 | host_test_flag "pop3"
+                 | host_test_flag "imap2"
+                 | host_test_flag "telnet"
+                 | host_test_flag "BBDISPLAY"
+                 | host_test_flag "BBNET"
+                 | host_test_flag "BBPAGER"
+                  | host_test_url
+
+
+    let host_opts = [ label "probes" . sep_spc . Util.del_str "#" . host_test* ]
+
+    let host = [ label "host" . host_ip . host_fqdn . host_opts . eol ]
+
+    (* Define group-compress and group-only *)
+    let group_compress = [ key "group-compress" . sep_spc . value_to_eol . eol_no_spc .
+                  ( comment | empty | host)*
+                 ]
+
+    let group_only_col  = [ label "col" . word ]
+    let group_only_cols = sep_spc . group_only_col . ( Util.del_str "|" . group_only_col )*
+    let group_only      = [ key "group-only" . group_only_cols . sep_spc . value_to_eol . eol_no_spc .
+                  ( comment | empty | host)*
+                 ]
+
+
+    (* Define page *)
+    let page_title = [ label "title" . sep_spc . value_to_eol . eol_no_spc ]
+    let page = [ key "page" . sep_spc . word . page_title .
+                  ( comment | empty | host )* . ( group_compress | group_only )*
+                 ]
+
+
+    (* Define lens *)
+
+    let lns = (comment | empty)* . page*
+
+    let filter = incl "/etc/bb/bb-hosts"
+               . Util.stdexcl
+
+    let xfm = transform lns filter
+
diff --git a/lenses/build.aug b/lenses/build.aug
new file mode 100644 (file)
index 0000000..693a611
--- /dev/null
@@ -0,0 +1,141 @@
+(*
+Module: Build
+   Generic functions to build lenses
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Reference
+  This file provides generic functions to build Augeas lenses
+*)
+
+
+module Build =
+
+let eol = Util.eol
+
+(************************************************************************
+ * Group:               GENERIC CONSTRUCTIONS
+ ************************************************************************)
+
+(************************************************************************
+ * View: brackets
+ *   Put a lens inside brackets
+ *
+ *   Parameters:
+ *     l:lens   - the left bracket lens
+ *     r: lens  - the right bracket lens
+ *     lns:lens - the lens to put inside brackets
+ ************************************************************************)
+let brackets (l:lens) (r:lens) (lns:lens) = l . lns . r
+
+
+(************************************************************************
+ * Group:             LIST CONSTRUCTIONS
+ ************************************************************************)
+
+(************************************************************************
+ * View: list
+ *   Build a list of identical lenses separated with a given separator
+ *   (at least 2 elements)
+ *
+ *   Parameters:
+ *     lns:lens - the lens to repeat in the list
+ *     sep:lens - the separator lens, which can be taken from the <Sep> module
+ ************************************************************************)
+let list (lns:lens) (sep:lens) = lns . ( sep . lns )+
+
+
+(************************************************************************
+ * View: opt_list
+ *   Same as <list>, but there might be only one element in the list
+ *
+ *   Parameters:
+ *     lns:lens - the lens to repeat in the list
+ *     sep:lens - the separator lens, which can be taken from the <Sep> module
+ ************************************************************************)
+let opt_list (lns:lens) (sep:lens) = lns . ( sep . lns )*
+
+
+(************************************************************************
+ * Group:                   LABEL OPERATIONS
+ ************************************************************************)
+
+(************************************************************************
+ * View: xchg
+ *   Replace a pattern with a different label in the tree,
+ *   thus emulating a key but allowing to replace the keyword
+ *   with a different value than matched
+ *
+ *   Parameters:
+ *     m:regexp - the pattern to match
+ *     d:string - the default value when a node in created
+ *     l:string - the label to apply for such nodes
+ ************************************************************************)
+let xchg (m:regexp) (d:string) (l:string) = del m d . label l
+
+(************************************************************************
+ * View: xchgs
+ *   Same as <xchg>, but the pattern is the default string
+ *
+ *   Parameters:
+ *     m:string - the string to replace, also used as default
+ *     l:string - the label to apply for such nodes
+ ************************************************************************)
+let xchgs (m:string) (l:string) = xchg m m l
+
+
+(************************************************************************
+ * Group:                   SUBNODE CONSTRUCTIONS
+ ************************************************************************)
+
+(************************************************************************
+ * View: key_value_line
+ *   A subnode with a keyword, a separator and a storing lens,
+ *   and an end of line
+ *
+ *   Parameters:
+ *     kw:regexp - the pattern to match as key
+ *     sep:lens  - the separator lens, which can be taken from the <Sep> module
+ *     sto:lens  - the storing lens
+ ************************************************************************)
+let key_value_line (kw:regexp) (sep:lens) (sto:lens) =
+                                   [ key kw . sep . sto . eol ]
+
+(************************************************************************
+ * View: key_value_line_comment
+ *   Same as <key_value_line>, but allows to have a comment in the end of a line
+ *   and an end of line
+ *
+ *   Parameters:
+ *     kw:regexp    - the pattern to match as key
+ *     sep:lens     - the separator lens, which can be taken from the <Sep> module
+ *     sto:lens     - the storing lens
+ *     comment:lens - the comment lens, which can be taken from <Util>
+ ************************************************************************)
+let key_value_line_comment (kw:regexp) (sep:lens) (sto:lens) (comment:lens) =
+                                   [ key kw . sep . sto . (eol|comment) ]
+
+(************************************************************************
+ * View: key_value
+ *   Same as <key_value_line>, but does not end with an end of line
+ *
+ *   Parameters:
+ *     kw:regexp - the pattern to match as key
+ *     sep:lens  - the separator lens, which can be taken from the <Sep> module
+ *     sto:lens  - the storing lens
+ ************************************************************************)
+let key_value (kw: regexp) (sep:lens) (sto:lens) =
+                                   [ key kw . sep . sto ]
+
+(************************************************************************
+ * View: flag
+ *   A simple flag subnode, consisting of a single key
+ *
+ *   Parameters:
+ *     kw:regexp - the pattern to match as key
+ ************************************************************************)
+let flag (kw:regexp) = [ key kw ]
+
diff --git a/lenses/cgconfig.aug b/lenses/cgconfig.aug
new file mode 100644 (file)
index 0000000..d2f8a97
--- /dev/null
@@ -0,0 +1,119 @@
+(*
+Module: cgconfig
+    Parses /etc/cgconfig.conf
+
+Author:
+    Ivana Hutarova Varekova <varekova@redhat.com>
+    Raphael Pinson          <raphink@gmail.com>
+
+About: Licence
+    This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+    Sample usage of this lens in augtool
+        * print all mounted cgroups
+           print /files/etc/cgconfig.conf/mount
+
+About: Configuration files
+    This lens applies to /etc/cgconfig.conf. See <filter>.
+ *)
+
+module Cgconfig =
+   autoload xfm
+
+   let indent  = Util.indent
+   let eol     = Util.eol
+   let comment = Util.comment
+   let empty   = Util.empty
+
+   let id        = /[a-zA-Z0-9_\-\/\.]+/
+   let name      = /[^#= \n\t{}\/]+/
+   let cont_name = /(cpuacct|cpu|devices|ns|cpuset|memory|freezer|net_cls)/
+   let role_name = /(admin|task)/
+   let id_name   = /(uid|gid)/
+   let address   = /[^#; \n\t{}]+/
+
+   let lbracket = del /[ \t\n]*\{/ " {"
+   let rbracket = del /[ \t]*\}/ "}"
+   let eq       = indent . Util.del_str "=" . indent
+
+(******************************************
+ * Function to deal with abc=def; entries
+ ******************************************)
+
+   let key_value (key_rx:regexp) (val_rx:regexp) =
+     [ indent . key key_rx . eq . store val_rx
+         . indent . Util.del_str ";" ]
+
+   (* Function to deal with bracketted entries *)
+   let brack_entry_base (lnsa:lens) (lnsb:lens) =
+     [ indent . lnsa . lbracket . lnsb . rbracket ]
+
+   let brack_entry_key (kw:regexp) (lns:lens) =
+     let lnsa = key kw in
+     brack_entry_base lnsa lns
+
+   let brack_entry (kw:regexp) (lns:lens) =
+     let full_lns = (lns | comment | empty)* in
+     brack_entry_key kw full_lns
+
+(******************************************
+ * control groups
+ ******************************************)
+
+   let permission_setting = key_value id_name address
+
+(* task setting *)
+   let t_info =  brack_entry "task" permission_setting
+
+(* admin setting *)
+   let a_info =  brack_entry "admin" permission_setting
+
+(* permissions setting *)
+   let perm_info =
+     let ce = (comment|empty)* in
+     let perm_info_lns = ce .
+       ((t_info . ce . (a_info . ce)?)
+       |(a_info . ce . (t_info . ce)?))? in
+     brack_entry_key "perm" perm_info_lns
+
+   let variable_setting = key_value name address
+
+(* controllers setting *)
+   let controller_info =
+     let lnsa = label "controller" . store cont_name in
+     let lnsb = ( variable_setting | comment | empty ) * in
+     brack_entry_base lnsa lnsb
+
+(* group { ... } *)
+   let group_data  =
+     let lnsa = key "group" . indent . store id in
+     let lnsb = ( perm_info | controller_info | comment | empty )* in
+     brack_entry_base lnsa lnsb
+
+
+(*************************************************
+ * mount point
+ *************************************************)
+
+(* controller = mount_point; *)
+   let mount_point = key_value name address
+
+(* mount { .... } *)
+   let mount_data = brack_entry "mount" mount_point
+
+
+(****************************************************
+ * namespace
+ ****************************************************)
+
+(* controller = cgroup; *)
+   let namespace_instance = key_value name address
+
+
+(* namespace { .... } *)
+   let namespace = brack_entry "namespace" namespace_instance
+
+   let lns =  ( comment | empty | mount_data | group_data | namespace )*
+
+   let xfm = transform lns (incl "/etc/cgconfig.conf")
diff --git a/lenses/cgrules.aug b/lenses/cgrules.aug
new file mode 100644 (file)
index 0000000..e763bed
--- /dev/null
@@ -0,0 +1,85 @@
+(*
+Module: cgrules
+    Parses /etc/cgrules.conf
+
+Author:
+    Raphael Pinson          <raphink@gmail.com>
+    Ivana Hutarova Varekova <varekova@redhat.com>
+
+About: Licence
+    This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+    Sample usage of this lens in augtool:
+
+About: Configuration files
+   This lens applies to /etc/cgconfig.conf. See <filter>.
+ *)
+
+module Cgrules =
+   autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Separators *)
+(* Variable: ws *)
+   let ws = del /[ \t]+/ " "
+
+(* Group: Comments and empty lines *)
+(* Variable: eol *)
+   let eol     = Util.eol
+
+(* Variable: comment *)
+   let comment = Util.comment
+
+(* Variable: empty *)
+   let empty   = Util.empty
+
+(* Group: Generic primitive definitions *)
+(* Variable: name *)
+   let name       = /[^@%\# \t\n][^ \t\n]*/
+(* Variable: ctrl_key *)
+   let ctrl_key   = /[^ \t\n\/]+/
+(* Variable: ctrl_value *)
+   let ctrl_value = /[^ \t\n]+/
+
+(************************************************************************
+ * Group:                 CONTROLLER
+ *************************************************************************)
+
+(* Variable: controller *)
+let controller =  ws . [ key ctrl_key . ws . store ctrl_value ]
+
+let more_controller = Util.del_str "%" . controller . eol
+
+(************************************************************************
+ * Group:                 RECORDS
+ *************************************************************************)
+
+let generic_record (lbl:string) (lns:lens) =
+                  [ label lbl . lns
+                  . controller . eol
+                  . more_controller* ]
+
+(* Variable: user_record *)
+let user_record = generic_record "user" (store name)
+
+(* Variable: group_record *)
+let group_record = generic_record "group" (Util.del_str "@" . store name)
+
+(************************************************************************
+ * Group:                        LENS & FILTER
+ *************************************************************************)
+
+(* View: lns
+     The main lens, any amount of
+       * <empty> lines
+       * <comment>
+       * <user_record>
+       * <group_record>
+*)
+let lns =  (  empty | comment | user_record | group_record )*
+
+let xfm = transform lns (incl "/etc/cgrules.conf")
diff --git a/lenses/cobblermodules.aug b/lenses/cobblermodules.aug
new file mode 100644 (file)
index 0000000..21bf6f9
--- /dev/null
@@ -0,0 +1,17 @@
+
+module CobblerModules =
+  autoload xfm
+
+let comment    = IniFile.comment "#" "#"
+let sep        = IniFile.sep "=" "="
+
+let entry    = IniFile.entry IniFile.entry_re sep comment
+
+let title   = IniFile.indented_title IniFile.record_re
+let record  = IniFile.record title entry
+
+let lns     = IniFile.lns record comment
+
+let filter = (incl "/etc/cobbler/modules.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/cobblersettings.aug b/lenses/cobblersettings.aug
new file mode 100644 (file)
index 0000000..66edbca
--- /dev/null
@@ -0,0 +1,72 @@
+(*
+    Parse the /etc/cobbler/settings file  which is in
+    YAML 1.0 format.
+
+    The lens can handle the following contructs
+    * key: value
+    * key: "value"
+    * key: 'value'
+    * key: [value1, value2]
+    * key:
+       - value1
+       - value2
+    * key:
+       key2: value1
+       key3: value2
+
+    Author: Bryan Kearney
+
+    About: License
+      This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+module CobblerSettings =
+    autoload xfm
+
+    let kw = /[a-zA-Z0-9_]+/
+    (* TODO Would be better if this stripped off the "" and '' chracters *)
+    let kv = /([^]['", \t\n#:@-]+|"[^"\n]*"|'[^'\n]*')/
+
+    let lbr = del /\[/ "["
+    let rbr = del /\]/ "]"
+    let colon = del /[ \t]*:[ \t]*/ ": "
+    let dash = del /-[ \t]*/ "- "
+    (* let comma = del /,[ \t]*(\n[ \t]+)?/ ", " *)
+    let comma = del /[ \t]*,[ \t]*/ ", "
+
+    let eol_only = del /\n/ "\n"
+
+    (* TODO Would be better to make items a child of a document *)
+    let docmarker = /-{3}/
+
+    let eol   = Util.eol
+    let comment = Util.comment
+    let empty   = Util.empty
+    let indent = del /[ \t]+/ "\t"
+    let ws = del /[ \t]*/ " "
+
+    let value_list = Build.opt_list [label "item" . store kv] comma
+    let setting = [key kw . colon . store kv] . eol
+    let simple_setting_suffix = store kv . eol
+    let setting_list_suffix =  [label "sequence" . lbr . ws . (value_list . ws)? . rbr ] . eol
+    let indendented_setting_list_suffix =  eol_only . (indent . setting)+
+    let indented_list_suffix =  [label "list" . eol_only . ([ label "value" . indent . dash  . store kv] . eol)+]
+
+    (* Break out setting because of a current bug in augeas *)
+    let nested_setting = [key kw . colon . (
+                                            (* simple_setting_suffix | *)
+                                            setting_list_suffix |
+                                            indendented_setting_list_suffix |
+                                            indented_list_suffix
+                                            )
+                        ]
+
+    let document = [label "---" . store docmarker] . eol
+
+    let lns = (document | comment | empty | setting | nested_setting )*
+
+    let xfm = transform lns (incl "/etc/cobbler/settings")
+
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/cron.aug b/lenses/cron.aug
new file mode 100644 (file)
index 0000000..6332278
--- /dev/null
@@ -0,0 +1,144 @@
+(*
+Module: Cron
+ Parses /etc/cron.d/*, /etc/crontab
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+ This lens tries to keep as close as possible to `man 5 crontab` where
+ possible.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Get the entry that launches '/usr/bin/ls'
+      >  match '/files/etc/crontab/entry[. = "/usr/bin/ls"]'
+
+About: Configuration files
+  This lens applies to /etc/cron.d/* and /etc/crontab. See <filter>.
+*)
+
+module Cron =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Generic primitives *)
+
+(* Variable: eol *)
+let eol     = Util.eol
+
+(* Variable: indent *)
+let indent  = Util.indent
+
+(* Variable: comment *)
+let comment = Util.comment
+
+(* Variable: empty *)
+let empty   = Util.empty
+
+(* Variable: num *)
+let num        = /[0-9\*][0-9\/,-\*]*/
+
+(* Variable: alpha *)
+let alpha      = /[A-Za-z]{3}/
+
+(* Variable: alphanum *)
+let alphanum   = num | alpha
+
+
+(* Group: Separators *)
+
+(* Variable: sep_spc *)
+let sep_spc = Util.del_ws_spc
+
+(* Variable: sep_eq *)
+let sep_eq  = Util.del_str "="
+
+
+
+(************************************************************************
+ * Group:                       ENTRIES
+ *************************************************************************)
+
+
+(************************************************************************
+ * View: shellvar
+ *   A shell variable in crontab
+ *************************************************************************)
+
+let shellvar =
+  let key_re = Shellvars.key_re - "entry" in
+  [ key key_re . sep_eq . Shellvars.simple_value . eol ]
+
+
+(* View: minute *)
+let minute     = [ label "minute"       . store num ]
+
+(* View: hour *)
+let hour       = [ label "hour"         . store num ]
+
+(* View: dayofmonth *)
+let dayofmonth = [ label "dayofmonth" . store num ]
+
+(* View: month *)
+let month      = [ label "month"        . store alphanum ]
+
+(* View: dayofweek *)
+let dayofweek  = [ label "dayofweek"  . store alphanum ]
+
+
+(* View: user *)
+let user       = [ label "user"         . store Rx.word ]
+
+
+(************************************************************************
+ * View: time
+ *   Time in the format "minute hour dayofmonth month dayofweek"
+ *************************************************************************)
+let time        = [ label "time" .
+                  minute . sep_spc . hour  . sep_spc . dayofmonth
+                         . sep_spc . month . sep_spc . dayofweek ]
+
+(* Variable: the valid values for schedules *)
+let schedule_re = "reboot" | "yearly" | "annually" | "monthly"
+                | "weekly" | "daily"  | "midnight" | "hourly"
+
+(************************************************************************
+ * View: schedule
+ *   Time in the format "@keyword"
+ *************************************************************************)
+let schedule    = [ label "schedule" . Util.del_str "@"
+                   . store schedule_re ]
+
+
+(************************************************************************
+ * View: entry
+ *   A crontab entry
+ *************************************************************************)
+
+let entry       = [ label "entry" . indent
+                   . ( time | schedule )
+                   . sep_spc . user
+                   . sep_spc . store Rx.space_in . eol ]
+
+
+(*
+ * View: lns
+ *   The cron lens
+ *)
+let lns = ( empty | comment | shellvar | entry )*
+
+
+(* Variable: filter *)
+let filter =
+  incl "/etc/cron.d/*" .
+  incl "/etc/crontab" .
+  Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/crypttab.aug b/lenses/crypttab.aug
new file mode 100644 (file)
index 0000000..19b1163
--- /dev/null
@@ -0,0 +1,103 @@
+(* -*- coding: utf-8 -*-
+Module: Crypttab
+  Parses /etc/crypttab from the cryptsetup package.
+
+Author: Frédéric Lespez <frederic.lespez@free.fr>
+
+About: Reference
+  This lens tries to keep as close as possible to `man crypttab` where possible.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Create a new entry for an encrypted block devices
+      > ins 01 after /files/etc/crypttab/*[last()]
+      > set /files/etc/crypttab/01/target crypt_sda2
+      > set /files/etc/crypttab/01/device /dev/sda2
+      > set /files/etc/crypttab/01/password /dev/random
+      > set /files/etc/crypttab/01/opt swap
+    * Print the entry applying to the "/dev/sda2" device
+      > print /files/etc/crypttab/01
+    * Remove the entry applying to the "/dev/sda2" device
+      > rm /files/etc/crypttab/*[device="/dev/sda2"]
+
+About: Configuration files
+  This lens applies to /etc/crypttab. See <filter>.
+*)
+
+module Crypttab =
+  autoload xfm
+
+  (************************************************************************
+   * Group:                 USEFUL PRIMITIVES
+   *************************************************************************)
+
+  (* Group: Separators *)
+
+  (* Variable: sep_tab *)
+  let sep_tab = Sep.tab
+
+  (* Variable: comma *)
+  let comma   = Sep.comma
+
+  (* Group: Generic primitives *)
+
+  (* Variable: eol *)
+  let eol     = Util.eol
+
+  (* Variable: comment *)
+  let comment = Util.comment
+
+  (* Variable: empty *)
+  let empty   = Util.empty
+
+  (* Variable: word *)
+  let word    = Rx.word
+
+   (* Variable: optval *)
+  let optval  = /[A-Za-z0-9_.:-]+/
+
+  (* Variable: target *)
+  let target  = Rx.device_name
+
+  (* Variable: fspath *)
+  let fspath  = Rx.fspath
+
+  (************************************************************************
+   * Group:                       ENTRIES
+   *************************************************************************)
+
+  (************************************************************************
+   * View: comma_sep_list
+   *   A comma separated list of options (opt=value or opt)
+   *************************************************************************)
+  let comma_sep_list (l:string) =
+    let value = [ label "value" . Util.del_str "=" . store optval ] in
+      let lns = [ label l . store word . value? ] in
+         Build.opt_list lns comma
+
+  (************************************************************************
+   * View: record
+   *   A crypttab record
+   *************************************************************************)
+
+  let record = [ seq "entry" .
+                   [ label "target" . store target ] . sep_tab .
+                   [ label "device" . store fspath ] .
+                   (sep_tab . [ label "password" . store fspath ] .
+                    ( sep_tab . comma_sep_list "opt")? )?
+                 . eol ]
+
+  (*
+   * View: lns
+   *   The crypttab lens
+   *)
+  let lns = ( empty | comment | record ) *
+
+  (* Variable: filter *)
+  let filter = (incl "/etc/crypttab")
+
+  let xfm = transform lns filter
diff --git a/lenses/darkice.aug b/lenses/darkice.aug
new file mode 100644 (file)
index 0000000..d267599
--- /dev/null
@@ -0,0 +1,30 @@
+(* Darkice module for Augeas
+   Author: Free Ekanayaka <free@64studio.com>
+
+   Reference: man 5 darkice.cfg
+*)
+
+
+module Darkice =
+  autoload xfm
+
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+
+let entry_re = ( /[A-Za-z0-9][A-Za-z0-9\._-]*/ )
+let entry = IniFile.entry entry_re sep comment
+
+let title   = IniFile.title_label "target" IniFile.record_label_re
+let record  = IniFile.record title entry
+
+let lns    = IniFile.lns record comment
+
+let filter = (incl "/etc/darkice.cfg")
+           . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/debctrl.aug b/lenses/debctrl.aug
new file mode 100644 (file)
index 0000000..f073059
--- /dev/null
@@ -0,0 +1,135 @@
+(*
+Module: debctrl
+  Parses ./debian/control
+
+Author:
+        Dominique Dumont domi.dumont@free.fr or dominique.dumont@hp.com
+
+About: Reference
+  http://augeas.net/page/Create_a_lens_from_bottom_to_top
+  http://www.debian.org/doc/debian-policy/ch-controlfields.html
+
+About: License
+  This file is licensed under the LGPL v2+.
+
+About: Lens Usage
+  Since control file is not a system configuration file, you will have
+  to use augtool -r option to point to 'debian' directory.
+
+  Run augtool:
+  $ augtool -r debian
+
+  Sample usage of this lens in augtool:
+
+    * Get the value stored in control file
+      > print /files/control
+      ...
+
+  Saving your file:
+
+      > save
+
+
+*)
+
+module Debctrl =
+  autoload xfm
+
+let eol = Util.eol
+let del_ws_spc = del /[\t ]*/ " "
+let hardeol = del /\n/ "\n"
+let del_opt_ws = del /[\t ]*/ ""
+let colon = del /:[ \t]*/ ": "
+
+let simple_entry (k:regexp) =
+   let value =  store /[^ \t][^\n]+/ in
+   [ key k . colon . value . hardeol ]
+
+let cont_line = del /\n[ \t]+/ "\n "
+let comma     = del  /,[ \t]*/  ", "
+
+let sep_comma_with_nl = del /[ \t\n]*,[ \t\n]*/ ",\n "
+ (*= del_opt_ws . cont_line* . comma . cont_line**)
+
+let email =  store ( /([A-Za-z]+ )+<[^\n>]+>/ |  /[^\n,\t<> ]+/ )
+
+let multi_line_array_entry (k:regexp) (v:lens) =
+    [ key k . colon . [ counter "array" . seq "array" .  v ] .
+      [ seq "array" . sep_comma_with_nl . v ]* . hardeol ]
+
+(* dependency stuff *)
+
+let version_depends =
+    [ label "version"
+     . [   del / *\( */ " ( " . label "relation" . store /[<>=]+/ ]
+     . [   del_ws_spc . label "number" . store /[a-zA-Z0-9_\.\-]+/
+         . del / *\)/ " )" ]
+    ]
+
+let arch_depends =
+    [ label "arch"
+    . [  del / *\[ */ " [ " . label "prefix" . store /!?/ ]
+    . [ label "name" . store /[a-zA-Z0-9_\.\-]+/ . del / *\]/ " ]" ] ]
+
+
+let package_depends
+  =  [ key ( /[a-zA-Z0-9_\-]+/ | /\$\{[a-zA-Z0-9:]+\}/ )
+        . ( version_depends | arch_depends ) * ]
+
+
+let dependency = [ label "or" . package_depends ]
+               . [ label "or" . del / *\| */ " | "
+                   . package_depends ] *
+
+let dependency_list (field:regexp) =
+    [ key field . colon . [ label "and" .  dependency ]
+      . [ label "and" . sep_comma_with_nl . dependency ]*
+      . eol ]
+
+(* source package *)
+let uploaders  =
+    multi_line_array_entry /Uploaders/ email
+
+let simple_src_keyword = "Source" | "Section" | "Priority"
+    | "Standards\-Version" | "Homepage" | /Vcs\-Svn/ | /Vcs\-Browser/
+    | "Maintainer"
+let depend_src_keywords = /Build\-Depends/ | /Build\-Depends\-Indep/
+
+let src_entries = (   simple_entry simple_src_keyword
+                    | uploaders
+                    | dependency_list depend_src_keywords ) *
+
+
+(* package paragraph *)
+
+let simple_bin_keyword = "Package" | "Architecture" |  "Section"
+    | "Priority" | "Essential" | "Homepage"
+
+let simple_bin_entry = simple_entry simple_bin_keyword
+
+let multi_line_entry (k:string) =
+     let line = /.*[^ \t\n].*/ in
+      [ label k .  del / / " " .  store line . hardeol ] *
+
+
+let description
+  = [ key "Description" . colon
+     . [ label "summary" . store /[a-zA-Z][^\n]+/ . hardeol ]
+     . multi_line_entry "text" ]
+
+
+(* binary package *)
+let simple_bin_keywords = "Package" | "Architecture"
+let depend_bin_keywords = "Depends" | "Recommends" | "Suggests"
+
+let bin_entries = ( simple_entry simple_bin_keywords
+                  | dependency_list depend_bin_keywords
+                  ) + . description
+
+(* The whole stuff *)
+let lns =  [ label "srcpkg" .  src_entries  ]
+        .  [ label "binpkg" . hardeol+ . bin_entries ]+
+        . eol*
+
+(* lens must be used with AUG_ROOT set to debian package source directory *)
+let xfm = transform lns (incl "/control")
diff --git a/lenses/device_map.aug b/lenses/device_map.aug
new file mode 100644 (file)
index 0000000..090edd5
--- /dev/null
@@ -0,0 +1,28 @@
+(* Parsing grub's device.map *)
+
+module Device_map =
+  autoload xfm
+
+  let sep_tab = Sep.tab
+  let eol     = Util.eol
+  let fspath  = Rx.fspath
+  let del_str = Util.del_str
+
+  let comment = Util.comment
+  let empty   = Util.empty
+
+  let dev_name = /(h|f|c)d[0-9]+(,[0-9a-zA-Z]+){0,2}/
+  let dev_hex  = /0x[0-9a-fA-F]+/
+  let dev_dec  = /[0-9]+/
+
+  let device = del_str "(" . key ( dev_name | dev_hex | dev_dec ) .  del_str ")"
+
+  let map = [ device . sep_tab . store fspath . eol ]
+
+  let lns = ( empty | comment | map ) *
+
+  let xfm = transform lns (incl "/boot/grub/device.map")
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/dhclient.aug b/lenses/dhclient.aug
new file mode 100644 (file)
index 0000000..bccacf2
--- /dev/null
@@ -0,0 +1,169 @@
+(* Intefraces module for Augeas
+   Author: Free Ekanayaka <free@64studio.com>
+
+   Reference: man dhclient.conf
+   The only difference with the reference syntax is that this lens assumes
+   that statements end with a new line, while the reference syntax allows
+   new statements to be started right after the trailing ";" of the
+   previous statement. This should not be a problem in real-life
+   configuration files as statements get usually splitted across several
+   lines, rather than merged in a single one.
+
+   TODO: support the "default", "supersede", "append" and "prepend"
+   statements
+*)
+
+module Dhclient =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol               = Util.eol
+let comment           = Util.comment
+let comment_or_eol    = Util.comment_or_eol
+let empty             = Util.empty
+
+(* Define separators *)
+let sep_spc           = del /[ \t\n]+/ " "
+let sep_scl           = del /[ \t]*;/ ";"
+let sep_obr           = del /[ \t\n]*\{\n]*/ " {\n"
+let sep_cbr           = del /[ \t\n]*\}/ " }"
+let sep_com           = del /[ \t\n]*,[ \t\n]*/ ","
+let sep_slh           = del "\/" "/"
+let sep_col           = del ":" ":"
+let sep_eq            = del /[ \t]*=[ \t]*/ "="
+
+(* Define basic types *)
+let word              = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
+
+(* Define fields *)
+
+(* TODO: there could be a " " in the middle of a value ... *)
+let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
+let sto_to_scl        = store /[^ \t][^;\n]+[^ \t]|[^ \t;\n]+/
+let rfc_code          = [ key "code" . sep_spc . store word ]
+                      . sep_eq
+                      . [ label "value" . sto_to_scl ]
+let sto_number        = store /[0-9][0-9]*/
+
+(************************************************************************
+ *                         SIMPLE STATEMENTS
+ *************************************************************************)
+
+let stmt_simple_re    = "timeout"
+                      | "retry"
+                      | "select-timeout"
+                      | "reboot"
+                      | "backoff-cutoff"
+                      | "initial-interval"
+                      | "do-forward-updates"
+                      | "reject"
+
+let stmt_simple       = [ key stmt_simple_re
+                        . sep_spc
+                        . sto_to_spc
+                        . sep_scl
+                        . comment_or_eol ]
+
+
+(************************************************************************
+ *                          ARRAY STATEMENTS
+ *************************************************************************)
+
+(* TODO: the array could also be empty, like in the request statement *)
+let stmt_array_re     = "media"
+                      | "request"
+                      | "require"
+
+let stmt_array        = [ key stmt_array_re
+                        . sep_spc
+                        . counter "stmt_array"
+                        . [ seq "stmt_array" . sto_to_spc ]
+                        . [ sep_com . seq "stmt_array" . sto_to_spc ]*
+                        . sep_scl . comment_or_eol ]
+
+(************************************************************************
+ *                          HASH STATEMENTS
+ *************************************************************************)
+
+let stmt_hash_re      = "send"
+                      | "option"
+
+let stmt_hash         = [ key stmt_hash_re
+                        . sep_spc
+                        . [ key word . sep_spc . (sto_to_spc|rfc_code) ]
+                        . sep_scl
+                        . comment_or_eol ]
+
+(************************************************************************
+ *                         BLOCK STATEMENTS
+ *************************************************************************)
+
+let stmt_block_re     = "interface"
+                      | "lease"
+                      | "alias"
+
+let stmt_block_opt_re = "interface"
+                      | "script"
+                      | "bootp"
+                      | "fixed-address"
+                      | "filename"
+                      | "server-name"
+                      | "medium"
+                      | "vendor option space"
+
+(* TODO: some options could take no argument like bootp *)
+let stmt_block_opt    = [ key stmt_block_opt_re
+                         . sep_spc
+                         . sto_to_spc
+                         . sep_scl
+                         . comment_or_eol ]
+
+let stmt_block_date_re
+                      = "renew"
+                      | "rebind"
+                      | "expire"
+
+let stmt_block_date   = [ key stmt_block_date_re
+                        . [ sep_spc . label "weekday" . sto_number ]
+                        . [ sep_spc . label "year"    . sto_number ]
+                        . [ sep_slh . label "month"   . sto_number ]
+                        . [ sep_slh . label "day"     . sto_number ]
+                        . [ sep_spc . label "hour"    . sto_number ]
+                        . [ sep_col . label "minute"  . sto_number ]
+                        . [ sep_col . label "second"  . sto_number ]
+                        . sep_scl
+                        . comment_or_eol ]
+
+let stmt_block_arg    = sep_spc . sto_to_spc
+
+let stmt_block_entry  = sep_spc
+                      . ( stmt_array
+                        | stmt_hash
+                        | stmt_block_opt
+                        | stmt_block_date )
+
+let stmt_block        = [ key stmt_block_re
+                        . stmt_block_arg?
+                        . sep_obr
+                        . stmt_block_entry+
+                        . sep_cbr
+                        . comment_or_eol ]
+
+(************************************************************************
+ *                              LENS & FILTER
+ *************************************************************************)
+
+let statement = (stmt_simple|stmt_array|stmt_hash|stmt_block)
+
+let lns               = ( empty
+                        | comment
+                        | statement )*
+
+let filter            = incl "/etc/dhcp3/dhclient.conf"
+                      . Util.stdexcl
+
+let xfm                = transform lns filter
diff --git a/lenses/dhcpd.aug b/lenses/dhcpd.aug
new file mode 100644 (file)
index 0000000..7738368
--- /dev/null
@@ -0,0 +1,398 @@
+(*
+Module: Dhcpd
+  BIND dhcp 3 server configuration module for Augeas
+
+Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
+
+About: Reference
+  Reference: manual of dhcpd.conf and dhcp-eval
+  Follow dhclient module for tree structure
+
+About: License
+    This file is licensed under the GPL.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+  Directive without argument.
+  Set this dhcpd server authoritative on the domain.
+  > clear /files/etc/dhcp3/dhcpd.conf/authoritative
+
+  Directives with integer or string argument.
+  Set max-lease-time to one hour:
+  > set /files/etc/dhcp3/dhcpd.conf/max-lease-time 3600
+
+  Options are declared as a list, even for single values.
+  Set the domain of the network:
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name/arg example.org
+  Set two name server:
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[1] foo.example.org
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[2] bar.example.org
+
+  Create the subnet 172.16.0.1 with 10 addresses:
+  > clear /files/etc/dhcp3/dhcpd.conf/subnet[last() + 1]
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/network 172.16.0.0
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/netmask 255.255.255.0
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/from 172.16.0.10
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/to 172.16.0.20
+
+  Create a new group "foo" with one static host. Nodes type and address are ordered.
+  > ins group after /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/*[last()]
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[last()]/host foo
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/type "ethernet"
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/address "00:00:00:aa:bb:cc"
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/fixed-address 172.16.0.100
+
+About: Configuration files
+  This lens applies to /etc/dhcpd3/dhcpd.conf. See <filter>.
+*)
+
+module Dhcpd =
+
+autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+let dels (s:string)   = del s s
+let eol               = Util.eol
+let comment           = Util.comment
+let empty             = Util.empty
+let indent            = Util.indent
+let eos               = comment?
+
+(* Define separators *)
+let sep_spc           = del /[ \t]+/ " "
+let sep_osp           = del /[ \t]*/ ""
+let sep_scl           = del /[ \t]*;([ \t]*\n)*/ ";\n"
+let sep_obr           = del /[ \t]*\{([ \t]*\n)*/ " {\n"
+let sep_cbr           = del /[ \t]*\}([ \t]*\n)*/ "}\n"
+let sep_com           = del /[ \t\n]*,[ \t\n]*/ ", "
+let sep_slh           = del "\/" "/"
+let sep_col           = del ":" ":"
+let sep_eq            = del /[ \t]*=[ \t]*/ "="
+let scl               = del ";" ";"
+
+(* Define basic types *)
+let word              = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
+let ip                = Rx.ipv4
+
+(* Define fields *)
+
+(* borrowed from sysconfig.aug *)
+  (* Chars allowed in a bare string *)
+  let bchar = /[^ \t\n\"'\\{\}#,\(\)]|\\\\./
+  let qchar = /["']/  (* " *)
+
+  (* We split the handling of right hand sides into a few cases:
+   *   bare  - strings that contain no spaces, optionally enclosed in
+   *           single or double quotes
+   *   dquot - strings that contain at least one space or apostrophe,
+   *           which must be enclosed in double quotes
+   *   squot - strings that contain an unescaped double quote
+   *)
+  let bare = del qchar? "" . store (bchar+) . del qchar? ""
+  let dquot =
+    del qchar "\"" . store (bchar* . /[ \t']/ . bchar*)+ . del qchar "\""
+  let squot =
+    dels "'" . store ((bchar|/[ \t]/)* . "\"" . (bchar|/[ \t]/)*)+ . dels "'"
+
+let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
+let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
+
+let sto_number        = store /[0-9][0-9]*/
+
+(************************************************************************
+ *                         NO ARG STATEMENTS
+ *************************************************************************)
+
+let stmt_noarg_re     =   "authoritative"
+                        | "primary"
+                        | "secondary"
+
+let stmt_noarg        = [ indent
+                        . key stmt_noarg_re
+                        . sep_scl
+                        . eos ]
+
+(************************************************************************
+ *                         INT ARG STATEMENTS
+ *************************************************************************)
+
+let stmt_integer_re   = "default-lease-time"
+                      | "max-lease-time"
+                      | "min-lease-time"
+                      | /lease[ ]+limit/
+                      | "port"
+                      | /peer[ ]+port/
+                      | "max-response-delay"
+                      | "max-unacked-updates"
+                      | "mclt"
+                      | "split"
+                      | /load[ ]+balance[ ]+max[ ]+seconds/
+                      | "max-lease-misbalance"
+                      | "max-lease-ownership"
+                      | "min-balance"
+                      | "max-balance"
+                      | "adaptive-lease-time-threshold"
+                      | "dynamic-bootp-lease-length"
+                      | "local-port"
+                      | "min-sec"
+                      | "omapi-port"
+                      | "ping-timeout"
+                      | "remote-port"
+
+let stmt_integer      = [ indent
+                        . key stmt_integer_re
+                        . sep_spc
+                        . sto_number
+                        . sep_scl
+                        . eos ]
+
+(************************************************************************
+ *                         STRING ARG STATEMENTS
+ *************************************************************************)
+
+let stmt_string_re    = "ddns-update-style"
+                      | "ddns-updates"
+                      | "ddns-hostname"
+                      | "ddns-domainname"
+                      | "ddns-rev-domainname"
+                      | "log-facility"
+                      | "filename"
+                      | "server-name"
+                      | "fixed-address"
+                      | /failover[ ]+peer/
+                      | "use-host-decl-names"
+                      | "next-server"
+                      | "address"
+                      | /peer[ ]+address/
+                      | "type"
+                      | "file"
+                      | "algorithm"
+                      | "secret"
+                      | "key"
+                      | "include"
+                      | "hba"
+                      | "boot-unknown-clients"
+                      | "db-time-format"
+                      | "do-forward-updates"
+                      | "dynamic-bootp-lease-cutoff"
+                      | "get-lease-hostnames"
+                      | "infinite-is-reserved"
+                      | "lease-file-name"
+                      | "local-address"
+                      | "one-lease-per-client"
+                      | "pid-file-name"
+                      | "ping-check"
+                      | "server-identifier"
+                      | "site-option-space"
+                      | "stash-agent-options"
+                      | "update-conflict-detection"
+                      | "update-optimization"
+                      | "update-static-leases"
+                      | "use-host-decl-names"
+                      | "use-lease-addr-for-default-route"
+                      | "vendor-option-space"
+
+let stmt_string_tpl (l:lens) = [ indent
+                        . key stmt_string_re
+                        . sep_spc
+                        . l
+                        . sep_scl
+                        . eos ]
+
+let stmt_string  = stmt_string_tpl bare |stmt_string_tpl squot | stmt_string_tpl dquot
+
+(************************************************************************
+ *                         RANGE STATEMENTS
+ *************************************************************************)
+
+let stmt_range        = [ indent
+                        . key "range"
+                        . sep_spc
+                        . [ label "flag" . store /dynamic-bootp/ . sep_spc ]?
+                        . [ label "from" . store ip . sep_spc ]?
+                        . [ label "to" . store ip ]
+                        . sep_scl
+                        . eos ]
+
+(************************************************************************
+ *                         HARDWARE STATEMENTS
+ *************************************************************************)
+
+let stmt_hardware     = [ indent
+                        . key "hardware"
+                        . sep_spc
+                        . [ label "type" . store /ethernet|tokenring/ ]
+                        . sep_spc
+                        . [ label "address" . store /[a-fA-F0-9:-]+/ ]
+                        . sep_scl
+                        . eos ]
+
+(************************************************************************
+ *                         OPTION STATEMENTS
+ *************************************************************************)
+(* The general case is considering options as a list *)
+
+let stmt_option_code  = [ label "label" . store word . sep_spc ]
+                        . [ key "code" . sep_spc . store word ]
+                        . sep_eq
+                        . [ label "type" . store word ]
+
+
+let stmt_option_list  = ([ label "arg" . bare ] | [ label "arg" . dquot ] | [ label "arg" . squot ])
+                        . ( sep_com . ([ label "arg" . bare ] | [ label "arg" . dquot ] | [ label "arg" . squot ]))*
+
+let stmt_option_basic = [ key word . sep_spc . stmt_option_list ]
+let stmt_option_extra = [ key word . sep_spc . store /true|false/ . sep_spc . stmt_option_list ]
+
+let stmt_option_body = stmt_option_basic | stmt_option_extra
+
+let stmt_option1  = [ indent
+                        . key "option"
+                        . sep_spc
+                        . stmt_option_body
+                        . sep_scl
+                        . eos ]
+
+let stmt_option2  = [ indent
+                        . dels "option" . label "rfc-code"
+                        . sep_spc
+                        . stmt_option_code
+                        . sep_scl
+                        . eos ]
+
+let stmt_option = stmt_option1 | stmt_option2
+
+(************************************************************************
+ *                         SUBCLASS STATEMENTS
+ *************************************************************************)
+(* this statement is not well documented in the manual dhcpd.conf
+   we support basic use case *)
+
+let stmt_subclass = [ indent . key "subclass" . sep_spc .
+                      ([ label "name" . dquot ]|
+                       [ label "name" . squot ]|
+                       [ label "name" . bare ]) . sep_spc .
+                       [ label "value" . bare ] . sep_scl . eos ]
+
+(************************************************************************
+ *                         ALLOW/DENY STATEMENTS
+ *************************************************************************)
+(* We have to use special key for allow/deny members of
+  to avoid ambiguity in the put direction *)
+
+let allow_deny_re     = "unknown-clients"
+                      | /dynamic[ ]+bootp[ ]+clients/
+                      | /authenticated[ ]+clients/
+                      | /unauthenticated[ ]+clients/
+
+let stmt_secu_re      = "allow"
+                      | "deny"
+
+let del_allow = del /allow[ ]+members[ ]+of/ "allow members of"
+let del_deny  = del /deny[ \t]+members[ \t]+of/ "deny members of"
+
+let stmt_secu_tpl (l:lens) (s:string) =
+                  [ indent . l . sep_spc . label s . bare . sep_scl . eos ] |
+                  [ indent . l . sep_spc . label s . squot . sep_scl . eos ] |
+                  [ indent . l . sep_spc . label s . dquot . sep_scl . eos ]
+
+let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
+                          store allow_deny_re . sep_scl . eos ] |
+                        stmt_secu_tpl del_allow "allow-members-of" |
+                        stmt_secu_tpl del_deny "deny-members-of"
+
+(************************************************************************
+ *                         MATCH STATEMENTS
+ *************************************************************************)
+
+let sto_fct = store (word . /[ \t]*\([^)]*\)/)
+let sto_option = store (/option[ ]+/ . word)
+let sto_com = /[^ \t\n,\(\)][^,\(\)]*[^ \t\n,\(\)]|[^ \t\n,\(\)]+/ | word . /[ \t]*\([^)]*\)/
+let fct_re = "substring" | "binary-to-ascii"
+
+let fct_args = [ label "args" . dels "(" . sep_osp .
+                 ([ label "arg" . store sto_com ] . [ label "arg" . sep_com . store sto_com ]+) .
+                        sep_osp . dels ")" ]
+
+let stmt_match_if = [ dels "if" . sep_spc . store fct_re . sep_osp . label "function" . fct_args ] .
+                      sep_eq . ([ label "value" . bare ]|[ label "value" . squot ]|[ label "value" . dquot ])
+
+let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
+                       dels "(" . sep_osp .
+                       [ label "args" .
+                         [ label "arg" . store sto_com ] .
+                         [ sep_com . label "arg" . store sto_com ]+ ] .
+                       dels ")" ]
+
+let stmt_match_tpl (l:lens) = [ indent . key "match" . sep_spc . l . sep_scl . eos ]
+
+let stmt_match = stmt_match_tpl (stmt_match_if | stmt_match_pfv )
+
+(************************************************************************
+ *                         BLOCK STATEMENTS
+ *************************************************************************)
+(* Blocks doesn't support comments at the end of the closing bracket *)
+
+let stmt_entry        =   stmt_secu
+                        | stmt_option
+                        | stmt_hardware
+                        | stmt_range
+                        | stmt_string
+                        | stmt_integer
+                        | stmt_noarg
+                        | stmt_match
+                        | stmt_subclass
+                        | empty
+                        | comment
+
+let stmt_block_noarg_re = "pool"
+                        | "group"
+                        | "allow-update"
+
+let stmt_block_noarg (body:lens)
+                        = [ indent
+                        . key stmt_block_noarg_re
+                        . sep_obr
+                        . body*
+                        . sep_cbr ]
+
+let stmt_block_arg_re = "host"
+                      | "class"
+                      | "shared-network"
+                      | /failover[ ]+peer/
+                      | "zone"
+                      | "key"
+
+let stmt_block_arg (body:lens)
+                      = [ indent
+                        . key stmt_block_arg_re
+                        . sep_spc
+                        . sto_to_spc
+                        . sep_obr
+                        . body*
+                        . sep_cbr ]
+
+let stmt_block_subnet (body:lens)
+                      = [ indent
+                        . key "subnet"
+                        . sep_spc
+                        . [ label "network" . store ip ]
+                        . sep_spc
+                        . [ key "netmask" . sep_spc . store ip ]
+                        . sep_obr
+                        . body*
+                        . sep_cbr ]
+
+let all_block (body:lens) =
+    let lns1 = stmt_block_subnet body in
+    let lns2 = stmt_block_arg body in
+    let lns3 = stmt_block_noarg body in
+    (lns1 | lns2 | lns3 | stmt_entry)
+
+let rec lns_staging = stmt_entry|all_block lns_staging
+let lns = (lns_staging)*
+
+let xfm = transform lns (incl "/etc/dhcp3/dhcpd.conf")
diff --git a/lenses/dnsmasq.aug b/lenses/dnsmasq.aug
new file mode 100644 (file)
index 0000000..8167795
--- /dev/null
@@ -0,0 +1,47 @@
+(* Dnsmasq module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man dnsmasq (8)
+
+ "Format is one option per line, legal options are the same
+  as the long options legal on the command line. See
+ "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details."
+
+*)
+
+module Dnsmasq =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let spc        = Util.del_ws_spc
+let comment    = Util.comment
+let empty      = Util.empty
+
+let sep_eq     = del /=/ "="
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry_re   = /[A-Za-z0-9\._-]+/
+let entry      = [ key entry_re . (sep_eq . sto_to_eol)? . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns = (comment|empty|entry) *
+
+let filter            = incl "/etc/dnsmasq.conf"
+                      . incl "/etc/dnsmasq.d/*"
+                      . excl "#*#"
+                      . excl ".*"
+                      . Util.stdexcl
+
+let xfm                = transform lns filter
diff --git a/lenses/dpkg.aug b/lenses/dpkg.aug
new file mode 100644 (file)
index 0000000..41f252a
--- /dev/null
@@ -0,0 +1,91 @@
+(*
+Module: Dpkg
+    Parses /etc/dpkg/dpkg.cfg
+
+Author: Robin Lee Powell <rlpowell@digitalkingdom.org>
+
+About: License
+    This file, and the attendant test_dpgk.aug, are explicitely
+    placed in the public domain.
+
+About: Description
+    dpkg.cfg is a simple list of options, the same ones as the
+    command line options, with or without a value.
+
+    The tree is a list of either comments or option/value pairs by
+    name. Use "set" to set an option with a value, and "clear" for a
+    bare option.
+
+About: Usage Example
+
+(start code)
+    $ augtool -n
+    augtool> ls /files/etc/dpkg/dpkg.cfg
+    #comment[1] = dpkg configuration file
+    #comment[2] = This file can contain default options for dpkg.  All command-line
+    #comment[3] = options are allowed.  Values can be specified by putting them after
+    #comment[4] = the option, separated by whitespace and/or an `=' sign.
+    #comment[5] = Do not enable debsig-verify by default; since the distribution is not using
+    #comment[6] = embedded signatures, debsig-verify would reject all packages.
+    no-debsig = (none)
+    #comment[7] = Log status changes and actions to a file.
+    log = /var/log/dpkg.log
+    augtool> get /files/etc/dpkg/dpkg.cfg/no-debsig
+    /files/etc/dpkg/dpkg.cfg/no-debsig (none)
+    augtool> get /files/etc/dpkg/dpkg.cfg/log
+    /files/etc/dpkg/dpkg.cfg/log = /var/log/dpkg.log
+    augtool> clear /files/etc/dpkg/dpkg.cfg/testopt
+    augtool> set /files/etc/dpkg/dpkg.cfg/testopt2 test
+    augtool> save
+    Saved 1 file(s)
+    augtool>
+    $ cat /etc/dpkg/dpkg.cfg.augnew
+    # dpkg configuration file
+    #
+    # This file can contain default options for dpkg.  All command-line
+    # options are allowed.  Values can be specified by putting them after
+    # the option, separated by whitespace and/or an `=' sign.
+    #
+
+    # Do not enable debsig-verify by default; since the distribution is not using
+    # embedded signatures, debsig-verify would reject all packages.
+    no-debsig
+
+    # Log status changes and actions to a file.
+    log /var/log/dpkg.log
+    testopt
+    testopt2 test
+(end code)
+
+*)
+
+module Dpkg =
+  autoload xfm
+
+  let sep_tab = Util.del_ws_tab
+  let sep_spc = Util.del_ws_spc
+  let eol = del /[ \t]*\n/ "\n"
+
+  let comment = Util.comment
+  let empty   = Util.empty
+
+  let word = /[^,# \n\t]+/
+  let keyword = /[^,# \n\t\/]+/
+
+  (* View: record
+      Keyword, followed by optional whitespace and value, followed
+      by EOL.
+
+      The actual file specification doesn't require EOL, but the
+      likelyhood of the file not having one is pretty slim, and
+      this way things we add have EOL.
+  *)
+
+  let record = [ key keyword . (sep_spc . store word)? . eol ]
+
+  (* View: lns
+      Any number of empty lines, comments, and records.
+  *)
+  let lns = ( empty | comment | record ) *
+
+  let xfm = transform lns (incl "/etc/dpkg/dpkg.cfg")
diff --git a/lenses/dput.aug b/lenses/dput.aug
new file mode 100644 (file)
index 0000000..58ba0ca
--- /dev/null
@@ -0,0 +1,69 @@
+(* Dput module for Augeas
+   Author: Raphael Pinson <raphink@gmail.com>
+
+
+   Reference: dput uses Python's ConfigParser:
+     http://docs.python.org/lib/module-ConfigParser.html
+*)
+
+
+module Dput =
+  autoload xfm
+
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+
+
+let setting = "allow_dcut"
+            | "allow_non-us_software"
+            | "allow_unsigned_uploads"
+            | "check_version"
+            | "default_host_main"
+            | "default_host_non-us"
+            | "fqdn"
+            | "hash"
+            | "incoming"
+            | "login"
+            | "method"
+            | "passive_ftp"
+            | "post_upload_command"
+            | "pre_upload_command"
+            | "progress_indicator"
+            | "run_dinstall"
+            | "run_lintian"
+            | "scp_compress"
+            | "ssh_config_options"
+            | "allowed_distributions"
+
+(************************************************************************
+ * "name: value" entries, with continuations in the style of RFC 822;
+ * "name=value" is also accepted
+ * leading whitespace is removed from values
+ *************************************************************************)
+let entry = IniFile.entry setting sep comment
+
+
+(************************************************************************
+ * sections, led by a "[section]" header
+ * We can't use titles as node names here since they could contain "/"
+ * We remove #comment from possible keys
+ * since it is used as label for comments
+ * We also remove / as first character
+ * because augeas doesn't like '/' keys (although it is legal in INI Files)
+ *************************************************************************)
+let title   = IniFile.title_label "target" IniFile.record_label_re
+let record  = IniFile.record title entry
+
+let lns    = IniFile.lns record comment
+
+let filter = (incl "/etc/dput.cf")
+           . (incl "~/.dput.cf")
+           . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/ethers.aug b/lenses/ethers.aug
new file mode 100644 (file)
index 0000000..9cb633b
--- /dev/null
@@ -0,0 +1,25 @@
+(* Parsing /etc/ethers *)
+
+module Ethers =
+  autoload xfm
+
+  let sep_tab = Util.del_ws_tab
+
+  let eol = del /[ \t]*\n/ "\n"
+  let indent = del /[ \t]*/ ""
+
+  let comment = Util.comment
+  let empty   = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
+
+  let word = /[^# \n\t]+/
+  let address =
+    let hex = /[0-9a-fA-F][0-9a-fA-F]?/ in
+      hex . ":" . hex . ":" . hex . ":" . hex . ":" . hex . ":" . hex
+
+  let record = [ seq "ether" . indent .
+                              [ label "mac" . store  address ] . sep_tab .
+                              [ label "ip" . store word ] . eol ]
+
+  let lns = ( empty | comment | record ) *
+
+  let xfm = transform lns (incl "/etc/ethers")
diff --git a/lenses/exports.aug b/lenses/exports.aug
new file mode 100644 (file)
index 0000000..088d273
--- /dev/null
@@ -0,0 +1,98 @@
+(* Lens for Linux syntax of NFS exports(5) *)
+
+(*
+Module: Exports
+    Parses /etc/exports
+
+Author: David Lutterkort <lutter@redhat.com>
+
+About: Description
+    /etc/exports contains lines associating a directory with one or
+    more hosts, and NFS options for each host.
+
+About: Usage Example
+
+(start code)
+
+    $ augtool
+    augtool> ls /files/etc/exports/
+    comment[1] = /etc/exports: the access control list for filesystems which may be exported
+    comment[2] = to NFS clients.  See exports(5).
+    comment[3] = sample /etc/exports file
+    dir[1]/ = /
+    dir[2]/ = /projects
+    dir[3]/ = /usr
+    dir[4]/ = /home/joe
+
+
+    augtool> ls /files/etc/exports/dir[1]
+    client[1]/ = master
+    client[2]/ = trusty
+(end code)
+
+The corresponding line in the file is:
+
+(start code)
+       /               master(rw) trusty(rw,no_root_squash)
+(end code)
+
+    Digging further:
+
+(start code)
+    augtool> ls /files/etc/exports/dir[1]/client[1]
+    option = rw
+
+    To add a new entry, you'd do something like this:
+(end code)
+
+(start code)
+    augtool> set /files/etc/exports/dir[10000] /foo
+    augtool> set /files/etc/exports/dir[last()]/client[1] weeble
+    augtool> set /files/etc/exports/dir[last()]/client[1]/option[1] ro
+    augtool> set /files/etc/exports/dir[last()]/client[1]/option[2] all_squash
+    augtool> save
+    Saved 1 file(s)
+(end code)
+
+    Which creates the line:
+
+(start code)
+    /foo weeble(ro,all_squash)
+(end code)
+
+About: Limitations
+    This lens cannot handle options without a host, as with the last
+    example line in "man 5 exports":
+
+       /pub            (ro,insecure,all_squash)
+
+    In this case, though, you can just do:
+
+       /pub            *(ro,insecure,all_squash)
+
+    It also can't handle whitespace before the directory name.
+*)
+
+module Exports =
+  autoload xfm
+
+  let client_re = /[a-zA-Z0-9\.@\*\?\/\-]+/
+
+  let eol = Util.eol
+  let lbracket  = Util.del_str "("
+  let rbracket  = Util.del_str ")"
+  let sep_com   = Sep.comma
+  let sep_spc   = Sep.space
+
+  let option = [ label "option" . store /[^,)]+/ ]
+
+  let client    = [ label "client" . store client_re .
+                    ( Build.brackets lbracket rbracket
+                         ( Build.opt_list option sep_com ) )? ]
+
+  let entry = [ label "dir" . store /\/[^ \t]*/
+                . sep_spc . Build.opt_list client sep_spc . eol ]
+
+  let lns = (Hosts.empty | Hosts.comment | entry)*
+
+  let xfm = transform lns (incl "/etc/exports")
diff --git a/lenses/fstab.aug b/lenses/fstab.aug
new file mode 100644 (file)
index 0000000..b6c2d9f
--- /dev/null
@@ -0,0 +1,40 @@
+(* Parsing /etc/fstab *)
+
+module Fstab =
+  autoload xfm
+
+  let sep_tab = Sep.tab
+  let sep_spc = Sep.space
+  let comma   = Sep.comma
+  let eol     = Util.eol
+
+  let comment = Util.comment
+  let empty   = Util.empty
+
+  (* An option label can't contain comma, comment, equals, or space *)
+  let optlabel = /[^,#= \n\t]+/
+  let spec    = /[^,# \n\t][^ \n\t]*/
+
+  let comma_sep_list (l:string) =
+    let value = [ label "value" . Util.del_str "=" . store Rx.neg1 ] in
+      let lns = [ label l . store optlabel . value? ] in
+         Build.opt_list lns comma
+
+  let record = [ seq "mntent" .
+                   [ label "spec" . store spec ] . sep_tab .
+                   [ label "file" . store Rx.neg1 ] . sep_tab .
+                   comma_sep_list "vfstype" . sep_tab .
+                   comma_sep_list "opt" .
+                   (sep_tab . [ label "dump" . store /[0-9]+/ ] .
+                    ( sep_spc . [ label "passno" . store /[0-9]+/ ])? )?
+                 . eol ]
+
+  let lns = ( empty | comment | record ) *
+  let filter = (incl "/etc/fstab")
+             . (incl "/etc/mtab")
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/gdm.aug b/lenses/gdm.aug
new file mode 100644 (file)
index 0000000..5ac0bf8
--- /dev/null
@@ -0,0 +1,48 @@
+(* Gdm module for Augeas                       *)
+(* Author: Free Ekanayaka <freek@64studio.com> *)
+(*                                             *)
+
+module Gdm =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+let empty    = IniFile.empty
+
+
+(************************************************************************
+ *                        ENTRY
+ * Entry keywords can be bare digits as well (the [server] section)
+ *************************************************************************)
+let entry_re = ( /[A-Za-z0-9][A-Za-z0-9\._-]*/ )
+let entry    = IniFile.entry entry_re sep comment
+
+
+(************************************************************************
+ *                         TITLE
+ *
+ * We use IniFile.title_label because there can be entries
+ * outside of sections whose labels would conflict with section names
+ *************************************************************************)
+let title       = IniFile.title ( IniFile.record_re - ".anon" )
+let record      = IniFile.record title entry
+
+let record_anon = [ label ".anon" . ( entry | empty )+ ]
+
+
+(************************************************************************
+ *                         LENS & FILTER
+ * There can be entries before any section
+ * IniFile.entry includes comment management, so we just pass entry to lns
+ *************************************************************************)
+let lns    = record_anon? . record*
+
+let filter = (incl "/etc/gdm/gdm.conf*")
+             . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/group.aug b/lenses/group.aug
new file mode 100644 (file)
index 0000000..1fbec6d
--- /dev/null
@@ -0,0 +1,50 @@
+(* Group module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man 5 group
+
+*)
+
+module Group =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let comment    = Util.comment
+let empty      = Util.empty
+
+let colon      = Sep.colon
+let comma      = Sep.comma
+
+let sto_to_spc = store Rx.space_in
+
+let word    = Rx.word
+let password = /[A-Za-z0-9_.!*-]*/
+let integer = Rx.integer
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let user      = [ label "user" . store word ]
+let user_list = Build.opt_list user comma
+let params    = [ label "password" . store password  . colon ]
+                . [ label "gid"      . store integer . colon ]
+                . user_list?
+let entry     = Build.key_value_line word colon params
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter
+               = incl "/etc/group"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/grub.aug b/lenses/grub.aug
new file mode 100644 (file)
index 0000000..0652f70
--- /dev/null
@@ -0,0 +1,181 @@
+module Grub =
+  autoload xfm
+
+    (* This only covers the most basic grub directives. Needs to be *)
+    (* expanded to cover more (and more esoteric) directives        *)
+    (* It is good enough to handle the grub.conf on my Fedora 8 box *)
+
+    let value_to_eol = store /[^= \t\n][^\n]*[^= \t\n]|[^= \t\n]/
+    let eol = Util.eol
+    let del_to_eol = del /[^ \t\n]*/ ""
+    let spc = Util.del_ws_spc
+    let opt_ws = Util.del_opt_ws ""
+    let dels (s:string) = Util.del_str s
+    let eq = dels "="
+    let switch (n:regexp) = dels "--" . key n
+    let switch_arg (n:regexp) = switch n . eq . store Rx.no_spaces
+    let value_sep (dflt:string) = del /[ \t]*[ \t=][ \t]*/ dflt
+
+    let comment_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+                       - /# ## (Start|End) Default Options ##/
+
+    let comment    =
+        [ Util.indent . label "#comment" . del /#[ \t]*/ "# "
+            . store comment_re . eol ]
+    let empty   = Util.empty
+
+    let command (kw:regexp) (indent:string) =
+      Util.del_opt_ws indent . key kw
+
+    let kw_arg (kw:regexp) (indent:string) (dflt_sep:string) =
+      [ command kw indent . value_sep dflt_sep . value_to_eol . eol ]
+
+    let kw_boot_arg (kw:string) = kw_arg kw "\t" " "
+    let kw_menu_arg (kw:string) = kw_arg kw "" " "
+    let password_arg = [ key "password" .
+      (spc . [ switch "md5" ])? .
+      spc . store (/[^ \t\n]+/ - "--md5") .
+      (spc . [ label "file" . store /[^ \t\n]+/ ])? .
+      eol ]
+
+    let kw_pres (kw:string) = [ opt_ws . key kw . del_to_eol . eol ]
+
+    (* This is a shell-only directive in upstream grub; the grub versions
+       in at least Fedora/RHEL use this to find devices for UEFI boot *)
+    let device =
+         [ command "device" "" . Sep.space . store /\([A-Za-z0-9_.-]+\)/ . spc .
+                 [ label "file" . value_to_eol ] . Util.eol ]
+
+    let color =
+      (* Should we nail it down to exactly the color names that *)
+      (* grub supports ? *)
+      let color_name = store /[A-Za-z-]+/ in
+      let color_spec =
+        [ label "foreground" . color_name] .
+        dels "/" .
+        [ label "background" . color_name ] in
+      [ opt_ws . key "color" .
+        spc . [ label "normal" . color_spec ] .
+        (spc . [ label "highlight" . color_spec ])? .
+        eol ]
+
+    let serial =
+      [ command "serial" "" .
+        [ spc . switch_arg /unit|port|speed|word|parity|stop|device/ ]* .
+        eol ]
+
+    let terminal =
+      [ command "terminal" "" .
+          ([ spc . switch /dumb|no-echo|no-edit|silent/ ]
+          |[ spc . switch_arg /timeout|lines/ ])* .
+          [ spc . key /console|serial|hercules/ ]* . eol ]
+
+    let menu_setting = kw_menu_arg "default"
+                     | kw_menu_arg "fallback"
+                     | kw_pres "hiddenmenu"
+                     | kw_menu_arg "timeout"
+                     | kw_menu_arg "splashimage"
+                     | kw_menu_arg "gfxmenu"
+                     | kw_menu_arg "background"
+                     | serial
+                     | terminal
+                     | password_arg
+                     | color
+                    | device
+
+    let title = del /title[ \t=]+/ "title " . value_to_eol . eol
+
+    (* Permits a second form for Solaris multiboot kernels that *)
+    (* take a path (with a slash) as their first arg, e.g.      *)
+    (*   /boot/multiboot kernel/unix another=arg                *)
+    let multiboot_arg = [ label "@path" .
+                          store (Rx.word . "/" . Rx.no_spaces) ]
+
+    (* Parse the file name and args on a kernel or module line. *)
+    let kernel_args =
+      let arg = /[A-Za-z0-9_.\$-]+/ - /type|no-mem-option/  in
+      store /\/[^ \t\n]*/ .
+            (spc . multiboot_arg)? .
+            (spc . [ key arg . (eq. store /([^ \t\n])*/)?])* . eol
+
+    (* Solaris extension adds module$ and kernel$ for variable interpolation *)
+    let module_line =
+      [ command /module\$?/ "\t" . spc . kernel_args ]
+
+    let map_line =
+      [ command "map" "\t" . spc .
+           [ label "from" . store /[()A-za-z0-9]+/ ] . spc .
+           [ label "to" . store /[()A-za-z0-9]+/ ] . eol ]
+
+    let kernel =
+        [ command /kernel\$?/ "\t" .
+          (spc .
+             ([switch "type" . eq . store /[a-z]+/]
+             |[switch "no-mem-option"]))* .
+          spc . kernel_args ]
+
+    let chainloader =
+      [ command "chainloader" "\t" .
+          [ spc . switch "force" ]? . spc . store Rx.no_spaces . eol ]
+
+    let savedefault =
+      [ command "savedefault" "\t" . (spc . store Rx.integer)? . eol ]
+
+    let configfile =
+      [ command "configfile" "\t" . spc . store Rx.no_spaces . eol ]
+
+    let boot_setting = kw_boot_arg "root"
+                     | kernel
+                     | kw_boot_arg "initrd"
+                     | kw_boot_arg "rootnoverify"
+                     | chainloader
+                     | kw_boot_arg "uuid"
+                     | kw_boot_arg "findroot"  (* Solaris extension *)
+                     | kw_pres "quiet"  (* Seems to be a Ubuntu extension *)
+                     | savedefault
+                     | configfile
+                     | module_line
+                     | map_line
+
+    let boot =
+      let line = ((boot_setting|comment)* . boot_setting)? in
+      [ label "title" . title . line ]
+
+    let debian_header  = "## ## Start Default Options ##\n"
+    let debian_footer  = "## ## End Default Options ##\n"
+    let debian_comment_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+                            - "## End Default Options ##"
+    let debian_comment =
+        [ Util.indent . label "#comment" . del /##[ \t]*/ "## "
+            . store debian_comment_re . eol ]
+    let debian_value_sep = del /[ \t]*=/ "="
+    let debian_kw_arg (kw:regexp) =
+      [ Util.del_opt_ws "" . key kw . debian_value_sep
+          . value_to_eol? . eol ]
+
+    let debian_setting_re = "kopt"
+                          | "groot"
+                          | "alternative"
+                          | "lockalternative"
+                          | "defoptions"
+                          | "lockold"
+                          | "xenhopt"
+                          | "xenkopt"
+                          | "altoptions"
+                          | "howmany"
+                          | "memtest86"
+                          | "updatedefaultentry"
+                          | "savedefault"
+                          | "indomU"
+
+    let debian_setting = debian_kw_arg debian_setting_re
+
+    let debian_entry   = del "#" "#" . debian_setting
+    let debian         = [ label "debian"
+                    . del debian_header debian_header
+                    . (debian_comment|empty|debian_entry)*
+                    . del debian_footer debian_footer ]
+
+    let lns = (comment | empty | menu_setting | boot | debian)*
+    let xfm = transform lns (incl "/boot/grub/menu.lst"
+                           . incl "/etc/grub.conf")
diff --git a/lenses/hosts.aug b/lenses/hosts.aug
new file mode 100644 (file)
index 0000000..b4c8c97
--- /dev/null
@@ -0,0 +1,25 @@
+(* Parsing /etc/hosts *)
+
+module Hosts =
+  autoload xfm
+
+  let sep_tab = Util.del_ws_tab
+  let sep_spc = Util.del_ws_spc
+
+  let eol = Util.eol
+  let indent = Util.indent
+
+  let comment = Util.comment
+  let comment_or_eol = Util.comment_or_eol
+  let empty   = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
+
+  let word = /[^# \n\t]+/
+  let record = [ seq "host" . indent .
+                              [ label "ipaddr" . store  word ] . sep_tab .
+                              [ label "canonical" . store word ] .
+                              [ label "alias" . sep_spc . store word ]*
+                 . comment_or_eol ]
+
+  let lns = ( empty | comment | record ) *
+
+  let xfm = transform lns (incl "/etc/hosts")
diff --git a/lenses/httpd.aug b/lenses/httpd.aug
new file mode 100644 (file)
index 0000000..8fbd4a3
--- /dev/null
@@ -0,0 +1,99 @@
+(* Apache HTTPD lens for Augeas
+
+Authors:
+  David Lutterkort <lutter@redhat.com>
+  Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
+  Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  Online Apache configuration manual: http://httpd.apache.org/docs/trunk/
+
+About: License
+    This file is licensed under the LGPLv2+.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+  Apache configuration is represented by two main structures, nested sections
+  and directives. Sections are used as labels, while directives are kept as a
+  value. Sections and directives can have positional arguments inside values
+  of "arg" nodes. Arguments of sections must be the firsts child of the
+  section node.
+
+  This lens doesn't support automatic string quoting. Hence, the string must
+  be quoted when containing a space.
+
+  Create a new VirtualHost section with one directive:
+  > clear /files/etc/apache2/sites-available/foo/VirtualHost
+  > set /files/etc/apache2/sites-available/foo/VirtualHost/arg "172.16.0.1:80"
+  > set /files/etc/apache2/sites-available/foo/VirtualHost/directive "ServerAdmin"
+  > set /files/etc/apache2/sites-available/foo/VirtualHost/*[self::directive="ServerAdmin"]/arg "admin@example.com"
+
+About: Configuration files
+  This lens applies to files in /etc/httpd and /etc/apache2. See <filter>.
+
+*)
+
+
+module Httpd =
+
+autoload xfm
+
+(******************************************************************
+ *                           Utilities lens
+ *****************************************************************)
+let dels (s:string)     = del s s
+
+(* deal with continuation lines *)
+let sep_spc    =  del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "
+
+let sep_osp             = Sep.opt_space
+let sep_eq              = del /[ \t]*=[ \t]*/ "="
+
+let nmtoken             = /[a-zA-Z:_][a-zA-Z0-9:_\.-]*/
+let word                = /[a-zA-Z][a-zA-Z0-9\._\-]*/
+
+let comment             = Util.comment
+let eol                 = Util.eol
+let empty               = Util.empty
+let indent              = Util.indent
+
+(* borrowed from shellvars.aug *)
+let char_arg_dir  = /[^ '"\t\n]|\\\\"|\\\\'/
+let char_arg_sec  = /[^ '"\t\n>]|\\\\"|\\\\'/
+let dquot = /"([^"\\\n]|\\\\.)*"/
+let squot = /'([^'\\\n]|\\\\.)*'/
+
+(******************************************************************
+ *                            Attributes
+ *****************************************************************)
+
+let arg_dir = [ label "arg" . store (char_arg_dir+|dquot|squot) ]
+let arg_sec = [ label "arg" . store (char_arg_sec+|dquot|squot) ]
+
+let argv (l:lens) = l . (sep_spc . l)*
+
+let directive = [ indent . label "directive" . store word .
+                  (sep_spc . argv arg_dir)? . eol ]
+
+let section (body:lens) =
+    let h = (sep_spc . argv arg_sec)? . sep_osp .
+             dels ">" . eol . body* . indent . dels "</" in
+        [ indent . dels "<" . square word h . del ">" ">" . eol ]
+
+let rec content = section (content|directive|comment|empty)
+
+let lns = (content|directive|comment|empty)*
+
+let filter = (incl "/etc/apache2/apache2.conf") .
+             (incl "/etc/apache2/httpd.conf") .
+             (incl "/etc/apache2/ports.conf") .
+             (incl "/etc/apache2/conf.d/*") .
+             (incl "/etc/apache2/mods-available/*") .
+             (incl "/etc/apache2/sites-available/*") .
+             (incl "/etc/httpd/conf.d/*.conf") .
+             (incl "/etc/httpd/httpd.conf") .
+             (incl "/etc/httpd/conf/httpd.conf") .
+             Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/inetd.aug b/lenses/inetd.aug
new file mode 100644 (file)
index 0000000..c2d0879
--- /dev/null
@@ -0,0 +1,185 @@
+(* inetd.conf lens definition for Augeas
+   Auther: Matt Palmer <mpalmer@hezmatt.org>
+
+   Copyright (C) 2009 Matt Palmer, All Rights Reserved
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License version 2.1 as
+   published by the Free Software Foundation.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+   Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+This lens parses /etc/inetd.conf.  The current format is based on the
+syntax documented in the inetd manpage shipped with Debian's openbsd-inetd
+package version 0.20080125-2.  Apologies if your inetd.conf doesn't follow
+the same format.
+
+Each top-level entry will have a key being that of the service name (the
+first column in the service definition, which is the name or number of the
+port that the service should listen on).  The attributes for the service all
+sit under that.  In regular Augeas style, the order of the attributes
+matter, and attempts to set things in a different order will fail miserably.
+The defined attribute names (and the order in which they must appear) are as
+follows (with mandatory parameters indicated by [*]):
+
+address -- a sequence of IP addresses or hostnames on which this service
+       should listen.
+
+socket[*] -- The type of the socket that will be created (either stream or
+       dgram, although the lens doesn't constrain the possibilities here)
+
+protocol[*] -- The socket protocol.  I believe that the usual possibilities
+       are "tcp", "udp", or "unix", but no restriction is made on what you
+       can actually put here.
+
+sndbuf -- Specify a non-default size for the send buffer of the connection.
+
+rcvbuf -- Specify a non-default size for the receive buffer of the connection.
+
+wait[*] -- Whether to wait for new connections ("wait"), or just terminate
+       immediately ("nowait").
+
+max -- The maximum number of times that a service can be invoked in one minute.
+
+user[*] -- The user to run the service as.
+
+group -- A group to set the running service to, rather than the primary
+       group of the previously specified user.
+
+command[*] -- What program to run.
+
+arguments -- A sequence of arguments to pass to the command.
+
+In addition to this straightforward tree, inetd has the ability to set
+"default" listen addresses; this is a little used feature which nonetheless
+comes in handy sometimes.  The key for entries of this type is "address"
+, and the subtree should be a sequence of addresses.  "*" can
+always be used to return the default behaviour of listening on INADDR_ANY.
+
+*)
+
+module Inetd =
+       autoload xfm
+
+       (***************************
+        * PRIMITIVES
+        ***************************)
+
+       (* Store whitespace *)
+       let wsp = del /[ \t]+/ " "
+       let sep = del /[ \t]+/ "        "
+       let owsp(t:string) = del /[ \t]*/ t
+
+       (* It's the end of the line as we know it... doo, doo, dooooo *)
+       let eol = Util.eol
+
+       (* In the beginning, the earth was without form, and void *)
+       let empty = Util.empty
+
+       let comment = Util.comment
+
+       let del_str = Util.del_str
+
+       let address = [ seq "addrseq" . store /([a-zA-Z0-9\.-]+|\*)/ ]
+       let address_list = ( counter "addrseq" . (address . del_str ",")* . address )
+
+       let argument = [ seq "argseq" . store /[^ \t\n]+/ ]
+       let argument_list = ( counter "argseq" . [ label "arguments" . (argument . wsp)* . argument ] )
+
+       (***************************
+        * ELEMENTS
+        ***************************)
+
+       let service (l:string) = ( label l . [label "address" . address_list . del_str ":" ]? . store /[^ \t\n\/:#]+/ )
+
+       let socket = [ label "socket" . store /[^ \t\n#]+/ ]
+
+       let protocol = ( [ label "protocol" . store /[^ \t\n,#]+/ ]
+                        . [ del_str "," . key /sndbuf/ . del_str "=" . store /[^ \t\n,]+/ ]?
+                        . [ del_str "," . key /rcvbuf/ . del_str "=" . store /[^ \t\n,]+/ ]?
+                      )
+
+       let wait = ( [ label "wait" . store /(wait|nowait)/ ]
+                    . [ del_str "." . label "max" . store /[0-9]+/ ]?
+                  )
+
+       let usergroup = ( [ label "user" . store /[^ \t\n:\.]+/ ]
+                         . [ del /[:\.]/ ":" . label "group" . store /[^ \t\n:\.]+/ ]?
+                       )
+
+       let command = ( [ label "command" . store /[^ \t\n]+/ ]
+                       . (wsp . argument_list)?
+                     )
+
+       (***************************
+        * SERVICE LINES
+        ***************************)
+
+       let service_line = [ service "service"
+                            . sep
+                            . socket
+                            . sep
+                            . protocol
+                            . sep
+                            . wait
+                            . sep
+                            . usergroup
+                            . sep
+                            . command
+                            . eol
+                          ]
+
+
+       (***************************
+        * RPC LINES
+        ***************************)
+
+       let rpc_service = service "rpc_service" . Util.del_str "/"
+                        . [ label "version" . store Rx.integer ]
+
+        let rpc_endpoint = [ label "endpoint-type" . store Rx.word ]
+        let rpc_protocol = Util.del_str "rpc/"
+                         . (Build.opt_list
+                             [label "protocol" . store /[^ \t\n,#]+/ ]
+                             Sep.comma)
+
+       let rpc_line = [ rpc_service
+                            . sep
+                            . rpc_endpoint
+                            . sep
+                            . rpc_protocol
+                            . sep
+                            . wait
+                            . sep
+                            . usergroup
+                            . sep
+                            . command
+                            . eol
+                          ]
+
+
+       (***************************
+        * DEFAULT LISTEN ADDRESSES
+        ***************************)
+
+       let default_listen_address = [ label "address"
+                                      . address_list
+                                      . del_str ":"
+                                      . eol
+                                    ]
+
+       (***********************
+        * LENS / FILTER
+        ***********************)
+
+       let lns = (comment|empty|service_line|rpc_line|default_listen_address)*
+
+       let filter = incl "/etc/inetd.conf"
+
+       let xfm = transform lns filter
diff --git a/lenses/inifile.aug b/lenses/inifile.aug
new file mode 100644 (file)
index 0000000..aadb3c3
--- /dev/null
@@ -0,0 +1,312 @@
+(*
+Module: IniFile
+  Generic module to create INI files lenses
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: TODO
+  Things to add in the future
+  - Support double quotes in value
+  - Support multiline values (is it standard?)
+
+About: Lens usage
+  This lens is made to provide generic primitives to construct INI File lenses.
+  See <Puppet>, <PHP>, <MySQL> or <Dput> for examples of real life lenses using it.
+
+*)
+
+module IniFile  =
+
+
+(************************************************************************
+ * Group:               USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Internal primitives *)
+
+(*
+Variable: eol
+  End of line, inherited from <Util.eol>
+*)
+let eol                = Util.eol
+
+(*
+View: empty
+  Empty line, an <eol> subnode
+*)
+let empty              = [ eol ]
+
+
+(* Group: Separators *)
+
+
+
+(*
+Variable: sep
+  Generic separator
+
+  Parameters:
+    pat:regexp - the pattern to delete
+    default:string - the default string to use
+*)
+let sep (pat:regexp) (default:string)
+                       = Sep.opt_space . del pat default
+
+(*
+Variable: sep_re
+  The default regexp for a separator
+*)
+
+let sep_re             = /[=:]/
+
+(*
+Variable: sep_default
+  The default separator value
+*)
+let sep_default        = "="
+
+
+(* Group: Stores *)
+
+
+(*
+Variable: sto_to_eol
+  Store until end of line
+*)
+let sto_to_eol         = Sep.opt_space . store Rx.space_in
+
+(*
+Variable: sto_to_comment
+  Store until comment
+*)
+let sto_to_comment     = Sep.opt_space
+                         . store /[^;# \t\n][^;#\n]*[^;# \t\n]|[^;# \t\n]/
+
+
+(* Group: Define comment and defaults *)
+
+(*
+View: comment
+  Map comments into "#comment" nodes
+
+  Parameters:
+    pat:regexp - pattern to delete before commented data
+    default:string - default pattern before commented data
+
+  Sample Usage:
+  (start code)
+    let comment  = IniFile.comment "#" "#"
+    let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+  (end code)
+*)
+let comment (pat:regexp) (default:string)
+                       = [ label "#comment" . sep pat default
+                        . sto_to_eol? . eol ]
+(*
+Variable: comment_re
+  Default regexp for <comment> pattern
+*)
+
+let comment_re         = /[;#]/
+
+(*
+Variable: comment_default
+  Default value for <comment> pattern
+*)
+let comment_default    = ";"
+
+
+(************************************************************************
+ * Group:                     ENTRY
+ *************************************************************************)
+
+(* Group: entry includes comments *)
+
+(*
+View: entry
+  Generic INI File entry
+
+  Parameters:
+    kw:regexp    - keyword regexp for the label
+    sep:lens     - lens to use as key/value separator
+    comment:lens - lens to use as comment
+
+  Sample Usage:
+     > let entry = IniFile.entry setting sep comment
+*)
+let entry (kw:regexp) (sep:lens) (comment:lens)
+                       = [ key kw . sep . sto_to_comment? . (comment|eol) ] | comment
+
+(*
+View: indented_entry
+  Generic INI File entry that might be indented with an arbitrary
+  amount of whitespace
+
+  Parameters:
+    kw:regexp    - keyword regexp for the label
+    sep:lens     - lens to use as key/value separator
+    comment:lens - lens to use as comment
+
+  Sample Usage:
+     > let entry = IniFile.indented_entry setting sep comment
+*)
+let indented_entry (kw:regexp) (sep:lens) (comment:lens)
+                       = [ Util.del_opt_ws "" .
+                           key kw . sep . sto_to_comment? .
+                           (comment|eol)
+                         ]
+                         | comment
+
+(*
+Variable: entry_re
+  Default regexp for <entry> keyword
+*)
+let entry_re           = ( /[A-Za-z][A-Za-z0-9\._-]+/ )
+
+
+(************************************************************************
+ * Group:                      RECORD
+ *************************************************************************)
+
+(* Group: Title definition *)
+
+(*
+View: title
+  Title for <record>. This maps the title of a record as a node in the abstract tree.
+
+  Parameters:
+    kw:regexp - keyword regexp for the label
+
+  Sample Usage:
+    > let title   = IniFile.title IniFile.record_re
+*)
+let title (kw:regexp)
+                       = Util.del_str "[" . key kw
+                         . Util.del_str "]". eol
+
+(*
+View: indented_title
+  Title for <record>. This maps the title of a record as a node in the abstract tree. The title may be indented with arbitrary amounts of whitespace
+
+  Parameters:
+    kw:regexp - keyword regexp for the label
+
+  Sample Usage:
+    > let title   = IniFile.title IniFile.record_re
+*)
+let indented_title (kw:regexp)
+                       = Util.indent . title kw
+
+(*
+View: title_label
+  Title for <record>. This maps the title of a record as a value in the abstract tree.
+
+  Parameters:
+    name:string - name for the title label
+    kw:regexp   - keyword regexp for the label
+
+  Sample Usage:
+    > let title   = IniFile.title_label "target" IniFile.record_label_re
+*)
+let title_label (name:string) (kw:regexp)
+                       = label name
+                         . Util.del_str "[" . store kw
+                         . Util.del_str "]". eol
+
+(*
+View: indented_title_label
+  Title for <record>. This maps the title of a record as a value in the abstract tree. The title may be indented with arbitrary amounts of whitespace
+
+  Parameters:
+    name:string - name for the title label
+    kw:regexp   - keyword regexp for the label
+
+  Sample Usage:
+    > let title   = IniFile.title_label "target" IniFile.record_label_re
+*)
+let indented_title_label (name:string) (kw:regexp)
+                       = Util.indent . title_label name kw
+
+
+(*
+Variable: record_re
+  Default regexp for <title> keyword pattern
+*)
+let record_re          = ( /[^]\n\/]+/ - /#comment/ )
+
+(*
+Variable: record_label_re
+  Default regexp for <title_label> keyword pattern
+*)
+let record_label_re    = /[^]\n]+/
+
+
+(* Group: Record definition *)
+
+(*
+View: record_noempty
+  INI File Record with no empty lines allowed.
+
+  Parameters:
+    title:lens - lens to use for title. Use either <title> or <title_label>.
+    entry:lens - lens to use for entries in the record. See <entry>.
+*)
+let record_noempty (title:lens) (entry:lens)
+                       = [ title
+                      . entry* ]
+
+(*
+View: record
+  Generic INI File record
+
+  Parameters:
+    title:lens - lens to use for title. Use either <title> or <title_label>.
+    entry:lens - lens to use for entries in the record. See <entry>.
+
+  Sample Usage:
+    > let record  = IniFile.record title entry
+*)
+let record (title:lens) (entry:lens)
+                       = record_noempty title ( entry | empty )
+
+
+(************************************************************************
+ * Group:                      LENS
+ *************************************************************************)
+
+
+(*
+
+Group: Lens definition
+
+View: lns_noempty
+  Generic INI File lens with no empty lines
+
+  Parameters:
+    record:lens  - record lens to use. See <record_noempty>.
+    comment:lens - comment lens to use. See <comment>.
+
+  Sample Usage:
+    > let lns     = IniFile.lns_noempty record comment
+*)
+let lns_noempty (record:lens) (comment:lens)
+                       = comment* . record*
+
+(*
+View: lns
+  Generic INI File lens
+
+  Parameters:
+    record:lens  - record lens to use. See <record>.
+    comment:lens - comment lens to use. See <comment>.
+
+  Sample Usage:
+    > let lns     = IniFile.lns record comment
+*)
+let lns (record:lens) (comment:lens)
+                       = lns_noempty record (comment|empty)
+
+
diff --git a/lenses/inittab.aug b/lenses/inittab.aug
new file mode 100644 (file)
index 0000000..68593ec
--- /dev/null
@@ -0,0 +1,31 @@
+(* Parsing /etc/inittab *)
+module Inittab =
+   autoload xfm
+
+   let sep = Util.del_str ":"
+   let eol = Util.del_str "\n"
+
+   let id = /[^\/#:\n]{1,4}/
+   let value = /[^#:\n]*/
+
+   let comment = Util.comment|Util.empty
+
+   let record =
+     let field (name:string) = [ label name . store value ] in
+     let process = [ label "process" . store /[^#\n]*/ ] in
+     let eolcomment =
+       [ label "#comment" . del /#[ \t]*/ "# "
+           . store /([^ \t\n].*[^ \t\n]|[^ \t\n]?)/ ] in
+       [ key id . sep .
+           field "runlevels" . sep .
+           field "action" . sep .
+           process . eolcomment? . eol ]
+
+   let lns = ( comment | record ) *
+
+   let xfm = transform lns (incl "/etc/inittab")
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/interfaces.aug b/lenses/interfaces.aug
new file mode 100644 (file)
index 0000000..4dc280f
--- /dev/null
@@ -0,0 +1,106 @@
+(* Intefraces module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man interfaces
+
+*)
+
+module Interfaces =
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+
+(* Define separators *)
+
+(* a line can be extended across multiple lines by making the last  *)
+(*  character a backslash *)
+let sep_spc    =  del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "
+
+(* Define fields *)
+let sto_to_eol = store /([^\\ \t\n].*[^\\ \t\n]|[^\\ \t\n])/ . eol
+let sto_to_spc = store /[^\\ \t\n]+/
+
+(* Define comments and empty lines *)
+
+(* note that the comment definition from Util does not support *)
+(* splitting lines with a backlash                             *)
+let comment    = Util.comment
+
+let empty      = Util.empty
+
+(* Define tree stanza_ids *)
+let stanza_id    (t:string) = key t . sep_spc . sto_to_spc
+let stanza_param (l:string) = [ sep_spc . label l . sto_to_spc ]
+
+(* Define reseverved words *)
+let stanza_word = /(iface|auto|allow-[a-z-]+|mapping)/
+
+(* Define additional lines for multi-line stanzas *)
+let stanza_option = [  del /[ \t]*/ "   "
+                     . key  ( /[a-z_-]+/ - stanza_word )
+                     . sep_spc
+                     . sto_to_eol ]
+
+(************************************************************************
+ *                              AUTO
+ *************************************************************************)
+
+let array (r:regexp) (t:string) =  del r t . label t . counter t
+   . [ sep_spc . seq t . sto_to_spc ]+
+let auto = [ array /(allow-)?auto/ "auto" . eol ]
+
+(************************************************************************
+ *                              GENERIC ALLOW
+ *************************************************************************)
+
+let allow = [ key ( /allow-[a-z-]+/ - "allow-auto" )
+             . counter "allow_seq"
+             . [ sep_spc . seq "allow_seq" . sto_to_spc ]+
+             . eol ]
+
+(************************************************************************
+ *                              MAPPING
+ *************************************************************************)
+
+let mapping = [ stanza_id "mapping"
+               . eol
+               . (stanza_option|comment|empty)+ ]
+
+(************************************************************************
+ *                              IFACE
+ *************************************************************************)
+
+let iface   = [ Util.indent
+              . stanza_id    "iface"
+              . stanza_param "family"
+              . stanza_param "method"
+              . eol
+              . (stanza_option|comment|empty)* ]
+
+(************************************************************************
+ *                              STANZAS
+ *************************************************************************)
+
+(* The auto and hotplug stanzas always consist of one line only, while
+   iface and mapping can spand along more lines. Comment nodes are
+   inserted in the tree as direct children of the root node only when they
+   come after an auto or hotplug stanza, otherwise they are considered part
+   of a iface or mapping block *)
+
+let stanza_single = (auto|allow) . (comment|empty)*
+let stanza_multi  = iface|mapping
+
+(************************************************************************
+ *                              LENS & FILTER
+ *************************************************************************)
+
+   let lns = (comment|empty)* . (stanza_multi | stanza_single)*
+
+   let filter = incl "/etc/network/interfaces"
+              . Util.stdexcl
+
+   let xfm = transform lns filter
diff --git a/lenses/iptables.aug b/lenses/iptables.aug
new file mode 100644 (file)
index 0000000..21c5f18
--- /dev/null
@@ -0,0 +1,86 @@
+module Iptables =
+  autoload xfm
+
+(*
+Module: Iptables
+   Parse the iptables file format as produced by iptables-save. The
+   resulting tree is fairly simple; in particular a rule is simply
+   a long list of options/switches and their values (if any)
+
+   This lens should be considered experimental
+*)
+
+let comment = Util.comment
+let empty = Util.empty
+let eol = Util.eol
+let spc = Util.del_ws_spc
+let dels = Util.del_str
+
+let chain_name = store /[A-Za-z0-9_-]+/
+let chain =
+  let policy = [ label "policy" . store /ACCEPT|DROP|REJECT|-/ ] in
+  let counters_eol = del /[ \t]*(\[[0-9:]+\])?[ \t]*\n/ "\n" in
+    [ label "chain" .
+        dels ":" . chain_name . spc . policy . counters_eol ]
+
+let param (long:string) (short:string) =
+  [ label long .
+      spc . del (/--/ . long | /-/ . short) ("-" . short) . spc .
+      store /(![ \t]*)?[^ \t\n!-][^ \t\n]*/ ]
+
+(* A negatable parameter, which can either be FTW
+     ! --param arg
+   or
+     --param ! arg
+*)
+let neg_param (long:string) (short:string) =
+  [ label long .
+      [ spc . dels "!" . label "not" ]? .
+      spc . del (/--/ . long | /-/ . short) ("-" . short) . spc .
+      store /(![ \t]*)?[^ \t\n!-][^ \t\n]*/ ]
+
+let tcp_flags =
+  let flags = /SYN|ACK|FIN|RST|URG|PSH|ALL|NONE/ in
+  let flag_list (name:string) =
+    Build.opt_list [label name . store flags] (dels ",") in
+  [ label "tcp-flags" .
+      spc . dels "--tcp-flags" .
+      spc . flag_list "mask" . spc . flag_list "set" ]
+
+(* misses --set-counters *)
+let ipt_match =
+  let any_key = /[a-zA-Z-][a-zA-Z-]+/ -
+    /protocol|source|destination|jump|goto|in-interface|out-interface|fragment|match|tcp-flags/ in
+  let any_val = /([^\" \t\n!-][^ \t\n]*)|\"([^\"\\\n]|\\\\.)*\"/ in
+  let any_param =
+    [ [ spc . dels "!" . label "not" ]? .
+      spc . dels "--" . key any_key . (spc . store any_val)? ] in
+    (neg_param "protocol" "p"
+    |neg_param "source" "s"
+    |neg_param "destination" "d"
+    |param "jump" "j"
+    |param "goto" "g"
+    |neg_param "in-interface" "i"
+    |neg_param "out-interface" "o"
+    |neg_param "fragment" "f"
+    |param "match" "m"
+    |tcp_flags
+    |any_param)*
+
+let chain_action (n:string) (o:string) =
+    [ label n .
+        del (/--/ . n | o) o .
+        spc . chain_name . ipt_match . eol ]
+
+let table_rule = chain_action "append" "-A"
+              | chain_action "insert" "-I"
+              | empty
+
+
+let table = [ del /\*/ "*" . label "table" . store /[a-z]+/ . eol .
+                (chain|comment|table_rule)* .
+                dels "COMMIT" . eol ]
+
+let lns = (comment|empty|table)*
+let xfm = transform lns (incl "/etc/sysconfig/iptables"
+                       . incl "/etc/iptables-save")
diff --git a/lenses/json.aug b/lenses/json.aug
new file mode 100644 (file)
index 0000000..f8f2924
--- /dev/null
@@ -0,0 +1,52 @@
+module Json =
+
+(* A generic lens for Json files                                           *)
+(* Based on the following grammar from http://www.json.org/                *)
+(* Object ::= '{'Members ? '}'                                             *)
+(* Members ::= Pair+                                                       *)
+(* Pair ::= String ':' Value                                               *)
+(* Array ::= '[' Elements ']'                                              *)
+(* Elements ::= Value ( "," Value )*                                       *)
+(* Value ::= String | Number | Object | Array | "true" | "false" | "null"  *)
+(* String ::= "\"" Char* "\""                                              *)
+(* Number ::= /-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?/                      *)
+
+let spc = /[ \t\n]*/
+
+let ws = del spc ""
+let eol = del spc "\n"
+let delim (c:string) (d:string) = del (spc . c . spc) d
+let dels (s:string) = del s s
+
+let comma = delim "," ", "
+let colon = delim ":" ": "
+let lbrace = delim "{" "{ "
+let rbrace = delim "}" "} "
+let lbrack = delim "[" "[ "
+let rbrack = delim "]" " ]"
+
+let str_store =
+  let q =  del "\"" "\"" in
+  q . store /[^"]*/ . q             (* " Emacs, relax *)
+
+let number = [ label "number" . store /-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?/ ]
+let str = [ label "string" . str_store ]
+
+let const (r:regexp) = [ label "const" . store r ]
+
+let value0 = str | number | const /true|false|null/
+
+let fix_value (value:lens) =
+  let array = [ label "array" . lbrack . Build.opt_list value comma . rbrack ] in
+  let pair = [ label "entry" . str_store . colon . value ] in
+  let obj = [ label "dict" . lbrace . Build.opt_list pair comma . rbrace ] in
+  str | number | obj | array | const /true|false|null/
+
+(* Do shallow typechecks *)
+let value1 = fix_value value0
+(* FIXME: We are very sloppy with whitespace
+let value2 = fix_value value1
+*)
+
+(* Construct the real lens *)
+let rec lns = fix_value lns
diff --git a/lenses/keepalived.aug b/lenses/keepalived.aug
new file mode 100644 (file)
index 0000000..7750a51
--- /dev/null
@@ -0,0 +1,253 @@
+(*
+Module: Keepalived
+  Parses /etc/keepalived/keepalived.conf
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man 5 keepalived.conf` where possible.
+
+About: License
+   This file is licenced under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+   To be documented
+
+About: Configuration files
+   This lens applies to /etc/keepalived/keepalived.conf. See <filter>.
+*)
+
+
+module Keepalived =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Comments and empty lines *)
+
+(* View: indent *)
+let indent = Util.indent
+
+(* View: eol *)
+let eol = Util.eol
+
+(* View: sep_spc *)
+let sep_spc = Sep.space
+
+(* View: lbracket *)
+let lbracket = Util.del_str "{"
+
+(* View: rbracket *)
+let rbracket = Util.del_str "}"
+
+(* View: comment
+Map comments in "#comment" nodes *)
+let comment = Util.comment_generic /[ \t]*[#!][ \t]*/ "# "
+
+(* View: comment_eol
+Map comments at eol *)
+let comment_eol = Util.comment_generic /[ \t]*[#!][ \t]*/ " # "
+
+(* View: comment_or_eol
+A <comment_eol> or <eol> *)
+let comment_or_eol = comment_eol | (del /[ \t]*#?\n/ "\n")
+
+(* View: empty
+Map empty lines *)
+let empty   = Util.empty
+
+(* View: sto_email_addr *)
+let sto_email_addr = store Rx.email_addr
+
+(* Variable: word *)
+let word = Rx.word
+
+(* Variable: word_slash *)
+let word_slash = word | "/"
+
+(* View: sto_word *)
+let sto_word = store word
+
+(* View: sto_num *)
+let sto_num = store Rx.integer
+
+(* View: field *)
+let field (kw:string) (sto:lens) = indent . Build.key_value_line_comment kw sep_spc sto comment_eol
+
+(* View: flag
+A single word *)
+let flag (kw:regexp) = indent . Build.flag kw
+
+(* View: lens_block 
+A generic block with a title lens *)
+let lens_block (title:lens) (sto:lens) = [ indent . title . sep_spc . lbracket . eol
+                                         . (sto | empty | comment)+
+                                         . indent . rbracket . eol ]
+
+(* View: block
+A simple block with just a block title *)
+let block (kw:string) (sto:lens) = lens_block (key kw) sto
+
+(* View: named_block 
+A block with a block title and name *)
+let named_block (kw:string) (sto:lens) = lens_block (key kw . sep_spc . sto_word) sto
+
+(* View: named_block_arg_title
+A title lens for named_block_arg *)
+let named_block_arg_title (kw:string) (name:string) (arg:string) = 
+                            key kw . sep_spc
+                          . [ label name . sto_word ]
+                          . sep_spc
+                          . [ label arg . sto_word ]
+
+(* View: named_block_arg
+A block with a block title, a name and an argument *)
+let named_block_arg (kw:string) (name:string) (arg:string) (sto:lens) = 
+                           lens_block (named_block_arg_title kw name arg) sto
+
+
+(************************************************************************
+ * Group:                 GLOBAL CONFIGURATION
+ *************************************************************************)
+
+(* View: email
+A simple email address entry *)
+let email = [ indent . label "email" . sto_email_addr . comment_or_eol ]
+
+(* View: global_defs_field
+Possible fields in the global_defs block *)
+let global_defs_field = block "notification_email" email
+                      | field "notification_email_from" sto_email_addr
+                      | field "smtp_server" sto_word
+                      | field "smtp_connect_timeout" sto_num
+                      | field "lvs_id" sto_word
+                      | field "router_id" sto_word
+
+(* View: global_defs
+A global_defs block *)
+let global_defs = block "global_defs" global_defs_field
+
+(* View: prefixlen
+A prefix for IP addresses *)
+let prefixlen = [ label "prefixlen" . Util.del_str "/" . sto_num ]
+
+(* View: ipaddr
+An IP address or range with an optional mask *)
+let ipaddr = label "ipaddr" . store /[0-9\.-]+/ . prefixlen?
+
+(* View: ipdev
+A device for IP addresses *)
+let ipdev = [ key "dev" . sep_spc . sto_word ]
+
+(* View: static_ipaddress_field
+The whole string is fed to ip addr add.
+You can truncate the string anywhere you like and let ip addr add use defaults for the rest of the string.
+To be refined with fields according to `ip addr help`.
+*)
+let static_ipaddress_field = [ indent . ipaddr
+                             . (sep_spc . ipdev)?
+                             . comment_or_eol ]
+
+(* View: static_routes_field
+src $SRC_IP to $DST_IP dev $SRC_DEVICE
+*)
+let static_routes_field = [ indent . label "route"
+                          . [ key "src" . sto_word ] . sep_spc
+                          . [ key "to"  . sto_word ] . sep_spc
+                          . [ key "dev" . sto_word ] . comment_or_eol ]
+
+(* View: static_routes *)
+let static_routes = block "static_ipaddress" static_ipaddress_field
+                  | block "static_routes" static_routes_field
+
+
+(* View: global_conf 
+A global configuration entry *)
+let global_conf = global_defs | static_routes
+
+
+(************************************************************************
+ * Group:                 VRRP CONFIGURATION
+ *************************************************************************)
+
+(*View: vrrp_sync_group_field *)
+let vrrp_sync_group_field = block "group" [ indent . key word . comment_or_eol ]
+
+(* View: vrrp_sync_group *)
+let vrrp_sync_group = named_block "vrrp_sync_group" vrrp_sync_group_field
+
+(* View: vrrp_instance_field *)
+let vrrp_instance_field = field "state" sto_word
+                        | field "interface" sto_word
+                        | field "lvs_sync_daemon_interface" sto_word
+                        | field "virtual_router_id" sto_num
+                        | field "priority" sto_num
+                        | field "advert_int" sto_num
+                        | flag "smtp_alert"
+                        | flag "nopreempt"
+                        | block "authentication" (
+                                field "auth_type" sto_word
+                              | field "auth_pass" sto_word
+                              )
+                        | block "virtual_ipaddress" static_ipaddress_field
+
+(* View: vrrp_instance *)
+let vrrp_instance = named_block "vrrp_instance" vrrp_instance_field
+
+
+(* View: vrrpd_conf
+contains subblocks of VRRP synchronization group(s) and VRRP instance(s) *)
+let vrrpd_conf = vrrp_sync_group | vrrp_instance
+
+
+(************************************************************************
+ * Group:                 LVS CONFIGURATION
+ *************************************************************************)
+
+(* View: tcp_check_field *)
+let tcp_check_field = field "connect_timeout" sto_num
+                    | field "connect_port" sto_num
+
+(* View: real_server_field *)
+let real_server_field = field "weight" sto_num
+                      | block "TCP_CHECK" tcp_check_field
+
+(* View: virtual_server_field *)
+let virtual_server_field = field "delay_loop" sto_num
+                         | field "lb_algo" sto_word
+                         | field "lb_kind" sto_word
+                         | field "nat_mask" sto_word
+                         | field "protocol" sto_word
+                         | named_block_arg "real_server" "ip" "port" real_server_field
+
+(* View: virtual_server *)
+let virtual_server = named_block_arg "virtual_server" "ip" "port" virtual_server_field
+
+(* View: virtual_server_group_field *)
+let virtual_server_group_field = [ indent . label "vip"
+                               . [ ipaddr ]
+                              . sep_spc
+                              . [ label "port" . sto_num ]
+                              . comment_or_eol ]
+
+(* View: virtual_server_group *)
+let virtual_server_group = named_block "virtual_server_group" virtual_server_group_field
+
+(* View: lvs_conf
+contains subblocks of Virtual server group(s) and Virtual server(s) *)
+let lvs_conf = virtual_server | virtual_server_group
+
+
+(* View: lns
+     The keepalived lens
+*)
+let lns = ( empty | comment | global_conf | vrrpd_conf | lvs_conf )*
+
+(* Variable: filter *)
+let filter = incl "/etc/keepalived/keepalived.conf"
+    . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/krb5.aug b/lenses/krb5.aug
new file mode 100644 (file)
index 0000000..b417a8e
--- /dev/null
@@ -0,0 +1,128 @@
+module Krb5 =
+
+autoload xfm
+
+let comment = Inifile.comment "#" "#"
+let empty = Inifile.empty
+let eol = Inifile.eol
+let dels = Util.del_str
+
+let indent = del /[ \t]*/ ""
+let eq = del /[ \t]*=[ \t]*/ " = "
+let eq_openbr = del /[ \t]*=[ \t\n]*\{([ \t]*\n)*/ " = {"
+let closebr = del /[ \t]*\}/ "}"
+
+(* These two regexps for realms and apps are not entirely true
+   - strictly speaking, there's no requirement that a realm is all upper case
+   and an application only uses lowercase. But it's what's used in practice.
+
+   Without that distinction we couldn't distinguish between applications
+   and realms in the [appdefaults] section.
+*)
+
+let realm_re = /[A-Z][.a-zA-Z0-9-]*/
+let app_re = /[a-z][a-zA-Z0-9_]*/
+let name_re = /[.a-zA-Z0-9_-]+/
+
+let value = store /[^;# \t\n{}]+/
+let entry (kw:regexp) (sep:lens) (comment:lens)
+    = [ indent . key kw . sep . value . (comment|eol) ] | comment
+
+let simple_section (n:string) (k:regexp) =
+  let title = Inifile.indented_title n in
+  let entry = entry k eq comment in
+    Inifile.record title entry
+
+let record (t:string) (e:lens) =
+  let title = Inifile.indented_title t in
+    Inifile.record title e
+
+let libdefaults =
+  let option = entry (name_re - "v4_name_convert") eq comment in
+  let subsec = [ indent . key /host|plain/ . eq_openbr .
+                   (entry name_re eq comment)* . closebr . eol ] in
+  let v4_name_convert = [ indent . key "v4_name_convert" . eq_openbr .
+                          subsec* . closebr . eol ] in
+  record "libdefaults" (option|v4_name_convert)
+
+let login =
+  let keys = /krb[45]_get_tickets|krb4_convert|krb_run_aklog/
+    |/aklog_path|accept_passwd/ in
+    simple_section "login" keys
+
+let appdefaults =
+  let option = entry (name_re - "realm" - "application") eq comment in
+  let realm = [ indent . label "realm" . store realm_re .
+                  eq_openbr . option* . closebr . eol ] in
+  let app = [ indent . label "application" . store app_re .
+                eq_openbr . (realm|option)* . closebr . eol] in
+    record "appdefaults" (option|realm|app)
+
+let realms =
+  let simple_option = /kdc|admin_server|database_module|default_domain/
+      |/v4_realm|auth_to_local(_names)?|master_kdc|kpasswd_server/
+      |/admin_server/ in
+  let subsec_option = /v4_instance_convert/ in
+  let option = entry simple_option eq comment in
+  let subsec = [ indent . key subsec_option . eq_openbr .
+                   (entry name_re eq comment)* . closebr . eol ] in
+  let realm = [ indent . label "realm" . store realm_re .
+                  eq_openbr . (option|subsec)* . closebr . eol ] in
+    record "realms" (realm|comment)
+
+let domain_realm =
+  simple_section "domain_realm" name_re
+
+let logging =
+  let keys = /kdc|admin_server|default/ in
+  let xchg (m:regexp) (d:string) (l:string) =
+    del m d . label l in
+  let xchgs (m:string) (l:string) = xchg m m l in
+  let dest =
+    [ xchg /FILE[=:]/ "FILE=" "file" . value ]
+    |[ xchgs "STDERR" "stderr" ]
+    |[ xchgs "CONSOLE" "console" ]
+    |[ xchgs "DEVICE=" "device" . value ]
+    |[ xchgs "SYSLOG" "syslog" .
+         ([ xchgs ":" "severity" . store /[A-Za-z0-9]+/ ].
+          [ xchgs ":" "facility" . store /[A-Za-z0-9]+/ ]?)? ] in
+  let entry = [ indent . key keys . eq . dest . (comment|eol) ] | comment in
+    record "logging" entry
+
+let capaths =
+  let realm = [ indent . key realm_re .
+                  eq_openbr .
+                  (entry realm_re eq comment)* . closebr . eol ] in
+    record "capaths" (realm|comment)
+
+let dbdefaults =
+  let keys = /database_module|ldap_kerberos_container_dn|ldap_kdc_dn/
+    |/ldap_kadmind_dn|ldap_service_password_file|ldap_servers/
+    |/ldap_conns_per_server/ in
+    simple_section "dbdefaults" keys
+
+let dbmodules =
+  let keys = /db_library|ldap_kerberos_container_dn|ldap_kdc_dn/
+    |/ldap_kadmind_dn|ldap_service_password_file|ldap_servers/
+    |/ldap_conns_per_server/ in
+    simple_section "dbmodules" keys
+
+(* This section is not documented in the krb5.conf manpage,
+   but the Fermi example uses it. *)
+let instance_mapping =
+  let value = dels "\"" . store /[^;# \t\n{}]*/ . dels "\"" in
+  let map_node = label "mapping" . store /[a-zA-Z0-9\/*]+/ in
+  let mapping = [ indent . map_node . eq .
+                    [ label "value" . value ] . (comment|eol) ] in
+  let instance = [ indent . key name_re .
+                     eq_openbr . (mapping|comment)* . closebr . eol ] in
+    record "instancemapping" instance
+
+let kdc =
+  simple_section "kdc" /profile/
+
+let lns = (comment|empty)* .
+  (libdefaults|login|appdefaults|realms|domain_realm
+  |logging|capaths|dbdefaults|dbmodules|instance_mapping|kdc)*
+
+let xfm = transform lns (incl "/etc/krb5.conf")
diff --git a/lenses/limits.aug b/lenses/limits.aug
new file mode 100644 (file)
index 0000000..c935a75
--- /dev/null
@@ -0,0 +1,70 @@
+(* Limits module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: /etc/security/limits.conf
+
+*)
+
+module Limits =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let spc        = Util.del_ws_spc
+let comment    = Util.comment
+let empty      = Util.empty
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let domain     = label "domain" . store /[%@]?[A-Za-z0-9_.-]+|\*/
+
+let type_re    = "soft"
+               | "hard"
+               | "-"
+let type       = [ label "type" . store type_re ]
+
+let item_re    = "core"
+               | "data"
+               | "fsize"
+               | "memlock"
+               | "nofile"
+               | "rss"
+               | "stack"
+               | "cpu"
+               | "nproc"
+               | "as"
+               | "maxlogins"
+               | "maxsyslogins"
+               | "priority"
+               | "locks"
+               | "sigpending"
+               | "msgqueue"
+               | "nice"
+               | "rtprio"
+               | "chroot"
+let item       = [ label "item" . store item_re ]
+
+let value      = [ label "value" . store /[A-Za-z0-9_.\/-]+/ ]
+let entry      = [ domain . spc
+                 . type   . spc
+                 . item   . spc
+                 . value  . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/security/limits.conf"
+               . incl "/etc/security/limits.d/*.conf"
+
+let xfm        = transform lns filter
diff --git a/lenses/login_defs.aug b/lenses/login_defs.aug
new file mode 100644 (file)
index 0000000..8a39514
--- /dev/null
@@ -0,0 +1,29 @@
+(*
+Module: Login_defs
+  Lense for login.defs
+
+Author: Erinn Looney-Triggs
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Configuration files
+   This lens applies to /etc/login.defs. See <filter>.
+*)
+module Login_defs =
+autoload xfm
+
+(* View: record
+    A login.defs record *)
+let record =
+  let value = store /[^ \t\n]+([ \t]+[^ \t\n]+)*/ in
+  [ key Rx.word . Sep.space . value . Util.eol ]
+
+(* View: lns
+    The login.defs lens *)
+let lns = (record | Util.comment | Util.empty) *
+
+(* View: filter *)
+let filter = incl "/etc/login.defs" . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/logrotate.aug b/lenses/logrotate.aug
new file mode 100644 (file)
index 0000000..51be590
--- /dev/null
@@ -0,0 +1,117 @@
+(* Logrotate module for Augeas                *)
+(* Author: Raphael Pinson <raphink@gmail.com> *)
+(* Patches from:                              *)
+(*   Sean Millichamp <sean@bruenor.org>       *)
+(*                                            *)
+(* Supported :                                *)
+(*   - defaults                               *)
+(*   - rules                                  *)
+(*   - (pre|post)rotate entries               *)
+(*                                            *)
+(* Todo :                                     *)
+(*                                            *)
+
+module Logrotate =
+   autoload xfm
+
+   let sep_spc = Util.del_ws_spc
+   let sep_val = del /[ \t]*=[ \t]*|[ \t]+/ " "
+   let eol = Util.eol
+   let num = /[0-9]+/
+   let word = /[^,#= \n\t{}]+/
+   let filename = /\/[^,#= \n\t{}]+/
+   let size = num . /[kMG]?/
+
+   (* define comments and empty lines *)
+   let comment (indent:string) =
+     let nl = Util.del_str "\n" in
+     [ label "#comment" . del /[ \t]*/ indent . del /#[ \t]*/ "# " .  store /([^ \t\n].*)?/ . nl ]
+   let empty   = [ del /[ \t]*\n/ "\n" ]
+
+
+   (* Useful functions *)
+
+   let list_item = [ sep_spc . key /[^\/+,# \n\t{}]+/ ]
+   let select_to_eol (kw:string) (select:regexp) (indent:string) = [ del /[ \t]*/ indent . label kw . store select . eol ]
+   let value_to_eol (kw:string) (value:regexp) (indent:string )  = [ del /[ \t]*/ indent . key kw . sep_val . store value . eol ]
+   let flag_to_eol (kw:string) (indent:string)                   = [ del /[ \t]*/ indent . key kw . eol ]
+   let list_to_eol (kw:string) (indent:string)                   = [ del /[ \t]*/ indent . key kw . list_item+ . eol ]
+
+
+   (* Defaults *)
+
+   let create (indent:string ) =
+     let mode = sep_spc . [ label "mode" . store num ] in
+     let owner = sep_spc . [ label "owner" . store word ] in
+     let group = sep_spc . [ label "group" . store word ] in
+     [ del /[ \t]*/ indent . key "create" .
+         ( mode | mode . owner | mode . owner . group )?
+                   . eol ]
+
+   let tabooext (indent:string) = [ del /[ \t]*/ indent . key "tabooext" . ( sep_spc . store /\+/ )? . list_item+ . eol ]
+
+   let attrs (indent:string) = select_to_eol "schedule" /(daily|weekly|monthly|yearly)/ indent
+                | value_to_eol "rotate" num indent
+               | create indent
+               | flag_to_eol "nocreate" indent
+               | value_to_eol "include" word indent
+               | select_to_eol "missingok" /(no)?missingok/ indent
+               | select_to_eol "compress" /(no)?compress/ indent
+               | select_to_eol "delaycompress" /(no)?delaycompress/ indent
+               | select_to_eol "ifempty" /(not)?ifempty/ indent
+               | select_to_eol "sharedscripts" /(no)?sharedscripts/ indent
+               | value_to_eol "size" size indent
+               | tabooext indent
+               | value_to_eol "olddir" word indent
+               | flag_to_eol "noolddir" indent
+               | value_to_eol "mail" word indent
+               | flag_to_eol "mailfirst" indent
+               | flag_to_eol "maillast" indent
+               | flag_to_eol "nomail" indent
+               | value_to_eol "errors" word indent
+               | value_to_eol "extension" word indent
+               | select_to_eol "dateext" /(no)?dateext/ indent
+               | value_to_eol "compresscmd" word indent
+               | value_to_eol "uncompresscmd" word indent
+               | value_to_eol "compressext" word indent
+               | list_to_eol "compressoptions" indent
+               | select_to_eol "copy" /(no)?copy/ indent
+               | select_to_eol "copytruncate" /(no)?copytruncate/ indent
+               | value_to_eol "maxage" num indent
+               | value_to_eol "minsize" size indent
+               | select_to_eol "shred" /(no)?shred/ indent
+               | value_to_eol "shredcycles" num indent
+               | value_to_eol "start" num indent
+
+   (* Define hooks *)
+
+
+   let hook_lines =
+     let line_re = /.*/ - /[ \t]*endscript[ \t]*/ in
+       store ( line_re . ("\n" . line_re)* )? . del "\n" "\n"
+
+   let hooks =
+     let hook_names = /(pre|post)rotate|(first|last)action/ in
+     [ del /[ \t]*/ "\t" . key hook_names . eol .
+       hook_lines .
+       del /[ \t]*endscript\n/ "\tendscript\n" ]
+
+   (* Define rule *)
+
+   let body = del /\{[ \t]*\n/ "{\n"
+                       . ( comment "\t" | attrs "\t" | hooks | empty )*
+                       . del /[ \t]*\}[ \t]*\n/ "}\n"
+
+   let rule =
+     [ label "rule" . Util.indent .
+         [ label "file" . store filename ] .
+        [ del /[ \t\n]+/ " " . label "file" . store filename ]* .
+        del /[ \t\n]*/ " " . body ]
+
+   let lns = ( comment "" | empty | attrs "" | rule )*
+
+   let filter = incl "/etc/logrotate.d/*"
+              . incl "/etc/logrotate.conf"
+             . Util.stdexcl
+
+   let xfm = transform lns filter
diff --git a/lenses/lokkit.aug b/lenses/lokkit.aug
new file mode 100644 (file)
index 0000000..830f956
--- /dev/null
@@ -0,0 +1,84 @@
+module Lokkit =
+  autoload xfm
+
+(* Module: Lokkit
+   Parse the config file for lokkit from system-config-firewall
+*)
+
+let comment = Util.comment
+let empty = Util.empty
+let eol = Util.eol
+let spc = Util.del_ws_spc
+let dels = Util.del_str
+
+let eq = del /[ \t=]+/ "="
+let token = store /[a-zA-Z0-9][a-zA-Z0-9-]*/
+
+let long_opt (n:regexp) =
+  [ dels "--" . key n . eq . token . eol ]
+
+let flag (n:regexp) =
+  [ dels "--" . key n . eol ]
+
+let option (l:string) (s:string) =
+  del ("--" . l | "-" . s) ("--" . l) . label l . eq
+
+let opt (l:string) (s:string) =
+  [ option l s . token . eol ]
+
+(* trust directive
+   -t <interface>, --trust=<interface>
+*)
+let trust =
+  [ option "trust" "t" . store Rx.device_name . eol ]
+
+(* port directive
+   -p <port>[-<port>]:<protocol>, --port=<port>[-<port>]:<protocol>
+*)
+let port =
+  let portnum = store /[0-9]+/ in
+  [ option "port" "p" .
+    [ label "start" . portnum ] .
+    (dels "-" . [ label "end" . portnum])? .
+    dels ":" . [ label "protocol" . token ] . eol ]
+
+(* custom_rules directive
+   --custom-rules=[<type>:][<table>:]<filename>
+*)
+let custom_rules =
+  let types = store /ipv4|ipv6/ in
+  let tables = store /mangle|nat|filter/ in
+  let filename = store /[^ \t\n:=][^ \t\n:]*/ in
+  [ dels "--custom-rules" . label "custom-rules" . eq .
+      [ label "type" . types . dels ":" ]? .
+      [ label "table" . tables . dels ":"]? .
+      filename . eol ]
+
+(* forward_port directive
+   --forward-port=if=<interface>:port=<port>:proto=<protocol>[:toport=<destination port>][:toaddr=<destination address>]
+*)
+let forward_port =
+  let elem (n:string) (v:lens) =
+    [ key n . eq . v ] in
+  let ipaddr = store /[0-9.]+/ in
+  let colon = dels ":" in
+  [ dels "--forward-port" . label "forward-port" . eq .
+      elem "if" token . colon .
+      elem "port" token . colon .
+      elem "proto" token .
+      (colon . elem "toport" token)? .
+      (colon . elem "toaddr" ipaddr)? . eol ]
+
+let entry =
+  long_opt /selinux|selinuxtype|addmodule|removemodule|block-icmp/
+ |flag /enabled|disabled/
+ |opt "service" "s"
+ |port
+ |trust
+ |opt "masq" "m"
+ |custom_rules
+ |forward_port
+
+let lns = (comment|empty|entry)*
+
+let xfm = transform lns (incl "/etc/sysconfig/system-config-firewall")
diff --git a/lenses/mke2fs.aug b/lenses/mke2fs.aug
new file mode 100644 (file)
index 0000000..6d1bdc6
--- /dev/null
@@ -0,0 +1,140 @@
+(*
+Module: Mke2fs
+  Parses /etc/mke2fs.conf
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man 5 mke2fs.conf` where possible.
+
+About: License
+   This file is licenced under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+   To be documented
+
+About: Configuration files
+   This lens applies to /etc/mke2fs.conf. See <filter>.
+*)
+
+
+module Mke2fs =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* View: comment *)
+let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
+
+(* View: sep *)
+let sep = IniFile.sep /=[ \t]*/ "="
+
+(* View: empty *)
+let empty = IniFile.empty
+
+
+(************************************************************************
+ * Group:                 RECORD TYPES
+ *************************************************************************)
+
+
+(* View: entry
+    A generic entry for lens lns *)
+let entry (kw:regexp) (lns:lens) = Build.key_value_line kw sep lns
+
+
+(* View: list_sto
+    A list of values with given lens *)
+let list_sto (kw:regexp) (lns:lens) = counter "item" .
+                                          entry kw
+                                            (Build.opt_list 
+                                              [lns]
+                                              Sep.comma)
+
+(* View: entry_sto
+    Store a regexp as entry value *)
+let entry_sto (kw:regexp) (val:regexp) = entry kw (store val)
+
+
+(************************************************************************
+ * Group:                 COMMON ENTRIES
+ *************************************************************************)
+(* View: common_entry
+     Entries shared between <defaults> and <fs_types> sections *)
+let common_entry   = list_sto ("base_features"|"default_features")
+                        (key Rx.word)
+                   | entry_sto "blocksize" ("-"? . Rx.integer)
+                   | entry_sto "hash_alg" ("legacy"|"half_md4"|"tea")
+                   | entry_sto ("inode_ratio"|"inode_size") Rx.integer
+
+(************************************************************************
+ * Group:                 DEFAULTS SECTION
+ *************************************************************************)
+
+(* View: defaults_entry
+    Possible entries under the <defaults> section *)
+let defaults_entry = entry_sto "force_undo" ("true"|"false")
+                   | entry_sto "fs_type" Rx.word
+                   | entry_sto "undo_dir" Rx.fspath
+                   
+(* View: defaults_title
+    Title for the <defaults> section *)
+let defaults_title  = IniFile.title "defaults"
+
+(* View: defaults
+    A defaults section *)
+let defaults = IniFile.record defaults_title
+                  ((Util.indent . (defaults_entry|common_entry)) | comment)
+
+
+(************************************************************************
+ * Group:                 FS_TYPES SECTION
+ *************************************************************************)
+
+(* View: fs_types_entry
+    Possible entries under a <fs_types_record> group *)
+let fs_types_entry =list_sto "features"
+                        ([del /\^/ "^" . label "disable"]?
+                                           . key Rx.word)
+                   | list_sto "options"
+                        (key Rx.word . Util.del_str "="
+                       . store Rx.word)
+                   | entry_sto "lazy_itable_init" ("true"|"false")
+                   | entry_sto "flex_bg_size" Rx.integer
+
+(* View: fs_types_record
+     Fs group records under the <fs_types> section *)
+let fs_types_record = [ label "filesystem"
+                     . Util.indent . store Rx.word
+                     . del /[ \t]*=[ \t]*\{[ \t]*\n/ " = {\n"
+                     . ((Util.indent . (fs_types_entry|common_entry)) | empty | comment)*
+                     . del /[ \t]*\}[ \t]*\n/ " }\n" ]
+
+(* View: fs_types_title
+    Title for the <fs_types> section *)
+let fs_types_title = IniFile.title "fs_types"
+
+(* View: fs_types
+    A fs_types section *)
+let fs_types = IniFile.record fs_types_title
+                  (fs_types_record | comment)
+
+
+(************************************************************************
+ * Group:                 LENS AND FILTER
+ *************************************************************************)
+
+(* View: lns
+     The mke2fs lens
+*)
+let lns = (empty|comment)* . (defaults|fs_types)*
+
+(* Variable: filter *)
+let filter = incl "/etc/mke2fs.conf"
+    . Util.stdexcl
+
+let xfm = transform lns filter
+
+
diff --git a/lenses/modprobe.aug b/lenses/modprobe.aug
new file mode 100644 (file)
index 0000000..bdecafb
--- /dev/null
@@ -0,0 +1,56 @@
+(*
+Module: Modprobe
+  Parses /etc/modprobe.conf and /etc/modprobe.d/*
+*)
+module Modprobe =
+autoload xfm
+
+let comment = Util.comment
+let empty = Util.empty
+let eol = Util.eol | Util.comment
+
+(* modprobe.conf allows continuing a line by ending it with backslash +
+   newline; the backslash + newline token is suppressed We handle an
+   approximation of that by classifying backslash + newline as a
+   separator.
+*)
+
+(* A separator is either whitespace or \ followed by newline *)
+let sep_ch = /[ \t]|\\\\\n/
+(* Anything that's not a separator is part of a token *)
+let tok_ch = /[^ \t\n#\\]|\\\\[^ \t\n]/
+
+let spc = del sep_ch+ " "
+let token = store tok_ch+
+let indent = Util.del_opt_ws ""
+
+let cmd (n:regexp) = key n . spc
+let arg (n:string) = [ label n . token ]
+let token_to_eol = store (tok_ch . /([^#\n\\]|\\\\\n)*/ . tok_ch | tok_ch)
+
+let options =
+  let opt_ch = /[A-Za-z0-9_]/ in
+  let option = [ spc . key opt_ch+ . (del /=/ "=" . token)? ] in
+    [ cmd "options" . token . option* . eol ]
+
+let alias = [ cmd "alias" . token . spc . arg "modulename" . eol ]
+
+let include = [ cmd "include" . token . eol ]
+
+let cmd_token_to_eol (n:regexp) = [ cmd n . token_to_eol . eol ]
+
+let entry = alias
+  | include
+  | options
+  | cmd_token_to_eol /install|remove/
+  | [ cmd "blacklist" . token . eol ]
+  | [ cmd "config" . store /binary_indexes|yes|no/ ]
+
+let lns = (comment|empty|entry)*
+
+let filter = (incl "/etc/modprobe.conf") .
+  (incl "/etc/modprobe.d/*").
+  (incl "/etc/modprobe.conf.local").
+  Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/modules_conf.aug b/lenses/modules_conf.aug
new file mode 100644 (file)
index 0000000..5245e5f
--- /dev/null
@@ -0,0 +1,42 @@
+(*
+Module: Modules_conf
+  Parses /etc/modules.conf and /etc/conf.modules
+
+  Based on the similar Modprobe lens
+
+  Not all directives currently listed in modules.conf(5) are currently
+  supported.
+*)
+module Modules_conf =
+autoload xfm
+
+let comment = Util.comment
+let empty = Util.empty
+let eol = Util.eol | Util.comment
+
+(* Basic file structure is the same as modprobe.conf *)
+let cmd (n:regexp) = Modprobe.cmd n
+let token_to_eol = Modprobe.token_to_eol
+
+let path = [ key "path" . del "=" "=" . token_to_eol . eol ]
+let keep = [ key "keep" . eol ]
+let probeall = [ cmd "probeall" . token_to_eol . eol ]
+
+let entry =
+    Modprobe.alias
+  | Modprobe.options
+  | Modprobe.include
+  | Modprobe.cmd_token_to_eol /install|pre-install|post-install/
+  | Modprobe.cmd_token_to_eol /remove|pre-remove|post-remove/
+  | keep
+  | path
+  | probeall
+  
+
+let lns = (comment|empty|entry)*
+
+let filter = (incl "/etc/modules.conf") .
+  (incl "/etc/conf.modules").
+  Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/monit.aug b/lenses/monit.aug
new file mode 100644 (file)
index 0000000..dde4573
--- /dev/null
@@ -0,0 +1,70 @@
+(* Monit module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man monit (1), section "HOW TO MONITOR"
+
+ "A monit control file consists of a series of service entries and
+  global option statements in a free-format, token-oriented syntax.
+
+  Comments begin with a # and extend through the end of the line. There
+  are three kinds of tokens in the control file: grammar keywords, numbers
+  and strings. On a semantic level, the control file consists of three
+  types of statements:
+
+  1. Global set-statements
+      A global set-statement starts with the keyword set and the item to
+      configure.
+
+  2. Global include-statement
+      The include statement consists of the keyword include and a glob
+      string.
+
+  3. One or more service entry statements.
+       A service entry starts with the keyword check followed by the
+       service type"
+
+*)
+
+module Monit =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let spc        = Sep.space
+let comment    = Util.comment
+let empty      = Util.empty
+
+let sto_to_spc = store Rx.space_in
+let sto_no_spc = store Rx.no_spaces
+
+let word       = Rx.word
+let value      = Build.key_value_line word spc sto_to_spc
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+(* set statement *)
+let set        = Build.key_value "set" spc value
+
+(* include statement *)
+let include    = Build.key_value_line "include" spc sto_to_spc
+
+(* service statement *)
+let service    = Build.key_value "check" spc (Build.list value spc)
+
+let entry      = (set|include|service)
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/monit/monitrc"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/multipath.aug b/lenses/multipath.aug
new file mode 100644 (file)
index 0000000..82a6c16
--- /dev/null
@@ -0,0 +1,95 @@
+(* Process /etc/multipath.conf                             *)
+(* The lens is based on the multipath.conf(5) man page     *)
+module Multipath =
+
+autoload xfm
+
+let comment = Util.comment
+let empty = Util.empty
+let dels = Util.del_str
+let eol = Util.eol
+
+let ws = del /[ \t]+/ " "
+let indent = del /[ \t]*/ ""
+(* We require that braces are always followed by a newline *)
+let obr = del /\{([ \t]*)\n/ "{\n"
+let cbr = del /[ \t]*}[ \t]*\n/ "}\n"
+
+let ikey (k:regexp) = indent . key k
+
+let section (n:regexp) (b:lens) =
+  [ ikey n . ws . obr . (b|empty|comment)* . cbr ]
+
+let kv (k:regexp) (v:regexp) =
+  [ ikey k . ws . store v . eol ]
+
+(* FIXME: it would be much more concise to write                       *)
+(* [ key k . ws . (bare | quoted) ]                                    *)
+(* but the typechecker trips over that                                 *)
+let qstr (k:regexp) =
+  let delq = del /['"]/ "\"" in
+  let bare = del /["']?/ "" . store /[^"' \t\n]+/ . del /["']?/ "" in
+  let quoted = delq . store /.*[ \t].*/ . delq in
+  [ ikey k . ws . bare . eol ]
+ |[ ikey k . ws . quoted . eol ]
+
+let wwid = kv "wwid" (Rx.word|"*")
+
+(* Settings that can be changed in various places *)
+let common_setting =
+  kv "path_grouping_policy"
+    /failover|multibus|group_by_(serial|prio|node_name)/
+ |qstr /(getuid|prio)_callout/
+ |qstr /path_(selector|checker)|features/
+ |kv "failback" (Rx.integer | /immediate|manual/)
+ |kv "rr_weight" /priorities|uniform/
+ |kv "no_path_retry" (Rx.integer | /fail|queue/)
+ |kv "rr_min_io" Rx.integer
+
+(* A device subsection *)
+let device =
+  let setting =
+    qstr /vendor|product|product_blacklist|hardware_handler/
+   |common_setting in
+  section "device" setting
+
+(* The defaults section *)
+let defaults =
+  let setting =
+    common_setting
+   |kv "polling_interval" Rx.integer
+   |kv "udev_dir" Rx.fspath
+   |qstr "selector"
+   |kv "user_friendly_names" /yes|no/
+   (* These are not in the manpage but in the example multipath.conf *)
+   |kv "prio" Rx.word
+   |kv "max_fds" Rx.integer in
+  section "defaults" setting
+
+(* The blacklist and blacklist_exceptions sections *)
+let blacklist =
+  let setting =
+    wwid
+   |qstr "devnode"
+   |device in
+  section /blacklist(_exceptions)?/ setting
+
+(* A multipath subsection *)
+let multipath =
+  let setting =
+    wwid
+   |qstr "alias"
+   |common_setting in
+  section "multipath" setting
+
+(* The multipaths section *)
+let multipaths =
+  section "multipaths" multipath
+
+(* The devices section *)
+let devices =
+  section "devices" device
+
+let lns = (comment|empty|defaults|blacklist|devices|multipaths)*
+
+let xfm = transform lns (incl "/etc/multipath.conf")
diff --git a/lenses/mysql.aug b/lenses/mysql.aug
new file mode 100644 (file)
index 0000000..ad1b1f9
--- /dev/null
@@ -0,0 +1,41 @@
+(* MySQL module for Augeas                    *)
+(* Author: Tim Stoop <tim@kumina.nl>          *)
+(* Heavily based on php.aug by Raphael Pinson *)
+(* <raphink@gmail.com>                        *)
+(*                                            *)
+
+module MySQL =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+let comment  = IniFile.comment IniFile.comment_re "#"
+
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+
+let entry    = [ key IniFile.entry_re . sep . IniFile.sto_to_comment . (comment|IniFile.eol) ] | 
+               [ key IniFile.entry_re . store // . (comment|IniFile.eol) ] | 
+               [ key /\![A-Za-z][A-Za-z0-9\._-]+/ . del / / " " . store /\/[A-Za-z0-9\.\/_-]+/ . (comment|IniFile.eol) ] |
+               comment
+
+(************************************************************************
+ * sections, led by a "[section]" header
+ * We can't use titles as node names here since they could contain "/"
+ * We remove #comment from possible keys
+ * since it is used as label for comments
+ * We also remove / as first character
+ * because augeas doesn't like '/' keys (although it is legal in INI Files)
+ *************************************************************************)
+let title   = IniFile.indented_title_label "target" IniFile.record_label_re
+let record  = IniFile.record title entry
+
+let lns    = IniFile.lns record comment
+
+let filter = (incl "/etc/mysql/my.cnf")
+             . (incl "/etc/mysql/conf.d/*.cnf")
+             . (incl "/etc/my.cnf")
+             . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/nagioscfg.aug b/lenses/nagioscfg.aug
new file mode 100644 (file)
index 0000000..a29e6bf
--- /dev/null
@@ -0,0 +1,44 @@
+(*
+Module: NagiosConfig
+  Parses /etc/nagios3/*.cfg
+
+Authors: Sebastien Aperghis-Tramoni <sebastien@aperghis.net>
+         Raphaël Pinson <raphink@gmail.com>
+
+About: License
+  This file is licenced under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  To be documented
+
+About: Configuration files
+  This lens applies to /etc/nagios3/*.cfg. See <filter>.
+*)
+
+module NagiosCfg =
+    autoload xfm
+
+    (* View: param_def
+        define a field *)
+    let param_def =
+               key /[A-Za-z0-9_]+/
+             . Sep.opt_space . Sep.equal
+             . Sep.opt_space . store Rx.no_spaces
+
+    (* View: param
+        Params can have sub params *)
+    let param =
+         [ Util.indent . param_def
+         . [ Sep.space . param_def ]*
+         . Util.eol ]
+
+    (* View: lns
+        main structure *)
+    let lns = ( Util.empty | Util.comment | param )*
+
+    (* View: filter *)
+    let filter = incl "/etc/nagios3/*.cfg"
+               . Util.stdexcl
+
+    let xfm = transform lns filter
+
diff --git a/lenses/nagiosobjects.aug b/lenses/nagiosobjects.aug
new file mode 100644 (file)
index 0000000..50ce6d3
--- /dev/null
@@ -0,0 +1,58 @@
+(*
+Module: NagiosObjects
+  Parses /etc/nagios3/objects/*.cfg
+
+Authors: Sebastien Aperghis-Tramoni <sebastien@aperghis.net>
+         Raphaël Pinson <raphink@gmail.com>
+
+About: License
+  This file is licenced under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  To be documented
+
+About: Configuration files
+
+  This lens applies to /etc/nagios3/objects/*.cfg. See <filter>.
+*)
+
+module NagiosObjects =
+    autoload xfm
+
+    (* basic atoms *)
+    let eol = Util.eol
+    let ws  = Sep.space
+
+    let keyword      = key /[A-Za-z0-9_]+/
+
+    (* define an empty line *)
+    let empty = Util.empty
+
+    (* define a comment *)
+    let comment = Util.comment
+
+    (* define a field *)
+    let object_field    =
+       let field_name      = keyword in
+       let field_value     = store Rx.space_in in
+          [ Util.indent . field_name . ws
+                        . field_value . eol ]
+
+    (* define an object *)
+    let object_def  =
+       let object_type = keyword in
+          [ Util.indent
+          . Util.del_str "define" . ws
+          . object_type . ws
+          . Util.del_str "{" . eol
+          . ( empty | comment | object_field )*
+          . Util.del_str "}" . eol ]
+
+    (* main structure *)
+    let lns = ( empty | comment | object_def )*
+
+    let filter = incl "/etc/nagios3/objects/*.cfg"
+               . Util.stdexcl
+
+    let xfm = transform lns filter
+
diff --git a/lenses/nrpe.aug b/lenses/nrpe.aug
new file mode 100644 (file)
index 0000000..2936bc8
--- /dev/null
@@ -0,0 +1,96 @@
+(*
+Module: Nrpe
+  Parses nagios-nrpe configuration files.
+
+Author: Marc Fournier <marc.fournier@camptocamp.com>
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+
+module Nrpe =
+  autoload xfm
+
+
+let eol = Util.eol
+let eq = Sep.equal
+
+(* View: word *)
+let word = /[^=\n\t ]+/
+
+
+(* View: command
+    nrpe.cfg usually has many entries defining commands to run
+
+    > command[check_foo]=/path/to/nagios/plugin -w 123 -c 456
+    > command[check_bar]=/path/to/another/nagios/plugin --option
+*)
+let command =
+  let obrkt = del /\[/ "[" in
+  let cbrkt = del /\]/ "]" in
+    [ key "command" .
+    [ obrkt . key /[^]\/\n]+/ . cbrkt . eq
+            . store /[^=\n]+/ . del /\n/ "\n" ]
+    ]
+
+
+(* View: item_re
+     regular entries re *)
+let item_re = "server_port"
+            | "command_prefix"
+            | "server_address"
+            | "allowed_hosts"
+            | "debug"
+            | "nrpe_user"
+            | "nrpe_group"
+            | "dont_blame_nrpe"
+            | "command_timeout"
+            | "connection_timeout"
+            | "allow_weak_random_seed"
+            | "pid_file"
+            | "log_facility"
+
+(* View: item
+     regular entries *)
+let item = [ key item_re . eq . store word . eol ]
+
+
+(* View: include
+    An include entry.
+
+    nrpe.cfg can include more than one file or directory of files
+
+    > include=/path/to/file1.cfg
+    > include=/path/to/file2.cfg
+*)
+let include = [ key "include" .
+  [ label "file" . eq . store word . eol ]
+]
+
+(* View: include_dir
+    > include_dir=/path/to/dir/
+*)
+let include_dir = [ key "include_dir" .
+  [ label "dir" . eq . store word . eol ]
+]
+
+
+(* View: comment
+    Nrpe comments must start at beginning of line *)
+let comment = Util.comment_generic /#[ \t]*/ "# "
+
+(* blank lines and empty comments *)
+let empty = Util.empty
+
+(* View: lns
+    The Nrpe lens *)
+let lns = ( command | item | include | include_dir | comment | empty ) *
+
+(* View: filter
+    File filter *)
+let filter = Util.stdexcl .
+             incl "/etc/nrpe.cfg" .
+             incl "/etc/nagios/nrpe.cfg"
+
+let xfm = transform lns (filter)
+
diff --git a/lenses/nsswitch.aug b/lenses/nsswitch.aug
new file mode 100644 (file)
index 0000000..c675f29
--- /dev/null
@@ -0,0 +1,94 @@
+(*
+Module: Nsswitch
+  Parses /etc/nsswitch.conf
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man nsswitch.conf` where possible.
+
+About: Licence
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+
+About: Configuration files
+  This lens applies to /etc/nsswitch.conf. See <filter>.
+*)
+
+module Nsswitch =
+autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* View: comment *)
+let comment = Util.comment
+
+(* View: empty *)
+let empty = Util.empty
+
+(* View: sep_colon
+    The separator for database entries *)
+let sep_colon = del /:[ \t]*/ ": "
+
+(* View: service
+    The service specification like `files', `db', or `nis' *)
+let service = [ label "service" . store Rx.word ]
+
+(* View: reaction
+    The reaction on lookup result like `[NOTFOUND=return]'
+    TODO: Use case-insensitive regexps when ticket #147 is fixed.
+*)
+let reaction =
+  let status_kw = /[Ss][Uu][Cc][Cc][Ee][Ss][Ss]/
+                | /[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]/
+                | /[Uu][Nn][Aa][Vv][Aa][Ii][Ll]/
+                | /[Tt][Rr][Yy][Aa][Gg][Aa][Ii][Nn]/
+    in let action_kw = /[Rr][Ee][Tt][Uu][Rr][Nn]/
+                     | /[Cc][Oo][Nn][Tt][Ii][Nn][Uu][Ee]/
+      in let negate = [ Util.del_str "!" . label "negate" ]
+        in let reaction_entry = [ label "status" . negate?
+                                . store status_kw
+                                . Util.del_str "="
+                                . [ label "action" . store action_kw ] ]
+          in Util.del_str "["
+             . [ label "reaction"
+               . (Build.opt_list reaction_entry Sep.space) ]
+             . Util.del_str "]"
+
+(* View: database *)
+let database = 
+  let database_kw = "aliases"
+                  | "automount"
+                  | "bootparams"
+                  | "ethers"
+                  | "group"
+                  | "hosts"
+                  | "netgroup"
+                  | "netmasks"
+                  | "networks"
+                  | "passwd"
+                  | "protocols"
+                  | "publickey"
+                  | "rpc"
+                  | "sendmailvars"
+                  | "services"
+                  | "shadow"
+                  | "sudoers"
+    in [ label "database" . store database_kw
+               . sep_colon
+               . (Build.opt_list
+                    (service|reaction)
+                    Sep.space)
+               . Util.eol ]
+
+(* View: lns *)
+let lns = ( empty | comment | database )*
+
+(* Variable: filter *)
+let filter = (incl "/etc/nsswitch.conf")
+    . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/ntp.aug b/lenses/ntp.aug
new file mode 100644 (file)
index 0000000..c9c4b72
--- /dev/null
@@ -0,0 +1,123 @@
+(* NTP module for Augeas                      *)
+(* Author: Raphael Pinson <raphink@gmail.com> *)
+(*                                            *)
+(* Status: basic settings supported           *)
+
+module Ntp =
+  autoload xfm
+
+
+    (* Define useful shortcuts *)
+
+    let eol = del /[ \t]*/ "" . [ label "#comment" . store /#.*/]?
+            . Util.del_str "\n"
+    let sep_spc = Util.del_ws_spc
+    let word = /[^,# \n\t]+/
+    let num  = /[0-9]+/
+
+
+    (* define comments and empty lines *)
+    let comment = [ label "#comment" . del /#[ \t]*/ "#" .
+                    store /([^ \t\n][^\n]*)?/ . del "\n" "\n" ]
+    let empty   = [ del /[ \t]*\n/ "\n" ]
+
+
+    let kv (k:regexp) (v:regexp) =
+      [ key k . sep_spc. store v . eol ]
+
+    (* Define generic record *)
+    let record (kw:regexp) (value:lens) =
+      [ key kw . sep_spc . store word . value . eol ]
+
+    (* Define a command record; see confopt.html#cfg in the ntp docs *)
+    let command_record =
+      let opt = [ sep_spc . key /minpoll|maxpoll|ttl|version|key/ .
+                      sep_spc . store word ]
+        | [ sep_spc . key (/autokey|burst|iburst|noselect|preempt/ |
+                           /prefer|true|dynamic/) ] in
+      let cmd = /server|peer|broadcast|manycastclient/
+        | /multicastclient|manycastserver/ in
+        record cmd opt*
+
+    let broadcastclient =
+      [ key "broadcastclient" . [ sep_spc . key "novolley" ]? . eol ]
+
+    (* Define a fudge record *)
+    let fudge_opt_re = "refid" | "stratum"
+    let fudge_opt  = [ sep_spc . key fudge_opt_re . sep_spc . store word ]
+    let fudge_record = record "fudge" fudge_opt?
+
+    (* Define simple settings, see miscopt.html in ntp docs *)
+    let flags =
+      let flags_re = /auth|bclient|calibrate|kernel|monitor|ntp|pps|stats/ in
+      let flag = [ label "flag" . store flags_re ] in
+        [ key /enable|disable/ . (sep_spc . flag)* . eol ]
+
+    let simple_setting (k:regexp) = kv k word
+
+    (* Still incomplete, misses logconfig, phone, setvar, tos,
+       trap, ttl *)
+    let simple_settings =
+        kv "broadcastdelay" Rx.decimal
+      | flags
+      | simple_setting /driftfile|leapfile|logfile|includefile/
+         | simple_setting "statsdir"
+
+    (* Misc commands, see miscopt.html in ntp docs *)
+
+    (* Define restrict *)
+    let restrict_record   =
+      let action    = [ label "action" . sep_spc . store word ] in
+      [ key "restrict" . sep_spc .
+          [ label "ipv6" . Util.del_str "-6" . sep_spc ]? .
+          store (word - "-6") . action* . eol ]
+
+    (* Define statistics *)
+    let statistics_flag (kw:string) = [ sep_spc . key kw ]
+
+    let statistics_opts = statistics_flag "loopstats"
+                        | statistics_flag "peerstats"
+                       | statistics_flag "clockstats"
+                       | statistics_flag "rawstats"
+
+    let statistics_record = [ key "statistics" . statistics_opts* . eol ]
+
+
+    (* Define filegen *)
+    let filegen = del /filegen[ \t]+/ "filegen " . store word
+    let filegen_opt (kw:string) = [ sep_spc . key kw . sep_spc . store word ]
+    (* let filegen_flag (kw:string) = [ label kw . sep_spc . store word ] *)
+    let filegen_select (kw:string) (select:regexp) = [ label kw . sep_spc . store select ]
+
+    let filegen_opts = filegen_opt "file"
+                     | filegen_opt "type"
+                    | filegen_select "enable" /(en|dis)able/
+                    | filegen_select "link" /(no)?link/
+
+    let filegen_record = [ label "filegen" . filegen . filegen_opts* . eol ]
+
+    (* Authentication commands, see authopt.html#cmd; incomplete *)
+    let auth_command =
+      [ key /controlkey|keys|keysdir|requestkey/ .
+            sep_spc . store word . eol ]
+     | [ key /autokey|revoke/ . [sep_spc . store word]? . eol ]
+     | [ key /trustedkey/ . [ sep_spc . label "key" . store word ]+ . eol ]
+
+    (* tinker [step step | panic panic | dispersion dispersion |
+               stepout stepout | minpoll minpoll | allan allan | huffpuff huffpuff] *)
+    let tinker =
+      let arg_names = /step|panic|dispersion|stepout|minpoll|allan|huffpuff/ in
+      let arg = [ key arg_names . sep_spc . store Rx.decimal ] in
+      [ key "tinker" . (sep_spc . arg)* . eol ]
+
+    (* Define lens *)
+
+    let lns = ( comment | empty | command_record | fudge_record
+              | restrict_record | simple_settings | statistics_record
+              | filegen_record | broadcastclient
+              | auth_command | tinker )*
+
+    let filter = (incl "/etc/ntp.conf")
+        . Util.stdexcl
+
+    let xfm = transform lns filter
diff --git a/lenses/odbc.aug b/lenses/odbc.aug
new file mode 100644 (file)
index 0000000..633891d
--- /dev/null
@@ -0,0 +1,43 @@
+(*
+ ODBC lens for Augeas
+ Author: Marc Fournier <marc.fournier@camptocamp.com>
+
+ odbc.ini and odbcinst.ini are standard INI files.
+*)
+
+
+module Odbc =
+  autoload xfm
+
+(************************************************************************
+ *                     INI File settings
+ * odbc.ini only supports "# as commentary and "=" as separator
+ ************************************************************************)
+let comment    = IniFile.comment "#" "#"
+let sep        = IniFile.sep "=" "="
+
+
+(************************************************************************
+ *                        ENTRY
+ * odbc.ini uses standard INI File entries
+ ************************************************************************)
+let entry   = IniFile.indented_entry IniFile.entry_re sep comment
+
+
+(************************************************************************
+ *                        RECORD
+ * odbc.ini uses standard INI File records
+ ************************************************************************)
+let title   = IniFile.indented_title IniFile.record_re
+let record  = IniFile.record title entry
+
+
+(************************************************************************
+ *                        LENS & FILTER
+ ************************************************************************)
+let lns     = IniFile.lns record comment
+
+let filter = incl "/etc/odbc.ini"
+           . incl "/etc/odbcinst.ini"
+
+let xfm = transform lns filter
diff --git a/lenses/openvpn.aug b/lenses/openvpn.aug
new file mode 100644 (file)
index 0000000..0685888
--- /dev/null
@@ -0,0 +1,205 @@
+(* OpenVPN module for Augeas
+ Author: Raphael Pinson <raphink@gmail.com>
+
+ Reference: http://openvpn.net/index.php/documentation/howto.html
+*)
+
+
+module OpenVPN =
+  autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol    = Util.eol
+let indent = Util.indent
+
+(* Define separators *)
+let sep    = Util.del_ws_spc
+let sep_dquote = Util.del_str "\""
+
+(* Define value regexps *)
+let ip_re  = Rx.ipv4
+let num_re = Rx.integer
+let fn_re  = /[^#; \t\n][^#;\n]*[^#; \t\n]|[^#; \t\n]/
+let an_re  = /[a-z][a-z0-9_-]*/
+
+(* Define store aliases *)
+let ip     = store ip_re
+let num    = store num_re
+let filename = store fn_re
+let sto_to_dquote = store /[^"\n]+/   (* " Emacs, relax *)
+
+(* define comments and empty lines *)
+let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
+let comment_or_eol = eol | Util.comment_generic /[ \t]*[;#][ \t]*/ " # "
+
+let empty   = Util.empty
+
+
+(************************************************************************
+ *                               SINGLE VALUES
+ *
+ *   - local => IP
+ *   - port  => num
+ *   - proto => tcp|udp
+ *   - dev   => (tun|tap)\d*
+ *   - dev-node => MyTap
+ *   - ca    => filename
+ *   - cert  => filename
+ *   - key   => filename
+ *   - dh    => filename
+ *   - ifconfig-pool-persist => filename
+ *   - learn-address => filename
+ *   - cipher => [A-Z0-9-]+
+ *   - max-clients => num
+ *   - user  => alphanum
+ *   - group => alphanum
+ *   - status => filename
+ *   - log   => filename
+ *   - log-append => filename
+ *   - verb => num
+ *   - mute => num
+ *   - ns-cert-type => "server"
+ *   - resolv-retry => "infinite"
+ *************************************************************************)
+
+let single_ip  = "local"
+let single_num = "port"
+               | "max-clients"
+               | "verb"
+              | "mute"
+let single_fn  = "ca"
+               | "cert"
+              | "key"
+              | "dh"
+              | "ifconfig-pool-persist"
+              | "learn-address"
+              | "status"
+              | "log"
+              | "log-append"
+let single_an  = "user"
+               | "group"
+
+
+let single_entry (kw:regexp) (re:regexp)
+               = [ key kw . sep . store re . comment_or_eol ]
+
+let single     = single_entry single_num num_re
+              | single_entry single_fn  fn_re
+              | single_entry single_an  an_re
+              | single_entry "local"    ip_re
+              | single_entry "proto"    /(tcp|udp)/
+               | single_entry "dev"      /(tun|tap)[0-9]*/
+              | single_entry "dev-node" "MyTap"
+              | single_entry "cipher"   /[A-Z][A-Z0-9-]*/
+              | single_entry "ns-cert-type" "server"
+              | single_entry "resolv-retry" "infinite"
+
+
+(************************************************************************
+ *                               FLAGS
+ *
+ *   - client-to-client
+ *   - duplicate-cn
+ *   - comp-lzo
+ *   - persist-key
+ *   - persist-tun
+ *   - client
+ *   - remote-random
+ *   - nobind
+ *   - mute-replay-warnings
+ *   - http-proxy-retry
+ *************************************************************************)
+
+let flag_words = "client-to-client"
+               | "duplicate-cn"
+              | "comp-lzo"
+              | "persist-key"
+              | "persist-tun"
+              | "client"
+              | "remote-random"
+              | "nobind"
+              | "mute-replay-warnings"
+              | "http-proxy-retry"
+
+let flag_entry (kw:regexp)
+               = [ key kw . comment_or_eol ]
+
+let flag       = flag_entry flag_words
+
+
+(************************************************************************
+ *                               OTHER FIELDS
+ *
+ *   - server        => IP IP
+ *   - server-bridge => IP IP IP IP
+ *   - push          => "string"
+ *   - keepalive     => num num
+ *   - tls-auth      => filename [01]
+ *   - remote        => hostname/IP num
+ *************************************************************************)
+
+let server        = [ key "server" . sep
+                    . [ label "address" . ip ] . sep
+                   . [ label "netmask" . ip ] . comment_or_eol
+                   ]
+
+let server_bridge = [ key "server-bridge" . sep
+                    . [ label "address" . ip ] . sep
+                   . [ label "netmask" . ip ] . sep
+                   . [ label "start"   . ip ] . sep
+                   . [ label "end"     . ip ] . comment_or_eol
+                   ]
+
+let push          = [ key "push" . sep
+                    . sep_dquote
+                   . sto_to_dquote
+                   . sep_dquote
+                   . comment_or_eol
+                    ]
+
+let keepalive     = [ key "keepalive" . sep
+                    . [ label "ping"    . num ] . sep
+                   . [ label "timeout" . num ] . comment_or_eol
+                    ]
+
+let tls_auth      = [ key "tls-auth" . sep
+                    . [ label "key"       . filename     ] . sep
+                   . [ label "is_client" . store /[01]/ ] . comment_or_eol
+                    ]
+
+let remote        = [ key "remote" . sep
+                    . [ label "server" . filename ] . sep
+                   . [ label "port"   . num      ] . comment_or_eol
+                   ]
+
+let http_proxy    = [ key "http-proxy" .
+                    ( sep . [ label "server" . store /[A-Za-z0-9\._-]+/ ] .
+                   ( sep . [ label "port"   . num      ] )? )?
+                   . comment_or_eol
+                   ]
+
+let other         = server
+                  | server_bridge
+                  | push
+                 | keepalive
+                 | tls_auth
+                 | remote
+                 | http_proxy
+
+
+(************************************************************************
+ *                              LENS & FILTER
+ *************************************************************************)
+
+let lns    = ( comment | empty | single | flag | other )*
+
+let filter = (incl "/etc/openvpn/client.conf")
+           . (incl "/etc/openvpn/server.conf")
+
+let xfm = transform lns filter
+
+
+
diff --git a/lenses/pam.aug b/lenses/pam.aug
new file mode 100644 (file)
index 0000000..14408be
--- /dev/null
@@ -0,0 +1,46 @@
+(* Proces /etc/pam.d *)
+module Pam =
+  autoload xfm
+
+  let eol = Util.eol
+  let indent = Util.indent
+
+  (* For the control syntax of [key=value ..] we could split the key value *)
+  (* pairs into an array and generate a subtree control/N/KEY = VALUE      *)
+  let control = /(\[[^]#\n]*\]|[^[ \t][^ \t]*)/
+  let word = /[^# \t\n]+/
+  (* Allowed types. FIXME: Should be case insensitive *)
+  let types = /(auth|session|account|password)/
+
+  (* This isn't entirely right: arguments enclosed in [ .. ] are allowed   *)
+  (* and should be parsed as one                                           *)
+  let argument = /[^#\n \t]+/
+
+  let comment = Util.comment
+  let comment_or_eol = Util.comment_or_eol
+  let empty   = Util.empty
+
+
+  (* Not mentioned in the man page, but Debian uses the syntax             *)
+  (*   @include module                                                     *)
+  (* quite a bit                                                           *)
+  let include = [ indent . Util.del_str "@" . key "include" .
+                  Util.del_ws_spc . store word . eol ]
+
+  let record = [ seq "record" . indent .
+                   [ label "optional" . del "-" "-" ]? .
+                   [ label "type" . store types ] .
+                   Util.del_ws_tab .
+                   [ label "control" . store control] .
+                   Util.del_ws_tab .
+                   [ label "module" . store word ] .
+                   [ Util.del_ws_tab . label "argument" . store argument ]* .
+                comment_or_eol
+               ]
+  let lns = ( empty | comment | include | record ) *
+
+  let xfm = transform lns ((incl "/etc/pam.d/*") . Util.stdexcl)
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/passwd.aug b/lenses/passwd.aug
new file mode 100644 (file)
index 0000000..8ea0541
--- /dev/null
@@ -0,0 +1,70 @@
+(* Passwd module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man 5 passwd
+
+*)
+
+module Passwd =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let comment    = Util.comment
+let empty      = Util.empty
+let dels       = Util.del_str
+
+let colon      = del /:/ ":"
+
+let sto_to_col  = store /[^:\n]+/
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+let word       = /[A-Za-z0-9_.-]+/
+let integer    = /[0-9]+/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word
+                . colon
+                . [ label "password" . store word    . colon ]
+                . [ label "uid"      . store integer . colon ]
+                . [ label "gid"      . store integer . colon ]
+                . [ label "name"     . sto_to_col?   . colon ]
+                . [ label "home"     . sto_to_col?  . colon ]
+                . [ label "shell"    . sto_to_eol? ]
+                . eol ]
+
+(* A NIS entry has nothing bar the +@:::::: bits. *)
+let nisentry =
+  let nisuser = /\+\@[A-Za-z0-9_.-]+/ in
+  let colons = "::::::" in
+  [ dels "+@" . label "@nis" . store word . dels colons . eol ]
+
+let nisdefault =
+  let overrides =
+        colon
+      . [ label "password" . store word?    . colon ]
+      . [ label "uid"      . store integer? . colon ]
+      . [ label "gid"      . store integer? . colon ]
+      . [ label "name"     . sto_to_col?    . colon ]
+      . [ label "home"     . sto_to_col?    . colon ]
+      . [ label "shell"    . sto_to_eol? ] in
+  [ dels "+" . label "@nisdefault" . overrides? . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry|nisentry|nisdefault) *
+
+let filter
+               = incl "/etc/passwd"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/pbuilder.aug b/lenses/pbuilder.aug
new file mode 100644 (file)
index 0000000..4963c69
--- /dev/null
@@ -0,0 +1,31 @@
+(*
+Module: Pbuilder
+ Parses /etc/pbuilderrc, /etc/pbuilder/pbuilderrc
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  Pbuilderrc is a standard shellvars file.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Configuration files
+  This lens applies to /etc/pbuilderrc and /etc/pbuilder/pbuilderrc.
+  See <filter>.
+*)
+
+module Pbuilder =
+
+autoload xfm
+
+(* View: filter
+    The pbuilder conffiles *)
+let filter = incl "/etc/pbuilder/pbuilderrc"
+           . incl "/etc/pbuilderrc"
+
+(* View: lns
+    The pbuilder lens *)
+let lns    = Shellvars.lns
+
+let xfm    = transform lns filter
diff --git a/lenses/pg_hba.aug b/lenses/pg_hba.aug
new file mode 100644 (file)
index 0000000..052cd06
--- /dev/null
@@ -0,0 +1,80 @@
+(*
+Module: Pg_Hba
+  Parses PostgreSQL's pg_hba.conf
+
+Author: Aurelien Bompard <aurelien@bompard.org>
+
+About: Reference
+  The file format is described in PostgreSQL's documentation:
+  http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Configuration files
+  This lens applies to pg_hba.conf. See <filter> for exact locations.
+*)
+
+
+module Pg_Hba =
+    autoload xfm
+
+    (* Group: Generic primitives *)
+
+    let eol     = Util.eol
+    let word    = Rx.neg1
+    (* Variable: ipaddr
+       CIDR or ip+netmask *)
+    let ipaddr   = /[0-9a-fA-F:\.]+(\/[0-9]+|[ \t]+[0-9\.]+)/
+
+    let comma_sep_list (l:string) =
+        let lns = [ label l . store word ] in
+            Build.opt_list lns Sep.comma
+
+    (* Group: Columns definitions *)
+
+    (* View: database
+       TODO: support for quoted strings *)
+    let database = comma_sep_list "database"
+    (* View: user
+       TODO: support for quoted strings *)
+    let user = comma_sep_list "user"
+    (* View: address *)
+    let address = [ label "address" . store ipaddr ]
+    (* View: option
+       part of <method> *)
+    let option = [ label "option" . store word ]
+    (* View: method
+       can contain an <option> *)
+    let method = [ label "method" . store Rx.word . ( Sep.tab . option )? ]
+
+    (* Group: Records definitions *)
+
+    (* View: record_local
+       when type is "local", there is no "address" field *)
+    let record_local = [ label "type" . store "local" ] . Sep.tab .
+                       database . Sep.tab . user . Sep.tab . method
+
+    (* Variable: remtypes
+       non-local connection types *)
+    let remtypes = "host" | "hostssl" | "hostnossl"
+
+    (* View: record_remote *)
+    let record_remote = [ label "type" . store remtypes ] . Sep.tab .
+                        database . Sep.tab .  user . Sep.tab .
+                        address . Sep.tab . method
+
+    (* View: record
+        A sequence of <record_local> or <record_remote> entries *)
+    let record = [ seq "entries" . (record_local | record_remote) . eol ]
+
+    (* View: filter
+        The pg_hba.conf conf file *)
+    let filter = (incl "/var/lib/pgsql/data/pg_hba.conf" .
+                  incl "/etc/postgresql/*/*/pg_hba.conf" )
+
+    (* View: lns
+        The pg_hba.conf lens *)
+    let lns = ( record | Util.comment | Util.empty ) *
+
+    let xfm = transform lns filter
diff --git a/lenses/php.aug b/lenses/php.aug
new file mode 100644 (file)
index 0000000..5d44363
--- /dev/null
@@ -0,0 +1,52 @@
+(* PHP module for Augeas                      *)
+(* Author: Raphael Pinson <raphink@gmail.com> *)
+(*                                            *)
+
+module PHP =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
+let empty    = IniFile.empty
+
+
+(************************************************************************
+ *                        ENTRY
+ *
+ * We have to remove the keyword "section" from possible entry keywords
+ * otherwise it would lead to an ambiguity with the "section" label
+ * since PHP allows entries outside of sections.
+ *************************************************************************)
+let entry    = IniFile.entry IniFile.entry_re sep comment
+
+
+(************************************************************************
+ *                         TITLE
+ *
+ * We use IniFile.title_label because there can be entries
+ * outside of sections whose labels would conflict with section names
+ *************************************************************************)
+let title       = IniFile.title ( IniFile.record_re - ".anon" )
+let record      = IniFile.record title entry
+
+let record_anon = [ label ".anon" . ( entry | empty )+ ]
+
+
+(************************************************************************
+ *                         LENS & FILTER
+ * There can be entries before any section
+ * IniFile.entry includes comment management, so we just pass entry to lns
+ *************************************************************************)
+let lns    = record_anon? . record*
+
+let filter = (incl "/etc/php*/*/*.ini")
+             . (incl "/etc/php.ini")
+             . (incl "/etc/php.d/*.ini")
+             . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/phpvars.aug b/lenses/phpvars.aug
new file mode 100644 (file)
index 0000000..998fff5
--- /dev/null
@@ -0,0 +1,118 @@
+(* Phpvars module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: PHP syntax
+
+*)
+
+module Phpvars =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let indent     = Util.indent
+let empty      = Util.empty
+
+let sep_php    = del /<\?php[ \t]*\n/ "<?php\n"
+let sep_eq     = del /[ \n]*=/ " ="
+let sep_spc    = del /[ \n]+/ " "
+let sep_dollar = del /\$/ "$"
+let sep_scl    = del /[ \t]*;/ ";"
+
+let chr_blank = /[ \t]/
+let chr_nblank = /[^ \t\n]/
+let chr_any    = /./
+let chr_star   = /\*/
+let chr_nstar  = /[^\* \t\n]/
+let chr_slash  = /\//
+let chr_nslash = /[^\/ \t\n]/
+
+let sto_to_scl = store /([^ \t\n].*[^ \t\n;]|[^ \t\n;])/
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+(************************************************************************
+ *                              COMMENTS
+ *************************************************************************)
+
+let comment_re = chr_nblank
+               | ( chr_nblank . chr_any*
+                   . ( chr_star  . chr_nslash
+                     | chr_nstar . chr_slash
+                     | chr_nstar . chr_nslash
+                     | chr_blank . chr_nblank ) )
+
+let comment_first_line
+               = [ indent
+                 . seq "#comment"
+                 . store comment_re
+                  ]
+let comment_other_line
+               = [ del /[ \t]*\n[ \t\n]*/ "\n"
+                 . seq "#comment"
+                 . store comment_re
+                  ]
+let comment_end
+               = del /[ \t\n]*/ "" . del (chr_star . chr_slash) "*/"
+
+let comment_extended
+                 = [ indent
+                 . del (chr_slash . chr_star) "/*"
+                 . label "#comment"
+                 . counter "#comment"
+                 . ( (comment_first_line . comment_other_line+)
+                   | comment_first_line?)
+                 . comment_end
+                 . eol ]
+
+let comment_inline
+                 = [ indent
+                 . del (chr_slash . chr_slash) "//"
+                 . label "#inline"
+                 . indent
+                 . sto_to_eol
+                 . eol ]
+
+let comment      = comment_extended | comment_inline
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let global     = [ key "global"
+                 . sep_spc
+                 . sep_dollar
+                 . sto_to_scl
+                 . sep_scl
+                 . eol ]
+
+let variable_re
+               = /\$[][A-Za-z0-9'_-]+/
+let variable   = [ key variable_re
+                 . sep_eq
+                 . sep_spc
+                 . sto_to_scl
+                 . sep_scl
+                 . eol ]
+
+let include    = [ key "@include"
+                 . sep_spc
+                 . sto_to_scl
+                 . sep_scl
+               .   eol ]
+
+let entry      = global|variable|include
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = sep_php . (empty|comment|entry)*
+
+let filter     = incl "/etc/squirrelmail/config.php"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/postfix_access.aug b/lenses/postfix_access.aug
new file mode 100644 (file)
index 0000000..8b6a5de
--- /dev/null
@@ -0,0 +1,29 @@
+(* Parsing /etc/postfix/access *)
+
+module Postfix_Access =
+  autoload xfm
+
+  let sep_tab = Util.del_ws_tab
+  let sep_spc = Util.del_ws_spc
+
+  let eol = del /[ \t]*\n/ "\n"
+  let indent = del /[ \t]*/ ""
+
+  let comment = Util.comment
+  let empty   = Util.empty
+
+  let char = /[^# \n\t]/
+  let text =
+    let cont = /\n[ \t]+/ in
+    let any = /[^#\n]/ in
+    char | (char . (any | cont)* .char)
+
+  let word = char+
+  let record = [ seq "spec" .
+                  [ label "pattern" . store  word ] . sep_tab .
+                  [ label "action" . store word ] .
+                  [ label "parameters" . sep_spc . store text ]? . eol ]
+
+  let lns = ( empty | comment | record )*
+
+  let xfm = transform lns (incl "/etc/postfix/access")
diff --git a/lenses/postfix_main.aug b/lenses/postfix_main.aug
new file mode 100644 (file)
index 0000000..35e834f
--- /dev/null
@@ -0,0 +1,50 @@
+(* Postfix_Main module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference:
+
+
+*)
+
+module Postfix_Main =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let indent     = del /[ \t]*(\n[ \t]+)?/ " "
+let comment    = Util.comment
+let empty      = Util.empty
+let eq         = del /[ \t]*=/ " ="
+let word       = /[A-Za-z0-9_.-]+/
+
+(* The value of a parameter, after the '=' sign. Postfix allows that
+ * lines are continued by starting continuation lines with spaces.
+ * The definition needs to make sure we don't add indented comment lines
+ * into values *)
+let value =
+  let chr = /[^# \t\n]/ in
+  let any = /.*/ in
+  let line = (chr . any* . chr | chr) in
+  let lines = line . (/\n[ \t]+/ . line)* in
+    store lines
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word . eq . (indent . value)? . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/postfix/main.cf"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/postfix_master.aug b/lenses/postfix_master.aug
new file mode 100644 (file)
index 0000000..6b4259e
--- /dev/null
@@ -0,0 +1,54 @@
+(* Postfix_Master module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference:
+
+*)
+
+module Postfix_Master =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let ws         = del /[ \t\n]+/ " "
+let comment    = Util.comment
+let empty      = Util.empty
+
+let word       = /[A-Za-z0-9_.-]+/
+let words      = /[A-Za-z0-9$(){}=!_.-][A-Za-z0-9$!(){} ="\/_.-]*[A-Za-z0-9$!(){}="\/_.-]/
+
+let bool       = /y|n|-/
+let integer    = /([0-9]+|-)\??/
+let command   = words . (/\n[ \t]+/ . words)*
+
+let field (l:string) (r:regexp)
+               = [ label l . store r ]
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word . ws
+                . field "type"         /inet|unix|fifo|pass/  . ws
+                . field "private"      bool                   . ws
+                . field "unpriviliged" bool                   . ws
+                . field "chroot"       bool                   . ws
+                . field "wakeup"       integer                . ws
+                . field "limit"        integer                . ws
+                . field "command"      command
+                . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter     = incl "/etc/postfix/master.cf"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/puppet.aug b/lenses/puppet.aug
new file mode 100644 (file)
index 0000000..bae6534
--- /dev/null
@@ -0,0 +1,43 @@
+(* Puppet module for Augeas
+ Author: Raphael Pinson <raphink@gmail.com>
+
+ puppet.conf is a standard INI File.
+*)
+
+
+module Puppet =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *
+ * puppet.conf only supports "# as commentary and "=" as separator
+ *************************************************************************)
+let comment    = IniFile.comment "#" "#"
+let sep        = IniFile.sep "=" "="
+
+
+(************************************************************************
+ *                        ENTRY
+ * puppet.conf uses standard INI File entries
+ *************************************************************************)
+let entry   = IniFile.indented_entry IniFile.entry_re sep comment
+
+
+(************************************************************************
+ *                        RECORD
+ * puppet.conf uses standard INI File records
+ *************************************************************************)
+let title   = IniFile.indented_title IniFile.record_re
+let record  = IniFile.record title entry
+
+
+(************************************************************************
+ *                        LENS & FILTER
+ * puppet.conf uses standard INI File records
+ *************************************************************************)
+let lns     = IniFile.lns record comment
+
+let filter = (incl "/etc/puppet/puppet.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/puppetfileserver.aug b/lenses/puppetfileserver.aug
new file mode 100644 (file)
index 0000000..2af8340
--- /dev/null
@@ -0,0 +1,110 @@
+(* -*- coding: utf-8 -*-
+Module: PuppetFileserver
+  Parses /etc/puppet/fileserver.conf used by puppetmasterd daemon.
+
+Author: Frédéric Lespez <frederic.lespez@free.fr>
+
+About: Reference
+  This lens tries to keep as close as possible to puppet documentation
+  for this file:
+  http://docs.puppetlabs.com/guides/file_serving.html
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Create a new mount point
+      > ins test_mount after /files/etc/puppet/fileserver.conf/*[last()]
+      > defvar test_mount /files/etc/puppet/fileserver.conf/test_mount
+      > set $test_mount/path /etc/puppet/files
+      > set $test_mount/allow *.example.com
+      > ins allow after $test_mount/*[last()]
+      > set $test_mount/allow[last()] server.domain.com
+      > set $test_mount/deny dangerous.server.com
+    * List the definition of a mount point
+      > print /files/etc/puppet/fileserver.conf/files
+    * Remove a mount point
+      > rm /files/etc/puppet/fileserver.conf/test_mount
+
+About: Configuration files
+  This lens applies to /etc/puppet/fileserver.conf. See <filter>.
+*)
+
+
+module PuppetFileserver =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: INI File settings *)
+
+(* Variable: sep_tab *)
+let eol = IniFile.eol
+
+(*
+Variable: comment
+  Only supports "#" as commentary
+*)
+let comment = IniFile.comment "#" "#"
+
+(*
+Variable: entry_re
+  Regexp for possible <entry> keyword (path, allow, deny)
+*)
+let entry_re = /path|allow|deny/
+
+
+(************************************************************************
+ * Group:                 ENTRY
+ *************************************************************************)
+
+(*
+View: entry
+  Non standard INI File entry:
+  - It might be indented with an arbitrary amount of whitespace
+  - It does not have any separator between keywords and their values
+  - It cannot contain a comment after a value (on the same line)
+  - It can only have keywords with the following values (path, allow, deny)
+*)
+let entry = [ Util.del_opt_ws "" . key entry_re .
+              Util.del_ws_spc . store /[^# \n\t]+/ .
+              eol ] | comment
+
+
+(************************************************************************
+ * Group:                      RECORD
+ *************************************************************************)
+
+(* Group: Title definition *)
+
+(*
+View: title
+  Uses standard INI File title
+*)
+let title = IniFile.indented_title IniFile.record_re
+
+(*
+View: title
+  Uses standard INI File record
+*)
+let record = IniFile.record title entry
+
+
+(************************************************************************
+ * Group:                      LENS
+ *************************************************************************)
+
+(*
+View: lns
+  Uses standard INI File lens
+*)
+let lns = IniFile.lns record comment
+
+(* Variable: filter *)
+let filter = (incl "/etc/puppet/fileserver.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/resolv.aug b/lenses/resolv.aug
new file mode 100644 (file)
index 0000000..9403165
--- /dev/null
@@ -0,0 +1,109 @@
+(*
+Module: Resolv
+  Parses /etc/resolv.conf
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man resolv.conf` where possible.
+
+About: Licence
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+
+About: Configuration files
+  This lens applies to /etc/resolv.conf. See <filter>.
+*)
+
+module Resolv =
+autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* View: comment *)
+let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
+
+(* View: empty *)
+let empty = Util.empty
+
+
+(************************************************************************
+ * Group:                 MAIN OPTIONS
+ *************************************************************************)
+
+(* View: netmask
+A network mask for IP addresses *)
+let netmask = [ label "netmask" . Util.del_str "/" . store Rx.ip ]
+
+(* View: ipaddr 
+An IP address or range with an optional mask *) 
+let ipaddr = [label "ipaddr" . store Rx.ip . netmask?]
+
+
+(* View: nameserver
+     A nameserver entry *)
+let nameserver = Build.key_value_line 
+                    "nameserver" Sep.space (store Rx.ip)
+
+(* View: domain *)
+let domain = Build.key_value_line
+                    "domain" Sep.space (store Rx.word)
+
+(* View: search *)
+let search = Build.key_value_line
+                    "search" Sep.space
+                    (Build.opt_list 
+                           [label "domain" . store Rx.word]
+                            Sep.space)
+
+(* View: sortlist *)
+let sortlist = Build.key_value_line
+                    "sortlist" Sep.space
+                    (Build.opt_list
+                           ipaddr
+                           Sep.space) 
+
+(************************************************************************
+ * Group:                 SPECIAL OPTIONS
+ *************************************************************************)
+
+(* View: ip6_dotint
+     ip6-dotint option, which supports negation *)
+let ip6_dotint = 
+  let negate = [ del "no-" "no-" . label "negate" ]
+    in [ negate? . key "ip6-dotint" ]
+
+(* View: options 
+     Options values *)
+let options =
+      let options_entry = Build.key_value ("ndots"|"timeout"|"attempts") 
+                                          (Util.del_str ":") (store Rx.integer)
+                        | Build.flag ("debug"|"rotate"|"no-check-names"
+                                     |"inet6"|"ip6-bytestring"|"edns0")
+                        | ip6_dotint
+
+            in Build.key_value_line
+                    "options" Sep.space
+                    (Build.opt_list
+                           options_entry
+                           Sep.space)
+
+(* View: entry *)
+let entry = nameserver
+          | domain
+          | search
+          | sortlist
+          | options
+
+(* View: lns *)
+let lns = ( empty | comment | entry )*
+
+(* Variable: filter *)
+let filter = (incl "/etc/resolv.conf")
+    . Util.stdexcl
+
+let xfm = transform lns filter
+
diff --git a/lenses/rsyncd.aug b/lenses/rsyncd.aug
new file mode 100644 (file)
index 0000000..abee461
--- /dev/null
@@ -0,0 +1,67 @@
+(* Rsyncd module for Augeas
+   Author: Marc Fournier <marc.fournier@camptocamp.com>
+
+  Reference: man rsyncd.conf(5)
+
+*)
+
+module Rsyncd =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+let comment    = IniFile.comment IniFile.comment_re "#"
+let sep        = IniFile.sep IniFile.sep_re IniFile.sep_default
+let indent     = del /[ \t]*/ "  "
+
+(* Import useful INI File primitives *)
+let eol        = IniFile.eol
+let empty      = IniFile.empty
+let sto_to_comment
+               = Util.del_opt_ws " "
+               . store /[^;# \t\n][^;#\n]*[^;# \t\n]|[^;# \t\n]/
+
+
+(************************************************************************
+ *                        ENTRY
+ * rsyncd.conf allows indented entries, but by default entries outside
+ * sections are unindented
+ *************************************************************************)
+let entry_re   = /[A-Za-z0-9_.-][A-Za-z0-9 _.-]*[A-Za-z0-9_.-]/
+
+let entry      = let kw = entry_re in
+               [ indent
+               . key kw
+               . sep
+               . sto_to_comment?
+               . (comment|eol) ]
+               | comment
+
+let anon_entry = let kw = entry_re in
+               [ key kw
+               . sep
+               . sto_to_comment?
+               . (comment|eol) ]
+               | comment
+
+(************************************************************************
+ *                        RECORD & TITLE
+ * We use IniFile.title_label because there can be entries
+ * outside of sections whose labels would conflict with section names
+ *************************************************************************)
+let title   = IniFile.title ( IniFile.record_re - ".anon" )
+let record  = IniFile.record title entry
+
+let record_anon = [ label ".anon" . ( anon_entry | empty )+ ]
+
+(************************************************************************
+ *                        LENS & FILTER
+ * There can be entries before any section
+ * IniFile.entry includes comment management, so we just pass entry to lns
+ *************************************************************************)
+let lns     = record_anon? . record*
+
+let filter = (incl "/etc/rsyncd.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/rx.aug b/lenses/rx.aug
new file mode 100644 (file)
index 0000000..95df76d
--- /dev/null
@@ -0,0 +1,80 @@
+(*
+Module: Rx
+   Generic regexps to build lenses
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+
+
+module Rx =
+
+(* Spaces *)
+let space     = /[ \t]+/
+let opt_space = /[ \t]*/
+let space_in  = /[^ \t\n].*[^ \t\n]|[^ \t\n]/
+let no_spaces = /[^ \t\n]+/
+
+(* Generic fields *)
+let word      = /[A-Za-z0-9_.-]+/
+let integer   = /[0-9]+/
+let decimal   = /[0-9]+([.,][0-9]+)?/
+
+(* A filesystem path *)
+let fspath    = /[^ \t\n]+/
+
+(* All but... *)
+(* Anything but a space, a comma or a comment sign *)
+let neg1      = /[^,# \n\t]+/
+
+
+(*
+ * IPs
+ * Cf. http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6/ (in fr)
+ *)
+let ipv4 =
+  let dot     = "." in
+  let digits  = /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ in
+    digits . dot . digits . dot . digits . dot . digits
+
+let ipv6 =
+  /(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})/
+  | (    /([0-9A-Fa-f]{1,4}:){6}/
+           . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
+           . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
+    )
+  | (    /([0-9A-Fa-f]{1,4}:){0,5}:/
+           . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
+           . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
+    )
+  | (    /::([0-9A-Fa-f]{1,4}:){0,5}/
+           . /((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}/
+           . /(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))/
+    )
+  | (    /[0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}/
+           . /[0-9A-Fa-f]{1,4}/
+    )
+  | /(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})/
+  | /(([0-9A-Fa-f]{1,4}:){1,7}:)/
+
+let ip        = ipv4 | ipv6
+
+(*
+ * A Linux device name like eth0 or i2c-0. Might still be too restrictive
+ *)
+
+let device_name = /[a-zA-Z0-9_?.+:!-]+/
+
+(*
+ * Variable: email_addr
+ *    To be refined
+ *)
+let email_addr = /[A-Za-z0-9_\+\.-]+@[A-Za-z0-9_\.-]+/
+
diff --git a/lenses/samba.aug b/lenses/samba.aug
new file mode 100644 (file)
index 0000000..30db88e
--- /dev/null
@@ -0,0 +1,57 @@
+(* Samba module for Augeas
+   Author: Free Ekanayaka <free@64studio.com>
+
+   Reference: man smb.conf(5)
+
+*)
+
+
+module Samba =
+  autoload xfm
+
+(************************************************************************
+ * INI File settings
+ *************************************************************************)
+
+let comment  = IniFile.comment IniFile.comment_re IniFile.comment_default
+let sep      = del /[ \t]*=/ " ="
+let indent   = del /[ \t]*/ "   "
+
+(* Import useful INI File primitives *)
+let eol      = IniFile.eol
+let empty    = IniFile.empty
+let sto_to_comment
+             = Util.del_opt_ws " "
+             . store /[^;# \t\n][^;#\n]*[^;# \t\n]|[^;# \t\n]/
+
+(************************************************************************
+ *                        ENTRY
+ * smb.conf allows indented entries
+ *************************************************************************)
+
+let entry_re = /[A-Za-z0-9_.-][A-Za-z0-9 _.:-]*[A-Za-z0-9_.-]/
+let entry    = let kw = entry_re in
+             [ indent
+             . key kw
+             . sep
+             . sto_to_comment?
+             . (comment|eol) ]
+             | comment
+
+(************************************************************************
+ *                         TITLE
+ *************************************************************************)
+
+let title    = IniFile.title_label "target" IniFile.record_label_re
+let record   = IniFile.record title entry
+
+(************************************************************************
+ *                         LENS & FILTER
+ *************************************************************************)
+
+let lns      = IniFile.lns record comment
+
+let filter   = (incl "/etc/samba/smb.conf")
+             . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/securetty.aug b/lenses/securetty.aug
new file mode 100644 (file)
index 0000000..80ba097
--- /dev/null
@@ -0,0 +1,18 @@
+(* Parses entries in /etc/securetty
+
+   Author: Simon Josi <josi@yokto.net> 
+*)
+module Securetty =
+   autoload xfm
+
+   let word = /[^ \t\n#]+/
+   let eol = Util.eol
+   let empty = Util.empty
+   let comment = Util.comment
+   let comment_or_eol = Util.comment_or_eol
+
+   let record = [ seq "securetty" . store word . comment_or_eol ]
+   let lns = ( empty | comment | record )*
+
+   let filter = (incl "/etc/securetty")
+   let xfm = transform lns filter
diff --git a/lenses/sep.aug b/lenses/sep.aug
new file mode 100644 (file)
index 0000000..92e453a
--- /dev/null
@@ -0,0 +1,21 @@
+(*
+Module: Sep
+   Generic separators to build lenses
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+
+
+module Sep =
+
+let colon = Util.del_str ":"
+let comma = Util.del_str ","
+let equal = Util.del_str "="
+let space = del Rx.space " "
+let tab   = del Rx.space "\t"
+let opt_space = del Rx.opt_space ""
+let opt_tab   = del Rx.opt_space "\t"
+
diff --git a/lenses/services.aug b/lenses/services.aug
new file mode 100644 (file)
index 0000000..df29db3
--- /dev/null
@@ -0,0 +1,87 @@
+(*
+Module: Services
+ Parses /etc/services
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+ This lens tries to keep as close as possible to 'man services' where possible.
+
+The definitions from 'man services' are put as commentaries for reference
+throughout the file. More information can be found in the manual.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Get the name of the service running on port 22 with protocol tcp
+      > match "/files/etc/services/service-name[port = '22'][protocol = 'tcp']"
+    * Remove the tcp entry for "domain" service
+      > rm "/files/etc/services/service-name[. = 'domain'][protocol = 'tcp']"
+    * Add a tcp service named "myservice" on port 55234
+      > ins service-name after /files/etc/services/service-name[last()]
+      > set /files/etc/services/service-name[last()] "myservice"
+      > set "/files/etc/services/service-name[. = 'myservice']/port" "55234"
+      > set "/files/etc/services/service-name[. = 'myservice']/protocol" "tcp"
+
+About: Configuration files
+  This lens applies to /etc/services. See <filter>.
+*)
+
+module Services =
+  autoload xfm
+
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Generic primitives *)
+
+(* Variable: eol *)
+let eol         = del /[ \t]*(#)?[ \t]*\n/ "\n"
+let indent      = Util.indent
+let comment     = Util.comment
+let comment_or_eol = Util.comment_or_eol
+let empty       = Util.empty
+let protocol_re = /[a-zA-Z]+/
+let word_re     = /[a-zA-Z0-9_.+*\/-]+/
+let num_re      = /[0-9]+/
+
+(* Group: Separators *)
+let sep_spc = Util.del_ws_spc
+
+
+(************************************************************************
+ * Group:                 LENSES
+ *************************************************************************)
+
+(* View: port *)
+let port = [ label "port" . store num_re ]
+
+(* View: protocol *)
+let protocol = [ label "protocol" . store protocol_re ]
+
+(* View: alias *)
+let alias = [ label "alias" . store word_re ]
+
+(*
+ * View: record
+ *   A standard /etc/services record
+ *   TODO: make sure a space is added before a comment on new nodes
+ *)
+let record = [ label "service-name" . store word_re . sep_spc . port
+                 . del "/" "/" . protocol . ( sep_spc . alias )*
+                 . comment_or_eol ]
+
+(* View: lns
+    The services lens is either <empty>, <comment> or <record> *)
+let lns = ( empty | comment | record )*
+
+
+(* View: filter *)
+let filter = (incl "/etc/services")
+
+let xfm = transform lns filter
diff --git a/lenses/shells.aug b/lenses/shells.aug
new file mode 100644 (file)
index 0000000..07c96fa
--- /dev/null
@@ -0,0 +1,37 @@
+(*
+Module: Shells
+  Parses /etc/shells
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man 5 shells` where possible.
+
+About: License
+   This file is licenced under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+   To be documented
+
+About: Configuration files
+   This lens applies to /etc/shells. See <filter>.
+*)
+
+
+module Shells =
+  autoload xfm
+
+let empty = Util.empty
+let comment = Util.comment
+let shell = [ seq "shell" . store /[^# \t\n]+/ . Util.eol ]
+
+(* View: lns
+     The shells lens
+*)
+let lns = ( empty | comment | shell )*
+
+(* Variable: filter *)
+let filter = incl "/etc/shells"
+    . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
new file mode 100644 (file)
index 0000000..3a64b38
--- /dev/null
@@ -0,0 +1,133 @@
+(* Generic lens for shell-script config files like the ones found *)
+(* in /etc/sysconfig                                              *)
+module Shellvars =
+  autoload xfm
+
+  let eol = Util.eol
+
+  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
+  let eq = Util.del_str "="
+  let comment = Util.comment
+  let comment_or_eol = Util.comment_or_eol
+  let empty   = Util.empty
+  let xchgs   = Build.xchgs
+
+  let char  = /[^#() '"\t\n]|\\\\"/
+  let dquot = /"([^"\\\n]|\\\\.)*"/                    (* " Emacs, relax *)
+  let squot = /'[^'\n]*'/
+  (* For some reason, `` conflicts with comment_or_eol *)
+  let bquot = /`[^#`\n]*`/
+
+  (* Array values of the form '(val1 val2 val3)'. We do not handle empty *)
+  (* arrays here because of typechecking headaches. Instead, they are    *)
+  (* treated as a simple value                                           *)
+  let array =
+    let array_value = store (char+ | dquot) in
+    del /\([ \t]*/ "(" . counter "values" .
+      [ seq "values" . array_value ] .
+      [ del /[ \t\n]+/ " " . seq "values" . array_value ] *
+      . del /[ \t]*\)/ ")"
+
+  (* Treat an empty list () as a value '()'; that's not quite correct *)
+  (* but fairly close.                                                *)
+  let simple_value =
+    let empty_array = /\([ \t]*\)/ in
+      store (char* | dquot | squot | bquot | empty_array)
+
+  let export = [ key "export" . Util.del_ws_spc ]
+  let kv = [ export? . key key_re . eq . (simple_value | array) . comment_or_eol ]
+
+  let var_action (name:string) =
+    [ xchgs name ("@" . name) . Util.del_ws_spc . store key_re . comment_or_eol ]
+
+  let unset = var_action "unset"
+  let bare_export = var_action "export"
+
+  let source =
+    [
+      del /\.|source/ "." . label ".source" .
+      Util.del_ws_spc . store /[^= \t\n]+/ . eol
+    ]
+
+  let shell_builtin_cmds = "ulimit"
+
+  let builtin =
+    [ label "@builtin"
+      . store shell_builtin_cmds
+      . Util.del_ws_spc
+      . [ label "args" . store /[^ \t\n][^;\n]+[^ \t\n]|[^ \t;\n]+/ ]
+      . eol ]
+
+  let lns = (comment | empty | source | kv | unset | bare_export | builtin) *
+
+  let sc_incl (n:string) = (incl ("/etc/sysconfig/" . n))
+  let filter_sysconfig =
+      sc_incl "atd" .
+      sc_incl "authconfig" .
+      sc_incl "autofs" .
+      sc_incl "clock" .
+      sc_incl "cpuspeed" .
+      sc_incl "crond" .
+      sc_incl "crontab" .
+      sc_incl "desktop" .
+      sc_incl "firstboot" .
+      sc_incl "grub" .
+      sc_incl "hsqldb" .
+      sc_incl "httpd" .
+      sc_incl "i18n" .
+      sc_incl "init" .
+      sc_incl "iptables-config" .
+      sc_incl "irda" .
+      sc_incl "irqbalance" .
+      sc_incl "kdump" .
+      sc_incl "keyboard" .
+      sc_incl "kudzu" .
+      sc_incl "libvirtd" .
+      sc_incl "lircd" .
+      sc_incl "nasd" .
+      sc_incl "netconsole" .
+      sc_incl "network" .
+      sc_incl "nfs" .
+      sc_incl "ntpd" .
+      sc_incl "prelink" .
+      sc_incl "puppet" .
+      sc_incl "puppetmaster" .
+      sc_incl "readonly-root" .
+      sc_incl "rsyslog" .
+      sc_incl "samba" .
+      sc_incl "saslauthd" .
+      sc_incl "selinux" .
+      sc_incl "sendmail" .
+      sc_incl "smartmontools" .
+      sc_incl "snmpd" .
+      sc_incl "snmpd.options" .
+      sc_incl "snmptrapd" .
+      sc_incl "snmptrapd.options" .
+      sc_incl "spamassassin" .
+      sc_incl "suseconfig" .
+      sc_incl "sysstat" .
+      sc_incl "system-config-users" .
+      sc_incl "vncservers" .
+      sc_incl "wpa_supplicant" .
+      sc_incl "xend" .
+      sc_incl "xendomains"
+
+  let filter_ifcfg   = incl "/etc/sysconfig/network-scripts/ifcfg-*"
+                     . incl "/etc/sysconfig/network/ifcfg-*"
+  let filter_default = incl "/etc/default/*"
+  let filter_misc    = incl "/etc/arno-iptables-firewall/debconf.cfg"
+                     . incl "/etc/cron-apt/config"
+                     . incl "/etc/environment"
+                     . incl "/etc/rc.conf"
+
+  let filter = filter_sysconfig
+             . filter_ifcfg
+             . filter_default
+             . filter_misc
+             . Util.stdexcl
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/shellvars_list.aug b/lenses/shellvars_list.aug
new file mode 100644 (file)
index 0000000..7f5fa2c
--- /dev/null
@@ -0,0 +1,54 @@
+(* Generic lens for shell-script config files like the ones found *)
+(* in /etc/sysconfig, where a string needs to be split into       *)
+(* single words.                                                  *)
+module Shellvars_list =
+  autoload xfm
+
+  let eol = Util.eol
+
+  let key_re = /[A-Za-z0-9_]+/
+  let eq      = Util.del_str "="
+  let comment = Util.comment
+  let empty   = Util.empty
+  let indent  = Util.indent
+
+  let sqword = /[^ '\t\n]+/
+  let dqword = /([^ "\\\t\n]|\\\\.)+/
+  let uqword = /([^ "'\\\t\n]|\\\\.)+/
+
+  (* lists values of the form ...  val1 val2 val3  ... *)
+  let list(word:regexp) =
+    let list_value = store word in
+      indent .
+      [ label "value" . list_value ] .
+      [ del /[ \t\n]+/ " "  . label "value" . list_value ]* . indent
+
+
+  (* handle single quoted lists *)
+  let squote_arr = [ label "quote" . store /'/ ] . (list sqword)? . del /'/ "'"
+
+  (* similarly handle double qouted lists *)
+  let dquote_arr = [ label "quote" . store /"/ ] . (list dqword)? . del /"/ "\""
+
+  (* handle unquoted single value *)
+  let unquot_val = [ label "quote" . store "" ] . [label "value"  . store uqword+]?
+
+
+  (* lens for key value pairs *)
+  let kv = [ key key_re . eq . ( squote_arr | dquote_arr | unquot_val ) .  eol ]
+
+  let lns = ( comment | empty | kv )*
+
+  let sc_incl (n:string) = (incl ("/etc/sysconfig/" . n))
+  let filter_sysconfig =
+      sc_incl "bootloader" .
+      sc_incl "kernel"
+
+  let filter = filter_sysconfig
+             . Util.stdexcl
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/slapd.aug b/lenses/slapd.aug
new file mode 100644 (file)
index 0000000..246dfa1
--- /dev/null
@@ -0,0 +1,155 @@
+(* Slapd module for Augeas
+   Author: Free Ekanayaka <free@64studio.com>
+
+   Reference: man slapd.conf(5), man slapd.access (5)
+
+*)
+
+module Slapd =
+  autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol         = Util.eol
+let spc         = Util.del_ws_spc
+let sep         = del /[ \t\n]+/ " "
+
+let sto_to_eol  = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+let sto_to_spc  = store /[^\\# \t\n]+/
+let sto_to_by   = store (/[^\\# \t\n]+/ - "by")
+
+(************************************************************************
+ *                           ACCESS TO
+ *************************************************************************)
+
+let access_re   = "access to"
+let who         = [ spc . label "who"     . sto_to_spc ]
+let what        = [ spc . label "what"    . sto_to_spc ]
+
+(* TODO: parse the control field, see man slapd.access (5) *)
+let control     = [ spc . label "control" . sto_to_by  ]
+let by          = [ sep . key "by". who . what. control? ]
+
+let access      = [ key access_re . spc. sto_to_spc . by+ . eol ]
+
+(************************************************************************
+ *                             GLOBAL
+ *************************************************************************)
+
+(* TODO: parse special field separately, see man slapd.conf (5) *)
+let global_re   = "allow"
+                | "argsfile"
+                | "attributeoptions"
+                | "attributetype"
+                | "authz-policy"
+                | "ldap"
+                | "dn"
+                | "concurrency"
+                | "cron_max_pending"
+                | "conn_max_pending_auth"
+                | "defaultsearchbase"
+                | "disallow"
+                | "ditcontentrule"
+                | "gentlehup"
+                | "idletimeout"
+                | "include"
+                | "index_substr_if_minlen"
+                | "index_substr_if_maxlen"
+                | "index_substr_any_len"
+                | "index_substr_any_step"
+                | "localSSF"
+                | "loglevel"
+                | "moduleload"
+                | "modulepath"
+                | "objectclass"
+                | "objectidentifier"
+                | "password-hash"
+                | "password-crypt-salt-format"
+                | "pidfile"
+                | "referral"
+                | "replica-argsfile"
+                | "replica-pidfile"
+                | "replicationinterval"
+                | "require"
+                | "reverse-lookup"
+                | "rootDSE"
+                | "sasl-host "
+                | "sasl-realm"
+                | "sasl-secprops"
+                | "schemadn"
+                | "security"
+                | "sizelimit"
+                | "sockbuf_max_incoming "
+                | "sockbuf_max_incoming_auth"
+                | "threads"
+                | "timelimit time"
+                | "tool-threads"
+                | "TLSCipherSuite"
+                | "TLSCACertificateFile"
+                | "TLSCACertificatePath"
+                | "TLSCertificateFile"
+                | "TLSCertificateKeyFile"
+                | "TLSDHParamFile"
+                | "TLSRandFile"
+                | "TLSVerifyClient"
+                | "TLSCRLCheck"
+                | "backend"
+
+let global     = Spacevars.entry global_re
+
+(************************************************************************
+ *                             DATABASE
+ *************************************************************************)
+
+(* TODO: support all types of database backend *)
+let database_hdb = "cachesize"
+                | "cachefree"
+                | "checkpoint"
+                | "dbconfig"
+                | "dbnosync"
+                | "directory"
+                | "dirtyread"
+                | "idlcachesize"
+                | "index"
+                | "linearindex"
+                | "lockdetect"
+                | "mode"
+                | "searchstack"
+                | "shm_key"
+
+let database_re = "suffix"
+                | "lastmod"
+                | "limits"
+                | "maxderefdepth"
+                | "overlay"
+                | "readonly"
+                | "replica uri"
+                | "replogfile"
+                | "restrict"
+                | "rootdn"
+                | "rootpw"
+                | "suffix"
+                | "subordinate"
+                | "syncrepl rid"
+                | "updatedn"
+                | "updateref"
+                | database_hdb
+
+let database    = [ key "database"
+                  . spc
+                  . sto_to_eol
+                  . eol
+                  . Spacevars.lns (Spacevars.entry database_re|access) ]
+
+(************************************************************************
+ *                              LENS
+ *************************************************************************)
+
+let lns         = Spacevars.lns (global|access) . (database)*
+
+let filter      = incl "/etc/ldap/slapd.conf"
+                . incl "/etc/openldap/slapd.conf"
+
+let xfm         = transform lns filter
diff --git a/lenses/solaris_system.aug b/lenses/solaris_system.aug
new file mode 100644 (file)
index 0000000..03e277a
--- /dev/null
@@ -0,0 +1,110 @@
+(*
+Module: Solaris_System
+  Parses /etc/system on Solaris
+
+Author: Dominic Cleal <dcleal@redhat.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man 4 system` where possible.
+
+About: Licence
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+
+About: Configuration files
+  This lens applies to /etc/system on Solaris. See <filter>.
+*)
+
+module Solaris_System =
+autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ ************************************************************************)
+
+(* View: comment *)
+let comment = Util.comment_generic /[ \t]*\*[ \t]*/ "* "
+
+(* View: empty
+    Map empty lines, including empty asterisk comments *)
+let empty   = [ del /[ \t]*\*?[ \t]*\n/ "\n" ]
+
+(* View: sep_colon
+    The separator for key/value entries *)
+let sep_colon = del /:[ \t]*/ ": "
+
+(* View: sep_moddir
+    The separator of directories in a moddir search path *)
+let sep_moddir = del /[: ]+/ " "
+
+(* View: modpath
+    Individual moddir search path entry *)
+let modpath = [ seq "modpath" . store /[^ :\t\n]+/ ]
+
+(* Variable: set_operator
+    Valid set operators: equals, bitwise AND and OR *)
+let set_operators = /[=&\|]/
+
+(* View: set_value
+    Sets an integer value or char pointer *)
+let set_value = [ label "value" . store Rx.no_spaces ]
+
+(************************************************************************
+ * Group:                     COMMANDS
+ ************************************************************************)
+
+(* View: cmd_kv
+    Function for simple key/value setting commands such as rootfs *)
+let cmd_kv (cmd:string) (value:regexp) =
+    Build.key_value_line cmd sep_colon (store value)
+
+(* View: cmd_moddir
+    The moddir command for specifying module search paths *)
+let cmd_moddir =
+    Build.key_value_line "moddir" sep_colon
+        (Build.opt_list modpath sep_moddir)
+
+(* View: set_var
+    Loads the variable name from a set command, no module *)
+let set_var = [ label "variable" . store Rx.word ]
+
+(* View: set_var
+    Loads the module and variable names from a set command *)
+let set_varmod = [ label "module" . store Rx.word ]
+                 . Util.del_str ":" . set_var
+
+(* View: set_sep_spc *)
+let set_sep_spc = Util.del_opt_ws " "
+
+(* View: cmd_set
+    The set command for individual kernel/module parameters *)
+let cmd_set = [ key "set"
+              . Util.del_ws_spc
+              . ( set_var | set_varmod )
+              . set_sep_spc
+              . [ label "operator" . store set_operators ]
+              . set_sep_spc
+              . set_value
+              . Util.eol ]
+
+(************************************************************************
+ * Group:                     LENS
+ ************************************************************************)
+
+(* View: lns *)
+let lns = ( empty
+          | comment
+          | cmd_moddir
+          | cmd_kv "rootdev" Rx.fspath
+          | cmd_kv "rootfs" Rx.word
+          | cmd_kv "exclude" Rx.fspath
+          | cmd_kv "include" Rx.fspath
+          | cmd_kv "forceload" Rx.fspath
+          | cmd_set )*
+
+(* Variable: filter *)
+let filter = (incl "/etc/system")
+    . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/soma.aug b/lenses/soma.aug
new file mode 100644 (file)
index 0000000..45aa1a8
--- /dev/null
@@ -0,0 +1,45 @@
+(* Soma module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man 5 soma.cfg
+
+*)
+
+module Soma =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let comment    = Util.comment
+let empty      = Util.empty
+
+let sep_eq     = del /[ \t]*=[ \t]*/ " = "
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+let word       = /[A-Za-z0-9_.-]+/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word
+                . sep_eq
+                . sto_to_eol
+                . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let filter
+               = incl "/etc/somad/soma.cfg"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/spacevars.aug b/lenses/spacevars.aug
new file mode 100644 (file)
index 0000000..dc2ea36
--- /dev/null
@@ -0,0 +1,47 @@
+(* Spacevars module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference: man interfaces
+ This is a generic lens for simple key/value configuration files where
+ keys and values are separated by a sequence of spaces or tabs.
+
+*)
+
+module Spacevars =
+  autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol     = Util.eol
+let spc     = Util.del_ws_spc
+let comment = Util.comment
+let empty   = Util.empty
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+
+let entry (kw:regexp)
+               = [ key kw . spc . sto_to_eol . eol ]
+let entry_re   = /[A-Za-z0-9\._-]+(\[[0-9]+\])?/
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns (entry:lens) = (comment|empty|entry) *
+
+let simple_lns = lns (entry entry_re)
+
+(* configuration files that can be parsed without customizing the lens *)
+let filter = Util.stdexcl
+           . incl "/etc/havp/havp.config"
+           . incl "/etc/ldap.conf"
+           . incl "/etc/ldap/ldap.conf"
+
+let xfm = transform simple_lns filter
diff --git a/lenses/squid.aug b/lenses/squid.aug
new file mode 100644 (file)
index 0000000..40291b8
--- /dev/null
@@ -0,0 +1,430 @@
+(* Squid module for Augeas
+   Author: Free Ekanayaka <free@64studio.com>
+
+   Reference: the self-documented default squid.conf file
+
+*)
+
+module Squid =
+  autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol         = Util.eol
+let spc         = Util.del_ws_spc
+let indent      = Util.indent
+
+let word        =  /[A-Za-z0-9!_.-]+(\[[0-9]+\])?/
+let sto_to_spc  = store /[^# \t\n]+/
+
+let comment     = Util.comment
+let comment_or_eol = Util.comment_or_eol
+let value (kw:string)
+                = [ spc . label kw . sto_to_spc ]
+let parameters  = [ label "parameters"
+                   . counter "parameters"
+                   . [ spc . seq "parameters" . sto_to_spc ]+ ]
+
+(************************************************************************
+ *                          SPACEVARS SETTINGS
+ *************************************************************************)
+
+let entry_re =    "accept_filter"
+                | "access_log"
+                | "acl_uses_indirect_client"
+                | "adaptation_access"
+                | "adaptation_service_set"
+                | "allow_underscore"
+                | "always_direct"
+                | "announce_file"
+                | "announce_host"
+                | "announce_period"
+                | "announce_port"
+                | "append_domain"
+                | "as_whois_server"
+                | "authenticate_cache_garbage_interval"
+                | "authenticate_ip_shortcircuit_access"
+                | "authenticate_ip_shortcircuit_ttl"
+                | "authenticate_ip_ttl"
+                | "authenticate_ttl"
+                | "background_ping_rate"
+                | "balance_on_multiple_ip"
+                | "broken_posts"
+                | "buffered_logs"
+                | "cache"
+                | "cache_dir"
+                | "cache_dns_program"
+                | "cache_effective_group"
+                | "cache_effective_user"
+                | "cache_log"
+                | "cache_mem"
+                | "cache_mgr"
+                | "cachemgr_passwd"
+                | "cache_peer"
+                | "cache_peer_access"
+                | "cache_peer_domain"
+                | "cache_replacement_policy"
+                | "cache_store_log"
+                | "cache_swap_high"
+                | "cache_swap_low"
+                | "cache_swap_state"
+                | "cache_vary"
+                | "check_hostnames"
+                | "chroot"
+                | "client_db"
+                | "client_lifetime"
+                | "client_netmask"
+                | "client_persistent_connections"
+                | "clientside_tos"
+                | "collapsed_forwarding"
+                | "connect_timeout"
+                | "coredump_dir"
+                | "dead_peer_timeout"
+                | "debug_options"
+                | "delay_access"
+                | "delay_class"
+                | "delay_initial_bucket_level"
+                | "delay_parameters"
+                | "delay_pools"
+                | "delay_pool_uses_indirect_client"
+                | "deny_info"
+                | "detect_broken_pconn"
+                | "digest_bits_per_entry"
+                | "digest_generation"
+                | "digest_rebuild_chunk_percentage"
+                | "digest_rebuild_period"
+                | "digest_rewrite_period"
+                | "digest_swapout_chunk_size"
+                | "diskd_program"
+                | "dns_children"
+                | "dns_defnames"
+                | "dns_nameservers"
+                | "dns_retransmit_interval"
+                | "dns_testnames"
+                | "dns_timeout"
+                | "dns_v4_fallback"
+                | "ecap_enable"
+                | "ecap_service"
+                | "email_err_data"
+                | "emulate_httpd_log"
+                | "err_html_text"
+                | "error_default_language"
+                | "error_directory"
+                | "error_log_languages"
+                | "error_map"
+                | "err_page_stylesheet"
+                | "esi_parser"
+                | "external_acl_type"
+                | "external_refresh_check"
+                | "follow_x_forwarded_for"
+                | "forwarded_for"
+                | "forward_log"
+                | "forward_timeout"
+                | "fqdncache_size"
+                | "ftp_epsv_all"
+                | "ftp_list_width"
+                | "ftp_passive"
+                | "ftp_sanitycheck"
+                | "ftp_telnet_protocol"
+                | "ftp_user"
+                | "global_internal_static"
+                | "half_closed_clients"
+                | "header_access"
+                | "header_replace"
+                | "hierarchy_stoplist"
+                | "high_memory_warning"
+                | "high_page_fault_warning"
+                | "high_response_time_warning"
+                | "hostname_aliases"
+                | "hosts_file"
+                | "htcp_access"
+                | "htcp_clr_access"
+                | "htcp_port"
+                | "http_accel_surrogate_remote"
+                | "http_access2"
+                | "httpd_accel_no_pmtu_disc"
+                | "httpd_accel_surrogate_id"
+                | "httpd_suppress_version_string"
+                | "http_port"
+                | "http_reply_access"
+                | "https_port"
+                | "icap_access"
+                | "icap_class"
+                | "icap_client_username_encode"
+                | "icap_client_username_header"
+                | "icap_connect_timeout"
+                | "icap_default_options_ttl"
+                | "icap_enable"
+                | "icap_io_timeout"
+                | "icap_persistent_connections"
+                | "icap_preview_enable"
+                | "icap_preview_size"
+                | "icap_send_client_ip"
+                | "icap_send_client_username"
+                | "icap_service"
+                | "icap_service_failure_limit"
+                | "icap_service_revival_delay"
+                | "icon_directory"
+                | "icp_access"
+                | "icp_hit_stale"
+                | "icp_port"
+                | "icp_query_timeout"
+                | "ident_lookup_access"
+                | "ident_timeout"
+                | "ie_refresh"
+                | "ignore_expect_100"
+                | "ignore_ims_on_miss"
+                | "ignore_unknown_nameservers"
+                | "incoming_dns_average"
+                | "incoming_http_average"
+                | "incoming_icp_average"
+                | "incoming_rate"
+                | "ipcache_high"
+                | "ipcache_low"
+                | "ipcache_size"
+                | "loadable_modules"
+                | "location_rewrite_access"
+                | "location_rewrite_children"
+                | "location_rewrite_concurrency"
+                | "location_rewrite_program"
+                | "log_access"
+                | "logfile_daemon"
+                | "logfile_rotate"
+                | "logformat"
+                | "log_fqdn"
+                | "log_icp_queries"
+                | "log_ip_on_direct"
+                | "log_mime_hdrs"
+                | "log_uses_indirect_client"
+                | "mail_from"
+                | "mail_program"
+                | "max_filedescriptors"
+                | "maximum_icp_query_timeout"
+                | "maximum_object_size"
+                | "maximum_object_size_in_memory"
+                | "maximum_single_addr_tries"
+                | "max_open_disk_fds"
+                | "max_stale"
+                | "mcast_groups"
+                | "mcast_icp_query_timeout"
+                | "mcast_miss_addr"
+                | "mcast_miss_encode_key"
+                | "mcast_miss_port"
+                | "mcast_miss_ttl"
+                | "memory_pools"
+                | "memory_pools_limit"
+                | "memory_replacement_policy"
+                | "mime_table"
+                | "min_dns_poll_cnt"
+                | "min_http_poll_cnt"
+                | "min_icp_poll_cnt"
+                | "minimum_direct_hops"
+                | "minimum_direct_rtt"
+                | "minimum_expiry_time"
+                | "minimum_icp_query_timeout"
+                | "minimum_object_size"
+                | "miss_access"
+                | "negative_dns_ttl"
+                | "negative_ttl"
+                | "neighbor_type_domain"
+                | "netdb_filename"
+                | "netdb_high"
+                | "netdb_low"
+                | "netdb_ping_period"
+                | "never_direct"
+                | "nonhierarchical_direct"
+                | "offline_mode"
+                | "pconn_timeout"
+                | "peer_connect_timeout"
+                | "persistent_connection_after_error"
+                | "persistent_request_timeout"
+                | "pid_filename"
+                | "pinger_enable"
+                | "pinger_program"
+                | "pipeline_prefetch"
+                | "positive_dns_ttl"
+                | "prefer_direct"
+                | "qos_flows"
+                | "query_icmp"
+                | "quick_abort_max"
+                | "quick_abort_min"
+                | "quick_abort_pct"
+                | "range_offset_limit"
+                | "read_ahead_gap"
+                | "read_timeout"
+                | "redirector_bypass"
+                | "referer_log"
+                | "refresh_all_ims"
+                | "refresh_stale_hit"
+                | "relaxed_header_parser"
+                | "reload_into_ims"
+                | "reply_body_max_size"
+                | "reply_header_access"
+                | "reply_header_max_size"
+                | "request_body_max_size"
+                | "request_entities"
+                | "request_header_access"
+                | "request_header_max_size"
+                | "request_timeout"
+                | "retry_on_error"
+                | "server_http11"
+                | "server_persistent_connections"
+                | "short_icon_urls"
+                | "shutdown_lifetime"
+                | "sleep_after_fork"
+                | "snmp_access"
+                | "snmp_incoming_address"
+                | "snmp_outgoing_address"
+                | "snmp_port"
+                | "ssl_bump"
+                | "ssl_engine"
+                | "sslpassword_program"
+                | "sslproxy_cafile"
+                | "sslproxy_capath"
+                | "sslproxy_cert_error"
+                | "sslproxy_cipher"
+                | "sslproxy_client_certificate"
+                | "sslproxy_client_key"
+                | "sslproxy_flags"
+                | "sslproxy_options"
+                | "sslproxy_version"
+                | "ssl_unclean_shutdown"
+                | "store_avg_object_size"
+                | "store_dir_select_algorithm"
+                | "store_objects_per_bucket"
+                | "storeurl_access"
+                | "storeurl_rewrite_children"
+                | "storeurl_rewrite_concurrency"
+                | "storeurl_rewrite_program"
+                | "strip_query_terms"
+                | "tcp_outgoing_address"
+                | "tcp_outgoing_tos"
+                | "tcp_recv_bufsize"
+                | "test_reachability"
+                | "udp_incoming_address"
+                | "udp_outgoing_address"
+                | "umask"
+                | "unique_hostname"
+                | "unlinkd_program"
+                | "update_headers"
+                | "uri_whitespace"
+                | "url_rewrite_access"
+                | "url_rewrite_bypass"
+                | "url_rewrite_children"
+                | "url_rewrite_concurrency"
+                | "url_rewrite_host_header"
+                | "url_rewrite_program"
+                | "useragent_log"
+                | "vary_ignore_expire"
+                | "via"
+                | "visible_hostname"
+                | "wccp2_address"
+                | "wccp2_assignment_method"
+                | "wccp2_forwarding_method"
+                | "wccp2_rebuild_wait"
+                | "wccp2_return_method"
+                | "wccp2_router"
+                | "wccp2_service"
+                | "wccp2_service_info"
+                | "wccp2_weight"
+                | "wccp_address"
+                | "wccp_router"
+                | "wccp_version"
+                | "windows_ipaddrchangemonitor"
+                | "zero_buffers"
+                | "zph_local"
+                | "zph_mode"
+                | "zph_option"
+                | "zph_parent"
+                | "zph_sibling"
+let entry       = indent . Spacevars.entry entry_re
+
+(************************************************************************
+ *                                AUTH
+ *************************************************************************)
+
+let auth_re     = "auth_param"
+let auth        = indent
+                  . [ key "auth_param"
+                  . value "scheme"
+                  . value "parameter"
+                  . (value "setting") ?
+                  . comment_or_eol ]
+
+(************************************************************************
+ *                                ACL
+ *************************************************************************)
+
+let acl_re     = "acl"
+let acl        = indent
+                 . [ key acl_re . spc
+                 . [ key word
+                   . value "type"
+                   . value "setting"
+                   . parameters?
+                   . comment_or_eol ] ]
+
+(************************************************************************
+ *                             HTTP ACCESS
+ *************************************************************************)
+
+let http_access_re
+               = "http_access"
+               | "upgrade_http0.9"
+               | "broken_vary_encoding"
+
+let http_access
+               = indent
+                 . [ key http_access_re
+                 . spc
+                 . [ key /allow|deny/
+                   . spc
+                   . sto_to_spc
+                   . parameters? ]
+                 . comment_or_eol ]
+
+(************************************************************************
+ *                             REFRESH PATTERN
+ *************************************************************************)
+
+let refresh_pattern_option_re = "override-expire"
+                             | "override-lastmod"
+                             | "reload-into-ims"
+                             | "ignore-reload"
+                             | "ignore-no-cache"
+                             | "ignore-no-store"
+                             | "ignore-must-revalidate"
+                             | "ignore-private"
+                             | "ignore-auth"
+                             | "refresh-ims"
+                             | "store-stale"
+
+let refresh_pattern = indent . [ key "refresh_pattern" . spc
+                      . [ label "case_insensitive" . Util.del_str "-i" . spc ]?
+                      . store /[^ \t\n]+/ . spc
+                      . [ label "min" . store Rx.integer ] . spc
+                      . [ label "percent" . store Rx.integer . Util.del_str "%" ] . spc
+                      . [ label "max" . store Rx.integer ]
+                      . (spc . Build.opt_list [ label "option" . store refresh_pattern_option_re ] spc)?
+                      . comment_or_eol ]
+
+(************************************************************************
+ *                             EXTENSION METHODS
+ *************************************************************************)
+
+let extension_methods = indent . [ key "extension_methods" . spc
+                        . Build.opt_list [ seq "extension_method" . store Rx.word ] spc
+                        . comment_or_eol ]
+
+(************************************************************************
+ *                               LENS
+ *************************************************************************)
+
+let lns         = Spacevars.lns (entry|auth|acl|http_access|refresh_pattern|extension_methods)
+
+let filter      = Util.stdexcl
+                . incl "/etc/squid/squid.conf"
+
+let xfm         = transform lns filter
diff --git a/lenses/sshd.aug b/lenses/sshd.aug
new file mode 100644 (file)
index 0000000..8a3973b
--- /dev/null
@@ -0,0 +1,131 @@
+(*
+Module: Sshd
+  Parses /etc/ssh/sshd_config
+
+Author: David Lutterkort lutter@redhat.com
+        Dominique Dumont dominique.dumont@hp.com
+
+About: Reference
+  sshd_config man page.
+  See http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config&sektion=5
+
+About: License
+  This file is licensed under the LGPL v2+.
+
+About: Lens Usage
+  Sample usage of this lens in augtool:
+
+    * Get your current setup
+      > print /files/etc/ssh/sshd_config
+      ...
+
+    * Set X11Forwarding to "no"
+      > set /files/etc/ssh/sshd_config/X11Forwarding "no"
+
+  More advanced usage:
+
+    * Set a Match section
+      > set /files/etc/ssh/sshd_config/Match[1]/Condition/User "foo"
+      > set /files/etc/ssh/sshd_config/Match[1]/Settings/X11Forwarding "yes"
+
+  Saving your file:
+
+      > save
+
+
+About: CAVEATS
+
+  In sshd_config, Match blocks must be located at the end of the file.
+  This means that any new "global" parameters (i.e. outside of a Match
+  block) must be written before the first Match block. By default,
+  Augeas will write new parameters at the end of the file.
+
+  I.e. if you have a Match section and no ChrootDirectory parameter,
+  this command:
+
+     > set /files/etc/ssh/sshd_config/ChrootDirectory "foo"
+
+  will be stored in a new node after the Match section and Augeas will
+  refuse to save sshd_config file.
+
+  To create a new parameter as the right place, you must first create
+  a new Augeas node before the Match section:
+
+     > ins ChrootDirectory before /files/etc/ssh/sshd_config/Match
+
+  Then, you can set the parameter
+
+     > set /files/etc/ssh/sshd_config/ChrootDirectory "foo"
+
+
+About: Configuration files
+  This lens applies to /etc/ssh/sshd_config
+
+*)
+
+module Sshd =
+   autoload xfm
+
+   let eol = del /[ \t]*\n/ "\n"
+
+   let sep = Util.del_ws_spc
+
+   let key_re = /[A-Za-z0-9]+/
+         - /MACs|Match|AcceptEnv|Subsystem|(Allow|Deny)(Groups|Users)/
+
+   let comment = Util.comment
+   let empty = Util.empty
+
+   let array_entry (k:string) =
+     let value = store /[^ \t\n]+/ in
+     [ key k . [ sep . seq k . value]* . eol ]
+
+   let other_entry =
+     let value = store /[^ \t\n]+([ \t]+[^ \t\n]+)*/ in
+     [ key key_re . sep . value . eol ]
+
+   let accept_env = array_entry "AcceptEnv"
+
+   let allow_groups = array_entry "AllowGroups"
+   let allow_users = array_entry "AllowUsers"
+   let deny_groups = array_entry "DenyGroups"
+   let deny_users = array_entry "DenyUsers"
+
+   let subsystemvalue =
+     let value = store (/[^ \t\n](.*[^ \t\n])?/) in
+     [ key /[A-Za-z0-9]+/ . sep . value . eol ]
+
+   let subsystem =
+     [ key "Subsystem" .  sep .  subsystemvalue ]
+
+   let macs =
+     let mac_value = store /[^, \t\n]+/ in
+     [ key "MACs" . sep .
+         [ seq "macs" . mac_value ] .
+         ([ seq "macs" . Util.del_str "," . mac_value])* .
+         eol ]
+
+   let condition_entry =
+    let value = store  /[^ \t\n]+/ in
+    [ sep . key /[A-Za-z0-9]+/ . sep . value ]
+
+   let match_cond =
+     [ label "Condition" . condition_entry+ . eol ]
+
+   let match_entry =
+     ( comment | empty | (Util.indent . other_entry) )
+
+   let match =
+     [ key "Match" . match_cond
+        . [ label "Settings" .  match_entry+ ]
+     ]
+
+  let lns = (comment | empty | accept_env | allow_groups | allow_users
+          | deny_groups | subsystem | deny_users | macs
+          | other_entry ) * . match*
+
+  let xfm = transform lns (incl "/etc/ssh/sshd_config")
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/sudoers.aug b/lenses/sudoers.aug
new file mode 100644 (file)
index 0000000..a108ee2
--- /dev/null
@@ -0,0 +1,498 @@
+(*
+Module: Sudoers
+  Parses /etc/sudoers
+
+Author: Raphael Pinson <raphink@gmail.com>
+
+About: Reference
+  This lens tries to keep as close as possible to `man sudoers` where possible.
+
+For example, recursive definitions such as
+
+     > Cmnd_Spec_List ::= Cmnd_Spec |
+     >                    Cmnd_Spec ',' Cmnd_Spec_List
+
+are replaced by
+
+  >   let cmnd_spec_list = cmnd_spec . ( sep_com . cmnd_spec )*
+
+since Augeas cannot deal with recursive definitions.
+The definitions from `man sudoers` are put as commentaries for reference
+throughout the file. More information can be found in the manual.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Set first Defaults to apply to the "LOCALNET" network alias
+      > set /files/etc/sudoers/Defaults[1]/type "@LOCALNET"
+    * List all user specifications applying explicitely to the "admin" Unix group
+      > match /files/etc/sudoers/spec/user "%admin"
+    * Remove the full 3rd user specification
+      > rm /files/etc/sudoers/spec[3]
+
+About: Configuration files
+  This lens applies to /etc/sudoers. See <filter>.
+*)
+
+
+
+module Sudoers =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Generic primitives *)
+(* Variable: eol *)
+let eol       = del /[ \t]*\n/ "\n"
+
+(* Variable: indent *)
+let indent    = del /[ \t]*/ ""
+
+
+(* Group: Separators *)
+
+(* Variable: sep_spc *)
+let sep_spc  = del /[ \t]+/ " "
+
+(* Variable: sep_cont *)
+let sep_cont = del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "
+
+(* Variable: sep_cont_opt *)
+let sep_cont_opt = del /([ \t]*|[ \t]*\\\\\n[ \t]*)/ " "
+
+(* Variable: sep_com *)
+let sep_com  = sep_cont_opt . Util.del_str "," . sep_cont_opt
+
+(* Variable: sep_eq *)
+let sep_eq   = sep_cont_opt . Util.del_str "=" . sep_cont_opt
+
+(* Variable: sep_col *)
+let sep_col  = sep_cont_opt . Util.del_str ":" . sep_cont_opt
+
+(* Variable: sep_dquote *)
+let sep_dquote   = Util.del_str "\""
+
+
+(* Group: Stores *)
+
+(* Variable: sto_to_com_cmnd
+sto_to_com_cmnd does not begin or end with a space *)
+let sto_to_com_cmnd = store /([^,=:#() \t\n\\\\]([^,=:#()\n\\\\]|\\\\[=:,\\\\])*[^,=:#() \t\n\\\\])|[^,=:#() \t\n\\\\]/
+
+(* Variable: sto_to_com
+
+There could be a \ in the middle of a command *)
+let sto_to_com      = store /([^,=:#() \t\n\\\\][^,=:#()\n]*[^,=:#() \t\n\\\\])|[^,=:#() \t\n\\\\]/
+
+(* Variable: sto_to_com_host *)
+let sto_to_com_host = store /[^,=:#() \t\n\\\\]+/
+
+
+(* Variable: sto_to_com_user
+Escaped spaces are allowed *)
+let sto_to_com_user = store ( /([^,=:#() \t\n]([^,=:#() \t\n]|(\\\\[ \t]))*[^,=:#() \t\n])|[^,=:#() \t\n]/
+                              - /(User|Runas|Host|Cmnd)_Alias|Defaults.*/ )
+
+(* Variable: sto_to_com_col *)
+let sto_to_com_col      = store /[^",=#() \t\n\\\\]+/ (* " relax emacs *)
+
+(* Variable: sto_to_eq *)
+let sto_to_eq  = store /[^,=:#() \t\n\\\\]+/
+
+(* Variable: sto_to_spc *)
+let sto_to_spc = store /[^", \t\n\\\\]+|"[^", \t\n\\\\]+"/
+
+(* Variable: sto_to_spc_no_dquote *)
+let sto_to_spc_no_dquote = store /[^", \t\n\\\\]+/ (* " relax emacs *)
+
+(* Variable: sto_integer *)
+let sto_integer = store /[0-9]+/
+
+
+(* Group: Comments and empty lines *)
+
+(* View: comment
+Map comments in "#comment" nodes *)
+let comment =
+  let sto_to_eol = store (/([^ \t\n].*[^ \t\n]|[^ \t\n])/ - /include(dir)?.*/) in
+  [ label "#comment" . del /[ \t]*#[ \t]*/ "# " . sto_to_eol . eol ]
+
+(* View: empty
+Map empty lines *)
+let empty   = [ del /[ \t]*#?[ \t]*\n/ "\n" ]
+
+(* View: includedir *)
+let includedir =
+  [ key /#include(dir)?/ . Sep.space . store Rx.fspath . eol ]
+
+
+(************************************************************************
+ * Group:                                    ALIASES
+ *************************************************************************)
+
+(************************************************************************
+ * View: alias_field
+ *   Generic alias field to gather all Alias definitions
+ *
+ *   Definition:
+ *     > User_Alias ::= NAME '=' User_List
+ *     > Runas_Alias ::= NAME '=' Runas_List
+ *     > Host_Alias ::= NAME '=' Host_List
+ *     > Cmnd_Alias ::= NAME '=' Cmnd_List
+ *
+ *   Parameters:
+ *     kw:string - the label string
+ *     sto:lens  - the store lens
+ *************************************************************************)
+let alias_field (kw:string) (sto:lens) = [ label kw . sto ]
+
+(* View: alias_list
+     List of <alias_fields>, separated by commas *)
+let alias_list  (kw:string) (sto:lens) =
+  alias_field kw sto . ( sep_com . alias_field kw sto )*
+
+(************************************************************************
+ * View: alias_name
+ *   Name of an <alias_entry_single>
+ *
+ *   Definition:
+ *     > NAME ::= [A-Z]([A-Z][0-9]_)*
+ *************************************************************************)
+let alias_name
+    = [ label "name" . store /[A-Z][A-Z0-9_]*/ ]
+
+(************************************************************************
+ * View: alias_entry_single
+ *   Single <alias_entry>, named using <alias_name> and listing <alias_list>
+ *
+ *   Definition:
+ *     > Alias_Type NAME = item1, item2, ...
+ *
+ *   Parameters:
+ *     field:string - the field name, passed to <alias_list>
+ *     sto:lens     - the store lens, passed to <alias_list>
+ *************************************************************************)
+let alias_entry_single (field:string) (sto:lens)
+    = [ label "alias" . alias_name . sep_eq . alias_list field sto ]
+
+(************************************************************************
+ * View: alias_entry
+ *   Alias entry, a list of comma-separated <alias_entry_single> fields
+ *
+ *   Definition:
+ *     > Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
+ *
+ *   Parameters:
+ *     kw:string    - the alias keyword string
+ *     field:string - the field name, passed to <alias_entry_single>
+ *     sto:lens     - the store lens, passed to <alias_entry_single>
+ *************************************************************************)
+let alias_entry (kw:string) (field:string) (sto:lens)
+    = [ indent . key kw . sep_cont . alias_entry_single field sto
+          . ( sep_col . alias_entry_single field sto )* . eol ]
+
+(* TODO: go further in user definitions *)
+(* View: user_alias
+     User_Alias, see <alias_field> *)
+let user_alias  = alias_entry "User_Alias" "user" sto_to_com
+(* View: runas_alias
+     Run_Alias, see <alias_field> *)
+let runas_alias = alias_entry "Runas_Alias" "runas_user" sto_to_com
+(* View: host_alias
+     Host_Alias, see <alias_field> *)
+let host_alias  = alias_entry "Host_Alias" "host" sto_to_com
+(* View: cmnd_alias
+     Cmnd_Alias, see <alias_field> *)
+let cmnd_alias  = alias_entry "Cmnd_Alias" "command" sto_to_com_cmnd
+
+
+(************************************************************************
+ * View: alias
+ *   Every kind of Alias entry,
+ *     see <user_alias>, <runas_alias>, <host_alias> and <cmnd_alias>
+ *
+ *   Definition:
+ *     > Alias ::= 'User_Alias'  User_Alias (':' User_Alias)* |
+ *     >           'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
+ *     >           'Host_Alias'  Host_Alias (':' Host_Alias)* |
+ *     >           'Cmnd_Alias'  Cmnd_Alias (':' Cmnd_Alias)*
+ *************************************************************************)
+let alias = user_alias | runas_alias | host_alias | cmnd_alias
+(************************************************************************
+ * Group:                          DEFAULTS
+ *************************************************************************)
+
+(************************************************************************
+ * View: default_type
+ *   Type definition for <defaults>
+ *
+ *   Definition:
+ *     > Default_Type ::= 'Defaults' |
+ *     >                  'Defaults' '@' Host_List |
+ *     >                  'Defaults' ':' User_List |
+ *     >                  'Defaults' '>' Runas_List
+ *************************************************************************)
+let default_type     =
+  let value = store /[@:>][^ \t\n\\\\]+/ in
+  [ label "type" . value ]
+
+(************************************************************************
+ * View: del_negate
+ *   Delete an even number of '!' signs
+ *************************************************************************)
+let del_negate = del /(!!)*/ ""
+
+(************************************************************************
+ * View: negate_node
+ *   Negation of boolean values for <defaults>. Accept one optional '!'
+ *   and produce a 'negate' node if there is one.
+ *************************************************************************)
+let negate_node = [ del "!" "!" . label "negate" ]
+
+let negate_or_value (key:lens) (value:lens) =
+  [ del_negate . (negate_node . key | key . value) ]
+
+(************************************************************************
+ * View: parameter_flag
+ *   A flag parameter for <defaults>
+ *
+ *   Flags are implicitly boolean and can be turned off via the '!'  operator.
+ *   Some integer, string and list parameters may also be used in a boolean
+ *     context to disable them.
+ *************************************************************************)
+let parameter_flag_kw    = "always_set_home" | "authenticate" | "env_editor"
+                         | "env_reset" | "fqdn" | "ignore_dot"
+                         | "ignore_local_sudoers" | "insults" | "log_host"
+                         | "log_year" | "long_otp_prompt" | "mail_always"
+                         | "mail_badpass" | "mail_no_host" | "mail_no_perms"
+                         | "mail_no_user" | "noexec" | "path_info"
+                         | "passprompt_override" | "preserve_groups"
+                         | "requiretty" | "root_sudo" | "rootpw" | "runaspw"
+                         | "set_home" | "set_logname" | "setenv"
+                         | "shell_noargs" | "stay_setuid" | "targetpw"
+                         | "tty_tickets" | "visiblepw"
+
+let parameter_flag       = [ del_negate . negate_node?
+                               . key parameter_flag_kw ]
+
+(************************************************************************
+ * View: parameter_integer
+ *   An integer parameter for <defaults>
+ *************************************************************************)
+let parameter_integer_nobool_kw = "passwd_tries"
+
+let parameter_integer_nobool    = [ key parameter_integer_nobool_kw . sep_eq
+                                      . del /"?/ "" . sto_integer
+                                      . del /"?/ "" ]
+
+
+let parameter_integer_bool_kw   = "loglinelen" | "passwd_timeout"
+                                | "timestamp_timeout" | "umask"
+
+let parameter_integer_bool      =
+  negate_or_value
+    (key parameter_integer_bool_kw)
+    (sep_eq . del /"?/ "" . sto_integer . del /"?/ "")
+
+let parameter_integer           = parameter_integer_nobool
+                                | parameter_integer_bool
+
+(************************************************************************
+ * View: parameter_string
+ *   A string parameter for <defaults>
+ *
+ *   An odd number of '!' operators negate the value of the item;
+ *      an even number just cancel each other out.
+ *************************************************************************)
+let parameter_string_nobool_kw = "badpass_message" | "editor" | "mailsub"
+                               | "noexec_file" | "passprompt" | "runas_default"
+                               | "syslog_badpri" | "syslog_goodpri"
+                               | "timestampdir" | "timestampowner" | "secure_path"
+
+let parameter_string_nobool    = [ key parameter_string_nobool_kw . sep_eq
+                                     . del /"?/ "" . sto_to_com_col
+                                     . del /"?/ "" ]
+
+let parameter_string_bool_kw   = "exempt_group" | "lecture" | "lecture_file"
+                               | "listpw" | "logfile" | "mailerflags"
+                               | "mailerpath" | "mailto" | "exempt_group"
+                               | "syslog" | "verifypw" | "logfile"
+                               | "mailerflags" | "mailerpath" | "mailto"
+                               | "syslog" | "verifypw"
+
+let parameter_string_bool      =
+  negate_or_value
+    (key parameter_string_bool_kw)
+    (sep_eq . sto_to_com_col)
+
+let parameter_string           = parameter_string_nobool
+                               | parameter_string_bool
+
+(************************************************************************
+ * View: parameter_lists
+ *   A single list parameter for <defaults>
+ *
+ *   All lists can be used in a boolean context
+ *   The argument may be a double-quoted, space-separated list or a single
+ *      value without double-quotes.
+ *   The list can be replaced, added to, deleted from, or disabled
+ *      by using the =, +=, -=, and ! operators respectively.
+ *   An odd number of '!' operators negate the value of the item;
+ *      an even number just cancel each other out.
+ *************************************************************************)
+let parameter_lists_kw           = "env_check" | "env_delete" | "env_keep"
+let parameter_lists_value        = [ label "var" . sto_to_spc_no_dquote ]
+let parameter_lists_value_dquote = [ label "var"
+                                     . del /"?/ "" . sto_to_spc_no_dquote
+                                     . del /"?/ "" ]
+
+let parameter_lists_values = parameter_lists_value_dquote
+                           | ( sep_dquote . parameter_lists_value
+                               . ( sep_cont . parameter_lists_value )+
+                               . sep_dquote )
+
+let parameter_lists_sep    = sep_cont_opt
+                             . ( [ del "+" "+" . label "append" ]
+                               | [ del "-" "-" . label "remove" ] )?
+                             . del "=" "=" . sep_cont_opt
+
+let parameter_lists        =
+  negate_or_value
+    (key parameter_lists_kw)
+    (parameter_lists_sep . parameter_lists_values)
+
+(************************************************************************
+ * View: parameter
+ *   A single parameter for <defaults>
+ *
+ *   Definition:
+ *     > Parameter ::= Parameter '=' Value |
+ *     >               Parameter '+=' Value |
+ *     >               Parameter '-=' Value |
+ *     >               '!'* Parameter
+ *
+ *     Parameters may be flags, integer values, strings, or lists.
+ *
+ *************************************************************************)
+let parameter        = parameter_flag | parameter_integer
+                     | parameter_string | parameter_lists
+
+(************************************************************************
+ * View: parameter_list
+ *   A list of comma-separated <parameters> for <defaults>
+ *
+ *   Definition:
+ *     > Parameter_List ::= Parameter |
+ *     >                    Parameter ',' Parameter_List
+ *************************************************************************)
+let parameter_list   = parameter . ( sep_com . parameter )*
+
+(************************************************************************
+ * View: defaults
+ *   A Defaults entry
+ *
+ *   Definition:
+ *     > Default_Entry ::= Default_Type Parameter_List
+ *************************************************************************)
+let defaults = [ indent . key "Defaults" . default_type? . sep_cont
+                   . parameter_list . eol ]
+
+
+
+(************************************************************************
+ * Group:                     USER SPECIFICATION
+ *************************************************************************)
+
+(************************************************************************
+ * View: runas_spec
+ *   A runas specification for <spec>, using <alias_list>
+ *
+ *   Definition:
+ *     > Runas_Spec ::= '(' Runas_List ')'
+ *************************************************************************)
+let runas_spec = Util.del_str "(" . alias_list "runas_user" sto_to_com
+    . Util.del_str ")" . sep_cont_opt
+
+(************************************************************************
+ * View: tag_spec
+ *   Tag specification for <spec>
+ *
+ *   Definition:
+ *     > Tag_Spec ::= ('NOPASSWD:' | 'PASSWD:' | 'NOEXEC:' | 'EXEC:' |
+ *     >              'SETENV:' | 'NOSETENV:')
+ *************************************************************************)
+let tag_spec   =
+  [ label "tag" . store /(NO)?(PASSWD|EXEC|SETENV)/ . sep_col ]
+
+(************************************************************************
+ * View: cmnd_spec
+ *   Command specification for <spec>,
+ *     with optional <runas_spec> and any amount of <tag_specs>
+ *
+ *   Definition:
+ *     > Cmnd_Spec ::= Runas_Spec? Tag_Spec* Cmnd
+ *************************************************************************)
+let cmnd_spec  =
+  [ label "command" .  runas_spec? . tag_spec* . sto_to_com_cmnd ]
+
+(************************************************************************
+ * View: cmnd_spec_list
+ *   A list of comma-separated <cmnd_specs>
+ *
+ *   Definition:
+ *     > Cmnd_Spec_List ::= Cmnd_Spec |
+ *     >                    Cmnd_Spec ',' Cmnd_Spec_List
+ *************************************************************************)
+let cmnd_spec_list = cmnd_spec . ( sep_com . cmnd_spec )*
+
+
+(************************************************************************
+ * View: spec_list
+ *   Group of hosts with <cmnd_spec_list>
+ *************************************************************************)
+let spec_list = [ label "host_group" . alias_list "host" sto_to_com_host
+                    . sep_eq . cmnd_spec_list ]
+
+(************************************************************************
+ * View: spec
+ *   A user specification, listing colon-separated <spec_lists>
+ *
+ *   Definition:
+ *     > User_Spec ::= User_List Host_List '=' Cmnd_Spec_List \
+ *     >               (':' Host_List '=' Cmnd_Spec_List)*
+ *************************************************************************)
+let spec = [ label "spec" . indent
+               . alias_list "user" sto_to_com_user . sep_cont
+               . spec_list
+               . ( sep_col . spec_list )* . eol ]
+
+
+(************************************************************************
+ * Group:                        LENS & FILTER
+ *************************************************************************)
+
+(* View: lns
+     The sudoers lens, any amount of
+       * <empty> lines
+       * <comments>
+       * <includedirs>
+       * <aliases>
+       * <defaults>
+       * <specs>
+*)
+let lns = ( empty | comment | includedir | alias | defaults | spec  )*
+
+(* View: filter *)
+let filter = (incl "/etc/sudoers")
+    . (incl "/usr/local/etc/sudoers")
+    . (incl "/etc/sudoers.d/*")
+    . (incl "/usr/local/etc/sudoers.d/*")
+    . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/sysconfig.aug b/lenses/sysconfig.aug
new file mode 100644 (file)
index 0000000..9ee668e
--- /dev/null
@@ -0,0 +1,60 @@
+(* Variation of the Shellvars lens                                     *)
+(* Supports only what's needed to handle sysconfig files               *)
+(* Modified to strip quotes. In the put direction, add double quotes   *)
+(* around values that need them                                        *)
+(* To keep things simple, we also do not support shell variable arrays *)
+module Sysconfig =
+  let eol = Util.eol
+
+  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
+  let eq = Util.del_str "="
+  let comment = Util.comment
+  let empty   = Util.empty
+  let xchgs   = Build.xchgs
+  let dels    = Util.del_str
+
+  let nothing = del /(""|'')?/ "" . value ""
+
+  (* Chars allowed in a bare string *)
+  let bchar = /[^ \t\n\"'\\]|\\\\./
+  let qchar = /["']/  (* " *)
+
+  (* We split the handling of right hand sides into a few cases:
+   *   bare  - strings that contain no spaces, optionally enclosed in
+   *           single or double quotes
+   *   dquot - strings that contain at least one space or apostrophe,
+   *           which must be enclosed in double quotes
+   *   squot - strings that contain an unescaped double quote
+   *)
+  let bare = del qchar? "" . store (bchar+) . del qchar? ""
+  let dquot =
+    del qchar "\"" . store (bchar* . /[ \t']/ . bchar*)+ . del qchar "\""
+  let squot =
+    dels "'" . store ((bchar|/[ \t]/)* . "\"" . (bchar|/[ \t]/)*)+ . dels "'"
+
+  let export = [ key "export" . Util.del_ws_spc ]
+  let kv (value:lens) = [ export? . key key_re . eq . value . eol ]
+  let assign = kv nothing | kv bare | kv dquot | kv squot
+
+  let var_action (name:string) =
+    [ xchgs name ("@" . name) . Util.del_ws_spc . store key_re . eol ]
+
+  let unset = var_action "unset"
+  let bare_export = var_action "export"
+
+  let source =
+    [
+      del /\.|source/ "." . label ".source" .
+      Util.del_ws_spc . store /[^= \t\n]+/ . eol
+    ]
+
+  let lns = (comment | empty | source | assign | unset | bare_export) *
+
+(*
+  Examples:
+
+  abc   -> abc -> abc
+  "abc" -> abc -> abc
+  "a b" -> a b -> "a b"
+  'a"b' -> a"b -> 'a"b'
+*)
diff --git a/lenses/sysctl.aug b/lenses/sysctl.aug
new file mode 100644 (file)
index 0000000..5b33f65
--- /dev/null
@@ -0,0 +1,21 @@
+module Sysctl =
+  autoload xfm
+
+  let filter = incl "/etc/sysctl.conf"
+
+  let eol = Util.eol
+  let indent = Util.indent
+  let key_re = /[A-Za-z0-9_.-]+/
+  let eq = del /[ \t]*=[ \t]*/ " = "
+  let value_re = /[^ \t\n](.*[^ \t\n])?/
+
+  let comment = [ indent . label "#comment" . del /[#;][ \t]*/ "# "
+        . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
+
+  let empty = Util.empty
+
+  let kv = [ indent . key key_re . eq . store value_re . eol ]
+
+  let lns = (empty | comment | kv) *
+
+  let xfm = transform lns filter
diff --git a/lenses/syslog.aug b/lenses/syslog.aug
new file mode 100644 (file)
index 0000000..cda17bb
--- /dev/null
@@ -0,0 +1,251 @@
+(*
+Module: Syslog
+  parses /etc/syslog.conf
+
+Author: Mathieu Arnold <mat@FreeBSD.org>
+
+About: Reference
+  This lens tries to keep as close as possible to `man 5 resolv.conf` where possible.
+  An online source being :
+  http://www.freebsd.org/cgi/man.cgi?query=syslog.conf&sektion=5
+
+About: Licence
+  This file is licensed under the BSD License.
+
+About: Lens Usage
+   To be documented
+
+About: Configuration files
+  This lens applies to /etc/syslog.conf. See <filter>.
+
+ *)
+module Syslog =
+  autoload xfm
+
+       (************************************************************************
+        * Group:                 USEFUL PRIMITIVES
+        *************************************************************************)
+
+       (* Group: Comments and empty lines *)
+
+       (* Variable: empty *)
+        let empty      = Util.empty
+       (* Variable: eol *)
+        let eol        = Util.eol
+       (* Variable: sep_tab *)
+        let sep_tab    = del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ "\t"
+
+       (* Variable: sep_tab_opt *)
+        let sep_tab_opt = del /([ \t]*|[ \t]*\\\\\n[ \t]*)/ ""
+
+       (* View: comment
+         Map comments into "#comment" nodes
+         Can't use Util.comment as #+ and #! have a special meaning *)
+       let comment =
+         [ label "#comment" . del /#[ \t]*/ "# "
+             . store /([^ \t\n+!-].*[^ \t\n]|[^ \t\n+!-])/ . eol ]
+
+       (* Group: single characters macro *)
+
+        (* Variable: comma
+        Deletes a comma and default to it
+        *)
+       let comma      = sep_tab_opt . Util.del_str "," . sep_tab_opt
+       (* Variable: colon
+        Deletes a colon and default to it
+        *)
+       let colon      = sep_tab_opt . Util.del_str ":" . sep_tab_opt
+       (* Variable: semicolon
+        Deletes a semicolon and default to it
+        *)
+       let semicolon  = sep_tab_opt . Util.del_str ";" . sep_tab_opt
+       (* Variable: at
+        Deletes a at and default to it
+        *)
+       let at         = Util.del_str "@"
+       (* Variable: dot
+        Deletes a dot and default to it
+        *)
+       let dot        = Util.del_str "."
+       (* Variable: pipe
+        Deletes a pipe and default to it
+        *)
+       let pipe       = Util.del_str "|"
+       (* Variable: plus
+        Deletes a plus and default to it
+        *)
+       let plus       = Util.del_str "+"
+       (* Variable: bang
+        Deletes a bang and default to it
+        *)
+       let bang       = Util.del_str "!"
+
+       (* Variable: opt_hash
+         deletes an optional # sign
+         *)
+       let opt_hash   = del /#?/ ""
+       (* Variable: opt_plus
+         deletes an optional + sign
+         *)
+       let opt_plus   = del /\+?/ ""
+
+       (* Group: various macros *)
+
+       (* Variable: word
+         our version can't start with [_.-] because it would mess up the grammar
+         *)
+       let word      = /[A-Za-z0-9][A-Za-z0-9_.-]*/
+
+       (* Variable: comparison
+         a comparison is an optional ! with optionaly some of [<=>]
+         *)
+        let comparison = /(!|[<=>]+|![<=>]+)/
+
+       (* Variable: token
+         alphanum or "*"
+         *)
+        let token      = /([a-z0-9]+|\*)/
+
+       (* Variable: file_r
+        a file begins with a / and get almost anything else after
+        *)
+       let file_r     = /\/[^ \t\n]+/
+
+       (* Variable: loghost_r
+        Matches a hostname, that is labels speparated by dots, labels can't
+        start or end with a "-".  maybe a bit too complicated for what it's worth *)
+       let loghost_r = /[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*/
+
+       (* Group: Function *)
+
+       (* View: label_opt_list
+        Uses Build.opt_list to generate a list of labels
+
+        Parameters:
+         l:string - the label name
+         r:lens   - the lens going after the label
+         s:lens   - the separator lens passed to Build.opt_list
+        *)
+       let label_opt_list (l:string) (r:lens) (s:lens) = Build.opt_list [ label l . r ] s
+
+       (* View: label_opt_list_or
+        Either label_opt_list matches something or it emits a single label
+        with the "or" string.
+
+        Parameters:
+         l:string  - the label name
+         r:lens    - the lens going after the label
+         s:lens    - the separator lens passed to Build.opt_list
+         or:string - the string used if the label_opt_list does not match anything
+        *)
+       let label_opt_list_or (l:string) (r:lens) (s:lens) (or:string) =
+         ( label_opt_list l r s | [ label l . store or ] )
+
+
+       (************************************************************************
+        * Group:                 LENSE DEFINITION
+        *************************************************************************)
+
+       (* Group: selector *)
+
+       (* View: facilities
+        a list of facilities, separated by commas
+        *)
+       let facilities = label_opt_list "facility" (store token) comma
+
+       (* View: selector
+        a selector is a list of facilities, an optional comparison and a level
+        *)
+       let selector = facilities . dot .
+                       [ label "comparison" . store comparison]? .
+                       [ label "level" . store token ]
+
+       (* View: selectors
+        a list of selectors, separated by semicolons
+        *)
+        let selectors = label_opt_list "selector" selector semicolon
+
+       (* Group: action *)
+
+       (* View: file
+        a file may start with a "-" meaning it does not gets sync'ed everytime
+        *)
+       let file = [ Build.xchgs "-" "no_sync" ]? . [ label "file" . store file_r ]
+
+       (* View: loghost
+        a loghost is an @  sign followed by the hostname and a possible port
+        *)
+       let loghost = at . [ label "hostname" . store loghost_r ] .
+           (colon . [ label "port" . store /[0-9]+/ ] )?
+
+       (* View: users
+        a list of users or a "*"
+        *)
+       let users = label_opt_list_or "user" (store word) comma "*"
+
+       (* View: logprogram
+        a log program begins with a pipe
+        *)
+       let logprogram = pipe . [ label "program" . store /[^ \t\n][^\n]+[^ \t\n]/ ]
+
+       (* View: action
+        an action is either a file, a host, users, or a program
+        *)
+        let action = (file | loghost | users | logprogram)
+
+       (* Group: Entry *)
+
+       (* View: entry
+        an entry contains selectors and an action
+        *)
+        let entry = [ label "entry" .
+           selectors . sep_tab .
+           [ label "action" . action ] . eol ]
+
+       (* View: entries
+        entries are either comments/empty lines or entries
+        *)
+       let entries = (empty | comment | entry)*
+
+       (* Group: Program matching *)
+
+       (* View: programs
+        a list of programs
+        *)
+       let programs = label_opt_list_or "program" (store word) comma "*"
+
+       (* View: program
+        a program begins with an optional hash, a bang, and an optional + or -
+        *)
+       let program = [ label "program" . opt_hash . bang .
+             ( opt_plus | [ Build.xchgs "-" "reverse" ] ) .
+             programs . eol .  entries ]
+
+       (* Group: Hostname maching *)
+
+       (* View: hostnames
+        a list of hostnames
+        *)
+       let hostnames = label_opt_list_or "hostname" (store Rx.word) comma "*"
+
+       (* View: hostname
+        a program begins with an optional hash, and a + or -
+        *)
+       let hostname = [ label "hostname" . opt_hash .
+             ( plus | [ Build.xchgs "-" "reverse" ] ) .
+             hostnames . eol .  entries ]
+
+       (* Group: Top of the tree *)
+
+       (* View: lns
+        generic entries then programs or hostnames matching blocs
+        *)
+        let lns = entries . ( program | hostname )*
+
+       (* Variable: filter
+        all you need is /etc/syslog.conf
+        *)
+        let filter = incl "/etc/syslog.conf"
+
+        let xfm = transform lns filter
+
diff --git a/lenses/tests/test_access.aug b/lenses/tests/test_access.aug
new file mode 100644 (file)
index 0000000..3d31fbd
--- /dev/null
@@ -0,0 +1,78 @@
+module Test_access =
+
+let conf = "+ : ALL : LOCAL
++ : root : localhost.localdomain
+- : root : 127.0.0.1 .localdomain
++ : root @admins : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6
+# IP v6 support
++ : john foo : 2001:4ca0:0:101::1 2001:4ca0:0:101::/64
+# Except
++ : ALL EXCEPT john @wheel : ALL EXCEPT LOCAL .win.tue.nl
+"
+
+test Access.lns get conf =
+    { "access" = "+"
+        { "user" = "ALL" }
+        { "origin" = "LOCAL" } }
+    { "access" = "+"
+        { "user" = "root" }
+        { "origin" = "localhost.localdomain" } }
+    { "access" = "-"
+        { "user" = "root" }
+        { "origin" = "127.0.0.1" }
+        { "origin" = ".localdomain" } }
+    { "access" = "+"
+        { "user" = "root" }
+        { "netgroup" = "admins" }
+        { "origin" = "cron" }
+        { "origin" = "crond" }
+        { "origin" = ":0" }
+        { "origin" = "tty1" }
+        { "origin" = "tty2" }
+        { "origin" = "tty3" }
+        { "origin" = "tty4" }
+        { "origin" = "tty5" }
+        { "origin" = "tty6" } }
+    { "#comment" = "IP v6 support" }
+    { "access" = "+"
+        { "user" = "john" }
+        { "user" = "foo" }
+        { "origin" = "2001:4ca0:0:101::1" }
+        { "origin" = "2001:4ca0:0:101::/64" } }
+    { "#comment" = "Except" }
+    { "access" = "+"
+        { "user" = "ALL" }
+        { "except"
+           { "user" = "john" }
+           { "netgroup" = "wheel" } }
+        { "origin" = "ALL" }
+        { "except"
+           { "origin" = "LOCAL" }
+           { "origin" = ".win.tue.nl" } } }
+
+test Access.lns put conf after
+    insa "access" "access[last()]" ;
+    set "access[last()]" "-" ;
+    set "access[last()]/user" "ALL" ;
+    set "access[last()]/origin" "ALL"
+ = "+ : ALL : LOCAL
++ : root : localhost.localdomain
+- : root : 127.0.0.1 .localdomain
++ : root @admins : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6
+# IP v6 support
++ : john foo : 2001:4ca0:0:101::1 2001:4ca0:0:101::/64
+# Except
++ : ALL EXCEPT john @wheel : ALL EXCEPT LOCAL .win.tue.nl
+- : ALL : ALL
+"
+
+(* Bug #190 *)
+test Access.lns get "+ : @group@@domain : ALL \n" =
+  { "access" = "+"
+    { "netgroup" = "group"
+      { "nisdomain" = "domain" } }
+    { "origin" = "ALL" } }
+
+test Access.lns put "+ : @group : ALL \n" after
+  set "/access/netgroup[. = 'group']/nisdomain" "domain" =
+"+ : @group@@domain : ALL \n"
diff --git a/lenses/tests/test_aliases.aug b/lenses/tests/test_aliases.aug
new file mode 100644 (file)
index 0000000..4041f8a
--- /dev/null
@@ -0,0 +1,69 @@
+module Test_aliases =
+
+  let file = "#
+#  Aliases in this file will NOT be expanded in the header from
+#  Mail, but WILL be visible over networks or from /bin/mail.
+
+# Basic system aliases -- these MUST be present.
+mailer-daemon: postmaster
+postmaster:    root
+
+# General redirections for pseudo accounts.
+bin:           root, adm
+daemon:                root
+adm:           root
+"
+  test Aliases.lns get file =
+    { }
+    { "#comment" = "Aliases in this file will NOT be expanded in the header from" }
+    { "#comment" = "Mail, but WILL be visible over networks or from /bin/mail." }
+    {}
+    { "#comment" = "Basic system aliases -- these MUST be present." }
+    { "1" { "name" = "mailer-daemon" }
+          { "value" = "postmaster" } }
+    { "2" { "name" = "postmaster" }
+          { "value" = "root" } }
+    {}
+    { "#comment" = "General redirections for pseudo accounts." }
+    { "3" { "name" = "bin" }
+          { "value" = "root" }
+          { "value" = "adm" } }
+    { "4" { "name" = "daemon" }
+          { "value" = "root" } }
+    { "5" { "name" = "adm" }
+          { "value" = "root" } }
+
+  test Aliases.lns put file after
+    rm "/4" ; rm "/5" ;
+      set "/1/value[2]" "barbar" ;
+      set "/3/value[2]" "ruth"
+    = "#
+#  Aliases in this file will NOT be expanded in the header from
+#  Mail, but WILL be visible over networks or from /bin/mail.
+
+# Basic system aliases -- these MUST be present.
+mailer-daemon: postmaster, barbar
+postmaster:    root
+
+# General redirections for pseudo accounts.
+bin:           root, ruth
+"
+
+  (* Schema violation, no 3/name *)
+  test Aliases.lns put file after
+      rm "/3" ;
+      set "/3/value/2" "ruth"
+    = *
+
+  (* Don't have to have whitespace after a comma *)
+  let nocomma = "alias: target1,target2\n"
+
+  test Aliases.lns get nocomma =
+    { "1"
+        { "name" = "alias" }
+        { "value" = "target1" }
+        { "value" = "target2" } }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_approx.aug b/lenses/tests/test_approx.aug
new file mode 100644 (file)
index 0000000..9cc3408
--- /dev/null
@@ -0,0 +1,40 @@
+(* Test for approx lens *)
+module Test_approx =
+
+  let default_approx = "# The following are the defaults, so there is no need
+# to uncomment them unless you want a different value.
+# See approx.conf(5) for details.
+
+$interface     any
+$port          9999
+$interval      720
+$max_wait      10
+$max_rate      unlimited
+$debug         false
+
+# Here are some examples of remote repository mappings.
+# See http://www.debian.org/mirror/list for mirror sites.
+
+debian         http://ftp.nl.debian.org/debian
+debian-volatile http://ftp.nl.debian.org/debian-volatile
+security       http://security.debian.org
+"
+
+  test Approx.lns get default_approx =
+  { "#comment" = "The following are the defaults, so there is no need" }
+  { "#comment" = "to uncomment them unless you want a different value." }
+  { "#comment" = "See approx.conf(5) for details." }
+  {  }
+  { "$interface" = "any" }
+  { "$port" = "9999" }
+  { "$interval" = "720" }
+  { "$max_wait" = "10" }
+  { "$max_rate" = "unlimited" }
+  { "$debug" = "false" }
+  {  }
+  { "#comment" = "Here are some examples of remote repository mappings." }
+  { "#comment" = "See http://www.debian.org/mirror/list for mirror sites." }
+  {  }
+  { "debian" = "http://ftp.nl.debian.org/debian" }
+  { "debian-volatile" = "http://ftp.nl.debian.org/debian-volatile" }
+  { "security" = "http://security.debian.org" }
diff --git a/lenses/tests/test_aptpreferences.aug b/lenses/tests/test_aptpreferences.aug
new file mode 100644 (file)
index 0000000..e65be43
--- /dev/null
@@ -0,0 +1,48 @@
+module Test_aptpreferences =
+
+    let conf ="Explanation: Backport packages are never prioritary
+Package: *
+Pin: release a=backports
+Pin-Priority: 100
+
+Explanation: My packages are the most prioritary
+Package: *
+Pin: release l=Raphink, v=3.0
+Pin-Priority: 700
+
+Package: liferea-data
+Pin: version 1.4.26-4
+Pin-Priority: 600
+"
+
+    test AptPreferences.lns get conf =
+       { "1"
+          { "Explanation"  = "Backport packages are never prioritary" }
+          { "Package"      = "*" }
+          { "Pin"          = "release"
+              { "a" = "backports" } }
+          { "Pin-Priority" = "100" } }
+       { "2"
+          { "Explanation"  = "My packages are the most prioritary" }
+          { "Package"      = "*" }
+          { "Pin"          = "release"
+              { "l" = "Raphink" }
+              { "v" = "3.0"     } }
+          { "Pin-Priority" = "700" } }
+       { "3"
+          { "Package"      = "liferea-data" }
+          { "Pin"          = "version"
+              { "version" = "1.4.26-4" } }
+          { "Pin-Priority" = "600" } }
+
+(*************************************************************************)
+
+    test AptPreferences.lns put "\n" after
+       set "/1/Package" "something-funny";
+       set "/1/Pin" "version";
+       set "/1/Pin/version" "1.2.3-4";
+       set "/1/Pin-Priority" "2000"
+    = "Package: something-funny
+Pin: version 1.2.3-4
+Pin-Priority: 2000
+"
diff --git a/lenses/tests/test_aptsource.aug b/lenses/tests/test_aptsource.aug
new file mode 100644 (file)
index 0000000..181e0f3
--- /dev/null
@@ -0,0 +1,70 @@
+module Test_aptsource =
+
+  let simple_source = "deb ftp://mirror.bytemark.co.uk/debian/ etch main\n"
+  let multi_components = "deb http://security.debian.org/ etch/updates main contrib non-free\n"
+
+  test Aptsources.lns get simple_source =
+    { "1"
+      { "type"         = "deb" }
+      { "uri"          = "ftp://mirror.bytemark.co.uk/debian/" }
+      { "distribution" = "etch" }
+      { "component"    = "main" }
+    }
+
+  test Aptsources.lns get multi_components =
+    { "1"
+      { "type"         = "deb" }
+      { "uri"          = "http://security.debian.org/" }
+      { "distribution" = "etch/updates" }
+      { "component" = "main" }
+      { "component" = "contrib" }
+      { "component" = "non-free" }
+    }
+
+
+let multi_line = "#deb http://www.backports.org/debian/ sarge postfix
+ # deb http://people.debian.org/~adconrad sarge subversion
+
+deb ftp://mirror.bytemark.co.uk/debian/ etch main non-free contrib
+  deb http://security.debian.org/ etch/updates main contrib non-free # security line
+       deb-src http://mirror.bytemark.co.uk/debian etch main contrib non-free\n"
+
+  test Aptsources.lns get multi_line =
+    { "#comment" = "deb http://www.backports.org/debian/ sarge postfix" } 
+    { "#comment" = "deb http://people.debian.org/~adconrad sarge subversion" }
+    {}
+    { "1"
+      { "type"         = "deb" }
+      { "uri"          = "ftp://mirror.bytemark.co.uk/debian/" }
+      { "distribution" = "etch" }
+      { "component" = "main" }
+      { "component"   = "non-free" }
+      { "component"   = "contrib" }
+    }
+    { "2"
+      { "type"         = "deb" }
+      { "uri"          = "http://security.debian.org/" }
+      { "distribution" = "etch/updates" }
+      { "component"    = "main" }
+      { "component"    = "contrib" }
+      { "component"    = "non-free" }
+    }
+    { "3"
+      { "type"         = "deb-src" }
+      { "uri"          = "http://mirror.bytemark.co.uk/debian" }
+      { "distribution" = "etch" }
+      { "component"    = "main" }
+      { "component"    = "contrib" }
+      { "component"    = "non-free" }
+    }
+
+    let trailing_comment = "deb ftp://server/debian/ etch main # comment\n"
+
+    (* Should be a noop; makes sure that we preserve the trailing comment *)
+    test Aptsources.lns put trailing_comment after
+      set "/1/type" "deb"
+    = trailing_comment
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_bbhosts.aug b/lenses/tests/test_bbhosts.aug
new file mode 100644 (file)
index 0000000..b00e3ed
--- /dev/null
@@ -0,0 +1,94 @@
+module Test_bbhosts =
+
+   let conf = "
+# A comment
+
+page firstpage My first page
+
+group-compress  A group
+1.2.3.4                amachine        # http://url.to/monitor https://another.url/to/monitor cont;http://a.cont.url/to/monitor;wordtofind
+1.2.3.5                amachine2       # http://url.to/monitor https://another.url/to/monitor !cont;http://a.cont.url/to/monitor;wordtofind
+
+group-only  dns  VIP DNS
+10.50.25.48    mydnsmachine.network #
+10.50.25.49     myotherdnsmachine.network # noping noconn !ssh dns;mydnstocheck
+# a comment in a group
+
+
+page anotherpage A new page
+
+# a comment in a page
+
+group-compress My test
+192.168.0.2    myhost  # https://myurl.com:1256 noconn pop3 imap2 ssh
+192.168.0.3    myhost2 # !imap2 telnet dns
+"
+
+   test BBhosts.lns get conf =
+      {}
+      { "#comment" = "A comment" }
+      {}
+      { "page" = "firstpage"
+         { "title"          = "My first page" }
+         {}
+        { "group-compress" = "A group"
+           { "host"
+              { "ip"   = "1.2.3.4" }
+              { "fqdn" = "amachine" }
+              { "probes"
+                 { "url" = "http://url.to/monitor" }
+                 { "url" = "https://another.url/to/monitor" }
+                 { "cont" = ""
+                    { "url"     = "http://a.cont.url/to/monitor" }
+                    { "keyword" = "wordtofind" } } } }
+           { "host"
+              { "ip"   = "1.2.3.5" }
+              { "fqdn" = "amachine2" }
+              { "probes"
+                 { "url" = "http://url.to/monitor" }
+                 { "url" = "https://another.url/to/monitor" }
+                 { "cont" = "!"
+                    { "url"     = "http://a.cont.url/to/monitor" }
+                    { "keyword" = "wordtofind" } } } }
+            {} }
+         { "group-only" = "VIP DNS"
+            { "col" = "dns" }
+            { "host"
+               { "ip"   = "10.50.25.48" }
+               { "fqdn" = "mydnsmachine.network" }
+               { "probes" } }
+             { "host"
+               { "ip"   = "10.50.25.49" }
+               { "fqdn" = "myotherdnsmachine.network" }
+               { "probes"
+                  { "noping" = "" }
+                  { "noconn" = "" }
+                  { "ssh" = "!" }
+                  { "dns" = ""
+                     { "url" = "mydnstocheck" } } } }
+            { "#comment" = "a comment in a group" }
+            {}
+            {} } }
+       { "page" = "anotherpage"
+          { "title" = "A new page" }
+         {}
+         { "#comment" = "a comment in a page" }
+         {}
+         { "group-compress" = "My test"
+            { "host"
+               { "ip" = "192.168.0.2" }
+               { "fqdn" = "myhost" }
+               { "probes"
+                  { "url" = "https://myurl.com:1256" }
+                  { "noconn" = "" }
+                  { "pop3" = "" }
+                  { "imap2" = "" }
+                  { "ssh" = "" } } }
+            { "host"
+               { "ip" = "192.168.0.3" }
+               { "fqdn" = "myhost2" }
+               { "probes"
+                  { "imap2" = "!" }
+                  { "telnet" = "" }
+                  { "dns" = "" } } } } }
+
diff --git a/lenses/tests/test_cgconfig.aug b/lenses/tests/test_cgconfig.aug
new file mode 100644 (file)
index 0000000..44c2f45
--- /dev/null
@@ -0,0 +1,255 @@
+module Test_cgconfig =
+
+let conf="#cgconfig test cofiguration file
+mount { 123 = 456; 456 = 789;}
+"
+
+test Cgconfig.lns get conf =
+  { "#comment" = "cgconfig test cofiguration file" }
+  { "mount"
+      { "123" = "456" }
+      { "456" = "789" } }
+  {}
+
+(* white spaces before mount sign *)
+let conf2="
+ mount { 123 = 456;}
+    mount { 123 = 456;}
+
+mount { 123 = 456;}mount { 123 = 456;}
+"
+
+test Cgconfig.lns get conf2 =
+  { }
+  { "mount" { "123" = "456"} }
+  { }
+  { "mount" { "123" = "456"} }
+  { }
+  { }
+  { "mount" { "123" = "456"} }
+  { "mount" { "123"  = "456" } }
+  { }
+
+let conf3="#cgconfig test cofiguration file
+mount { 123 = 456;
+#eswkh
+ 456 = 789;}
+"
+test Cgconfig.lns get conf3 =
+  { "#comment" = "cgconfig test cofiguration file" }
+  { "mount"
+    { "123" = "456" }
+    {}
+    { "#comment" = "eswkh" }
+    { "456" = "789" } }
+  {}
+
+let conf4="#cgconfig test cofiguration file
+mount {
+123 = 456;1245=456;
+}
+mount { 323=324;}mount{324=5343;  }# this is a comment
+"
+
+test Cgconfig.lns get conf4 =
+  {"#comment" = "cgconfig test cofiguration file" }
+  {"mount"
+     {  }
+     { "123" = "456"}
+     { "1245" = "456" }
+     {  }}
+  { }
+  { "mount" { "323" = "324" } }
+  { "mount" { "324" = "5343" } }
+  { "#comment" = "this is a comment" }
+
+let group1="
+group user {
+       cpuacct {
+      lll = jjj;
+       }
+       cpu {
+       }
+}"
+
+test Cgconfig.lns get group1 =
+  {  }
+  { "group" = "user"
+    {  }
+    { "controller" = "cpuacct"
+      {  }
+      { "lll" = "jjj" }
+      {  } }
+    {  }
+    { "controller" = "cpu" {  } }
+    {  } }
+
+let group2="
+group aa{
+     perm {
+                task { }
+                admin { }
+      }
+}"
+
+test Cgconfig.lns get group2 =
+  {  }
+  { "group" = "aa"
+    {  }
+    { "perm"
+      {  }
+      { "task" }
+      {  }
+      { "admin" }
+      {  } }
+    {  } }
+
+
+let group3 ="
+group xx/www {
+ perm {
+       task {
+               gid = root;
+               uid = root;
+       }
+       admin {
+               gid = aaa;
+# no aaa
+               uid = aaa;
+       }
+}
+}
+"
+
+test Cgconfig.lns get group3 =
+  {  }
+  { "group" = "xx/www"
+    {  }
+    { "perm"
+      {  }
+      { "task"
+        {  }
+        { "gid" = "root" }
+        {  }
+        { "uid" = "root" }
+        {  } }
+      {  }
+      { "admin"
+        {  }
+        { "gid" = "aaa" }
+        {  }
+        { "#comment" = "no aaa" }
+        { "uid" = "aaa" }
+        {  } }
+      {  } }
+    {  } }
+  {  }
+
+let group4 ="
+#group daemons {
+#           cpuacct{
+#           }
+#}
+
+group daemons/ftp {
+                     cpuacct{
+                                          }
+}
+
+   group daemons/www {
+        perm {
+                task {
+                        uid = root;
+                        gid = root;
+                }
+                admin {
+                        uid = root;
+                        gid = root;
+                }
+        }
+#       cpu {
+#               cpu.shares = 1000;
+#       }
+}
+#
+#
+
+  mount {
+       devices = /mnt/cgroups/devices;cpuacct = /mnt/cgroups/cpuset;
+        cpuset = /mnt/cgroups/cpuset;
+
+
+        cpu = /mnt/cpu;
+#        cpuset = /mnt/cgroups/cpuset2;
+}
+mount   {
+devices = /mnt/cgroups/devices;
+#       cpuacct = /mnt/cgroups/cpuacct;
+        ns = /mnt/cgroups/ns;
+#
+}
+
+"
+
+test Cgconfig.lns get group4 =
+  {  }
+  { "#comment" = "group daemons {" }
+  { "#comment" = "cpuacct{" }
+  { "#comment" = "}" }
+  { "#comment" = "}" }
+  {  }
+  { "group" = "daemons/ftp"
+    {  }
+    { "controller" = "cpuacct" {  } }
+    {  } }
+  {  }
+  {  }
+  { "group" = "daemons/www"
+    {  }
+    { "perm"
+      {  }
+      { "task"
+        {  }
+        { "uid" = "root" }
+        {  }
+        { "gid" = "root" }
+        {  } }
+      {  }
+      { "admin"
+        {  }
+        { "uid" = "root" }
+        {  }
+        { "gid" = "root" }
+        {  } }
+      {  } }
+    {  }
+    { "#comment" = "cpu {" }
+    { "#comment" = "cpu.shares = 1000;" }
+    { "#comment" = "}" } }
+  {  }
+  {  }
+  {  }
+  {  }
+  { "mount"
+    {  }
+    { "devices" = "/mnt/cgroups/devices" }
+    { "cpuacct" = "/mnt/cgroups/cpuset" }
+    {  }
+    { "cpuset" = "/mnt/cgroups/cpuset" }
+    {  }
+    {  }
+    {  }
+    { "cpu" = "/mnt/cpu" }
+    {  }
+    { "#comment" = "cpuset = /mnt/cgroups/cpuset2;" } }
+  {  }
+  { "mount"
+    {  }
+    { "devices" = "/mnt/cgroups/devices" }
+    {  }
+    { "#comment" = "cpuacct = /mnt/cgroups/cpuacct;" }
+    { "ns" = "/mnt/cgroups/ns" }
+    {  }
+    {  } }
+  {  }
+  {  }
diff --git a/lenses/tests/test_cgrules.aug b/lenses/tests/test_cgrules.aug
new file mode 100644 (file)
index 0000000..3e29d4f
--- /dev/null
@@ -0,0 +1,32 @@
+module Test_cgrules =
+
+let conf="#cgrules test configuration file
+poooeter       cpu             test1/
+%              memory          test2/
+@somegroup     cpu             toto/
+%              devices         toto1/
+%              memory          toto3/
+"
+test Cgrules.lns get conf =
+  { "#comment" = "cgrules test configuration file" }
+  { "user" = "poooeter"
+    { "cpu"    = "test1/" }
+    { "memory" = "test2/" } }
+  { "group" = "somegroup"
+    { "cpu"     = "toto/" }
+    { "devices" = "toto1/" }
+    { "memory"  = "toto3/" } }
+
+test Cgrules.lns put conf after
+  set  "user/cpu" "test3/";
+  rm   "user/memory";
+  rm   "group";
+  insa "devices" "user/*[last()]";
+  set  "user/devices" "newtest/";
+  insb "memory"  "user/devices";
+  set  "user/memory"  "memtest/"
+= "#cgrules test configuration file
+poooeter       cpu             test3/
+%              memory          memtest/
+% devices newtest/
+"
diff --git a/lenses/tests/test_cobblermodules.aug b/lenses/tests/test_cobblermodules.aug
new file mode 100644 (file)
index 0000000..c525f6c
--- /dev/null
@@ -0,0 +1,30 @@
+module Test_cobblermodules =
+
+   let conf = "
+[serializes]
+settings = serializer_catalog
+
+[authentication]
+modules = auth_denyall
+"
+
+   test CobblerModules.lns get conf =
+      {}
+      { "serializes"
+         { "settings" = "serializer_catalog" }
+         {} }
+      { "authentication"
+         { "modules" = "auth_denyall" } }
+
+    test CobblerModules.lns put conf after
+       set "serializes/distro" "serializer_catalog";
+       set "serializes/repo" "serializer_catalog"
+    = "
+[serializes]
+settings = serializer_catalog
+
+distro=serializer_catalog
+repo=serializer_catalog
+[authentication]
+modules = auth_denyall
+"
diff --git a/lenses/tests/test_cobblersettings.aug b/lenses/tests/test_cobblersettings.aug
new file mode 100644 (file)
index 0000000..9646741
--- /dev/null
@@ -0,0 +1,46 @@
+module Test_cobblersettings =
+
+test Cobblersettings.lns get "Simple_Setting: Value \n" =
+  { "Simple_Setting" = "Value" }
+
+test Cobblersettings.lns get "Simple_Setting2: 'Value2@acme.com' \n" =
+  { "Simple_Setting2" = "'Value2@acme.com'" }
+
+test Cobblersettings.lns get "Simple_Setting3: ''\n" =
+  { "Simple_Setting3" = "''" }
+
+test Cobblersettings.lns get "Simple_Setting4: \"\"\n" =
+  { "Simple_Setting4" = "\"\"" }
+
+test Cobblersettings.lns get "Simple_Setting_Trailing_Space : Value \n" =
+  { "Simple_Setting_Trailing_Space" = "Value" }
+
+test Cobblersettings.lns get "Setting_List:[Value1, Value2, Value3]\n" =
+  { "Setting_List"
+      { "sequence"
+          { "item" = "Value1" }
+          { "item" = "Value2" }
+          { "item" = "Value3" } } }
+
+test Cobblersettings.lns get "Empty_Setting_List: []\n" =
+  { "Empty_Setting_List"
+      { "sequence" } }
+
+test Cobblersettings.lns get "# Commented_Out_Setting: 'some value'\n" =
+  { "#comment" = "Commented_Out_Setting: 'some value'" }
+
+test Cobblersettings.lns get "---\n" =
+  { "---" = "---"}
+
+test Cobblersettings.lns get "Nested_Setting:\n Test: Value\n" =
+  { "Nested_Setting"
+      { "Test" = "Value" } }
+
+test Cobblersettings.lns get "Nested_Setting:\n - Test \n" =
+  { "Nested_Setting"
+      { "list"
+          { "value" = "Test" } } }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_cron.aug b/lenses/tests/test_cron.aug
new file mode 100644 (file)
index 0000000..cfd8e2a
--- /dev/null
@@ -0,0 +1,40 @@
+module Test_cron =
+
+   let conf = "# /etc/cron.d/anacron: crontab entries for the anacron package
+
+SHELL=/bin/sh
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+CRON_TZ=America/Los_Angeles
+
+       30 7      * * *   root  test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
+  00 */3    15-25/2 May 1-5   user   somecommand
+# a comment
+@yearly                                foo    a command\n"
+
+   test Cron.lns get conf =
+      { "#comment" = "/etc/cron.d/anacron: crontab entries for the anacron package" }
+      {}
+      { "SHELL" = "/bin/sh" }
+      { "PATH"  = "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" }
+      { "CRON_TZ" = "America/Los_Angeles" }
+      {}
+      { "entry" = "test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null"
+          { "time"
+              { "minute"       = "30"   }
+              { "hour"         = "7"    }
+              { "dayofmonth"   = "*"    }
+              { "month"        = "*"    }
+              { "dayofweek"    = "*"    } }
+          { "user"         = "root" } }
+      { "entry" = "somecommand"
+          { "time"
+              { "minute"       = "00"      }
+              { "hour"         = "*/3"     }
+              { "dayofmonth"   = "15-25/2" }
+              { "month"        = "May"     }
+              { "dayofweek"    = "1-5"     } }
+          { "user"         = "user"    } }
+      { "#comment" = "a comment" }
+      { "entry" = "a command"
+          { "schedule"     = "yearly"  }
+          { "user"         = "foo"     } }
diff --git a/lenses/tests/test_crypttab.aug b/lenses/tests/test_crypttab.aug
new file mode 100644 (file)
index 0000000..b396eb7
--- /dev/null
@@ -0,0 +1,48 @@
+module Test_crypttab =
+
+  let simple = "sda1_crypt\t /dev/sda1\t    /dev/random \t      swap\n"
+
+  let simple_tree =
+    { "1"
+        { "target" = "sda1_crypt" }
+        { "device" = "/dev/sda1" }
+        { "password" = "/dev/random" }
+        { "opt" = "swap" } }
+
+  let trailing_ws = "sda1_crypt\t /dev/sda1\t    /dev/random \t      swap\t\n"
+
+  let no_opts = "sda1_crypt\t /dev/sda1\t    /etc/key\n"
+
+  let no_opts_tree =
+    { "1"
+        { "target" = "sda1_crypt" }
+        { "device" = "/dev/sda1" }
+        { "password" = "/etc/key" } }
+
+  let no_password = "sda1_crypt\t /dev/sda1\n"
+
+  let no_password_tree =
+    { "1"
+        { "target" = "sda1_crypt" }
+        { "device" = "/dev/sda1" } }
+
+  let multi_opts = "sda1_crypt\t /dev/sda1\t    /etc/key \t      cipher=aes-cbc-essiv:sha256,verify\n"
+
+  let multi_opts_tree =
+    { "1"
+        { "target" = "sda1_crypt" }
+        { "device" = "/dev/sda1" }
+        { "password" = "/etc/key" }
+        { "opt" = "cipher"
+            { "value" = "aes-cbc-essiv:sha256" } }
+        { "opt" = "verify" } }
+
+  test Crypttab.lns get simple = simple_tree
+
+  test Crypttab.lns get trailing_ws = simple_tree
+
+  test Crypttab.lns get no_opts = no_opts_tree
+
+  test Crypttab.lns get no_password = no_password_tree
+
+  test Crypttab.lns get multi_opts = multi_opts_tree
diff --git a/lenses/tests/test_darkice.aug b/lenses/tests/test_darkice.aug
new file mode 100644 (file)
index 0000000..a6542b6
--- /dev/null
@@ -0,0 +1,24 @@
+module Test_darkice =
+
+   let conf = "# this is a comment
+
+[general]
+duration        = 0
+bufferSecs      = 5         # size of internal slip buffer, in seconds
+
+[icecast2-0]
+bitrateMode=cbr
+format = vorbis
+"
+
+   test Darkice.lns get conf =
+      { "#comment" = "this is a comment" }
+      {}
+      { "target" = "general"
+         { "duration"  = "0" }
+         { "bufferSecs"  = "5"
+            { "#comment" = "size of internal slip buffer, in seconds" } }
+         {} }
+      { "target" = "icecast2-0"
+         { "bitrateMode"  = "cbr" }
+         { "format"  = "vorbis" } }
diff --git a/lenses/tests/test_debctrl.aug b/lenses/tests/test_debctrl.aug
new file mode 100644 (file)
index 0000000..f81d1e2
--- /dev/null
@@ -0,0 +1,207 @@
+module Test_debctrl =
+
+ let source = "Source: libtest-distmanifest-perl\n"
+ let source_result =   { "Source" = "libtest-distmanifest-perl" }
+
+ test (Debctrl.simple_entry Debctrl.simple_src_keyword ) get source =
+    source_result
+
+ test (Debctrl.simple_entry Debctrl.simple_src_keyword ) get 
+  "Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>\n"
+   = {  "Maintainer" = "Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>"
+     }
+
+ let uploaders 
+   = "Uploaders: foo@bar, Dominique Dumont <dominique.dumont@xx.yyy>,\n"
+   . "  gregor herrmann <gregoa@xxx.yy>\n"
+
+ let uploaders_result =
+    { "Uploaders"
+       { "1" = "foo@bar"}
+       { "2" = "Dominique Dumont <dominique.dumont@xx.yyy>" }
+       { "3" = "gregor herrmann <gregoa@xxx.yy>" } }
+
+ test Debctrl.uploaders get uploaders = uploaders_result
+
+(* test package dependencies *)
+test Debctrl.version_depends get "( >= 5.8.8-12 )" = 
+   { "version" { "relation"  = ">=" } { "number"  = "5.8.8-12" } }
+
+test Debctrl.arch_depends get "[ !hurd-i386]" = 
+   { "arch" { "prefix"  = "!" } { "name"  = "hurd-i386" } }
+
+test Debctrl.arch_depends get "[ hurd-i386]" = 
+   { "arch" { "prefix"  = "" } { "name"  = "hurd-i386" } }
+
+let p_depends_test = "perl ( >= 5.8.8-12 ) [ !hurd-i386]"
+
+test Debctrl.package_depends get p_depends_test =
+   { "perl"
+       { "version"
+                   { "relation"  = ">=" }
+                   { "number"  = "5.8.8-12" } }
+       { "arch" { "prefix"  = "!" } { "name"  = "hurd-i386" } } }
+
+let dependency_test = "perl-modules (>= 5.10) | libmodule-build-perl"
+
+test Debctrl.dependency get dependency_test = 
+   { "or" { "perl-modules" 
+                { "version" { "relation"  = ">=" } 
+                            { "number"  = "5.10" } } } }
+   { "or" { "libmodule-build-perl" } }
+
+test (Debctrl.dependency_list "Build-Depends-Indep") get 
+  "Build-Depends-Indep: perl (>= 5.8.8-12) [ !hurd-i386], \n"
+  . "   perl-modules (>= 5.10) | libmodule-build-perl,\n"
+  . "   libcarp-assert-more-perl,\n"
+  . "   libconfig-tiny-perl\n"
+  = { "Build-Depends-Indep"
+       { "and" { "or" { "perl" 
+                        { "version"
+                          { "relation"  = ">=" }
+                          { "number"  = "5.8.8-12" } }
+                        { "arch" 
+                          { "prefix"  = "!" } 
+                          { "name"  = "hurd-i386" } } } } }
+       { "and" { "or" { "perl-modules" 
+                        { "version" { "relation"  = ">=" }  
+                                    { "number"  = "5.10" } } } }
+               { "or" { "libmodule-build-perl" } } }
+       { "and" { "or" { "libcarp-assert-more-perl" } } }
+       { "and" { "or" { "libconfig-tiny-perl" } } } }
+
+test (Debctrl.dependency_list "Depends") get 
+  "Depends: ${perl:Depends}, ${misc:Depends},\n"
+  ." libparse-recdescent-perl (>= 1.90.0)\n"
+  = { "Depends"
+       {  "and" { "or" { "${perl:Depends}" }} }
+       {  "and" { "or" { "${misc:Depends}" }} }
+       {  "and" { "or" { "libparse-recdescent-perl"  
+                         { "version"
+                           { "relation"  = ">=" }
+                           { "number"  = "1.90.0" } } } } }
+    } 
+
+ let description = "Description: describe and edit configuration data\n"
+ ." Config::Model enables [...] must:\n"
+ ."    - if the configuration data\n"
+ ." .\n"
+ ." With the elements above, (...) on ReadLine.\n"
+
+ test Debctrl.description get description = 
+  { "Description" 
+    { "summary" = "describe and edit configuration data" }
+    { "text" = "Config::Model enables [...] must:" }
+    { "text" = "   - if the configuration data" }
+    { "text" = "." }            
+    { "text" = "With the elements above, (...) on ReadLine."} }
+
+ let simple_bin_pkg1 = "Package: libconfig-model-perl\n"
+     . "Architecture: all\n"
+     . "Description: dummy1\n"
+     . " dummy text 1\n"
+
+ let simple_bin_pkg2 = "Package: libconfig-model2-perl\n"
+     . "Architecture: all\n"
+     . "Description: dummy2\n"
+     . " dummy text 2\n"
+
+ test Debctrl.src_entries get source.uploaders 
+ =  { "Source" = "libtest-distmanifest-perl" }
+                { "Uploaders"
+                  { "1" = "foo@bar"}
+                  { "2" = "Dominique Dumont <dominique.dumont@xx.yyy>" }
+                  { "3" = "gregor herrmann <gregoa@xxx.yy>" } }
+
+ test Debctrl.bin_entries get simple_bin_pkg1 = 
+  { "Package" = "libconfig-model-perl" }
+  { "Architecture" = "all" } 
+  { "Description" { "summary" = "dummy1" } {"text" = "dummy text 1" } }
+
+ let paragraph_simple = source . uploaders ."\n" 
+       . simple_bin_pkg1 . "\n" 
+       . simple_bin_pkg2 
+
+ test Debctrl.lns get paragraph_simple =
+   { "srcpkg"   { "Source" = "libtest-distmanifest-perl" }
+                { "Uploaders"
+                  { "1" = "foo@bar"}
+                  { "2" = "Dominique Dumont <dominique.dumont@xx.yyy>" }
+                  { "3" = "gregor herrmann <gregoa@xxx.yy>" } } }
+   { "binpkg" { "Package" = "libconfig-model-perl" }
+                    { "Architecture" = "all" } 
+                    { "Description" { "summary" = "dummy1" } 
+                                    { "text" = "dummy text 1" } } }
+   { "binpkg" { "Package" = "libconfig-model2-perl" }
+                    { "Architecture" = "all" } 
+                   { "Description" { "summary" = "dummy2" } 
+                                    { "text" = "dummy text 2" } } } 
+
+
+(* PUT TESTS *)
+
+test Debctrl.src_entries
+     put uploaders  
+     after set "/Uploaders/1" "foo@bar"
+   =  uploaders
+
+test Debctrl.src_entries
+     put uploaders  
+  after set "/Uploaders/1" "bar@bar" 
+ =  "Uploaders: bar@bar, Dominique Dumont <dominique.dumont@xx.yyy>,\n"
+   . "  gregor herrmann <gregoa@xxx.yy>\n"
+
+test Debctrl.src_entries
+     put uploaders  
+     after set "/Uploaders/4" "baz@bar"
+   =  "Uploaders: foo@bar, Dominique Dumont <dominique.dumont@xx.yyy>,\n"
+   . "  gregor herrmann <gregoa@xxx.yy>,\n"
+   . " baz@bar\n"
+
+test Debctrl.lns put (source."\nPackage: test\nDescription: foobar\n")
+  after
+  set "/srcpkg/Uploaders/1" "foo@bar" ;
+  set "/srcpkg/Uploaders/2" "Dominique Dumont <dominique.dumont@xx.yyy>" ;
+  set "/srcpkg/Uploaders/3" "gregor herrmann <gregoa@xxx.yy>" ;
+  set "/srcpkg/Build-Depends-Indep/and[1]/or/perl/version/relation" ">=" ;
+  set "/srcpkg/Build-Depends-Indep/and[1]/or/perl/version/number" "5.8.8-12" ;
+  set "/srcpkg/Build-Depends-Indep/and[1]/or/perl/arch/prefix" "!" ;
+  set "/srcpkg/Build-Depends-Indep/and[1]/or/perl/arch/name" "hurd-i386" ;
+  set "/srcpkg/Build-Depends-Indep/and[2]/or[1]/perl-modules/version/relation" ">=" ;
+  set "/srcpkg/Build-Depends-Indep/and[2]/or[1]/perl-modules/version/number" "5.10" ;
+  set "/srcpkg/Build-Depends-Indep/and[2]/or[2]/libmodule-build-perl" "";
+  set "/srcpkg/Build-Depends-Indep/and[3]/or/libcarp-assert-more-perl" "" ;
+  set "/srcpkg/Build-Depends-Indep/and[4]/or/libconfig-tiny-perl" "" ;
+  set "/binpkg[1]/Package" "libconfig-model-perl"  ; 
+  (* must remove description because set cannot insert Archi before description *)
+  rm  "/binpkg[1]/Description" ;
+  set "/binpkg/Architecture" "all"  ;
+  set "/binpkg[1]/Description/summary" "dummy1" ;
+  set "/binpkg[1]/Description/text" "dummy text 1" ;
+  set "/binpkg[2]/Package" "libconfig-model2-perl" ;
+  set "/binpkg[2]/Architecture" "all" ;
+  set "/binpkg[2]/Description/summary" "dummy2" ;
+  set "/binpkg[2]/Description/text" "dummy text 2" 
+  =  
+"Source: libtest-distmanifest-perl
+Uploaders: foo@bar,
+ Dominique Dumont <dominique.dumont@xx.yyy>,
+ gregor herrmann <gregoa@xxx.yy>
+Build-Depends-Indep: perl ( >= 5.8.8-12 ) [ !hurd-i386 ],
+ perl-modules ( >= 5.10 ) | libmodule-build-perl,
+ libcarp-assert-more-perl,
+ libconfig-tiny-perl
+
+Package: libconfig-model-perl
+Architecture: all
+Description: dummy1
+ dummy text 1
+
+Package: libconfig-model2-perl
+Architecture: all
+Description: dummy2
+ dummy text 2
+"
+
diff --git a/lenses/tests/test_device_map.aug b/lenses/tests/test_device_map.aug
new file mode 100644 (file)
index 0000000..2a7810a
--- /dev/null
@@ -0,0 +1,34 @@
+module Test_device_map =
+
+  let conf = "# this device map was generated by anaconda
+(fd0)     /dev/fda
+(hd0)     /dev/sda
+(cd0)     /dev/cdrom
+(hd1,1)   /dev/sdb1
+(hd0,a)   /dev/sda1
+(0x80)    /dev/sda
+(128)     /dev/sda
+"
+
+  test Device_map.lns get conf =
+    { "#comment" = "this device map was generated by anaconda" }
+    { "fd0" = "/dev/fda" }
+    { "hd0" = "/dev/sda" }
+    { "cd0" = "/dev/cdrom" }
+    { "hd1,1" = "/dev/sdb1" }
+    { "hd0,a" = "/dev/sda1" }
+    { "0x80"  = "/dev/sda" }
+    { "128"   = "/dev/sda" }
+
+  test Device_map.lns put conf after
+    set "hd2,1" "/dev/sdb1"
+  = "# this device map was generated by anaconda
+(fd0)     /dev/fda
+(hd0)     /dev/sda
+(cd0)     /dev/cdrom
+(hd1,1)   /dev/sdb1
+(hd0,a)   /dev/sda1
+(0x80)    /dev/sda
+(128)     /dev/sda
+(hd2,1)\t/dev/sdb1
+"
diff --git a/lenses/tests/test_dhclient.aug b/lenses/tests/test_dhclient.aug
new file mode 100644 (file)
index 0000000..3fa481d
--- /dev/null
@@ -0,0 +1,133 @@
+module Test_dhclient =
+
+    let conf ="  # Sample dhclient.conf
+    # Protocol timing
+timeout 3; # Expect a fast server
+retry
+      10;
+# Lease requirements and requests
+request
+       subnet-mask,
+  broadcast-address,
+       ntp-servers;
+# Dynamic DNS
+send
+       fqdn.fqdn
+         \"grosse.fugue.com.\";
+
+option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
+
+interface ep0 {
+   script /sbin/dhclient-script;
+   send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
+   send dhcp-lease-time 3600;
+   request subnet-mask, broadcast-address, time-offset, routers,
+          domain-name, domain-name-servers, host-name;
+   media media10baseT/UTP, \"media10base2/BNC\";
+}
+
+alias {
+  interface \"ep0\";
+  fixed-address 192.5.5.213;
+  option subnet-mask 255.255.255.255;
+}
+
+lease {
+  interface \"eth0\";
+  fixed-address 192.33.137.200;
+  medium \"link0 link1\";
+  vendor option space \"name\";
+  option host-name \"andare.swiftmedia.com\";
+  option subnet-mask 255.255.255.0;
+  option broadcast-address 192.33.137.255;
+  option routers 192.33.137.250;
+  option domain-name-servers 127.0.0.1;
+  renew 2 2000/1/12 00:00:01;
+  rebind 2 2000/1/12 00:00:01;
+  expire 2 2000/1/12 00:00:01;
+}
+"
+
+    test Dhclient.lns get conf =
+        { "#comment" = "Sample dhclient.conf" }
+        { "#comment" = "Protocol timing" }
+        { "timeout" = "3"
+           { "#comment" = "Expect a fast server" } }
+        { "retry" = "10" }
+        { "#comment" = "Lease requirements and requests" }
+        { "request"
+           { "1" = "subnet-mask" }
+           { "2" = "broadcast-address" }
+           { "3" = "ntp-servers" } }
+        { "#comment" = "Dynamic DNS" }
+        { "send"
+           { "fqdn.fqdn" = "\"grosse.fugue.com.\"" } }
+        {}
+        { "option"
+           { "rfc3442-classless-static-routes"
+               { "code"  = "121" }
+               { "value" = "array of unsigned integer 8" } } }
+        {}
+        { "interface" = "ep0"
+           { "script" = "/sbin/dhclient-script" }
+           { "send"
+               { "dhcp-client-identifier" = "1:0:a0:24:ab:fb:9c" } }
+           { "send"
+               { "dhcp-lease-time" = "3600" } }
+           { "request"
+               { "1" = "subnet-mask" }
+               { "2" = "broadcast-address" }
+               { "3" = "time-offset" }
+               { "4" = "routers" }
+               { "5" = "domain-name" }
+               { "6" = "domain-name-servers" }
+               { "7" = "host-name" } }
+           { "media"
+               { "1" = "media10baseT/UTP" }
+               { "2" = "\"media10base2/BNC\"" } } }
+        {}
+        { "alias"
+           { "interface" = "\"ep0\"" }
+           { "fixed-address" = "192.5.5.213" }
+           { "option"
+               { "subnet-mask" = "255.255.255.255" } } }
+        {}
+        { "lease"
+           { "interface" = "\"eth0\"" }
+           { "fixed-address" = "192.33.137.200" }
+           { "medium" = "\"link0 link1\"" }
+           { "vendor option space" = "\"name\"" }
+           { "option"
+               { "host-name" = "\"andare.swiftmedia.com\"" } }
+           { "option"
+               { "subnet-mask" = "255.255.255.0" } }
+           { "option"
+               { "broadcast-address" = "192.33.137.255" } }
+           { "option"
+               { "routers" = "192.33.137.250" } }
+           { "option"
+               { "domain-name-servers" = "127.0.0.1" } }
+           { "renew"
+               { "weekday" = "2" }
+               { "year"    = "2000" }
+               { "month"   = "1" }
+               { "day"     = "12" }
+               { "hour"    = "00" }
+               { "minute"  = "00" }
+               { "second"  = "01" } }
+           { "rebind"
+               { "weekday" = "2" }
+               { "year"    = "2000" }
+               { "month"   = "1" }
+               { "day"     = "12" }
+               { "hour"    = "00" }
+               { "minute"  = "00" }
+               { "second"  = "01" } }
+           { "expire"
+               { "weekday" = "2" }
+               { "year"    = "2000" }
+               { "month"   = "1" }
+               { "day"     = "12" }
+               { "hour"    = "00" }
+               { "minute"  = "00" }
+               { "second"  = "01" } } }
diff --git a/lenses/tests/test_dhcpd.aug b/lenses/tests/test_dhcpd.aug
new file mode 100644 (file)
index 0000000..e49ee86
--- /dev/null
@@ -0,0 +1,372 @@
+module Test_dhcpd =
+
+let lns = Dhcpd.lns
+
+let conf = "#
+# Sample configuration file for ISC dhcpd for Debian
+#
+# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
+# configuration file instead of this file.
+#
+# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
+#
+
+# The ddns-updates-style parameter controls whether or not the server will
+# attempt to do a DNS update when a lease is confirmed. We default to the
+# behavior of the version 2 packages ('none', since DHCP v2 didn't
+# have support for DDNS.)
+ddns-update-style none;
+
+# option definitions common to all supported networks...
+option domain-name \"example.org\";
+option domain-name-servers ns1.example.org, ns2.example.org;
+
+default-lease-time 600;
+max-lease-time 7200;
+
+# If this DHCP server is the official DHCP server for the local
+# network, the authoritative directive should be uncommented.
+authoritative;
+
+# Use this to send dhcp log messages to a different log file (you also
+# have to hack syslog.conf to complete the redirection).
+log-facility local7;
+
+# No service will be given on this subnet, but declaring it helps the
+# DHCP server to understand the network topology.
+
+subnet 10.152.187.0 netmask 255.255.255.0 {
+}
+
+# This is a very basic subnet declaration.
+
+subnet 10.254.239.0 netmask 255.255.255.224 {
+  range 10.254.239.10 10.254.239.20;
+  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
+}
+
+# This declaration allows BOOTP clients to get dynamic addresses,
+# which we don't really recommend.
+
+subnet 10.254.239.32 netmask 255.255.255.224 {
+  range dynamic-bootp 10.254.239.40 10.254.239.60;
+  option broadcast-address 10.254.239.31;
+  option routers rtr-239-32-1.example.org;
+}
+
+# A slightly different configuration for an internal subnet.
+subnet 10.5.5.0 netmask 255.255.255.224 {
+  range 10.5.5.26 10.5.5.30;
+  option domain-name-servers ns1.internal.example.org;
+  option domain-name \"internal.example.org\";
+  option routers 10.5.5.1;
+  option broadcast-address 10.5.5.31;
+  default-lease-time 600;
+  max-lease-time 7200;
+}
+
+# Hosts which require special configuration options can be listed in
+# host statements.   If no address is specified, the address will be
+# allocated dynamically (if possible), but the host-specific information
+# will still come from the host declaration.
+
+host passacaglia {
+  hardware ethernet 0:0:c0:5d:bd:95;
+  filename \"vmunix.passacaglia\";
+  server-name \"toccata.fugue.com\";
+}
+
+# Fixed IP addresses can also be specified for hosts.   These addresses
+# should not also be listed as being available for dynamic assignment.
+# Hosts for which fixed IP addresses have been specified can boot using
+# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
+# be booted with DHCP, unless there is an address range on the subnet
+# to which a BOOTP client is connected which has the dynamic-bootp flag
+# set.
+host fantasia {
+  hardware ethernet 08:00:07:26:c0:a5;
+  fixed-address fantasia.fugue.com;
+}
+
+# You can declare a class of clients and then do address allocation
+# based on that.   The example below shows a case where all clients
+# in a certain class get addresses on the 10.17.224/24 subnet, and all
+# other clients get addresses on the 10.0.29/24 subnet.
+
+#class \"foo\" {
+#  match if substring (option vendor-class-identifier, 0, 4) = \"SUNW\";
+#}
+
+shared-network 224-29 {
+  subnet 10.17.224.0 netmask 255.255.255.0 {
+    option routers rtr-224.example.org;
+  }
+  subnet 10.0.29.0 netmask 255.255.255.0 {
+    option routers rtr-29.example.org;
+  }
+  pool {
+    allow members of \"foo\";
+    range 10.17.224.10 10.17.224.250;
+  }
+  pool {
+    deny members of \"foo\";
+    range 10.0.29.10 10.0.29.230;
+  }
+}
+"
+
+test lns get "authoritative;" = { "authoritative" }
+test lns get "ddns-update-style none;" = { "ddns-update-style" = "none" }
+test lns get "option domain-name \"example.org\";" =
+  { "option"
+    { "domain-name"
+      { "arg" = "example.org" }
+    }
+  }
+
+test lns get "option domain-name-servers ns1.example.org, ns2.example.org;" =
+  { "option"
+    { "domain-name-servers"
+      { "arg" = "ns1.example.org" }
+      { "arg" = "ns2.example.org" }
+    }
+  }
+
+test lns get "default-lease-time 600;" = { "default-lease-time" = "600" }
+test lns get "range 10.254.239.60;" =
+{ "range"
+    { "to" = "10.254.239.60" }
+  }
+
+test lns get "range dynamic-bootp 10.254.239.60;" =
+  { "range"
+    { "flag" = "dynamic-bootp" }
+    { "to" = "10.254.239.60" }
+  }
+
+test lns get "range dynamic-bootp 10.254.239.40 10.254.239.60;" =
+  { "range"
+    { "flag" = "dynamic-bootp" }
+    { "from" = "10.254.239.40" }
+    { "to" = "10.254.239.60" }
+  }
+
+test lns get "subnet 10.152.187.0 netmask 255.255.255.0 {}\n" =
+  { "subnet"
+    { "network" = "10.152.187.0" }
+    { "netmask" = "255.255.255.0" }
+  }
+
+test lns get " pool {
+    pool {
+
+    }
+}
+" =
+  { "pool"
+    { "pool" }
+  }
+
+test lns get "group { host some-host {hardware ethernet 00:00:aa:bb:cc:dd;
+fixed-address 10.1.1.1;}}" =
+  { "group"
+    { "host" = "some-host"
+      { "hardware"
+        { "type" = "ethernet" }
+        { "address" = "00:00:aa:bb:cc:dd" }
+      }
+      { "fixed-address" = "10.1.1.1" }
+    }
+  }
+
+test Dhcpd.stmt_secu get "allow members of \"foo\";" =  { "allow-members-of" = "foo" }
+test Dhcpd.stmt_option get "option voip-boot-server code 66 = string;" =
+  { "rfc-code"
+    { "label" = "voip-boot-server" }
+    { "code" = "66" }
+    { "type" = "string" }
+  }
+
+test Dhcpd.lns get "authoritative;
+log-facility local7;
+ddns-update-style none;
+default-lease-time 21600;
+max-lease-time 43200;
+
+# Additional options for VOIP
+option voip-boot-server code 66 = string;
+option voip-vlan-id code 128 = string;
+" =
+  { "authoritative" }
+  { "log-facility" = "local7" }
+  { "ddns-update-style" = "none" }
+  { "default-lease-time" = "21600" }
+  { "max-lease-time" = "43200"
+    { "#comment" = "Additional options for VOIP" }
+  }
+  { "rfc-code"
+    { "label" = "voip-boot-server" }
+    { "code" = "66" }
+    { "type" = "string" }
+  }
+  { "rfc-code"
+    { "label" = "voip-vlan-id" }
+    { "code" = "128" }
+    { "type" = "string" }
+  }
+
+
+test Dhcpd.lns get "
+option domain-name-servers 10.1.1.1, 10.11.2.1, 10.1.3.1;
+next-server 10.1.1.1;
+
+failover peer \"redondance01\" {
+         primary;
+         address 10.1.1.1;
+         port 647;
+         peer address 10.1.1.1;
+         peer port 647;
+         max-response-delay 20;
+         max-unacked-updates 10;
+         mclt 3600;         #comment.
+         split 128;         #comment.
+         load balance max seconds 3;
+       }
+" =
+  {  }
+  { "option"
+    { "domain-name-servers"
+      { "arg" = "10.1.1.1" }
+      { "arg" = "10.11.2.1" }
+      { "arg" = "10.1.3.1" }
+    }
+  }
+  { "next-server" = "10.1.1.1" }
+  { "failover peer" = "\"redondance01\""
+    { "primary" }
+    { "address" = "10.1.1.1" }
+    { "port" = "647" }
+    { "peer address" = "10.1.1.1" }
+    { "peer port" = "647" }
+    { "max-response-delay" = "20" }
+    { "max-unacked-updates" = "10" }
+    { "mclt" = "3600"
+      { "#comment" = "comment." }
+    }
+    { "split" = "128"
+      { "#comment" = "comment." }
+    }
+    { "load balance max seconds" = "3" }
+  }
+
+test Dhcpd.lns get "
+option CallManager code 150 = ip-address;
+option slp-directory-agent true 10.1.1.1, 10.2.2.2;
+option slp-service-scope true \"SLP-GLOBAL\";
+option nds-context \"EXAMPLE\";
+option nds-tree-name \"EXAMPLE\";
+" =
+  {  }
+  { "rfc-code"
+    { "label" = "CallManager" }
+    { "code" = "150" }
+    { "type" = "ip-address" }
+  }
+  { "option"
+    { "slp-directory-agent" = "true"
+      { "arg" = "10.1.1.1" }
+      { "arg" = "10.2.2.2" }
+    }
+  }
+  { "option"
+    { "slp-service-scope" = "true"
+      { "arg" = "SLP-GLOBAL" }
+    }
+  }
+  { "option"
+    { "nds-context"
+      { "arg" = "EXAMPLE" }
+    }
+  }
+  { "option"
+    { "nds-tree-name"
+      { "arg" = "EXAMPLE" }
+    }
+  }
+
+
+test Dhcpd.lns get "option voip-vlan-id \"VLAN=1234;\";" =
+  { "option"
+    { "voip-vlan-id"
+      { "arg" = "VLAN=1234;" }
+    }
+  }
+
+test Dhcpd.lns get "option domain-name \"x.example.com y.example.com z.example.com\";" =
+  { "option"
+    { "domain-name"
+      { "arg" = "x.example.com y.example.com z.example.com" }
+    }
+  }
+
+test Dhcpd.lns get "include \"/etc/dhcpd.master\";" =
+  { "include" = "/etc/dhcpd.master" }
+
+test Dhcpd.fct_args get "(option dhcp-client-identifier, 1, 3)" =
+  { "args"
+    { "arg" = "option dhcp-client-identifier" }
+    { "arg" = "1" }
+    { "arg" = "3" }
+  }
+
+test Dhcpd.stmt_match get "match if substring (option dhcp-client-identifier, 1, 3) = \"RAS\";" =
+  { "match"
+    { "function" = "substring"
+      { "args"
+        { "arg" = "option dhcp-client-identifier" }
+        { "arg" = "1" }
+        { "arg" = "3" }
+      }
+    }
+    { "value" = "RAS" }
+  }
+
+test Dhcpd.lns get "match pick-first-value (option dhcp-client-identifier, hardware);" =
+  { "match"
+    { "function" = "pick-first-value"
+      { "args"
+        { "arg" = "option dhcp-client-identifier" }
+        { "arg" = "hardware"  }
+      }
+    }
+  }
+
+test Dhcpd.fct_args get "(16, 32, \"\", substring(hardware, 0, 4))" =
+  { "args"
+    { "arg" = "16" }
+    { "arg" = "32" }
+    { "arg" = "\"\"" }
+    { "arg" = "substring(hardware, 0, 4)" }
+  }
+
+test Dhcpd.stmt_match get "match if binary-to-ascii(16, 32, \"\", substring(hardware, 0, 4)) = \"1525400\";" =
+  { "match"
+    { "function" = "binary-to-ascii"
+      { "args"
+        { "arg" = "16" }
+        { "arg" = "32" }
+        { "arg" = "\"\"" }
+        { "arg" = "substring(hardware, 0, 4)" }
+      }
+    }
+    { "value" = "1525400" }
+  }
+
+test Dhcpd.lns get "subclass \"allocation-class-1\" 1:8:0:2b:4c:39:ad;" =
+  { "subclass"
+    { "name" = "allocation-class-1" }
+    { "value" = "1:8:0:2b:4c:39:ad" }
+  }
+
+(* overall test *)
+test Dhcpd.lns put conf after rm "/x" = conf
diff --git a/lenses/tests/test_dnsmasq.aug b/lenses/tests/test_dnsmasq.aug
new file mode 100644 (file)
index 0000000..0abfa6b
--- /dev/null
@@ -0,0 +1,17 @@
+module Test_dnsmasq =
+
+let conf = "# Configuration file for dnsmasq.
+#
+#bogus-priv
+
+conf-dir=/etc/dnsmasq.d
+selfmx
+"
+
+test Dnsmasq.lns get conf =
+  { "#comment" = "Configuration file for dnsmasq." }
+  {}
+  { "#comment" = "bogus-priv" }
+  {}
+  { "conf-dir" = "/etc/dnsmasq.d" }
+  { "selfmx" }
diff --git a/lenses/tests/test_dpkg.aug b/lenses/tests/test_dpkg.aug
new file mode 100644 (file)
index 0000000..64eda6a
--- /dev/null
@@ -0,0 +1,14 @@
+module Test_dpkg =
+
+let conf ="# dpkg configuration file
+# Do not enable debsig-verify by default
+no-debsig
+
+log /var/log/dpkg.log\n"
+
+test Dpkg.lns get conf =
+  { "#comment" = "dpkg configuration file" }
+  { "#comment" = "Do not enable debsig-verify by default" }
+  { "no-debsig" }
+  {}
+  { "log" = "/var/log/dpkg.log" }
diff --git a/lenses/tests/test_dput.aug b/lenses/tests/test_dput.aug
new file mode 100644 (file)
index 0000000..2e72ce1
--- /dev/null
@@ -0,0 +1,115 @@
+module Test_dput =
+
+   let conf = "# Example dput.cf that defines the host that can be used
+# with dput for uploading.
+
+[DEFAULT]
+login = username
+method = ftp
+hash = md5
+allow_unsigned_uploads = 0
+run_lintian = 0
+run_dinstall = 0
+check_version = 0
+scp_compress = 0
+post_upload_command =
+pre_upload_command =
+passive_ftp = 1
+default_host_non-us =
+default_host_main = hebex
+allowed_distributions = (?!UNRELEASED)
+
+[hebex]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/hebex
+passive_ftp = 0
+
+[dop/desktop]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/dop/desktop
+passive_ftp = 0
+
+[jp-non-us]
+fqdn = hp.debian.or.jp
+incoming = /pub/Incoming/upload-non-US
+login = anonymous
+
+# DISABLED due to being repaired currently
+#[erlangen]
+#fqdn = ftp.uni-erlangen.de
+#incoming = /public/pub/Linux/debian/UploadQueue/
+#login = anonymous
+
+[ftp-master]
+fqdn = ftp-master.debian.org
+incoming = /pub/UploadQueue/
+login = anonymous
+post_upload_command = /usr/bin/mini-dinstall --batch
+# And if you want to override one of the defaults, add it here.
+# # For example, comment out the next line
+# # login = another_username
+# # post_upload_command = /path/to/some/script
+# # pre_upload_command = /path/to/some/script
+
+"
+
+   test Dput.lns get conf =
+      { "#comment" = "Example dput.cf that defines the host that can be used" }
+      { "#comment" = "with dput for uploading." }
+      {}
+      { "target" = "DEFAULT"
+         { "login"  = "username" }
+         { "method" = "ftp" }
+         { "hash"   = "md5" }
+         { "allow_unsigned_uploads" = "0" }
+         { "run_lintian" = "0" }
+         { "run_dinstall" = "0" }
+         { "check_version" = "0" }
+         { "scp_compress" = "0" }
+         { "post_upload_command" }
+         { "pre_upload_command" }
+         { "passive_ftp" = "1" }
+         { "default_host_non-us" }
+         { "default_host_main" = "hebex" }
+         { "allowed_distributions" = "(?!UNRELEASED)" }
+         {} }
+      { "target" = "hebex"
+         { "fqdn" = "condor.infra.s1.p.fti.net" }
+        { "login" = "anonymous" }
+        { "method" = "ftp" }
+        { "incoming" = "/incoming/hebex" }
+        { "passive_ftp" = "0" }
+         {} }
+      { "target" = "dop/desktop"
+         { "fqdn" = "condor.infra.s1.p.fti.net" }
+        { "login" = "anonymous" }
+        { "method" = "ftp" }
+        { "incoming" = "/incoming/dop/desktop" }
+        { "passive_ftp" = "0" }
+         {} }
+      { "target" = "jp-non-us"
+         { "fqdn" = "hp.debian.or.jp" }
+        { "incoming" = "/pub/Incoming/upload-non-US" }
+        { "login" = "anonymous" }
+         {}
+         { "#comment" = "DISABLED due to being repaired currently" }
+         { "#comment" = "[erlangen]" }
+         { "#comment" = "fqdn = ftp.uni-erlangen.de" }
+         { "#comment" = "incoming = /public/pub/Linux/debian/UploadQueue/" }
+         { "#comment" = "login = anonymous" }
+         {} }
+      { "target" = "ftp-master"
+         { "fqdn" = "ftp-master.debian.org" }
+        { "incoming" = "/pub/UploadQueue/" }
+        { "login" = "anonymous" }
+        { "post_upload_command" = "/usr/bin/mini-dinstall --batch" }
+         { "#comment" = "And if you want to override one of the defaults, add it here." }
+         { "#comment" = "# For example, comment out the next line" }
+         { "#comment" = "# login = another_username" }
+         { "#comment" = "# post_upload_command = /path/to/some/script" }
+         { "#comment" = "# pre_upload_command = /path/to/some/script" }
+        {} }
diff --git a/lenses/tests/test_ethers.aug b/lenses/tests/test_ethers.aug
new file mode 100644 (file)
index 0000000..7209c1b
--- /dev/null
@@ -0,0 +1,61 @@
+(* Tests for the Ethers module *)
+
+module Test_ethers =
+
+(*
+  let empty_entries = "# see man ethers for syntax\n"
+
+  test Ethers.record get empty_entries =
+    { "#comment" = "see man ethers for syntax" }
+*)
+
+  let three_entries = "54:52:00:01:00:01 192.168.1.1
+# \tcomment\t
+54:52:00:01:00:02 foo.example.com
+00:16:3e:01:fe:03 bar
+"
+
+  test Ethers.lns get three_entries =
+   { "1" { "mac" = "54:52:00:01:00:01" }
+         { "ip" = "192.168.1.1" } }
+   { "#comment" = "comment" }
+   { "2" { "mac" = "54:52:00:01:00:02" }
+         { "ip" = "foo.example.com" } }
+   { "3" { "mac" = "00:16:3e:01:fe:03" }
+         { "ip" = "bar" } }
+
+  (* Deleting the 'ip' node violates the schema *)
+  test Ethers.lns put three_entries after
+      rm "/1/ip"
+    = *
+
+  test Ethers.lns put three_entries after
+    set "/2/ip" "192.168.1.2" ;
+    set "/3/ip" "baz"
+  = "54:52:00:01:00:01 192.168.1.1
+# \tcomment\t
+54:52:00:01:00:02 192.168.1.2
+00:16:3e:01:fe:03 baz
+"
+
+  test Ethers.lns put three_entries after
+    rm "/3"
+  = "54:52:00:01:00:01 192.168.1.1
+# \tcomment\t
+54:52:00:01:00:02 foo.example.com
+"
+
+  (* Make sure blank and indented lines get through *)
+  test Ethers.lns get "54:52:00:01:00:01\tfoo  \n \n\n
+54:52:00:01:00:02 bar\n" =
+    { "1" { "mac" = "54:52:00:01:00:01" }
+          { "ip" = "foo" } }
+    {} {} {}
+    { "2" { "mac" = "54:52:00:01:00:02" }
+          { "ip" = "bar" } }
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
+
+
diff --git a/lenses/tests/test_exports.aug b/lenses/tests/test_exports.aug
new file mode 100644 (file)
index 0000000..de38996
--- /dev/null
@@ -0,0 +1,44 @@
+module Test_exports = 
+
+let s = "/local 172.31.0.0/16(rw,sync) \t
+
+/home 172.31.0.0/16(rw,root_squash,sync) @netgroup(rw) *.example.com
+# Yes, we export /tmp
+/tmp 172.31.0.0/16(rw,root_squash,sync)
+/local2 somehost(rw,sync)
+/local3 some-host(rw,sync)
+/local3 an-other-host(rw,sync)
+"
+
+test Exports.lns get s =
+  { "dir" = "/local"
+      { "client" = "172.31.0.0/16"
+          { "option" = "rw" }
+          { "option" = "sync" } } }
+  { }
+  { "dir" = "/home"
+      { "client" = "172.31.0.0/16"
+          { "option" = "rw"}
+          { "option" = "root_squash" }
+          { "option" = "sync" } }
+      { "client" = "@netgroup"
+          { "option" = "rw" } }
+      { "client" = "*.example.com" } }
+  { "#comment" = "Yes, we export /tmp" }
+  { "dir" = "/tmp"
+      { "client" = "172.31.0.0/16"
+          { "option" = "rw" }
+          { "option" = "root_squash" }
+          { "option" = "sync" } } }
+  { "dir" = "/local2"
+      { "client" = "somehost"
+          { "option" = "rw" }
+          { "option" = "sync" } } }
+  { "dir" = "/local3"
+      { "client" = "some-host"
+          { "option" = "rw" }
+          { "option" = "sync" } } }
+  { "dir" = "/local3"
+      { "client" = "an-other-host"
+          { "option" = "rw" }
+          { "option" = "sync" } } }
diff --git a/lenses/tests/test_fstab.aug b/lenses/tests/test_fstab.aug
new file mode 100644 (file)
index 0000000..3c7e0d2
--- /dev/null
@@ -0,0 +1,107 @@
+module Test_fstab =
+
+  let simple = "/dev/vg00/lv00\t /\t ext3\t    defaults        1 1\n"
+
+  let simple_tree =
+    { "1"
+        { "spec" = "/dev/vg00/lv00" }
+        { "file" = "/" }
+        { "vfstype" = "ext3" }
+        { "opt" = "defaults" }
+        { "dump" = "1" }
+        { "passno" = "1" } }
+
+  let trailing_ws = "/dev/vg00/lv00\t /\t ext3\t    defaults        1 1  \t\n"
+
+  let gen_no_passno(passno:string) =
+    "LABEL=/boot\t /boot\t ext3\t    defaults        1" . passno . "  \t\n"
+  let no_passno = gen_no_passno ""
+
+  let no_passno_tree =
+    { "1"
+        { "spec" = "LABEL=/boot" }
+        { "file" = "/boot" }
+        { "vfstype" = "ext3" }
+        { "opt" = "defaults" }
+        { "dump" = "1" } }
+
+  let no_dump = "/dev/vg00/lv00\t /\t ext3\t    defaults\n"
+
+  let no_dump_tree =
+    { "1"
+        { "spec" = "/dev/vg00/lv00" }
+        { "file" = "/" }
+        { "vfstype" = "ext3" }
+        { "opt" = "defaults" } }
+
+
+  let multi_opts = "devpts\t /dev/pts\t devpts  gid=5,mode=620,fscontext=system_u:object_r:removable_t  0 0\n"
+
+  let multi_opts_tree =
+    { "1"
+        { "spec" = "devpts" }
+        { "file" = "/dev/pts" }
+        { "vfstype" = "devpts" }
+        { "opt" = "gid"
+            { "value" = "5" } }
+        { "opt" = "mode"
+            { "value" = "620" } }
+        { "opt" = "fscontext"
+            { "value" = "system_u:object_r:removable_t" } }
+        { "dump" = "0" }
+        { "passno" = "0" } }
+
+  test Fstab.lns get simple = simple_tree
+
+  test Fstab.lns get trailing_ws = simple_tree
+
+  test Fstab.lns get no_passno = no_passno_tree
+
+  test Fstab.lns put no_passno after set "/1/passno" "1" = gen_no_passno " 1"
+
+  test Fstab.lns get no_dump = no_dump_tree
+
+  test Fstab.lns get multi_opts = multi_opts_tree
+
+  test Fstab.lns get "/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto\t0\t0\n" =
+    { "1"
+        { "spec" = "/dev/hdc" }
+        { "file" = "/media/cdrom0" }
+        { "vfstype" = "udf" }
+        { "vfstype" = "iso9660" }
+        { "opt" = "user" }
+        { "opt" = "noauto" }
+        { "dump" = "0" }
+        { "passno" = "0" } }
+
+  (* Allow # in the spec *)
+  test Fstab.lns get "sshfs#jon@10.0.0.2:/home    /media/server    fuse    uid=1000,gid=100,port=1022 0 0\n" =
+  { "1"
+    { "spec" = "sshfs#jon@10.0.0.2:/home" }
+    { "file" = "/media/server" }
+    { "vfstype" = "fuse" }
+    { "opt" = "uid"
+         { "value" = "1000" } }
+    { "opt" = "gid"
+         { "value" = "100" } }
+    { "opt" = "port"
+         { "value" = "1022" } }
+    { "dump" = "0" }
+    { "passno" = "0" } }
+
+  (* Bug #191 *)
+  test Fstab.lns get "tmpfs /dev/shm tmpfs rw,rootcontext=\"system_u:object_r:tmpfs_t:s0\" 0 0\n" =
+  { "1"
+    { "spec" = "tmpfs" }
+    { "file" = "/dev/shm" }
+    { "vfstype" = "tmpfs" }
+    { "opt" = "rw" }
+    { "opt" = "rootcontext"
+      { "value" = "\"system_u:object_r:tmpfs_t:s0\"" } }
+    { "dump" = "0" }
+    { "passno" = "0" } }
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_gdm.aug b/lenses/tests/test_gdm.aug
new file mode 100644 (file)
index 0000000..50b12f3
--- /dev/null
@@ -0,0 +1,21 @@
+module Test_gdm =
+
+   let conf = "[daemon]
+# Automatic login, if true the first attached screen will automatically logged
+# in as user as set with AutomaticLogin key.
+AutomaticLoginEnable=false
+AutomaticLogin=
+
+[server]
+0=Standard device=/dev/console
+"
+
+   test Gdm.lns get conf =
+      { "daemon"
+         { "#comment" = "Automatic login, if true the first attached screen will automatically logged" }
+         { "#comment" = "in as user as set with AutomaticLogin key." }
+        { "AutomaticLoginEnable"  = "false" }
+        { "AutomaticLogin" }
+         {} }
+      { "server"
+         { "0" = "Standard device=/dev/console" } }
diff --git a/lenses/tests/test_group.aug b/lenses/tests/test_group.aug
new file mode 100644 (file)
index 0000000..92f590a
--- /dev/null
@@ -0,0 +1,40 @@
+module Test_group =
+
+let conf = "bin:x:2:
+audio:x:29:joe
+avahi-autoipd:!:113:bill,martha
+"
+
+test Group.lns get conf =
+   { "bin"
+     { "password" = "x" }
+     { "gid" = "2" } }
+   { "audio"
+     { "password" = "x" }
+     { "gid" = "29" }
+     { "user" = "joe" } }
+   { "avahi-autoipd"
+     { "password" = "!" }
+     { "gid" = "113" }
+     { "user" = "bill"}
+     { "user" = "martha"} }
+
+(* Password field can be empty *)
+test Group.lns get "root::0:root\n" =
+  { "root"
+    { "password" = "" }
+    { "gid" = "0" }
+    { "user" = "root" } }
+
+(* Password field can be disabled by ! or * *)
+test Group.lns get "testgrp:!:0:testusr\n" =
+  { "testgrp"
+    { "password" = "!" }
+    { "gid" = "0" }
+    { "user" = "testusr" } }
+
+test Group.lns get "testgrp:*:0:testusr\n" =
+  { "testgrp"
+    { "password" = "*" }
+    { "gid" = "0" }
+    { "user" = "testusr" } }
diff --git a/lenses/tests/test_grub.aug b/lenses/tests/test_grub.aug
new file mode 100644 (file)
index 0000000..1b21d7e
--- /dev/null
@@ -0,0 +1,203 @@
+module Test_grub =
+
+  let conf = "# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE:  You have a /boot partition.  This means that
+#          all kernel and initrd paths are relative to /boot/, eg.
+#          root (hd0,0)
+#          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+#          initrd /initrd-version.img
+#boot=/dev/sda
+device (hd0) HD(1,800,64000,9895c137-d4b2-4e3b-a93b-dc9ac4)
+password --md5 $1$M9NLj$p2gs87vwNv48BUu.wAfVw0
+default=0
+background 103332
+timeout=5
+splashimage=(hd0,0)/grub/splash.xpm.gz
+gfxmenu=(hd0,0)/boot/message
+hiddenmenu
+title Fedora (2.6.24.4-64.fc8)
+        root (hd0,0)
+        kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 crashkernel=
+        initrd /initrd-2.6.24.4-64.fc8.img
+title=Fedora (2.6.24.3-50.fc8)
+        root (hd0,0)
+        kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+        initrd /initrd-2.6.24.3-50.fc8.img
+title Fedora (2.6.21.7-3.fc8xen)
+        root (hd0,0)
+        kernel /xen.gz-2.6.21.7-3.fc8
+        module /vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00
+        module /initrd-2.6.21.7-3.fc8xen.img
+title Fedora (2.6.24.3-34.fc8)
+        root (hd0,0)
+        kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+        initrd /initrd-2.6.24.3-34.fc8.img
+        map (hd0) (hd1)
+title othermenu
+        configfile /boot/grub/othergrub.conf
+"
+
+  test Grub.lns get conf =
+    { "#comment" = "grub.conf generated by anaconda" }
+    {}
+    { "#comment" = "Note that you do not have to rerun grub after making changes to this file" }
+    { "#comment" = "NOTICE:  You have a /boot partition.  This means that" }
+    { "#comment" = "all kernel and initrd paths are relative to /boot/, eg." }
+    { "#comment" = "root (hd0,0)" }
+    { "#comment" = "kernel /vmlinuz-version ro root=/dev/vg00/lv00" }
+    { "#comment" = "initrd /initrd-version.img" }
+    { "#comment" = "boot=/dev/sda" }
+    { "device"   = "(hd0)"
+           { "file" = "HD(1,800,64000,9895c137-d4b2-4e3b-a93b-dc9ac4)" } }
+    { "password" = "$1$M9NLj$p2gs87vwNv48BUu.wAfVw0"
+        { "md5" } }
+    { "default" = "0" }
+    { "background" = "103332" }
+    { "timeout" = "5" }
+    { "splashimage" = "(hd0,0)/grub/splash.xpm.gz" }
+    { "gfxmenu" = "(hd0,0)/boot/message" }
+    { "hiddenmenu" }
+    { "title" = "Fedora (2.6.24.4-64.fc8)"
+        { "root" = "(hd0,0)" }
+        { "kernel" = "/vmlinuz-2.6.24.4-64.fc8"
+            { "ro" }  { "root" = "/dev/vg00/lv00" } {"crashkernel" = ""} }
+        { "initrd" = "/initrd-2.6.24.4-64.fc8.img" } }
+    { "title" = "Fedora (2.6.24.3-50.fc8)"
+        { "root" = "(hd0,0)" }
+        { "kernel" = "/vmlinuz-2.6.24.3-50.fc8"
+            { "ro" } { "root" = "/dev/vg00/lv00" } }
+        { "initrd" = "/initrd-2.6.24.3-50.fc8.img" } }
+    { "title" = "Fedora (2.6.21.7-3.fc8xen)"
+        { "root" = "(hd0,0)" }
+        { "kernel" = "/xen.gz-2.6.21.7-3.fc8" }
+        { "module" = "/vmlinuz-2.6.21.7-3.fc8xen"
+            { "ro" } { "root" = "/dev/vg00/lv00" } }
+        { "module" = "/initrd-2.6.21.7-3.fc8xen.img" } }
+    { "title" = "Fedora (2.6.24.3-34.fc8)"
+        { "root" = "(hd0,0)" }
+        { "kernel" = "/vmlinuz-2.6.24.3-34.fc8"
+            { "ro" } { "root" = "/dev/vg00/lv00" } }
+        { "initrd" = "/initrd-2.6.24.3-34.fc8.img" }
+        { "map" { "from" = "(hd0)" } { "to" = "(hd1)" } } }
+    { "title" = "othermenu"
+        { "configfile" = "/boot/grub/othergrub.conf" } }
+
+
+  test Grub.lns put conf after set "default" "0" = conf
+
+  test Grub.lns get "# menu.lst - See: grub(8), info grub, update-grub(8)
+
+## default num\n" =
+    { "#comment" = "menu.lst - See: grub(8), info grub, update-grub(8)" }
+    {}
+    { "#comment" = "# default num" }
+
+  (* Color directive *)
+  test Grub.lns get "color cyan/blue white/blue\n" =
+    { "color"
+      { "normal"    { "foreground" = "cyan" }
+                    { "background" = "blue" } }
+      { "highlight" { "foreground" = "white" }
+                    { "background" = "blue" } } }
+
+  test Grub.lns get "\tcolor cyan/light-blue\n" =
+    { "color"
+      { "normal" { "foreground" = "cyan" }
+                 { "background" = "light-blue" } } }
+
+  test Grub.lns put "color cyan/light-blue\n" after
+    set "/color/highlight/foreground" "white";
+    set "/color/highlight/background" "black"    =
+    "color cyan/light-blue white/black\n"
+
+  (* Boot stanza with savedefault *)
+  let boot_savedefault =
+"title\t\tDebian GNU/Linux, kernel 2.6.18-6-vserver-686
+root\t\t(hd0,0)
+  kernel\t\t/boot/vmlinuz-2.6.18-6-vserver-686 root=/dev/md0 ro
+initrd\t\t/boot/initrd.img-2.6.18-6-vserver-686
+\tsavedefault\n"
+
+  test Grub.lns get boot_savedefault =
+    { "title" = "Debian GNU/Linux, kernel 2.6.18-6-vserver-686"
+      { "root" = "(hd0,0)" }
+      { "kernel" = "/boot/vmlinuz-2.6.18-6-vserver-686"
+          { "root" = "/dev/md0" } { "ro" } }
+      { "initrd" = "/boot/initrd.img-2.6.18-6-vserver-686" }
+      { "savedefault" } }
+
+  test Grub.lns get
+      "serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1\n"
+    =
+    { "serial"
+        { "unit" = "0" }
+        { "speed" = "9600" }
+        { "word" = "8" }
+        { "parity" = "no" }
+        { "stop" = "1" } }
+
+  test Grub.lns get
+      "terminal --timeout=10 serial console\n" =
+    { "terminal"
+        { "timeout" = "10" }
+        { "serial" }
+        { "console" } }
+
+  test Grub.boot_setting get
+      "chainloader --force +1 \n" = { "chainloader" = "+1" { "force" } }
+
+  test Grub.savedefault put "savedefault\n" after
+    set "/savedefault" "3" = "savedefault 3\n"
+
+  (* BZ 590067 - handle comments in a title section *)
+  (* Comments within a boot stanza belong to that boot stanza *)
+  test Grub.lns get "title Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)
+    root (hd0,0)
+    kernel /vmlinuz-2.4.21-63.ELsmp ro root=LABEL=/
+    #initrd /initrd-2.4.21-63.ELsmp.img
+    initrd /initrd-2.4.21-63.EL.img.e1000.8139\n" =
+  { "title" = "Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)"
+    { "root" = "(hd0,0)" }
+    { "kernel" = "/vmlinuz-2.4.21-63.ELsmp" { "ro" } { "root" = "LABEL=/" } }
+    { "#comment" = "initrd /initrd-2.4.21-63.ELsmp.img" }
+    { "initrd" = "/initrd-2.4.21-63.EL.img.e1000.8139" } }
+
+  (* Comments at the end of a boot stanza go into the top level *)
+  test Grub.lns get "title Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)
+    root (hd0,0)
+    kernel /vmlinuz-2.4.21-63.ELsmp ro root=LABEL=/
+    initrd /initrd-2.4.21-63.EL.img.e1000.8139
+    # Now for something completely different\n" =
+  { "title" = "Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)"
+    { "root" = "(hd0,0)" }
+    { "kernel" = "/vmlinuz-2.4.21-63.ELsmp" { "ro" } { "root" = "LABEL=/" } }
+    { "initrd" = "/initrd-2.4.21-63.EL.img.e1000.8139" } }
+  { "#comment" = "Now for something completely different" }
+
+  (* Solaris 10 extensions: kernel$ and module$ are permitted and enable *)
+  (* variable expansion.  findroot also added, vaguely similar to root.  *)
+  test Grub.lns get "title Solaris 10 10/09 s10x_u8wos_08a X86
+    findroot (pool_rpool,0,a)
+    kernel$ /platform/i86pc/multiboot -B $ZFS-BOOTFS
+    module$ /platform/i86pc/boot_archive\n" =
+  { "title" = "Solaris 10 10/09 s10x_u8wos_08a X86"
+    { "findroot" = "(pool_rpool,0,a)" }
+    { "kernel$" = "/platform/i86pc/multiboot" { "-B" } { "$ZFS-BOOTFS" } }
+    { "module$" = "/platform/i86pc/boot_archive" } }
+
+  (* Solaris 10 extension: multiboot kernel may take a path as its first *)
+  (* argument. *)
+  test Grub.lns get "title Solaris failsafe
+    findroot (pool_rpool,0,a)
+    kernel /boot/multiboot kernel/unix -s
+    module /boot/x86.miniroot-safe\n" =
+  { "title" = "Solaris failsafe"
+    { "findroot" = "(pool_rpool,0,a)" }
+    { "kernel" = "/boot/multiboot" { "@path" = "kernel/unix" } { "-s" } }
+    { "module" = "/boot/x86.miniroot-safe" } }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_hosts.aug b/lenses/tests/test_hosts.aug
new file mode 100644 (file)
index 0000000..2bc61fb
--- /dev/null
@@ -0,0 +1,64 @@
+(* Tests for the Hosts module *)
+
+module Test_hosts =
+
+  let two_entries = "127.0.0.1 foo foo.example.com
+  # \tcomment\t
+192.168.0.1 pigiron.example.com pigiron pigiron.example
+"
+
+  test Hosts.record get "127.0.0.1 foo\n" =
+    { "1" { "ipaddr" = "127.0.0.1" }
+          { "canonical" = "foo" } }
+
+  test Hosts.lns get two_entries =
+   { "1" { "ipaddr" = "127.0.0.1" }
+          { "canonical" = "foo" }
+          { "alias" = "foo.example.com" }
+    }
+    { "#comment" = "comment" }
+    { "2" { "ipaddr" = "192.168.0.1" }
+          { "canonical" = "pigiron.example.com" }
+          { "alias" = "pigiron" }
+          { "alias" = "pigiron.example" }  }
+
+  test Hosts.record put "127.0.0.1 foo\n" after
+      set "/1/canonical" "bar"
+  = "127.0.0.1 bar\n"
+
+  test Hosts.lns put two_entries after
+    set "/2/alias[10]" "piggy" ;
+    rm "/1/alias[1]" ;
+    rm "/2/alias[2]"
+  = "127.0.0.1 foo
+  # \tcomment\t
+192.168.0.1 pigiron.example.com pigiron piggy
+"
+
+  (* Deleting the 'canonical' node violates the schema; each host entry *)
+  (* must have one                                                      *)
+  test Hosts.lns put two_entries after
+      rm "/1/canonical"
+    = *
+
+  (* Make sure blank and indented lines get through *)
+  test Hosts.lns get " \t 127.0.0.1\tlocalhost  \n \n\n
+127.0.1.1\tetch.example.com\tetch\n" =
+    { "1" { "ipaddr" = "127.0.0.1" }
+          { "canonical" = "localhost" } }
+    {} {} {}
+    { "2" { "ipaddr" = "127.0.1.1" }
+          { "canonical" = "etch.example.com" }
+          { "alias" = "etch" } }
+
+  (* Comment at the end of a line *)
+  test Hosts.lns get "127.0.0.1 localhost # must always be there \n" =
+    { "1" { "ipaddr" = "127.0.0.1" }
+          { "canonical" = "localhost" }
+          { "#comment" = "must always be there" } }
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
+
+
diff --git a/lenses/tests/test_httpd.aug b/lenses/tests/test_httpd.aug
new file mode 100644 (file)
index 0000000..af6cdc1
--- /dev/null
@@ -0,0 +1,341 @@
+module Test_httpd =
+
+(* directives testing *)
+let d1 = "ServerRoot \"/etc/apache2\"\n"
+test Httpd.directive get d1 =
+  { "directive" = "ServerRoot"
+    { "arg" = "\"/etc/apache2\"" }
+  }
+
+(* simple quotes *)
+let d1s = "ServerRoot '/etc/apache2'\n"
+test Httpd.directive get d1s =
+  { "directive" = "ServerRoot"
+    { "arg" = "'/etc/apache2'" }
+  }
+
+let d2 = "ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/\n"
+test Httpd.directive get d2 =
+  { "directive" = "ScriptAlias"
+    { "arg" = "/cgi-bin/" }
+    { "arg" = "/usr/lib/cgi-bin/" }
+  }
+
+let d3 = "LockFile /var/lock/apache2/accept.lock\n"
+test Httpd.directive get d3 =
+  { "directive" = "LockFile"
+    { "arg" = "/var/lock/apache2/accept.lock" }
+  }
+
+let c1 = "
+<IfModule>
+</IfModule>
+"
+let c1_put =
+"
+<IfModule foo bar>
+</IfModule>
+"
+
+
+test Httpd.lns get c1 = { }{ "IfModule" }
+
+test Httpd.lns put c1 after set "/IfModule/arg[1]" "foo";
+                            set "/IfModule/arg[2]" "bar" = c1_put
+
+let c2 = "
+<IfModule !mpm_winnt.c>
+  <IfModule !mpm_netware.c>
+    LockFile /var/lock/apache2/accept.lock
+  </IfModule>
+</IfModule>
+"
+
+test Httpd.lns get c2 =
+  {  }
+  { "IfModule"
+    { "arg" = "!mpm_winnt.c" }
+    { "IfModule"
+      { "arg" = "!mpm_netware.c" }
+      { "directive" = "LockFile"
+        { "arg" = "/var/lock/apache2/accept.lock" }
+      }
+    }
+  }
+
+(* arguments must be the first child of the section *)
+test Httpd.lns put c2 after rm "/IfModule/arg";
+                            insb "arg" "/IfModule/*[1]";
+                            set "/IfModule/arg" "foo"  =
+"
+<IfModule foo>
+  <IfModule !mpm_netware.c>
+    LockFile /var/lock/apache2/accept.lock
+  </IfModule>
+</IfModule>
+"
+
+let c3 = "
+<IfModule mpm_event_module>
+    StartServers          2
+    MaxClients          150
+    MinSpareThreads      25
+    MaxSpareThreads      75
+    ThreadLimit          64
+    ThreadsPerChild      25
+    MaxRequestsPerChild   0
+</IfModule>
+"
+
+test Httpd.lns get c3 =
+  {  }
+  { "IfModule"
+    { "arg" = "mpm_event_module" }
+    { "directive" = "StartServers"
+      { "arg" = "2" }
+    }
+    { "directive" = "MaxClients"
+      { "arg" = "150" }
+    }
+    { "directive" = "MinSpareThreads"
+      { "arg" = "25" }
+    }
+    { "directive" = "MaxSpareThreads"
+      { "arg" = "75" }
+    }
+    { "directive" = "ThreadLimit"
+      { "arg" = "64" }
+    }
+    { "directive" = "ThreadsPerChild"
+      { "arg" = "25" }
+    }
+    { "directive" = "MaxRequestsPerChild"
+      { "arg" = "0" }
+    }
+  }
+
+
+
+let c4 = "
+<Files ~ \"^\.ht\">
+    Order allow,deny
+    Deny from all
+    Satisfy all
+</Files>
+"
+
+test Httpd.lns get c4 =
+  {  }
+  { "Files"
+    { "arg" = "~" }
+    { "arg" = "\"^\.ht\"" }
+    { "directive" = "Order"
+      { "arg" = "allow,deny" }
+    }
+    { "directive" = "Deny"
+      { "arg" = "from" }
+      { "arg" = "all" }
+    }
+    { "directive" = "Satisfy"
+      { "arg" = "all" }
+    }
+  }
+
+
+
+let c5 = "LogFormat \"%{User-agent}i\" agent\n"
+test Httpd.lns get c5 =
+  { "directive" = "LogFormat"
+    { "arg" = "\"%{User-agent}i\"" }
+    { "arg" = "agent" }
+  }
+
+let c7 = "LogFormat \"%v:%p %h %l %u %t \\"%r\\" %>s %O \\"%{Referer}i\\" \\"%{User-Agent}i\\"\" vhost_combined\n"
+test Httpd.lns get c7 =
+  { "directive" = "LogFormat"
+    { "arg" = "\"%v:%p %h %l %u %t \\"%r\\" %>s %O \\"%{Referer}i\\" \\"%{User-Agent}i\\"\"" }
+    { "arg" = "vhost_combined" }
+  }
+
+let c8 = "IndexIgnore .??* *~ *# RCS CVS *,v *,t \n"
+test Httpd.directive get c8 =
+  { "directive" = "IndexIgnore"
+    { "arg" = ".??*" }
+    { "arg" = "*~" }
+    { "arg" = "*#" }
+    { "arg" = "RCS" }
+    { "arg" = "CVS" }
+    { "arg" = "*,v" }
+    { "arg" = "*,t" }
+  }
+
+(* FIXME: not yet supported:
+ * The backslash "\" may be used as the last character on a line to indicate
+ * that the directive continues onto the next line. There must be no other
+ * characters or white space between the backslash and the end of the line.
+ *)
+let multiline = "Options Indexes \
+FollowSymLinks MultiViews
+"
+
+test Httpd.directive get multiline =
+  { "directive" = "Options"
+    { "arg" = "Indexes" }
+    { "arg" = "FollowSymLinks" }
+    { "arg" = "MultiViews" }
+  }
+
+
+let conf2 = "<VirtualHost *:80>
+    ServerAdmin webmaster@localhost
+
+    DocumentRoot /var/www
+    <Directory />
+        Options FollowSymLinks
+        AllowOverride None
+    </Directory>
+    <Directory /var/www/>
+        Options Indexes FollowSymLinks MultiViews
+        AllowOverride None
+        Order allow,deny
+        allow from all
+    </Directory>
+
+    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
+    <Directory \"/usr/lib/cgi-bin\">
+        AllowOverride None
+        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+        Order allow,deny
+        Allow from all
+    </Directory>
+
+    ErrorLog /var/log/apache2/error.log
+
+    # Possible values include: debug, info, notice, warn, error, crit,
+    # alert, emerg.
+    LogLevel warn
+
+    CustomLog /var/log/apache2/access.log combined
+
+    SSLRequireSSL
+
+    Alias /doc/ \"/usr/share/doc/\"
+    <Directory \"/usr/share/doc/\">
+        Options Indexes MultiViews FollowSymLinks
+        AllowOverride None
+        Order deny,allow
+        Deny from all
+        Allow from 127.0.0.0/255.0.0.0 ::1/128
+    </Directory>
+
+</VirtualHost>
+"
+
+test Httpd.lns get conf2 =
+   { "VirtualHost"
+    { "arg" = "*:80" }
+    { "directive" = "ServerAdmin"
+      { "arg" = "webmaster@localhost" }
+    }
+    {  }
+    { "directive" = "DocumentRoot"
+      { "arg" = "/var/www" }
+    }
+    { "Directory"
+      { "arg" = "/" }
+      { "directive" = "Options"
+        { "arg" = "FollowSymLinks" }
+      }
+      { "directive" = "AllowOverride"
+        { "arg" = "None" }
+      }
+    }
+    { "Directory"
+      { "arg" = "/var/www/" }
+      { "directive" = "Options"
+        { "arg" = "Indexes" }
+        { "arg" = "FollowSymLinks" }
+        { "arg" = "MultiViews" }
+      }
+      { "directive" = "AllowOverride"
+        { "arg" = "None" }
+      }
+      { "directive" = "Order"
+        { "arg" = "allow,deny" }
+      }
+      { "directive" = "allow"
+        { "arg" = "from" }
+        { "arg" = "all" }
+      }
+    }
+    {  }
+    { "directive" = "ScriptAlias"
+      { "arg" = "/cgi-bin/" }
+      { "arg" = "/usr/lib/cgi-bin/" }
+    }
+    { "Directory"
+      { "arg" = "\"/usr/lib/cgi-bin\"" }
+      { "directive" = "AllowOverride"
+        { "arg" = "None" }
+      }
+      { "directive" = "Options"
+        { "arg" = "+ExecCGI" }
+        { "arg" = "-MultiViews" }
+        { "arg" = "+SymLinksIfOwnerMatch" }
+      }
+      { "directive" = "Order"
+        { "arg" = "allow,deny" }
+      }
+      { "directive" = "Allow"
+        { "arg" = "from" }
+        { "arg" = "all" }
+      }
+    }
+    {  }
+    { "directive" = "ErrorLog"
+      { "arg" = "/var/log/apache2/error.log" }
+    }
+    {  }
+    { "#comment" = "Possible values include: debug, info, notice, warn, error, crit," }
+    { "#comment" = "alert, emerg." }
+    { "directive" = "LogLevel"
+      { "arg" = "warn" }
+    }
+    {  }
+    { "directive" = "CustomLog"
+      { "arg" = "/var/log/apache2/access.log" }
+      { "arg" = "combined" }
+    }
+    {  }
+    { "directive" = "SSLRequireSSL" }
+    {  }
+    { "directive" = "Alias"
+      { "arg" = "/doc/" }
+      { "arg" = "\"/usr/share/doc/\"" }
+    }
+    { "Directory"
+      { "arg" = "\"/usr/share/doc/\"" }
+      { "directive" = "Options"
+        { "arg" = "Indexes" }
+        { "arg" = "MultiViews" }
+        { "arg" = "FollowSymLinks" }
+      }
+      { "directive" = "AllowOverride"
+        { "arg" = "None" }
+      }
+      { "directive" = "Order"
+        { "arg" = "deny,allow" }
+      }
+      { "directive" = "Deny"
+        { "arg" = "from" }
+        { "arg" = "all" }
+      }
+      { "directive" = "Allow"
+        { "arg" = "from" }
+        { "arg" = "127.0.0.0/255.0.0.0" }
+        { "arg" = "::1/128" }
+      }
+    }
+    {  }
+  }
+
diff --git a/lenses/tests/test_inetd.aug b/lenses/tests/test_inetd.aug
new file mode 100644 (file)
index 0000000..8f9f656
--- /dev/null
@@ -0,0 +1,170 @@
+module Test_inetd =
+
+       (* The standard "parse a bucket of text" test *)
+       let conf = "# Blah di blah comment
+
+simplesrv      stream  tcp     nowait  fred    /usr/bin/simplesrv
+arguserve      dgram   udp     wait    mary    /usr/bin/usenet         foo bar wombat
+
+1234           stream  tcp     nowait  fred    /usr/bin/numbersrv
+
+127.0.0.1:addrsrv      stream  tcp     nowait  fred    /usr/bin/addrsrv
+127.0.0.1,10.0.0.1:multiaddrsrv        stream tcp nowait fred /usr/bin/multiaddrsrv
+faff.fred.com:
+127.0.0.1,faff.fred.com:
+*:
+
+sndbufsrv      stream  tcp,sndbuf=12k  nowait  fred    /usr/bin/sndbufsrv
+rcvbufsrv      stream  tcp,rcvbuf=24k  nowait  fred    /usr/bin/rcvbufsrv
+allbufsrv      stream  tcp,sndbuf=1m,rcvbuf=24k        nowait  fred /usr/bin/allbufsrv
+
+dotgroupsrv    stream  tcp     nowait  fred.wilma      /usr/bin/dotgroupsrv
+colongroupsrv  stream  tcp     nowait  fred:wilma      /usr/bin/colongroupsrv
+
+maxsrv         stream  tcp     nowait.20       fred    /usr/bin/maxsrv
+
+dummy/1       tli     rpc/circuit_v,udp       wait    root    /tmp/test_svc   test_svc
+"
+
+       test Inetd.lns get conf =
+               { "#comment" = "Blah di blah comment" }
+               {}
+               { "service" = "simplesrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/simplesrv" }
+               }
+               { "service" = "arguserve"
+                       { "socket" = "dgram" }
+                       { "protocol" = "udp" }
+                       { "wait" = "wait" }
+                       { "user" = "mary" }
+                       { "command" = "/usr/bin/usenet" }
+                       { "arguments"
+                               { "1" = "foo" }
+                               { "2" = "bar" }
+                               { "3" = "wombat" }
+                       }
+               }
+               {}
+               { "service" = "1234"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/numbersrv" }
+               }
+               {}
+               { "service" = "addrsrv"
+                       { "address"
+                               { "1" = "127.0.0.1" }
+                       }
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/addrsrv" }
+               }
+               { "service" = "multiaddrsrv"
+                       { "address"
+                               { "1" = "127.0.0.1" }
+                               { "2" = "10.0.0.1" }
+                       }
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/multiaddrsrv" }
+               }
+               { "address"
+                       { "1" = "faff.fred.com" }
+               }
+               { "address"
+                       { "1" = "127.0.0.1" }
+                       { "2" = "faff.fred.com" }
+               }
+               { "address"
+                       { "1" = "*" }
+               }
+               {}
+               { "service" = "sndbufsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "sndbuf" = "12k" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/sndbufsrv" }
+               }
+               { "service" = "rcvbufsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "rcvbuf" = "24k" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/rcvbufsrv" }
+               }
+               { "service" = "allbufsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "sndbuf" = "1m" }
+                       { "rcvbuf" = "24k" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/allbufsrv" }
+               }
+               {}
+               { "service" = "dotgroupsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "group" = "wilma" }
+                       { "command" = "/usr/bin/dotgroupsrv" }
+               }
+               { "service" = "colongroupsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "user" = "fred" }
+                       { "group" = "wilma" }
+                       { "command" = "/usr/bin/colongroupsrv" }
+               }
+               {}
+               { "service" = "maxsrv"
+                       { "socket" = "stream" }
+                       { "protocol" = "tcp" }
+                       { "wait" = "nowait" }
+                       { "max" = "20" }
+                       { "user" = "fred" }
+                       { "command" = "/usr/bin/maxsrv" }
+               }
+                {}
+                { "rpc_service" = "dummy"
+                        { "version" = "1" }
+                        { "endpoint-type" = "tli" }
+                        { "protocol" = "circuit_v" }
+                        { "protocol" = "udp" }
+                        { "wait" = "wait" }
+                        { "user" = "root" }
+                        { "command" = "/tmp/test_svc" }
+                        { "arguments"
+                           { "1" = "test_svc" } }
+                }
+
+
+(**************************************************************************)
+
+       (* Test new file creation *)
+
+       test Inetd.lns put "" after
+                set "/service" "faffsrv";
+               set "/service/socket" "stream";
+               set "/service/protocol" "tcp";
+               set "/service/wait" "nowait";
+               set "/service/user" "george";
+               set "/service/command" "/sbin/faffsrv"
+       = "faffsrv      stream  tcp     nowait  george  /sbin/faffsrv\n"
+
+
diff --git a/lenses/tests/test_inifile.aug b/lenses/tests/test_inifile.aug
new file mode 100644 (file)
index 0000000..6155e30
--- /dev/null
@@ -0,0 +1,206 @@
+module Test_IniFile =
+
+  (* ALL TESTS TO RUN *)
+
+  (* separator   :  (a) default (/[:=]/ "=") ;   (b) "=" "="     *)
+  (* comment     :  (c) default (/[;#]/ ";") ;   (d) ";" ";"     *)
+  (* empty lines :  (e) default              ;   (f) noempty     *)
+
+
+  (* TEST a/c/e *)
+  let comment_ace = IniFile.comment IniFile.comment_re IniFile.comment_default
+  let sep_ace     = IniFile.sep IniFile.sep_re IniFile.sep_default
+  let entry_ace   = IniFile.entry IniFile.entry_re sep_ace comment_ace
+  let title_ace   = IniFile.title IniFile.record_re
+  let record_ace  = IniFile.record title_ace entry_ace
+  let lns_ace     = IniFile.lns record_ace comment_ace
+  let conf_ace    = "# comment with sharp
+
+[section1]
+test_ace = value # end of line comment
+test_ace =
+; comment with colon
+
+"
+  test lns_ace get conf_ace =
+      { "#comment" = "comment with sharp" }
+      {}
+      { "section1"
+          { "test_ace" = "value"
+            { "#comment" = "end of line comment" } }
+         { "test_ace" }
+         { "#comment"  = "comment with colon" }
+         {} }
+
+
+  (* TEST a/c/f *)
+  let comment_acf = IniFile.comment IniFile.comment_re IniFile.comment_default
+  let sep_acf     = IniFile.sep IniFile.sep_re IniFile.sep_default
+  let entry_acf   = IniFile.entry IniFile.entry_re sep_acf comment_acf
+  let title_acf   = IniFile.title IniFile.record_re
+  let record_acf  = IniFile.record_noempty title_acf entry_acf
+  let lns_acf     = IniFile.lns_noempty record_acf comment_acf
+  let conf_acf   = "# comment with sharp
+[section1]
+test_acf = value
+test_acf =
+test_acf : value2 # end of line comment
+; comment with colon
+"
+  test lns_acf get conf_acf =
+      { "#comment" = "comment with sharp" }
+      { "section1"
+         { "test_acf" = "value" }
+        { "test_acf" }
+         { "test_acf" = "value2"
+           { "#comment" = "end of line comment" } }
+        { "#comment"  = "comment with colon" } }
+
+
+  (* TEST a/d/e *)
+  let comment_ade = IniFile.comment ";" ";"
+  let sep_ade     = IniFile.sep IniFile.sep_re IniFile.sep_default
+  let entry_ade   = IniFile.entry IniFile.entry_re sep_ade comment_ade
+  let title_ade   = IniFile.title IniFile.record_re
+  let record_ade  = IniFile.record title_ade entry_ade
+  let lns_ade     = IniFile.lns record_ade comment_ade
+  let conf_ade    = "; a first comment with colon
+[section1]
+test_ade = value
+test_ade : value2 ; end of line comment
+; comment with colon
+
+test_ade =
+"
+   test lns_ade get conf_ade =
+      { "#comment" = "a first comment with colon" }
+      { "section1"
+         { "test_ade" = "value" }
+         { "test_ade" = "value2"
+           { "#comment" = "end of line comment" } }
+        { "#comment"  = "comment with colon" }
+        {}
+        { "test_ade" } }
+
+
+  (* TEST a/d/f *)
+  let comment_adf = IniFile.comment ";" ";"
+  let sep_adf     = IniFile.sep IniFile.sep_re IniFile.sep_default
+  let entry_adf   = IniFile.entry IniFile.entry_re sep_adf comment_adf
+  let title_adf   = IniFile.title IniFile.record_re
+  let record_adf  = IniFile.record_noempty title_adf entry_adf
+  let lns_adf     = IniFile.lns_noempty record_adf comment_adf
+  let conf_adf    = "; a first comment with colon
+[section1]
+test_adf = value
+test_adf : value2 ; end of line comment
+; comment with colon
+test_adf =
+"
+   test lns_adf get conf_adf =
+      { "#comment" = "a first comment with colon" }
+      { "section1"
+         { "test_adf" = "value" }
+         { "test_adf" = "value2"
+           { "#comment" = "end of line comment" } }
+        { "#comment"  = "comment with colon" }
+        { "test_adf" } }
+
+
+  (* TEST b/c/e *)
+  let comment_bce = IniFile.comment IniFile.comment_re IniFile.comment_default
+  let sep_bce     = IniFile.sep "=" "="
+  let entry_bce   = IniFile.entry IniFile.entry_re sep_bce comment_bce
+  let title_bce   = IniFile.title IniFile.record_re
+  let record_bce  = IniFile.record title_bce entry_bce
+  let lns_bce     = IniFile.lns record_bce comment_bce
+  let conf_bce   = "# comment with sharp
+
+[section1]
+test_bce = value # end of line comment
+; comment with colon
+
+test_bce =
+"
+  test lns_bce get conf_bce =
+      { "#comment" = "comment with sharp" }
+      {}
+      { "section1"
+          { "test_bce" = "value"
+            { "#comment" = "end of line comment" } }
+         { "#comment"  = "comment with colon" }
+         {}
+         { "test_bce" } }
+
+
+  (* TEST b/c/f *)
+  let comment_bcf = IniFile.comment IniFile.comment_re IniFile.comment_default
+  let sep_bcf     = IniFile.sep "=" "="
+  let entry_bcf   = IniFile.entry IniFile.entry_re sep_bcf comment_bcf
+  let title_bcf   = IniFile.title IniFile.record_re
+  let record_bcf  = IniFile.record_noempty title_bce entry_bcf
+  let lns_bcf     = IniFile.lns_noempty record_bce comment_bcf
+  let conf_bcf   = "# comment with sharp
+[section1]
+test_bcf = value # end of line comment
+; comment with colon
+test_bcf =
+"
+  test lns_bcf get conf_bcf =
+      { "#comment" = "comment with sharp" }
+      { "section1"
+          { "test_bcf" = "value"
+            { "#comment" = "end of line comment" } }
+         { "#comment"  = "comment with colon" }
+         { "test_bcf" } }
+
+
+  (* TEST b/d/e *)
+  let comment_bde = IniFile.comment ";" ";"
+  let sep_bde     = IniFile.sep "=" "="
+  let entry_bde   = IniFile.entry IniFile.entry_re sep_bde comment_bde
+  let title_bde   = IniFile.title IniFile.record_re
+  let record_bde  = IniFile.record title_bde entry_bde
+  let lns_bde     = IniFile.lns record_bde comment_bde
+  let conf_bde    = "; first comment with colon
+
+[section1]
+test_bde = value ; end of line comment
+; comment with colon
+
+test_bde =
+"
+  test lns_bde get conf_bde =
+      { "#comment" = "first comment with colon" }
+      {}
+      { "section1"
+          { "test_bde" = "value"
+            { "#comment" = "end of line comment" } }
+         { "#comment"  = "comment with colon" }
+         {}
+         { "test_bde" } }
+
+
+  (* TEST b/d/f *)
+  let comment_bdf = IniFile.comment ";" ";"
+  let sep_bdf     = IniFile.sep "=" "="
+  let entry_bdf   = IniFile.entry IniFile.entry_re sep_bdf comment_bdf
+  let title_bdf   = IniFile.title IniFile.record_re
+  let record_bdf  = IniFile.record_noempty title_bdf entry_bdf
+  let lns_bdf     = IniFile.lns_noempty record_bdf comment_bdf
+  let conf_bdf    = "; first comment with colon
+[section1]
+test_bdf = value ; end of line comment
+; comment with colon
+test_bdf =
+"
+  test lns_bdf get conf_bdf =
+      { "#comment" = "first comment with colon" }
+      { "section1"
+          { "test_bdf" = "value"
+            { "#comment" = "end of line comment" } }
+         { "#comment"  = "comment with colon" }
+         { "test_bdf" } }
+
+
+
diff --git a/lenses/tests/test_inittab.aug b/lenses/tests/test_inittab.aug
new file mode 100644 (file)
index 0000000..2704ff8
--- /dev/null
@@ -0,0 +1,69 @@
+module Test_inittab =
+
+  let simple  = "id:5:initdefault:\n"
+
+  let inittab = "id:5:initdefault:
+# System initialization.
+si::sysinit:/etc/rc.d/rc.sysinit
+
+# Trap CTRL-ALT-DELETE
+ca::ctrlaltdel:/sbin/shutdown -t3 -r now
+
+l0:0:wait:/etc/rc.d/rc 0
+"
+
+ test Inittab.lns get inittab =
+    { "id"
+          { "runlevels" = "5" }
+          { "action" = "initdefault" }
+          { "process" = "" } }
+    { "#comment" = "System initialization." }
+    { "si"
+          { "runlevels" = "" }
+          { "action" = "sysinit" }
+          { "process" = "/etc/rc.d/rc.sysinit" } }
+    { }
+    { "#comment" = "Trap CTRL-ALT-DELETE" }
+    { "ca"
+          { "runlevels" = "" }
+          { "action" = "ctrlaltdel" }
+          { "process" = "/sbin/shutdown -t3 -r now" } }
+    { }
+    { "l0"
+          { "runlevels" = "0" }
+          { "action" = "wait" }
+          { "process" = "/etc/rc.d/rc 0" } }
+
+  test Inittab.lns put simple after rm "/id/process" = *
+
+  test Inittab.lns put simple after set "/id/runlevels" "3" =
+    "id:3:initdefault:\n"
+
+  test Inittab.lns get
+    "co:2345:respawn:/usr/bin/command # End of line comment\n" =
+    { "co"
+        { "runlevels" = "2345" }
+        { "action" = "respawn" }
+        { "process" = "/usr/bin/command " }
+        { "#comment" = "End of line comment" } }
+
+  test Inittab.lns get
+    "co:2345:respawn:/usr/bin/blank_comment # \t \n" =
+    { "co"
+        { "runlevels" = "2345" }
+        { "action" = "respawn" }
+        { "process" = "/usr/bin/blank_comment " }
+        { "#comment" = "" } }
+
+  (* Bug 108: allow ':' in the process field *)
+  test Inittab.record get
+    "co:234:respawn:ttymon -p \"console login: \"\n" =
+    { "co"
+        { "runlevels" = "234" }
+        { "action" = "respawn" }
+        { "process" = "ttymon -p \"console login: \"" } }
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_interfaces.aug b/lenses/tests/test_interfaces.aug
new file mode 100644 (file)
index 0000000..71dda13
--- /dev/null
@@ -0,0 +1,89 @@
+module Test_interfaces =
+
+    let conf ="# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+# The loopback network interface
+
+auto lo eth0 #foo
+allow-hotplug eth1
+
+iface lo inet \
+ loopback
+
+mapping eth0
+       script /usr/local/sbin/map-scheme
+map HOME eth0-home
+     map \
+ WORK eth0-work
+
+iface eth0-home inet static
+
+address 192.168.1.1
+     netmask 255.255.255.0
+     bridge_maxwait 0
+#        up flush-mail
+    down Mambo #5
+
+  iface eth0-work inet dhcp
+
+allow-auto eth1
+iface eth1 inet dhcp
+
+mapping eth1
+       # I like mapping ...
+        # ... and I like comments
+
+       script\
+ /usr/local/sbin/map-scheme
+"
+
+    test Interfaces.lns get conf =
+        { "#comment" = "This file describes the network interfaces available on your system"}
+        { "#comment" = "and how to activate them. For more information, see interfaces(5)." }
+        { "#comment" = "The loopback network interface" }
+        {}
+        { "auto"
+            { "1" = "lo" }
+            { "2" = "eth0" }
+            { "3" = "#foo" } }
+        { "allow-hotplug" { "1" = "eth1" } }
+        { }
+        { "iface" = "lo"
+            { "family" = "inet"}
+            { "method" = "loopback"} {} }
+        { "mapping" = "eth0"
+            { "script" = "/usr/local/sbin/map-scheme"}
+            { "map" = "HOME eth0-home"}
+            { "map" = "WORK eth0-work"}
+            {} }
+        { "iface" = "eth0-home"
+            { "family" = "inet"}
+            { "method" = "static"}
+            {}
+            { "address" = "192.168.1.1" }
+            { "netmask" = "255.255.255.0" }
+            { "bridge_maxwait" = "0" }
+            { "#comment" = "up flush-mail" }
+            { "down" = "Mambo #5" }
+            {} }
+        { "iface" = "eth0-work"
+            { "family" = "inet"}
+            { "method" = "dhcp"}
+            {} }
+        { "auto"
+            { "1" = "eth1" } }
+        { "iface" = "eth1"
+            { "family" = "inet"}
+            { "method" = "dhcp"}
+           {} }
+        { "mapping" = "eth1"
+            { "#comment" = "I like mapping ..." }
+            { "#comment" = "... and I like comments" }
+            {}
+            { "script" = "/usr/local/sbin/map-scheme"} }
+
+test Interfaces.lns put "" after
+       set "/iface[1]" "eth0";
+       set "/iface[1]/family" "inet";
+       set "/iface[1]/method" "dhcp"
+= "iface eth0 inet dhcp\n"
diff --git a/lenses/tests/test_iptables.aug b/lenses/tests/test_iptables.aug
new file mode 100644 (file)
index 0000000..24c6bf5
--- /dev/null
@@ -0,0 +1,220 @@
+module Test_iptables =
+
+let add_rule = Iptables.table_rule
+let ipt_match = Iptables.ipt_match
+
+test add_rule get
+"-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n" =
+  { "append" = "INPUT"
+      { "match" = "state" }
+      { "state" = "ESTABLISHED,RELATED" }
+      { "jump" = "ACCEPT" } }
+
+test add_rule get
+"-A INPUT -p icmp -j \tACCEPT \n" =
+  { "append" = "INPUT"
+      { "protocol" = "icmp" }
+      { "jump" = "ACCEPT" } }
+
+test add_rule get
+"-A INPUT -i lo -j ACCEPT\n" =
+  { "append" = "INPUT"
+    { "in-interface" = "lo" }
+    { "jump" = "ACCEPT" } }
+
+test ipt_match get " -m tcp -p tcp --dport 53" =
+  { "match" = "tcp" } { "protocol" = "tcp" } { "dport" = "53" }
+
+let arule = " -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT"
+
+test add_rule get ("--append INPUT" . arule . "\n") =
+  { "append" = "INPUT"
+      { "match" = "state" }
+      { "state" = "NEW" }
+      { "match" = "tcp" }
+      { "protocol" = "tcp" }
+      { "dport" = "53" }
+      { "jump" = "ACCEPT" } }
+
+test ipt_match get arule =
+  { "match" = "state" } { "state" = "NEW" } { "match" = "tcp" }
+  { "protocol" = "tcp" } { "dport" = "53" } { "jump" = "ACCEPT" }
+
+test ipt_match get ("-A INPUT" . arule) = *
+
+test ipt_match get " -p esp -j ACCEPT" =
+  { "protocol" = "esp" } { "jump" = "ACCEPT" }
+
+test ipt_match get
+  " -m state --state NEW -m udp -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT"
+ =
+  { "match" = "state" } { "state" = "NEW" } { "match" = "udp" }
+  { "protocol" = "udp" } { "dport" = "5353" }
+  { "destination" = "224.0.0.251" } { "jump" = "ACCEPT" }
+
+test add_rule get
+  "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT\n" =
+  { "insert" = "FORWARD"
+      { "match" = "physdev" } { "physdev-is-bridged" } { "jump" = "ACCEPT" } }
+
+test add_rule get
+    "-A INPUT -j REJECT --reject-with icmp-host-prohibited\n" =
+  { "append" = "INPUT"
+      { "jump" = "REJECT" } { "reject-with" = "icmp-host-prohibited" } }
+
+test add_rule get
+  "-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT\n" =
+  { "append" = "RH-Firewall-1-INPUT"
+      { "protocol" = "icmp" }
+      { "icmp-type" = "any" }
+      { "jump" = "ACCEPT" } }
+
+test Iptables.table get "*filter
+:RH-Firewall-1-INPUT - [0:0]
+-A FORWARD -j RH-Firewall-1-INPUT
+-A RH-Firewall-1-INPUT -i lo -j ACCEPT
+COMMIT\n" =
+  { "table" = "filter"
+      { "chain" = "RH-Firewall-1-INPUT"
+          { "policy" = "-" } }
+      { "append" = "FORWARD"
+          { "jump" = "RH-Firewall-1-INPUT" } }
+      { "append" = "RH-Firewall-1-INPUT"
+          { "in-interface" = "lo" }
+          { "jump" = "ACCEPT" } } }
+
+let conf = "# Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002
+*filter
+:INPUT DROP [1:229]
+:FORWARD DROP [0:0]
+:OUTPUT DROP [0:0]
+-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
+
+-I FORWARD -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
+
+# comments and blank lines are allow between rules
+
+-A FORWARD -i eth1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
+--append OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
+COMMIT
+# Completed on Wed Apr 24 10:19:55 2002
+# Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002
+*mangle
+:PREROUTING ACCEPT [658:32445]
+
+:INPUT ACCEPT [658:32445]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [891:68234]
+:POSTROUTING ACCEPT [891:68234]
+COMMIT
+# Completed on Wed Apr 24 10:19:55 2002
+# Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002
+*nat
+:PREROUTING ACCEPT [1:229]
+:POSTROUTING ACCEPT [3:450]
+# The output chain
+:OUTPUT ACCEPT [3:450]
+# insert something
+--insert POSTROUTING -o eth0 -j SNAT --to-source 195.233.192.1 \t
+# and now commit
+COMMIT
+# Completed on Wed Apr 24 10:19:55 2002\n"
+
+test Iptables.lns get conf =
+  { "#comment" =
+      "Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002" }
+  { "table" = "filter"
+    { "chain" = "INPUT" { "policy" = "DROP" } }
+    { "chain" = "FORWARD" { "policy" = "DROP" } }
+    { "chain" = "OUTPUT" { "policy" = "DROP" } }
+    { "append" = "INPUT"
+      { "match" = "state" }
+      { "state" = "RELATED,ESTABLISHED" }
+      { "jump" = "ACCEPT" } }
+    {}
+    { "insert" = "FORWARD"
+      { "in-interface" = "eth0" }
+      { "match" = "state" }
+      { "state" = "RELATED,ESTABLISHED" }
+      { "jump" = "ACCEPT" } }
+    {}
+    { "#comment" = "comments and blank lines are allow between rules" }
+    {}
+    { "append" = "FORWARD"
+      { "in-interface" = "eth1" }
+      { "match" = "state" }
+      { "state" = "NEW,RELATED,ESTABLISHED" }
+      { "jump" = "ACCEPT" } }
+    { "append" = "OUTPUT"
+      { "match" = "state" }
+      { "state" = "NEW,RELATED,ESTABLISHED" }
+      { "jump" = "ACCEPT" } } }
+  { "#comment" = "Completed on Wed Apr 24 10:19:55 2002" }
+  { "#comment" =
+      "Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002" }
+  { "table" = "mangle"
+    { "chain" = "PREROUTING" { "policy" = "ACCEPT" } }
+    {}
+    { "chain" = "INPUT" { "policy" = "ACCEPT" } }
+    { "chain" = "FORWARD" { "policy" = "ACCEPT" } }
+    { "chain" = "OUTPUT" { "policy" = "ACCEPT" } }
+    { "chain" = "POSTROUTING" { "policy" = "ACCEPT" } } }
+  { "#comment" = "Completed on Wed Apr 24 10:19:55 2002" }
+  { "#comment" =
+      "Generated by iptables-save v1.2.6a on Wed Apr 24 10:19:55 2002" }
+  { "table" = "nat"
+    { "chain" = "PREROUTING" { "policy" = "ACCEPT" } }
+    { "chain" = "POSTROUTING" { "policy" = "ACCEPT" } }
+    { "#comment" = "The output chain" }
+    { "chain" = "OUTPUT" { "policy" = "ACCEPT" } }
+    { "#comment" = "insert something" }
+    { "insert" = "POSTROUTING"
+      { "out-interface" = "eth0" }
+      { "jump" = "SNAT" }
+      { "to-source" = "195.233.192.1" } }
+    { "#comment" = "and now commit" } }
+  { "#comment" = "Completed on Wed Apr 24 10:19:55 2002" }
+
+test ipt_match get " -m comment --comment \"A comment\"" =
+  { "match" = "comment" }
+  { "comment" = "\"A comment\"" }
+
+(*
+ * Test the various schemes for negation that iptables supports
+ *
+ * Note that the two ways in which a parameter can be negated lead to
+ * two different trees that mean the same.
+ *)
+test add_rule get "-I POSTROUTING ! -d 192.168.122.0/24 -j MASQUERADE\n" =
+  { "insert" = "POSTROUTING"
+    { "destination" = "192.168.122.0/24"
+      { "not" } }
+    { "jump" = "MASQUERADE" } }
+
+test add_rule get "-I POSTROUTING -d ! 192.168.122.0/24 -j MASQUERADE\n" =
+  { "insert" = "POSTROUTING"
+    { "destination" = "! 192.168.122.0/24" }
+    { "jump" = "MASQUERADE" } }
+
+test add_rule put "-I POSTROUTING ! -d 192.168.122.0/24 -j MASQUERADE\n"
+    after rm "/insert/destination/not" =
+  "-I POSTROUTING -d 192.168.122.0/24 -j MASQUERADE\n"
+
+(* I have no idea if iptables will accept double negations, but we
+ * allow it syntactically *)
+test add_rule put "-I POSTROUTING -d ! 192.168.122.0/24 -j MASQUERADE\n"
+    after clear "/insert/destination/not" =
+  "-I POSTROUTING ! -d ! 192.168.122.0/24 -j MASQUERADE\n"
+
+test Iptables.chain get ":tcp_packets - [0:0]
+" = 
+    { "chain" = "tcp_packets" { "policy" = "-" } }
+
+(* Bug #157 *)
+test ipt_match get " --tcp-flags SYN,RST,ACK,FIN SYN" =
+  { "tcp-flags"
+    { "mask" = "SYN" }
+    { "mask" = "RST" }
+    { "mask" = "ACK" }
+    { "mask" = "FIN" }
+    { "set" = "SYN" } }
diff --git a/lenses/tests/test_json.aug b/lenses/tests/test_json.aug
new file mode 100644 (file)
index 0000000..0bcd25d
--- /dev/null
@@ -0,0 +1,322 @@
+module Test_json =
+
+let lns = Json.lns
+
+test lns get "\"menu\"" = { "string" = "menu" }
+
+test lns get "true" = { "const" = "true" }
+
+test lns get "3.141" = { "number" = "3.141" }
+
+test lns get "[true, 0, \"yo\"]" =
+  { "array" { "const" = "true" } { "number" = "0" } { "string" = "yo" } }
+
+test lns get "{\"a\" : true}" =
+  { "dict" { "entry" = "a" { "const" = "true" } } }
+
+test lns get "{ \"0\":true, \"1\":false }" =
+  { "dict" { "entry" = "0" { "const" = "true" } }
+             { "entry" = "1" { "const" = "false" } } }
+
+
+test lns get "{ \"0\": true, \"1\":false }" =
+  { "dict"
+    { "entry" = "0" { "const" = "true" } }
+    { "entry" = "1" { "const" = "false" } } }
+
+test lns get "{\"menu\": \"entry one\"}" =
+  { "dict" { "entry" = "menu" { "string" = "entry one" } } }
+
+
+let s = "{\"menu\": {
+  \"id\": \"file\",
+  \"value\": \"File\",
+  \"popup\": {
+    \"menuitem\": [
+      {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},
+      {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},
+      {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}
+    ]
+  }
+}}"
+
+test lns get s =
+  { "dict"
+    { "entry" = "menu"
+      { "dict"
+        { "entry" = "id" { "string" = "file" } }
+        { "entry" = "value" { "string" = "File" } }
+        { "entry" = "popup"
+          { "dict"
+            { "entry" = "menuitem"
+              { "array"
+                { "dict"
+                  { "entry" = "value" { "string" = "New" } }
+                  { "entry" = "onclick"
+                    { "string" = "CreateNewDoc()" } } }
+                { "dict"
+                  { "entry" = "value" { "string" = "Open" } }
+                  { "entry" = "onclick" { "string" = "OpenDoc()" } } }
+                { "dict"
+                  { "entry" = "value" { "string" = "Close" } }
+                  { "entry" = "onclick" { "string" = "CloseDoc()" } }
+                } } } } } } } }
+
+let t = "
+{\"web-app\": {
+  \"servlet\": [
+    {
+      \"servlet-name\": \"cofaxCDS\",
+      \"servlet-class\": \"org.cofax.cds.CDSServlet\",
+      \"init-param\": {
+        \"configGlossary:installationAt\": \"Philadelphia, PA\",
+        \"configGlossary:adminEmail\": \"ksm@pobox.com\",
+        \"configGlossary:poweredBy\": \"Cofax\",
+        \"configGlossary:poweredByIcon\": \"/images/cofax.gif\",
+        \"configGlossary:staticPath\": \"/content/static\",
+        \"templateProcessorClass\": \"org.cofax.WysiwygTemplate\",
+        \"templateLoaderClass\": \"org.cofax.FilesTemplateLoader\",
+        \"templatePath\": \"templates\",
+        \"templateOverridePath\": \"\",
+        \"defaultListTemplate\": \"listTemplate.htm\",
+        \"defaultFileTemplate\": \"articleTemplate.htm\",
+        \"useJSP\": false,
+        \"jspListTemplate\": \"listTemplate.jsp\",
+        \"jspFileTemplate\": \"articleTemplate.jsp\",
+        \"cachePackageTagsTrack\": 200,
+        \"cachePackageTagsStore\": 200,
+        \"cachePackageTagsRefresh\": 60,
+        \"cacheTemplatesTrack\": 100,
+        \"cacheTemplatesStore\": 50,
+        \"cacheTemplatesRefresh\": 15,
+        \"cachePagesTrack\": 200,
+        \"cachePagesStore\": 100,
+        \"cachePagesRefresh\": 10,
+        \"cachePagesDirtyRead\": 10,
+        \"searchEngineListTemplate\": \"forSearchEnginesList.htm\",
+        \"searchEngineFileTemplate\": \"forSearchEngines.htm\",
+        \"searchEngineRobotsDb\": \"WEB-INF/robots.db\",
+        \"useDataStore\": true,
+        \"dataStoreClass\": \"org.cofax.SqlDataStore\",
+        \"redirectionClass\": \"org.cofax.SqlRedirection\",
+        \"dataStoreName\": \"cofax\",
+        \"dataStoreDriver\": \"com.microsoft.jdbc.sqlserver.SQLServerDriver\",
+        \"dataStoreUrl\": \"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon\",
+        \"dataStoreUser\": \"sa\",
+        \"dataStorePassword\": \"dataStoreTestQuery\",
+        \"dataStoreTestQuery\": \"SET NOCOUNT ON;select test='test';\",
+        \"dataStoreLogFile\": \"/usr/local/tomcat/logs/datastore.log\",
+        \"dataStoreInitConns\": 10,
+        \"dataStoreMaxConns\": 100,
+        \"dataStoreConnUsageLimit\": 100,
+        \"dataStoreLogLevel\": \"debug\",
+        \"maxUrlLength\": 500}},
+    {
+      \"servlet-name\": \"cofaxEmail\",
+      \"servlet-class\": \"org.cofax.cds.EmailServlet\",
+      \"init-param\": {
+      \"mailHost\": \"mail1\",
+      \"mailHostOverride\": \"mail2\"}},
+    {
+      \"servlet-name\": \"cofaxAdmin\",
+      \"servlet-class\": \"org.cofax.cds.AdminServlet\"},
+
+    {
+      \"servlet-name\": \"fileServlet\",
+      \"servlet-class\": \"org.cofax.cds.FileServlet\"},
+    {
+      \"servlet-name\": \"cofaxTools\",
+      \"servlet-class\": \"org.cofax.cms.CofaxToolsServlet\",
+      \"init-param\": {
+        \"templatePath\": \"toolstemplates/\",
+        \"log\": 1,
+        \"logLocation\": \"/usr/local/tomcat/logs/CofaxTools.log\",
+        \"logMaxSize\": \"\",
+        \"dataLog\": 1,
+        \"dataLogLocation\": \"/usr/local/tomcat/logs/dataLog.log\",
+        \"dataLogMaxSize\": \"\",
+        \"removePageCache\": \"/content/admin/remove?cache=pages&id=\",
+        \"removeTemplateCache\": \"/content/admin/remove?cache=templates&id=\",
+        \"fileTransferFolder\": \"/usr/local/tomcat/webapps/content/fileTransferFolder\",
+        \"lookInContext\": 1,
+        \"adminGroupID\": 4,
+        \"betaServer\": true}}],
+  \"servlet-mapping\": {
+    \"cofaxCDS\": \"/\",
+    \"cofaxEmail\": \"/cofaxutil/aemail/*\",
+    \"cofaxAdmin\": \"/admin/*\",
+    \"fileServlet\": \"/static/*\",
+    \"cofaxTools\": \"/tools/*\"},
+
+  \"taglib\": {
+    \"taglib-uri\": \"cofax.tld\",
+    \"taglib-location\": \"/WEB-INF/tlds/cofax.tld\"}}}"
+
+test lns get t =
+  { "dict"
+    { "entry" = "web-app"
+      { "dict"
+        { "entry" = "servlet"
+          { "array"
+            { "dict"
+              { "entry" = "servlet-name" { "string" = "cofaxCDS" } }
+              { "entry" = "servlet-class"
+                { "string" = "org.cofax.cds.CDSServlet" } }
+              { "entry" = "init-param"
+                { "dict"
+                  { "entry" = "configGlossary:installationAt"
+                    { "string" = "Philadelphia, PA" } }
+                  { "entry" = "configGlossary:adminEmail"
+                    { "string" = "ksm@pobox.com" } }
+                  { "entry" = "configGlossary:poweredBy"
+                    { "string" = "Cofax" } }
+                  { "entry" = "configGlossary:poweredByIcon"
+                    { "string" = "/images/cofax.gif" } }
+                  { "entry" = "configGlossary:staticPath"
+                    { "string" = "/content/static" } }
+                  { "entry" = "templateProcessorClass"
+                    { "string" = "org.cofax.WysiwygTemplate" } }
+                  { "entry" = "templateLoaderClass"
+                    { "string" = "org.cofax.FilesTemplateLoader" } }
+                  { "entry" = "templatePath"
+                    { "string" = "templates" } }
+                  { "entry" = "templateOverridePath"
+                    { "string" = "" } }
+                  { "entry" = "defaultListTemplate"
+                    { "string" = "listTemplate.htm" } }
+                  { "entry" = "defaultFileTemplate"
+                    { "string" = "articleTemplate.htm" } }
+                  { "entry" = "useJSP"
+                    { "const" = "false" } }
+                  { "entry" = "jspListTemplate"
+                    { "string" = "listTemplate.jsp" } }
+                  { "entry" = "jspFileTemplate"
+                    { "string" = "articleTemplate.jsp" } }
+                  { "entry" = "cachePackageTagsTrack"
+                    { "number" = "200" } }
+                  { "entry" = "cachePackageTagsStore"
+                    { "number" = "200" } }
+                  { "entry" = "cachePackageTagsRefresh"
+                    { "number" = "60" } }
+                  { "entry" = "cacheTemplatesTrack"
+                    { "number" = "100" } }
+                  { "entry" = "cacheTemplatesStore"
+                    { "number" = "50" } }
+                  { "entry" = "cacheTemplatesRefresh"
+                    { "number" = "15" } }
+                  { "entry" = "cachePagesTrack"
+                    { "number" = "200" } }
+                  { "entry" = "cachePagesStore"
+                    { "number" = "100" } }
+                  { "entry" = "cachePagesRefresh"
+                    { "number" = "10" } }
+                  { "entry" = "cachePagesDirtyRead"
+                    { "number" = "10" } }
+                  { "entry" = "searchEngineListTemplate"
+                    { "string" = "forSearchEnginesList.htm" } }
+                  { "entry" = "searchEngineFileTemplate"
+                    { "string" = "forSearchEngines.htm" } }
+                  { "entry" = "searchEngineRobotsDb"
+                    { "string" = "WEB-INF/robots.db" } }
+                  { "entry" = "useDataStore"
+                    { "const" = "true" } }
+                  { "entry" = "dataStoreClass"
+                    { "string" = "org.cofax.SqlDataStore" } }
+                  { "entry" = "redirectionClass"
+                    { "string" = "org.cofax.SqlRedirection" } }
+                  { "entry" = "dataStoreName"
+                    { "string" = "cofax" } }
+                  { "entry" = "dataStoreDriver"
+                    { "string" = "com.microsoft.jdbc.sqlserver.SQLServerDriver" } }
+                  { "entry" = "dataStoreUrl"
+                    { "string" = "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon" } }
+                  { "entry" = "dataStoreUser"
+                    { "string" = "sa" } }
+                  { "entry" = "dataStorePassword"
+                    { "string" = "dataStoreTestQuery" } }
+                  { "entry" = "dataStoreTestQuery"
+                    { "string" = "SET NOCOUNT ON;select test='test';" } }
+                  { "entry" = "dataStoreLogFile"
+                    { "string" = "/usr/local/tomcat/logs/datastore.log" } }
+                  { "entry" = "dataStoreInitConns"
+                    { "number" = "10" } }
+                  { "entry" = "dataStoreMaxConns"
+                    { "number" = "100" } }
+                  { "entry" = "dataStoreConnUsageLimit"
+                    { "number" = "100" } }
+                  { "entry" = "dataStoreLogLevel"
+                    { "string" = "debug" } }
+                  { "entry" = "maxUrlLength"
+                    { "number" = "500" } } } } }
+            { "dict"
+              { "entry" = "servlet-name"
+                { "string" = "cofaxEmail" } }
+              { "entry" = "servlet-class"
+                { "string" = "org.cofax.cds.EmailServlet" } }
+              { "entry" = "init-param"
+                { "dict"
+                  { "entry" = "mailHost"
+                    { "string" = "mail1" } }
+                  { "entry" = "mailHostOverride"
+                    { "string" = "mail2" } } } } }
+            { "dict"
+              { "entry" = "servlet-name"
+                { "string" = "cofaxAdmin" } }
+              { "entry" = "servlet-class"
+                { "string" = "org.cofax.cds.AdminServlet" } } }
+            { "dict"
+              { "entry" = "servlet-name"
+                { "string" = "fileServlet" } }
+              { "entry" = "servlet-class"
+                { "string" = "org.cofax.cds.FileServlet" } } }
+            { "dict"
+              { "entry" = "servlet-name"
+                { "string" = "cofaxTools" } }
+              { "entry" = "servlet-class"
+                { "string" = "org.cofax.cms.CofaxToolsServlet" } }
+              { "entry" = "init-param"
+                { "dict"
+                  { "entry" = "templatePath"
+                    { "string" = "toolstemplates/" } }
+                  { "entry" = "log"
+                    { "number" = "1" } }
+                  { "entry" = "logLocation"
+                    { "string" = "/usr/local/tomcat/logs/CofaxTools.log" } }
+                  { "entry" = "logMaxSize"
+                    { "string" = "" } }
+                  { "entry" = "dataLog"
+                    { "number" = "1" } }
+                  { "entry" = "dataLogLocation"
+                    { "string" = "/usr/local/tomcat/logs/dataLog.log" } }
+                  { "entry" = "dataLogMaxSize"
+                    { "string" = "" } }
+                  { "entry" = "removePageCache"
+                    { "string" = "/content/admin/remove?cache=pages&id=" } }
+                  { "entry" = "removeTemplateCache"
+                    { "string" = "/content/admin/remove?cache=templates&id=" } }
+                  { "entry" = "fileTransferFolder"
+                    { "string" = "/usr/local/tomcat/webapps/content/fileTransferFolder" } }
+                  { "entry" = "lookInContext"
+                    { "number" = "1" } }
+                  { "entry" = "adminGroupID"
+                    { "number" = "4" } }
+                  { "entry" = "betaServer"
+                    { "const" = "true" } } } } } } }
+        { "entry" = "servlet-mapping"
+          { "dict"
+            { "entry" = "cofaxCDS"
+              { "string" = "/" } }
+            { "entry" = "cofaxEmail"
+              { "string" = "/cofaxutil/aemail/*" } }
+            { "entry" = "cofaxAdmin"
+              { "string" = "/admin/*" } }
+            { "entry" = "fileServlet"
+              { "string" = "/static/*" } }
+            { "entry" = "cofaxTools"
+              { "string" = "/tools/*" } } } }
+        { "entry" = "taglib"
+          { "dict"
+            { "entry" = "taglib-uri"
+              { "string" = "cofax.tld" } }
+            { "entry" = "taglib-location"
+              { "string" = "/WEB-INF/tlds/cofax.tld" } } } } } } }
diff --git a/lenses/tests/test_keepalived.aug b/lenses/tests/test_keepalived.aug
new file mode 100644 (file)
index 0000000..ff5056a
--- /dev/null
@@ -0,0 +1,250 @@
+(* Test for keepalived lens *)
+
+module Test_keepalived =
+
+   let conf = "! This is a comment 
+! Configuration File for keepalived 
+
+global_defs { 
+   ! this is who emails will go to on alerts 
+   notification_email { 
+        admins@example.com 
+    fakepager@example.com 
+    ! add a few more email addresses here if you would like 
+   } 
+   notification_email_from admins@example.com 
+
+   smtp_server 127.0.0.1  ! I use the local machine to relay mail 
+   smtp_connect_timeout 30 
+
+   ! each load balancer should have a different ID 
+   ! this will be used in SMTP alerts, so you should make 
+   ! each router easily identifiable 
+   lvs_id LVS_EXAMPLE_01 
+} 
+
+vrrp_sync_group VG1 { 
+   group { 
+      inside_network  # name of vrrp_instance (below)
+      outside_network # One for each moveable IP.  
+   } 
+} 
+
+vrrp_instance VI_1 { 
+        state MASTER 
+        interface eth0 
+     
+        lvs_sync_daemon_interface eth0 
+
+    ! each virtual router id must be unique per instance name! 
+        virtual_router_id 51 
+
+    ! MASTER and BACKUP state are determined by the priority 
+    ! even if you specify MASTER as the state, the state will 
+    ! be voted on by priority (so if your state is MASTER but your 
+    ! priority is lower than the router with BACKUP, you will lose 
+    ! the MASTER state) 
+    ! I make it a habit to set priorities at least 50 points apart 
+    ! note that a lower number is lesser priority - lower gets less vote 
+        priority 150 
+
+    ! how often should we vote, in seconds? 
+        advert_int 1 
+
+    ! send an alert when this instance changes state from MASTER to BACKUP 
+        smtp_alert 
+
+    ! this authentication is for syncing between failover servers 
+    ! keepalived supports PASS, which is simple password 
+    ! authentication 
+    ! or AH, which is the IPSec authentication header. 
+    ! I don't use AH 
+    ! yet as many people have reported problems with it 
+        authentication { 
+                auth_type PASS 
+                auth_pass example 
+        } 
+
+    ! these are the IP addresses that keepalived will setup on this 
+    ! machine. Later in the config we will specify which real 
+        ! servers  are behind these IPs 
+    ! without this block, keepalived will not setup and takedown the 
+    ! any IP addresses 
+     
+        virtual_ipaddress { 
+                192.168.1.11 
+                10.234.66.146/32 dev vlan933 # parse it well
+        ! and more if you want them 
+        } 
+} 
+
+virtual_server 192.168.1.11 22 { 
+    delay_loop 6 
+
+    ! use round-robin as a load balancing algorithm 
+    lb_algo rr 
+
+    ! we are doing NAT 
+    lb_kind NAT 
+    nat_mask 255.255.255.0 
+
+    protocol TCP 
+
+    ! there can be as many real_server blocks as you need 
+
+    real_server 10.20.40.10 22 { 
+
+    ! if we used weighted round-robin or a similar lb algo, 
+    ! we include the weight of this server 
+
+        weight 1 
+
+    ! here is a health checker for this server. 
+    ! we could use a custom script here (see the keepalived docs) 
+    ! but we will just make sure we can do a vanilla tcp connect() 
+    ! on port 22 
+    ! if it fails, we will pull this realserver out of the pool 
+    ! and send email about the removal 
+        TCP_CHECK { 
+                connect_timeout 3 
+        connect_port 22 
+        } 
+    } 
+} 
+
+virtual_server_group DNS_1 {
+    192.168.0.1 22
+    10.234.55.22-25 36
+    10.45.58.59/32 27
+}
+
+! that's all
+"
+
+
+   test Keepalived.lns get conf =
+     { "#comment" = "This is a comment" }
+     { "#comment" = "Configuration File for keepalived" }
+     {}
+     { "global_defs"
+       { "#comment" = "this is who emails will go to on alerts" }
+       { "notification_email"
+            { "email" = "admins@example.com" }
+            { "email" = "fakepager@example.com" }
+            { "#comment" = "add a few more email addresses here if you would like" } }
+       { "notification_email_from" = "admins@example.com" }
+       { }
+       { "smtp_server" = "127.0.0.1"
+         { "#comment" = "I use the local machine to relay mail" } }
+       { "smtp_connect_timeout" = "30" }
+       {}
+       { "#comment" = "each load balancer should have a different ID" }
+       { "#comment" = "this will be used in SMTP alerts, so you should make" }
+       { "#comment" = "each router easily identifiable" }
+       { "lvs_id" = "LVS_EXAMPLE_01" } }
+     {}
+     { "vrrp_sync_group" = "VG1"
+       { "group"
+         { "inside_network"
+           { "#comment" = "name of vrrp_instance (below)" } }
+         { "outside_network"
+           { "#comment" = "One for each moveable IP." } } } }
+     {}
+     { "vrrp_instance" = "VI_1"
+       { "state" = "MASTER" }
+       { "interface" = "eth0" }
+       { }
+       { "lvs_sync_daemon_interface" = "eth0" }
+       { }
+       { "#comment" = "each virtual router id must be unique per instance name!" }
+       { "virtual_router_id" = "51" }
+       { }
+       { "#comment" = "MASTER and BACKUP state are determined by the priority" }
+       { "#comment" = "even if you specify MASTER as the state, the state will" }
+       { "#comment" = "be voted on by priority (so if your state is MASTER but your" }
+       { "#comment" = "priority is lower than the router with BACKUP, you will lose" }
+       { "#comment" = "the MASTER state)" }
+       { "#comment" = "I make it a habit to set priorities at least 50 points apart" }
+       { "#comment" = "note that a lower number is lesser priority - lower gets less vote" }
+       { "priority" = "150" }
+       { }
+       { "#comment" = "how often should we vote, in seconds?" }
+       { "advert_int" = "1" }
+       { }
+       { "#comment" = "send an alert when this instance changes state from MASTER to BACKUP" }
+       { "smtp_alert" }
+       { }
+       { }
+       { "#comment" = "this authentication is for syncing between failover servers" }
+       { "#comment" = "keepalived supports PASS, which is simple password" }
+       { "#comment" = "authentication" }
+       { "#comment" = "or AH, which is the IPSec authentication header." }
+       { "#comment" = "I don't use AH" }
+       { "#comment" = "yet as many people have reported problems with it" }
+       { "authentication"
+         { "auth_type" = "PASS" }
+         { "auth_pass" = "example" } }
+       { }
+       { "#comment" = "these are the IP addresses that keepalived will setup on this" }
+       { "#comment" = "machine. Later in the config we will specify which real" }
+       { "#comment" = "servers  are behind these IPs" }
+       { "#comment" = "without this block, keepalived will not setup and takedown the" }
+       { "#comment" = "any IP addresses" }
+       { }
+       { "virtual_ipaddress"
+         { "ipaddr" = "192.168.1.11" }
+         { "ipaddr" = "10.234.66.146"
+           { "prefixlen" = "32" }
+           { "dev" = "vlan933" }
+           { "#comment" = "parse it well" } }
+         { "#comment" = "and more if you want them" } } }
+       { }
+       { "virtual_server"
+         { "ip" = "192.168.1.11" }
+         { "port" = "22" }
+         { "delay_loop" = "6" }
+         { }
+         { "#comment" = "use round-robin as a load balancing algorithm" }
+         { "lb_algo" = "rr" }
+         { }
+         { "#comment" = "we are doing NAT" }
+         { "lb_kind" = "NAT" }
+         { "nat_mask" = "255.255.255.0" }
+         { }
+         { "protocol" = "TCP" }
+         { }
+         { "#comment" = "there can be as many real_server blocks as you need" }
+         { }
+         { "real_server"
+           { "ip" = "10.20.40.10" }
+           { "port" = "22" }
+           { }
+           { "#comment" = "if we used weighted round-robin or a similar lb algo," }
+           { "#comment" = "we include the weight of this server" }
+           { }
+           { "weight" = "1" }
+           { }
+           { "#comment" = "here is a health checker for this server." }
+           { "#comment" = "we could use a custom script here (see the keepalived docs)" }
+           { "#comment" = "but we will just make sure we can do a vanilla tcp connect()" }
+           { "#comment" = "on port 22" }
+           { "#comment" = "if it fails, we will pull this realserver out of the pool" }
+           { "#comment" = "and send email about the removal" }
+           { "TCP_CHECK"
+             { "connect_timeout" = "3" }
+             { "connect_port" = "22" } } } }
+       { }
+       { "virtual_server_group" = "DNS_1"
+         { "vip"
+          { "ipaddr" = "192.168.0.1" }
+          { "port" = "22" } }
+        { "vip"
+          { "ipaddr" = "10.234.55.22-25" }
+          { "port" = "36" } }
+        { "vip"
+          { "ipaddr" = "10.45.58.59"
+            { "prefixlen" = "32" } }
+          { "port" = "27" } } }
+       { }
+       { "#comment" = "that's all" }
+
diff --git a/lenses/tests/test_krb5.aug b/lenses/tests/test_krb5.aug
new file mode 100644 (file)
index 0000000..d2a4fef
--- /dev/null
@@ -0,0 +1,892 @@
+module Test_krb5 =
+
+  (* Krb5.conf from Fermi labs *)
+  let fermi_str = "###
+### This krb5.conf template is intended for use with Fermi
+### Kerberos v1_2 and later.  Earlier versions may choke on the
+### \"auth_to_local = \" lines unless they are commented out.
+### The installation process should do all the right things in
+### any case, but if you are reading this and haven't updated
+### your kerberos product to v1_2 or later, you really should!
+###
+[libdefaults]
+       ticket_lifetime = 1560m
+       default_realm = FNAL.GOV
+       ccache_type = 4
+       default_tgs_enCtypes = des-cbc-crc
+       default_tkt_enctypes = des-cbc-crc
+       default_lifetime = 7d
+       renew_lifetime = 7d
+       autologin = true
+       forward = true
+       forwardable = true
+       renewable = true
+       encrypt = true
+
+[realms]
+       FNAL.GOV = {
+               kdc = krb-fnal-1.fnal.gov:88
+               kdc = krb-fnal-2.fnal.gov:88
+               kdc = krb-fnal-3.fnal.gov:88
+               kdc = krb-fnal-4.fnal.gov:88
+               kdc = krb-fnal-5.fnal.gov:88
+               kdc = krb-fnal-6.fnal.gov:88
+               kdc = krb-fnal-7.fnal.gov:88
+               master_kdc = krb-fnal-admin.fnal.gov:88
+               admin_server = krb-fnal-admin.fnal.gov
+               default_domain = fnal.gov
+       }
+       WIN.FNAL.GOV = {
+               kdc = littlebird.win.fnal.gov:88
+               kdc = bigbird.win.fnal.gov:88
+               default_domain = fnal.gov
+       }
+       FERMI.WIN.FNAL.GOV = {
+               kdc = sully.fermi.win.fnal.gov:88
+               kdc = elmo.fermi.win.fnal.gov:88
+               kdc = grover.fermi.win.fnal.gov:88
+               kdc = oscar.fermi.win.fnal.gov:88
+               kdc = cookie.fermi.win.fnal.gov:88
+               kdc = herry.fermi.win.fnal.gov:88
+               default_domain = fnal.gov
+       }
+       UCHICAGO.EDU = {
+               kdc = kerberos-0.uchicago.edu
+               kdc = kerberos-1.uchicago.edu
+               kdc = kerberos-2.uchicago.edu
+               admin_server = kerberos.uchicago.edu
+               default_domain = uchicago.edu
+       }
+       PILOT.FNAL.GOV = {
+               kdc = i-krb-2.fnal.gov:88
+               master_kdc = i-krb-2.fnal.gov:88
+               admin_server = i-krb-2.fnal.gov
+               default_domain = fnal.gov
+        }
+       WINBETA.FNAL.GOV = {
+               kdc = wbdc1.winbeta.fnal.gov:88
+               kdc = wbdc2.winbeta.fnal.gov:88
+               default_domain = fnal.gov
+       }
+       FERMIBETA.WINBETA.FNAL.GOV = {
+               kdc = fbdc1.fermibeta.winbeta.fnal.gov:88
+               kdc = fbdc2.fermibeta.winbeta.fnal.gov:88
+               default_domain = fnal.gov
+       }
+       CERN.CH = {
+               kdc = afsdb2.cern.ch
+               kdc = afsdb3.cern.ch
+               kdc = afsdb1.cern.ch
+               default_domain = cern.ch
+               kpasswd_server = afskrb5m.cern.ch
+               admin_server = afskrb5m.cern.ch
+       }
+
+[instancemapping]
+ afs = {
+       cron/* = \"\"
+       cms/* = \"\"
+       afs/* = \"\"
+       e898/* = \"\"
+ }
+
+[capaths]
+
+# FNAL.GOV and PILOT.FNAL.GOV are the MIT Kerberos Domains
+# FNAL.GOV is production and PILOT is for testing
+# The FERMI Windows domain uses the WIN.FNAL.GOV root realm
+# with the FERMI.WIN.FNAL.GOV sub-realm where machines and users
+# reside.  The WINBETA and FERMIBETA domains are the equivalent
+# testing realms for the FERMIBETA domain.  The 2-way transitive
+# trust structure of this complex is as follows:
+#
+# FNAL.GOV <=> PILOT.FNAL.GOV
+# FNAL.GOV <=> WIN.FERMI.GOV <=> FERMI.WIN.FERMI.GOV
+# PILOT.FNAL.GOV <=> WINBETA.FNAL.GOV <=> FERMIBETA.WINBETA.FNAL.GOV
+
+FNAL.GOV = {
+       PILOT.FNAL.GOV = .
+       FERMI.WIN.FNAL.GOV = WIN.FNAL.GOV
+       WIN.FNAL.GOV = .
+       FERMIBETA.WINBETA.FNAL.GOV = WINBETA.FNAL.GOV
+       WINBETA.FNAL.GOV = PILOT.FNAL.GOV
+}
+PILOT.FNAL.GOV = {
+       FNAL.GOV = .
+       FERMI.WIN.FNAL.GOV = WIN.FNAL.GOV
+       WIN.FNAL.GOV = FNAL.GOV
+       FERMIBETA.WINBETA.FNAL.GOV = WINBETA.FNAL.GOV
+       WINBETA.FNAL.GOV = .
+}
+WIN.FNAL.GOV = {
+       FNAL.GOV = .
+       PILOT.FNAL.GOV = FNAL.GOV
+       FERMI.WIN.FNAL.GOV = .
+       FERMIBETA.WINBETA.FNAL.GOV = WINBETA.FNAL.GOV
+       WINBETA.FNAL.GOV = PILOT.FNAL.GOV
+}
+WINBETA.FNAL.GOV = {
+       PILOT.FNAL.GOV = .
+       FERMIBETA.WINBETA.FNAL.GOV = .
+       FNAL.GOV = PILOT.FNAL.GOV
+       FERMI.WIN.FNAL.GOV = WIN.FNAL.GOV
+       WIN.FNAL.GOV = PILOT.FNAL.GOV
+}
+
+[logging]
+       kdc = SYSLOG:info:local1
+       admin_server = SYSLOG:info:local2
+       default = SYSLOG:err:auth
+
+[domain_realm]
+# Fermilab's (non-windows-centric) domains
+       .fnal.gov = FNAL.GOV
+       .cdms-soudan.org = FNAL.GOV
+       .deemz.net = FNAL.GOV
+       .dhcp.fnal.gov = FNAL.GOV
+       .minos-soudan.org = FNAL.GOV
+       i-krb-2.fnal.gov = PILOT.FNAL.GOV
+       .win.fnal.gov = WIN.FNAL.GOV
+       .fermi.win.fnal.gov = FERMI.WIN.FNAL.GOV
+       .winbeta.fnal.gov = WINBETA.FNAL.GOV
+       .fermibeta.winbeta.fnal.gov = FERMIBETA.WINBETA.FNAL.GOV
+# Fermilab's KCA servers so FERMI.WIN principals work in FNAL.GOV realm
+#      winserver.fnal.gov = FERMI.WIN.FNAL.GOV
+#      winserver2.fnal.gov = FERMI.WIN.FNAL.GOVA
+# Accelerator nodes to FERMI.WIN for Linux/OS X users
+       adgroups.fnal.gov = FERMI.WIN.FNAL.GOV
+       adusers.fnal.gov = FERMI.WIN.FNAL.GOV
+       webad.fnal.gov = FERMI.WIN.FNAL.GOV
+# Friends and family (by request)
+       .cs.ttu.edu = FNAL.GOV
+       .geol.uniovi.es = FNAL.GOV
+       .harvard.edu = FNAL.GOV
+       .hpcc.ttu.edu = FNAL.GOV
+       .infn.it = FNAL.GOV
+       .knu.ac.kr  = FNAL.GOV
+       .lns.mit.edu = FNAL.GOV
+       .ph.liv.ac.uk = FNAL.GOV
+       .pha.jhu.edu = FNAL.GOV
+       .phys.ttu.edu = FNAL.GOV
+       .phys.ualberta.ca = FNAL.GOV
+       .physics.lsa.umich.edu = FNAL.GOV
+       .physics.ucla.edu = FNAL.GOV
+       .physics.ucsb.edu = FNAL.GOV
+       .physics.utoronto.ca = FNAL.GOV
+       .rl.ac.uk = FNAL.GOV
+       .rockefeller.edu = FNAL.GOV
+       .rutgers.edu = FNAL.GOV
+       .sdsc.edu = FNAL.GOV
+       .sinica.edu.tw = FNAL.GOV
+       .tsukuba.jp.hep.net = FNAL.GOV
+       .ucsd.edu = FNAL.GOV
+       .unl.edu = FNAL.GOV
+       .in2p3.fr = FNAL.GOV
+       .wisc.edu = FNAL.GOV
+       .pic.org.es = FNAL.GOV
+       .kisti.re.kr = FNAL.GOV
+
+# The whole \"top half\" is replaced during \"ups installAsRoot krb5conf\", so:
+# It would probably be a bad idea to change anything on or above this line
+
+# If you need to add any .domains or hosts, put them here
+[domain_realm]
+       mojo.lunet.edu = FNAL.GOV
+
+[appdefaults]
+       default_lifetime = 7d
+       retain_ccache = false
+       autologin = true
+       forward = true
+       forwardable = true
+       renewable = true
+       encrypt = true
+       krb5_aklog_path = /usr/bin/aklog
+
+       telnet = {
+       }
+
+       rcp = {
+               forward = true
+               encrypt = false
+               allow_fallback = true
+       }
+
+       rsh = {
+               allow_fallback = true
+       }
+
+       rlogin = {
+               allow_fallback = false
+       }
+
+
+       login = {
+               forwardable = true
+               krb5_run_aklog = false
+               krb5_get_tickets = true
+               krb4_get_tickets = false
+               krb4_convert = false
+       }
+
+       kinit = {
+               forwardable = true
+               krb5_run_aklog = false
+       }
+
+       kadmin = {
+               forwardable = false
+       }
+
+       rshd = {
+               krb5_run_aklog = false
+       }
+
+       ftpd = {
+               krb5_run_aklog = false
+               default_lifetime = 10h
+       }
+
+       pam = {
+               debug = false
+               forwardable = true
+               renew_lifetime = 7d
+               ticket_lifetime = 1560m
+               krb4_convert = true
+               afs_cells = fnal.gov
+               krb5_run_aklog = false
+       }
+"
+
+test Krb5.lns get fermi_str =
+  { "#comment" = "##" }
+  { "#comment" = "## This krb5.conf template is intended for use with Fermi" }
+  { "#comment" = "## Kerberos v1_2 and later.  Earlier versions may choke on the" }
+  { "#comment" = "## \"auth_to_local = \" lines unless they are commented out." }
+  { "#comment" = "## The installation process should do all the right things in" }
+  { "#comment" = "## any case, but if you are reading this and haven't updated" }
+  { "#comment" = "## your kerberos product to v1_2 or later, you really should!" }
+  { "#comment" = "##" }
+  { "libdefaults"
+    { "ticket_lifetime" = "1560m" }
+    { "default_realm" = "FNAL.GOV" }
+    { "ccache_type" = "4" }
+    { "default_tgs_enCtypes" = "des-cbc-crc" }
+    { "default_tkt_enctypes" = "des-cbc-crc" }
+    { "default_lifetime" = "7d" }
+    { "renew_lifetime" = "7d" }
+    { "autologin" = "true" }
+    { "forward" = "true" }
+    { "forwardable" = "true" }
+    { "renewable" = "true" }
+    { "encrypt" = "true" }
+    {  } }
+  { "realms"
+    { "realm" = "FNAL.GOV"
+      { "kdc" = "krb-fnal-1.fnal.gov:88" }
+      { "kdc" = "krb-fnal-2.fnal.gov:88" }
+      { "kdc" = "krb-fnal-3.fnal.gov:88" }
+      { "kdc" = "krb-fnal-4.fnal.gov:88" }
+      { "kdc" = "krb-fnal-5.fnal.gov:88" }
+      { "kdc" = "krb-fnal-6.fnal.gov:88" }
+      { "kdc" = "krb-fnal-7.fnal.gov:88" }
+      { "master_kdc" = "krb-fnal-admin.fnal.gov:88" }
+      { "admin_server" = "krb-fnal-admin.fnal.gov" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "WIN.FNAL.GOV"
+      { "kdc" = "littlebird.win.fnal.gov:88" }
+      { "kdc" = "bigbird.win.fnal.gov:88" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "FERMI.WIN.FNAL.GOV"
+      { "kdc" = "sully.fermi.win.fnal.gov:88" }
+      { "kdc" = "elmo.fermi.win.fnal.gov:88" }
+      { "kdc" = "grover.fermi.win.fnal.gov:88" }
+      { "kdc" = "oscar.fermi.win.fnal.gov:88" }
+      { "kdc" = "cookie.fermi.win.fnal.gov:88" }
+      { "kdc" = "herry.fermi.win.fnal.gov:88" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "UCHICAGO.EDU"
+      { "kdc" = "kerberos-0.uchicago.edu" }
+      { "kdc" = "kerberos-1.uchicago.edu" }
+      { "kdc" = "kerberos-2.uchicago.edu" }
+      { "admin_server" = "kerberos.uchicago.edu" }
+      { "default_domain" = "uchicago.edu" } }
+    { "realm" = "PILOT.FNAL.GOV"
+      { "kdc" = "i-krb-2.fnal.gov:88" }
+      { "master_kdc" = "i-krb-2.fnal.gov:88" }
+      { "admin_server" = "i-krb-2.fnal.gov" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "WINBETA.FNAL.GOV"
+      { "kdc" = "wbdc1.winbeta.fnal.gov:88" }
+      { "kdc" = "wbdc2.winbeta.fnal.gov:88" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "FERMIBETA.WINBETA.FNAL.GOV"
+      { "kdc" = "fbdc1.fermibeta.winbeta.fnal.gov:88" }
+      { "kdc" = "fbdc2.fermibeta.winbeta.fnal.gov:88" }
+      { "default_domain" = "fnal.gov" } }
+    { "realm" = "CERN.CH"
+      { "kdc" = "afsdb2.cern.ch" }
+      { "kdc" = "afsdb3.cern.ch" }
+      { "kdc" = "afsdb1.cern.ch" }
+      { "default_domain" = "cern.ch" }
+      { "kpasswd_server" = "afskrb5m.cern.ch" }
+      { "admin_server" = "afskrb5m.cern.ch" } }
+    { } }
+  { "instancemapping"
+    { "afs"
+      { "mapping" = "cron/*" { "value" = "" } }
+      { "mapping" = "cms/*"  { "value" = "" } }
+      { "mapping" = "afs/*"  { "value" = "" } }
+      { "mapping" = "e898/*" { "value" = "" } } }
+    { } }
+  { "capaths"
+    {  }
+    { "#comment" = "FNAL.GOV and PILOT.FNAL.GOV are the MIT Kerberos Domains" }
+    { "#comment" = "FNAL.GOV is production and PILOT is for testing" }
+    { "#comment" = "The FERMI Windows domain uses the WIN.FNAL.GOV root realm" }
+    { "#comment" = "with the FERMI.WIN.FNAL.GOV sub-realm where machines and users" }
+    { "#comment" = "reside.  The WINBETA and FERMIBETA domains are the equivalent" }
+    { "#comment" = "testing realms for the FERMIBETA domain.  The 2-way transitive" }
+    { "#comment" = "trust structure of this complex is as follows:" }
+    { "#comment" }
+    { "#comment" = "FNAL.GOV <=> PILOT.FNAL.GOV" }
+    { "#comment" = "FNAL.GOV <=> WIN.FERMI.GOV <=> FERMI.WIN.FERMI.GOV" }
+    { "#comment" = "PILOT.FNAL.GOV <=> WINBETA.FNAL.GOV <=> FERMIBETA.WINBETA.FNAL.GOV" }
+    {  }
+    { "FNAL.GOV"
+      { "PILOT.FNAL.GOV" = "." }
+      { "FERMI.WIN.FNAL.GOV" = "WIN.FNAL.GOV" }
+      { "WIN.FNAL.GOV" = "." }
+      { "FERMIBETA.WINBETA.FNAL.GOV" = "WINBETA.FNAL.GOV" }
+      { "WINBETA.FNAL.GOV" = "PILOT.FNAL.GOV" } }
+    { "PILOT.FNAL.GOV"
+      { "FNAL.GOV" = "." }
+      { "FERMI.WIN.FNAL.GOV" = "WIN.FNAL.GOV" }
+      { "WIN.FNAL.GOV" = "FNAL.GOV" }
+      { "FERMIBETA.WINBETA.FNAL.GOV" = "WINBETA.FNAL.GOV" }
+      { "WINBETA.FNAL.GOV" = "." } }
+    { "WIN.FNAL.GOV"
+      { "FNAL.GOV" = "." }
+      { "PILOT.FNAL.GOV" = "FNAL.GOV" }
+      { "FERMI.WIN.FNAL.GOV" = "." }
+      { "FERMIBETA.WINBETA.FNAL.GOV" = "WINBETA.FNAL.GOV" }
+      { "WINBETA.FNAL.GOV" = "PILOT.FNAL.GOV" } }
+    { "WINBETA.FNAL.GOV"
+      { "PILOT.FNAL.GOV" = "." }
+      { "FERMIBETA.WINBETA.FNAL.GOV" = "." }
+      { "FNAL.GOV" = "PILOT.FNAL.GOV" }
+      { "FERMI.WIN.FNAL.GOV" = "WIN.FNAL.GOV" }
+      { "WIN.FNAL.GOV" = "PILOT.FNAL.GOV" } }
+    { } }
+  { "logging"
+    { "kdc"
+      { "syslog"
+        { "severity" = "info" }
+        { "facility" = "local1" } } }
+    { "admin_server"
+      { "syslog"
+        { "severity" = "info" }
+        { "facility" = "local2" } } }
+    { "default"
+      { "syslog"
+        { "severity" = "err" }
+        { "facility" = "auth" } } }
+    {  } }
+  { "domain_realm"
+    { "#comment" = "Fermilab's (non-windows-centric) domains" }
+    { ".fnal.gov" = "FNAL.GOV" }
+    { ".cdms-soudan.org" = "FNAL.GOV" }
+    { ".deemz.net" = "FNAL.GOV" }
+    { ".dhcp.fnal.gov" = "FNAL.GOV" }
+    { ".minos-soudan.org" = "FNAL.GOV" }
+    { "i-krb-2.fnal.gov" = "PILOT.FNAL.GOV" }
+    { ".win.fnal.gov" = "WIN.FNAL.GOV" }
+    { ".fermi.win.fnal.gov" = "FERMI.WIN.FNAL.GOV" }
+    { ".winbeta.fnal.gov" = "WINBETA.FNAL.GOV" }
+    { ".fermibeta.winbeta.fnal.gov" = "FERMIBETA.WINBETA.FNAL.GOV" }
+    { "#comment" = "Fermilab's KCA servers so FERMI.WIN principals work in FNAL.GOV realm" }
+    { "#comment" = "winserver.fnal.gov = FERMI.WIN.FNAL.GOV" }
+    { "#comment" = "winserver2.fnal.gov = FERMI.WIN.FNAL.GOVA" }
+    { "#comment" = "Accelerator nodes to FERMI.WIN for Linux/OS X users" }
+    { "adgroups.fnal.gov" = "FERMI.WIN.FNAL.GOV" }
+    { "adusers.fnal.gov" = "FERMI.WIN.FNAL.GOV" }
+    { "webad.fnal.gov" = "FERMI.WIN.FNAL.GOV" }
+    { "#comment" = "Friends and family (by request)" }
+    { ".cs.ttu.edu" = "FNAL.GOV" }
+    { ".geol.uniovi.es" = "FNAL.GOV" }
+    { ".harvard.edu" = "FNAL.GOV" }
+    { ".hpcc.ttu.edu" = "FNAL.GOV" }
+    { ".infn.it" = "FNAL.GOV" }
+    { ".knu.ac.kr" = "FNAL.GOV" }
+    { ".lns.mit.edu" = "FNAL.GOV" }
+    { ".ph.liv.ac.uk" = "FNAL.GOV" }
+    { ".pha.jhu.edu" = "FNAL.GOV" }
+    { ".phys.ttu.edu" = "FNAL.GOV" }
+    { ".phys.ualberta.ca" = "FNAL.GOV" }
+    { ".physics.lsa.umich.edu" = "FNAL.GOV" }
+    { ".physics.ucla.edu" = "FNAL.GOV" }
+    { ".physics.ucsb.edu" = "FNAL.GOV" }
+    { ".physics.utoronto.ca" = "FNAL.GOV" }
+    { ".rl.ac.uk" = "FNAL.GOV" }
+    { ".rockefeller.edu" = "FNAL.GOV" }
+    { ".rutgers.edu" = "FNAL.GOV" }
+    { ".sdsc.edu" = "FNAL.GOV" }
+    { ".sinica.edu.tw" = "FNAL.GOV" }
+    { ".tsukuba.jp.hep.net" = "FNAL.GOV" }
+    { ".ucsd.edu" = "FNAL.GOV" }
+    { ".unl.edu" = "FNAL.GOV" }
+    { ".in2p3.fr" = "FNAL.GOV" }
+    { ".wisc.edu" = "FNAL.GOV" }
+    { ".pic.org.es" = "FNAL.GOV" }
+    { ".kisti.re.kr" = "FNAL.GOV" }
+    {  }
+    { "#comment" = "The whole \"top half\" is replaced during \"ups installAsRoot krb5conf\", so:" }
+    { "#comment" = "It would probably be a bad idea to change anything on or above this line" }
+    {  }
+    { "#comment" = "If you need to add any .domains or hosts, put them here" } }
+  { "domain_realm"
+    { "mojo.lunet.edu" = "FNAL.GOV" }
+    {  } }
+  { "appdefaults"
+    { "default_lifetime" = "7d" }
+    { "retain_ccache" = "false" }
+    { "autologin" = "true" }
+    { "forward" = "true" }
+    { "forwardable" = "true" }
+    { "renewable" = "true" }
+    { "encrypt" = "true" }
+    { "krb5_aklog_path" = "/usr/bin/aklog" }
+    {  }
+    { "application" = "telnet" }
+    {  }
+    { "application" = "rcp"
+      { "forward" = "true" }
+      { "encrypt" = "false" }
+      { "allow_fallback" = "true" } }
+    {  }
+    { "application" = "rsh"
+      { "allow_fallback" = "true" } }
+    {  }
+    { "application" = "rlogin"
+      { "allow_fallback" = "false" } }
+    {  }
+    {  }
+    { "application" = "login"
+      { "forwardable" = "true" }
+      { "krb5_run_aklog" = "false" }
+      { "krb5_get_tickets" = "true" }
+      { "krb4_get_tickets" = "false" }
+      { "krb4_convert" = "false" } }
+    {  }
+    { "application" = "kinit"
+      { "forwardable" = "true" }
+      { "krb5_run_aklog" = "false" } }
+    {  }
+    { "application" = "kadmin"
+      { "forwardable" = "false" } }
+    {  }
+    { "application" = "rshd"
+      { "krb5_run_aklog" = "false" } }
+    {  }
+    { "application" = "ftpd"
+      { "krb5_run_aklog" = "false" }
+      { "default_lifetime" = "10h" } }
+    {  }
+    { "application" = "pam"
+      { "debug" = "false" }
+      { "forwardable" = "true" }
+      { "renew_lifetime" = "7d" }
+      { "ticket_lifetime" = "1560m" }
+      { "krb4_convert" = "true" }
+      { "afs_cells" = "fnal.gov" }
+      { "krb5_run_aklog" = "false" } } }
+
+
+(* Example from the krb5 distrubution *)
+let dist_str = "[libdefaults]
+       default_realm = ATHENA.MIT.EDU
+       krb4_config = /usr/kerberos/lib/krb.conf
+       krb4_realms = /usr/kerberos/lib/krb.realms
+
+[realms]
+       ATHENA.MIT.EDU = {
+               admin_server = KERBEROS.MIT.EDU
+               default_domain = MIT.EDU
+               v4_instance_convert = {
+                       mit = mit.edu
+                       lithium = lithium.lcs.mit.edu
+               }
+       }
+       ANDREW.CMU.EDU = {
+               admin_server = vice28.fs.andrew.cmu.edu
+       }
+# use \"kdc =\" if realm admins haven't put SRV records into DNS
+        GNU.ORG = {
+                kdc = kerberos.gnu.org
+                kdc = kerberos-2.gnu.org
+                admin_server = kerberos.gnu.org
+        }
+
+[domain_realm]
+       .mit.edu = ATHENA.MIT.EDU
+       mit.edu = ATHENA.MIT.EDU
+       .media.mit.edu = MEDIA-LAB.MIT.EDU
+       media.mit.edu = MEDIA-LAB.MIT.EDU
+       .ucsc.edu = CATS.UCSC.EDU
+
+[logging]
+#      kdc = CONSOLE
+"
+
+test Krb5.lns get dist_str =
+  { "libdefaults"
+      { "default_realm" = "ATHENA.MIT.EDU" }
+      { "krb4_config" = "/usr/kerberos/lib/krb.conf" }
+      { "krb4_realms" = "/usr/kerberos/lib/krb.realms" }
+      { } }
+    { "realms"
+        { "realm" = "ATHENA.MIT.EDU"
+            { "admin_server" = "KERBEROS.MIT.EDU" }
+            { "default_domain" = "MIT.EDU" }
+            { "v4_instance_convert"
+                { "mit" = "mit.edu" }
+                { "lithium" = "lithium.lcs.mit.edu" } } }
+        { "realm" = "ANDREW.CMU.EDU"
+            { "admin_server" = "vice28.fs.andrew.cmu.edu" } }
+        { "#comment" = "use \"kdc =\" if realm admins haven't put SRV records into DNS" }
+        { "realm" = "GNU.ORG"
+            { "kdc" = "kerberos.gnu.org" }
+            { "kdc" = "kerberos-2.gnu.org" }
+            { "admin_server" = "kerberos.gnu.org" } }
+        { } }
+    { "domain_realm"
+        { ".mit.edu" = "ATHENA.MIT.EDU" }
+        { "mit.edu" = "ATHENA.MIT.EDU" }
+        { ".media.mit.edu" = "MEDIA-LAB.MIT.EDU" }
+        { "media.mit.edu" = "MEDIA-LAB.MIT.EDU" }
+        { ".ucsc.edu" = "CATS.UCSC.EDU" }
+        { } }
+    { "logging"
+        { "#comment" = "kdc = CONSOLE" } }
+
+(* Test for [libdefaults] *)
+test Krb5.libdefaults get "[libdefaults]
+       default_realm = ATHENA.MIT.EDU
+       krb4_config = /usr/kerberos/lib/krb.conf
+       krb4_realms = /usr/kerberos/lib/krb.realms\n\n" =
+  { "libdefaults"
+    { "default_realm" = "ATHENA.MIT.EDU" }
+    { "krb4_config" = "/usr/kerberos/lib/krb.conf" }
+    { "krb4_realms" = "/usr/kerberos/lib/krb.realms" }
+    { } }
+
+(* Test for [appfdefaults] *)
+test Krb5.appdefaults get "[appdefaults]\n\tdefault_lifetime = 7d\n" =
+  { "appdefaults" { "default_lifetime" = "7d" } }
+
+test Krb5.appdefaults get
+ "[appdefaults]\nrcp = { \n forward = true\n  encrypt = false\n  }\n" =
+  { "appdefaults"
+      { "application" = "rcp"
+          { "forward" = "true" }
+          { "encrypt" = "false" } } }
+
+test Krb5.appdefaults get "[appdefaults]\ntelnet = {\n\t}\n" =
+  { "appdefaults" { "application" = "telnet" } }
+
+test Krb5.appdefaults get  "[appdefaults]
+  rcp = {
+    forward = true
+    ATHENA.MIT.EDU = {
+      encrypt = false
+    }
+    MEDIA-LAB.MIT.EDU = {
+      encrypt = true
+    }
+    forwardable = true
+  }\n"  =
+  { "appdefaults"
+      { "application" = "rcp"
+          { "forward" = "true" }
+          { "realm" = "ATHENA.MIT.EDU"
+              { "encrypt" = "false" } }
+          { "realm" = "MEDIA-LAB.MIT.EDU"
+              { "encrypt" = "true" } }
+          { "forwardable" = "true" } } }
+
+let appdef = "[appdefaults]
+       default_lifetime = 7d
+       retain_ccache = false
+       autologin = true
+       forward = true
+       forwardable = true
+       renewable = true
+       encrypt = true
+       krb5_aklog_path = /usr/bin/aklog
+
+       telnet = {
+       }
+
+       rcp = {
+               forward = true
+               encrypt = false
+               allow_fallback = true
+       }
+
+       rsh = {
+               allow_fallback = true
+       }
+
+       rlogin = {
+               allow_fallback = false
+       }
+
+
+       login = {
+               forwardable = true
+               krb5_run_aklog = false
+               krb5_get_tickets = true
+               krb4_get_tickets = false
+               krb4_convert = false
+       }
+
+       kinit = {
+               forwardable = true
+               krb5_run_aklog = false
+       }
+
+       kadmin = {
+               forwardable = false
+       }
+
+       rshd = {
+               krb5_run_aklog = false
+       }
+
+       ftpd = {
+               krb5_run_aklog = false
+               default_lifetime = 10h
+       }
+
+       pam = {
+               debug = false
+               forwardable = true
+               renew_lifetime = 7d
+               ticket_lifetime = 1560m
+               krb4_convert = true
+               afs_cells = fnal.gov
+               krb5_run_aklog = false
+       }\n"
+
+let appdef_tree =
+  { "appdefaults"
+    { "default_lifetime" = "7d" }
+    { "retain_ccache" = "false" }
+    { "autologin" = "true" }
+    { "forward" = "true" }
+    { "forwardable" = "true" }
+    { "renewable" = "true" }
+    { "encrypt" = "true" }
+    { "krb5_aklog_path" = "/usr/bin/aklog" }
+    {  }
+    { "application" = "telnet" }
+    {  }
+    { "application" = "rcp"
+      { "forward" = "true" }
+      { "encrypt" = "false" }
+      { "allow_fallback" = "true" }
+    }
+    {  }
+    { "application" = "rsh"
+      { "allow_fallback" = "true" }
+    }
+    {  }
+    { "application" = "rlogin"
+      { "allow_fallback" = "false" }
+    }
+    {  }
+    {  }
+    { "application" = "login"
+      { "forwardable" = "true" }
+      { "krb5_run_aklog" = "false" }
+      { "krb5_get_tickets" = "true" }
+      { "krb4_get_tickets" = "false" }
+      { "krb4_convert" = "false" }
+    }
+    {  }
+    { "application" = "kinit"
+      { "forwardable" = "true" }
+      { "krb5_run_aklog" = "false" }
+    }
+    {  }
+    { "application" = "kadmin"
+      { "forwardable" = "false" }
+    }
+    {  }
+    { "application" = "rshd"
+      { "krb5_run_aklog" = "false" }
+    }
+    {  }
+    { "application" = "ftpd"
+      { "krb5_run_aklog" = "false" }
+      { "default_lifetime" = "10h" }
+    }
+    {  }
+    { "application" = "pam"
+      { "debug" = "false" }
+      { "forwardable" = "true" }
+      { "renew_lifetime" = "7d" }
+      { "ticket_lifetime" = "1560m" }
+      { "krb4_convert" = "true" }
+      { "afs_cells" = "fnal.gov" }
+      { "krb5_run_aklog" = "false" }
+    }
+  }
+
+
+test Krb5.appdefaults get appdef = appdef_tree
+test Krb5.lns get appdef = appdef_tree
+
+
+(* Test realms section *)
+let realms_str = "[realms]
+   ATHENA.MIT.EDU = {
+        admin_server = KERBEROS.MIT.EDU
+        default_domain = MIT.EDU
+        database_module = ldapconf
+        v4_instance_convert = {
+             mit = mit.edu
+             lithium = lithium.lcs.mit.edu
+        }
+        v4_realm = LCS.MIT.EDU
+   }\n"
+
+test Krb5.lns get realms_str =
+  { "realms"
+    { "realm" = "ATHENA.MIT.EDU"
+      { "admin_server" = "KERBEROS.MIT.EDU" }
+      { "default_domain" = "MIT.EDU" }
+      { "database_module" = "ldapconf" }
+      { "v4_instance_convert"
+        { "mit" = "mit.edu" }
+        { "lithium" = "lithium.lcs.mit.edu" } }
+      { "v4_realm" = "LCS.MIT.EDU" } } }
+
+(* Test dpmain_realm section *)
+let domain_realm_str = "[domain_realm]
+    .mit.edu = ATHENA.MIT.EDU
+    mit.edu = ATHENA.MIT.EDU
+    dodo.mit.edu = SMS_TEST.MIT.EDU
+    .ucsc.edu = CATS.UCSC.EDU\n"
+
+test Krb5.lns get domain_realm_str =
+  { "domain_realm"
+      { ".mit.edu" = "ATHENA.MIT.EDU" }
+      { "mit.edu" = "ATHENA.MIT.EDU" }
+      { "dodo.mit.edu" = "SMS_TEST.MIT.EDU" }
+      { ".ucsc.edu" = "CATS.UCSC.EDU" } }
+
+(* Test logging section *)
+let logging_str = "[logging]
+    kdc = CONSOLE
+    kdc = SYSLOG:INFO:DAEMON
+    admin_server = FILE:/var/adm/kadmin.log
+    admin_server = DEVICE=/dev/tty04\n"
+
+test Krb5.lns get logging_str =
+  { "logging"
+      { "kdc"
+          { "console" } }
+      { "kdc"
+          { "syslog"
+              { "severity" = "INFO" }
+              { "facility" = "DAEMON" } } }
+      { "admin_server"
+          { "file" = "/var/adm/kadmin.log" } }
+      { "admin_server"
+          { "device" = "/dev/tty04" } } }
+
+(* Test capaths section *)
+let capaths_str = "[capaths]
+    ANL.GOV = {
+         TEST.ANL.GOV = .
+         PNL.GOV = ES.NET
+         NERSC.GOV = ES.NET
+         ES.NET = .
+    }
+    TEST.ANL.GOV = {
+         ANL.GOV = .
+    }
+    PNL.GOV = {
+         ANL.GOV = ES.NET
+    }
+    NERSC.GOV = {
+         ANL.GOV = ES.NET
+    }
+    ES.NET = {
+         ANL.GOV = .
+    }\n"
+
+test Krb5.lns get capaths_str =
+  { "capaths"
+      { "ANL.GOV"
+          { "TEST.ANL.GOV" = "." }
+          { "PNL.GOV" = "ES.NET" }
+          { "NERSC.GOV" = "ES.NET" }
+          { "ES.NET" = "." } }
+      { "TEST.ANL.GOV"
+          { "ANL.GOV" = "." } }
+      { "PNL.GOV"
+          { "ANL.GOV" = "ES.NET" } }
+      { "NERSC.GOV"
+          { "ANL.GOV" = "ES.NET" } }
+      { "ES.NET"
+          { "ANL.GOV" = "." } } }
+
+(* Test instancemapping *)
+
+test Krb5.instance_mapping get "[instancemapping]
+ afs = {
+       cron/* = \"\"
+       cms/* = \"\"
+       afs/* = \"\"
+       e898/* = \"\"
+ }\n" =
+  { "instancemapping"
+      { "afs"
+          { "mapping" = "cron/*"
+              { "value" = "" } }
+          { "mapping" = "cms/*"
+              { "value" = "" } }
+          { "mapping" = "afs/*"
+              { "value" = "" } }
+          { "mapping" = "e898/*"
+              { "value" = "" } } } }
+
+test Krb5.kdc get "[kdc]
+ profile = /var/kerberos/krb5kdc/kdc.conf\n" =
+  { "kdc"
+    { "profile" = "/var/kerberos/krb5kdc/kdc.conf" } }
+
+(* v4_name_convert in libdefaults *)
+test Krb5.libdefaults get "[libdefaults]
+        default_realm = MY.REALM
+       clockskew = 300
+       v4_instance_resolve = false
+       v4_name_convert = {
+               host = {
+                       rcmd = host
+                       ftp = ftp
+               }
+               plain = {
+                       something = something-else
+               }
+       }\n" =
+
+  { "libdefaults"
+    { "default_realm" = "MY.REALM" }
+    { "clockskew" = "300" }
+    { "v4_instance_resolve" = "false" }
+    { "v4_name_convert"
+      { "host" { "rcmd" = "host" } { "ftp" = "ftp" } }
+      { "plain" { "something" = "something-else" } } } }
diff --git a/lenses/tests/test_ldap.aug b/lenses/tests/test_ldap.aug
new file mode 100644 (file)
index 0000000..a284204
--- /dev/null
@@ -0,0 +1,20 @@
+module Test_ldap =
+
+let conf = "host 127.0.0.1
+
+# The distinguished name of the search base.
+base dc=example,dc=com
+#tls_key
+ssl no
+pam_password md5
+"
+
+test Spacevars.simple_lns get conf =
+  { "host" = "127.0.0.1" }
+  {}
+  { "#comment" = "The distinguished name of the search base." }
+  { "base" = "dc=example,dc=com" }
+  { "#comment" = "tls_key" }
+  { "ssl" = "no" }
+  { "pam_password" = "md5" }
+
diff --git a/lenses/tests/test_limits.aug b/lenses/tests/test_limits.aug
new file mode 100644 (file)
index 0000000..0d95ccd
--- /dev/null
@@ -0,0 +1,31 @@
+module Test_limits =
+
+  let conf = "@audio - rtprio 99
+ftp hard nproc /ftp
+* soft core 0
+"
+
+  test Limits.lns get conf =
+    { "domain" = "@audio"
+      { "type"  = "-" }
+      { "item"  = "rtprio" }
+      { "value" = "99" } }
+    { "domain" = "ftp"
+      { "type" = "hard" }
+      { "item" = "nproc" }
+      { "value" = "/ftp" } }
+    { "domain" = "*"
+      { "type" = "soft" }
+      { "item" = "core" }
+      { "value" = "0" } }
+
+  test Limits.lns put conf after
+    insa "domain" "domain[last()]" ;
+    set "domain[last()]" "*" ;
+    set "domain[last()]/type" "-" ;
+    set "domain[last()]/item" "nofile" ;
+    set "domain[last()]/value" "4096"
+  = "@audio - rtprio 99
+ftp hard nproc /ftp
+* soft core 0
+* - nofile 4096\n"
diff --git a/lenses/tests/test_login_defs.aug b/lenses/tests/test_login_defs.aug
new file mode 100644 (file)
index 0000000..00d7ce8
--- /dev/null
@@ -0,0 +1,26 @@
+(*
+Module: Test_login_defs
+  Test cases for the login_defs lense
+
+Author: Erinn Looney-Triggs
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+module Test_login_defs =
+
+let record = "MAIL_DIR        /var/spool/mail
+ENCRYPT_METHOD SHA512 
+UMASK           077
+"
+
+test Login_defs.lns get record =
+    { "MAIL_DIR" = "/var/spool/mail" } 
+    { "ENCRYPT_METHOD" = "SHA512" }
+    { "UMASK" = "077" }
+
+let comment ="# *REQUIRED*
+"
+
+test Login_defs.lns get comment = 
+  {"#comment" = "*REQUIRED*"}
diff --git a/lenses/tests/test_logrotate.aug b/lenses/tests/test_logrotate.aug
new file mode 100644 (file)
index 0000000..6c8df40
--- /dev/null
@@ -0,0 +1,199 @@
+module Test_logrotate =
+
+   let conf = "# see man logrotate for details
+# rotate log files weekly
+weekly
+
+# keep 4 weeks worth of backlogs
+rotate 4
+
+# create new (empty) log files after rotating old ones
+create
+
+# uncomment this if you want your log files compressed
+#compress
+
+tabooext + .old .orig .ignore
+
+# packages drop log rotation information into this directory
+include /etc/logrotate.d
+
+# no packages own wtmp, or btmp -- we'll rotate them here
+/var/log/wtmp
+/var/log/wtmp2
+{
+    missingok
+    monthly
+    create 0664 root utmp
+    rotate 1
+}
+
+/var/log/btmp /var/log/btmp* {
+    missingok
+    # ftpd doesn't handle SIGHUP properly
+    monthly
+    create 0664 root utmp
+    rotate 1
+}
+/var/log/vsftpd.log {
+    # ftpd doesn't handle SIGHUP properly
+    nocompress
+    missingok
+    notifempty
+    rotate 4
+    weekly
+}
+
+/var/log/apache2/*.log {
+        weekly
+        missingok
+        rotate 52
+        compress
+        delaycompress
+        notifempty
+        create 640 root adm
+        sharedscripts
+        prerotate
+                if [ -f /var/run/apache2.pid ]; then
+                        /etc/init.d/apache2 restart > /dev/null
+                fi
+        endscript
+}
+"
+
+   test Logrotate.lns get conf =
+      { "#comment" = "see man logrotate for details" }
+      { "#comment" = "rotate log files weekly" }
+      { "schedule" = "weekly" }
+      {}
+      { "#comment" = "keep 4 weeks worth of backlogs" }
+      { "rotate"   = "4" }
+      {}
+      { "#comment" = "create new (empty) log files after rotating old ones" }
+      { "create" }
+      {}
+      { "#comment" = "uncomment this if you want your log files compressed" }
+      { "#comment" = "compress" }
+      {}
+      { "tabooext" = "+"  { ".old" } { ".orig" } { ".ignore" } }
+      {}
+      { "#comment" = "packages drop log rotation information into this directory" }
+      { "include" = "/etc/logrotate.d" }
+      {}
+      { "#comment" = "no packages own wtmp, or btmp -- we'll rotate them here" }
+      { "rule"
+           { "file"      = "/var/log/wtmp" }
+           { "file"      = "/var/log/wtmp2" }
+           { "missingok" = "missingok" }
+           { "schedule"  = "monthly" }
+           { "create"
+                { "mode"  = "0664" }
+                { "owner" = "root" }
+                { "group" = "utmp" } }
+           { "rotate" = "1" } }
+      {}
+      { "rule"
+           { "file"      = "/var/log/btmp" }
+          { "file"      = "/var/log/btmp*" }
+           { "missingok" = "missingok" }
+          { "#comment"   = "ftpd doesn't handle SIGHUP properly" }
+           { "schedule"  = "monthly" }
+           { "create"
+                { "mode"  = "0664" }
+                { "owner" = "root" }
+                { "group" = "utmp" } }
+           { "rotate" = "1" } }
+      { "rule"
+           { "file"      = "/var/log/vsftpd.log" }
+           { "#comment"   = "ftpd doesn't handle SIGHUP properly" }
+           { "compress"  = "nocompress" }
+           { "missingok" = "missingok" }
+           { "ifempty"   = "notifempty" }
+           { "rotate"    = "4" }
+           { "schedule"  = "weekly" } }
+      {}
+      { "rule"
+           { "file"          = "/var/log/apache2/*.log" }
+           { "schedule"      = "weekly" }
+           { "missingok"     = "missingok" }
+           { "rotate"        = "52" }
+           { "compress"      = "compress" }
+           { "delaycompress" = "delaycompress" }
+           { "ifempty"       = "notifempty" }
+           { "create"
+                { "mode"  = "640"  }
+                { "owner" = "root" }
+                { "group" = "adm"  } }
+           { "sharedscripts" = "sharedscripts" }
+           { "prerotate" = "                if [ -f /var/run/apache2.pid ]; then
+                        /etc/init.d/apache2 restart > /dev/null
+                fi" } }
+
+  test Logrotate.lns get "/var/log/file {\n dateext\n}\n" =
+    { "rule"
+      { "file" = "/var/log/file" }
+      { "dateext" = "dateext" } }
+
+  (* Make sure 'minsize 1M' works *)
+  test Logrotate.lns get "/avr/log/wtmp {\n minsize 1M\n}\n" =
+  { "rule"
+      { "file" = "/avr/log/wtmp" }
+      { "minsize" = "1M" } }
+
+  (* '=' is a legal separator, file names can be indented *)
+   test Logrotate.lns get " \t /file {\n size=5M\n}\n" =
+     { "rule"
+         { "file" = "/file" }
+         { "size" = "5M" } }
+
+  (* Can leave owner/group off a create statement *)
+  test Logrotate.lns get "/file {
+       create 600\n}\n" =
+     { "rule"
+         { "file" = "/file" }
+         { "create"
+             { "mode" = "600" } } }
+
+  test Logrotate.lns put "/file {\n    create 600\n}\n" after
+    set "/rule/create/owner" "user"
+  = "/file {\n create 600 user\n}\n"
+
+  (* The newline at the end of a script is optional *)
+  test Logrotate.lns put "/file {\n size=5M\n}\n" after
+    set "/rule/prerotate" "\tfoobar"
+  =
+"/file {
+ size=5M
+\tprerotate
+\tfoobar
+\tendscript\n}\n"
+
+  test Logrotate.lns put "/file {\n size=5M\n}\n" after
+    set "/rule/prerotate" "\tfoobar\n"
+  =
+"/file {
+ size=5M
+\tprerotate
+\tfoobar\n
+\tendscript\n}\n"
+
+(* Bug #101: whitespace at the end of the line *)
+test Logrotate.lns get "/file {\n missingok \t\n}\n" =
+  { "rule"
+    { "file" = "/file" }
+    { "missingok" = "missingok" } }
+
+(* Bug #104: file names can be separated by newlines *)
+let conf2 = "/var/log/mail.info
+/var/log/mail.warn
+/var/log/mail.err
+{
+       weekly
+}
+"
+test Logrotate.lns get conf2 =
+  { "rule"
+      { "file"      = "/var/log/mail.info" }
+      { "file"      = "/var/log/mail.warn" }
+      { "file"      = "/var/log/mail.err" }
+      { "schedule"  = "weekly" } }
diff --git a/lenses/tests/test_lokkit.aug b/lenses/tests/test_lokkit.aug
new file mode 100644 (file)
index 0000000..c197687
--- /dev/null
@@ -0,0 +1,88 @@
+module Test_lokkit =
+
+let conf = "# Configuration file for system-config-firewall
+
+--enabled
+--port=111:tcp
+-p 111:udp
+-p 2020-2049:tcp
+--port=5900-5910:tcp
+--custom-rules=ipv4:filter:/var/lib/misc/iptables-forward-bridged
+-s dns
+--service=ssh
+--trust=trust1
+--masq=eth42
+--block-icmp=5
+-t trust0
+--addmodule=fancy
+--removemodule=broken
+--forward-port=if=forw0:port=42:proto=tcp:toport=42:toaddr=192.168.0.42
+--selinux=permissive
+"
+
+test Lokkit.lns get conf =
+  { "#comment" = "Configuration file for system-config-firewall" }
+  { }
+  { "enabled" }
+  { "port"
+    { "start" = "111" }
+    { "protocol" = "tcp" } }
+  { "port"
+    { "start" = "111" }
+    { "protocol" = "udp" } }
+  { "port"
+    { "start" = "2020" }
+    { "end" = "2049" }
+    { "protocol" = "tcp" } }
+  { "port"
+    { "start" = "5900" }
+    { "end" = "5910" }
+    { "protocol" = "tcp" } }
+  { "custom-rules" = "/var/lib/misc/iptables-forward-bridged"
+    { "type" = "ipv4" }
+    { "table" = "filter" } }
+  { "service" = "dns" }
+  { "service" = "ssh" }
+  { "trust" = "trust1" }
+  { "masq" = "eth42" }
+  { "block-icmp" = "5" }
+  { "trust" = "trust0" }
+  { "addmodule" = "fancy" }
+  { "removemodule" = "broken" }
+  { "forward-port"
+    { "if" = "forw0" }
+    { "port" = "42" }
+    { "proto" = "tcp" }
+    { "toport" = "42" }
+    { "toaddr" = "192.168.0.42" } }
+  { "selinux" = "permissive" }
+
+test Lokkit.custom_rules get
+"--custom-rules=ipv4:filter:/some/file\n" =
+  { "custom-rules" = "/some/file"
+    { "type" = "ipv4" }
+    { "table" = "filter" } }
+
+test Lokkit.custom_rules get
+"--custom-rules=filter:/some/file\n" =
+  { "custom-rules" = "/some/file"
+    { "table" = "filter" } }
+
+test Lokkit.custom_rules get
+"--custom-rules=ipv4:/some/file\n" =
+  { "custom-rules" = "/some/file"
+    { "type" = "ipv4" } }
+
+test Lokkit.custom_rules get
+"--custom-rules=/some/file\n" =
+  { "custom-rules" = "/some/file" }
+
+test Lokkit.lns get
+"--trust=tun+\n--trust=eth0.42\n--trust=eth0:1\n" =
+  { "trust" = "tun+" }
+  { "trust" = "eth0.42" }
+  { "trust" = "eth0:1" }
+
+(* We didn't allow '-' in the service name *)
+test Lokkit.lns get "--service=samba-client\n" =
+  { "service" = "samba-client" }
diff --git a/lenses/tests/test_mke2fs.aug b/lenses/tests/test_mke2fs.aug
new file mode 100644 (file)
index 0000000..39ac9e2
--- /dev/null
@@ -0,0 +1,76 @@
+(* Test for keepalived lens *)
+
+module Test_mke2fs =
+
+   let conf = "# This is a comment 
+; and another comment
+
+[defaults]
+       base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
+       blocksize = 4096
+       inode_size = 256
+        ; here goes inode_ratio
+       inode_ratio = 16384
+
+[fs_types]
+ ; here we have fs_types
+       ext4dev = {
+                # this is ext4dev conf
+
+               features = has_journal,^extent
+               inode_size = 256
+               options = test_fs=1
+       }
+       small = {
+               blocksize = 1024
+               inode_size = 128
+               inode_ratio = 4096
+       }
+       largefile = {
+               inode_ratio = 1048576
+               blocksize = -1
+       }
+"
+
+   test Mke2fs.lns get conf =
+     { "#comment" = "This is a comment" }
+     { "#comment" = "and another comment" }
+     {}
+     { "defaults"
+        { "base_features"
+             { "sparse_super" }
+             { "filetype" }
+             { "resize_inode" }
+             { "dir_index" }
+             { "ext_attr" } }
+        { "blocksize" = "4096" }
+        { "inode_size" = "256" }
+        { "#comment" = "here goes inode_ratio" }
+        { "inode_ratio" = "16384" }
+        {} }
+     { "fs_types"
+        { "#comment" = "here we have fs_types" } 
+        { "filesystem" = "ext4dev"
+             { "#comment" = "this is ext4dev conf" }
+             {}
+             { "features"
+                { "has_journal" }
+                { "extent"
+                   { "disable" } } }
+             { "inode_size" = "256" }
+             { "options"
+                { "test_fs" = "1" } } }
+        { "filesystem" = "small"
+             { "blocksize" = "1024" }
+             { "inode_size" = "128" }
+             { "inode_ratio" = "4096" } }
+        { "filesystem" = "largefile"
+             { "inode_ratio" = "1048576" }
+             { "blocksize" = "-1" } } }
+
+
+test Mke2fs.fs_types_entry
+   put "features = has_journal,^extent\n"
+   after set "/features/has_journal/disable" "";
+   rm "/features/extent/disable" = "features = ^has_journal,extent\n"
+
diff --git a/lenses/tests/test_modprobe.aug b/lenses/tests/test_modprobe.aug
new file mode 100644 (file)
index 0000000..dea9db7
--- /dev/null
@@ -0,0 +1,77 @@
+module Test_modprobe =
+
+(* Based on 04config.sh from module-init-tools *)
+
+let conf = "# Various aliases
+alias alias_to_foo foo
+alias alias_to_bar bar
+alias alias_to_export_dep-$BITNESS export_dep-$BITNESS
+
+# Various options, including options to aliases.
+options alias_to_export_dep-$BITNESS I am alias to export_dep
+options alias_to_noexport_nodep-$BITNESS_with_tabbed_options index=0 id=\"Thinkpad\" isapnp=0 \\
+\tport=0x530 cport=0x538 fm_port=0x388 \\
+\tmpu_port=-1 mpu_irq=-1 \\
+\tirq=9 dma1=1 dma2=3 \\
+\tenable=1 isapnp=0
+
+# Blacklist
+blacklist watchdog_drivers  \t
+
+# Install commands
+install bar echo Installing bar
+install foo echo Installing foo
+install export_nodep-$BITNESS echo Installing export_nodep
+
+# Remove commands
+remove bar echo Removing bar
+remove foo echo Removing foo
+remove export_nodep-$BITNESS echo Removing export_nodep\n"
+
+test Modprobe.lns get conf =
+  { "#comment" = "Various aliases" }
+  { "alias" = "alias_to_foo"
+    { "modulename" = "foo" } }
+  { "alias" = "alias_to_bar"
+    { "modulename" = "bar" } }
+  { "alias" = "alias_to_export_dep-$BITNESS"
+    { "modulename" = "export_dep-$BITNESS" } }
+  { }
+  { "#comment" = "Various options, including options to aliases." }
+  { "options" = "alias_to_export_dep-$BITNESS"
+    { "I" }
+    { "am" }
+    { "alias" }
+    { "to" }
+    { "export_dep" } }
+  { "options" = "alias_to_noexport_nodep-$BITNESS_with_tabbed_options"
+    { "index" = "0" }
+    { "id" = "\"Thinkpad\"" }
+    { "isapnp" = "0" }
+    { "port" = "0x530" }
+    { "cport" = "0x538" }
+    { "fm_port" = "0x388" }
+    { "mpu_port" = "-1" }
+    { "mpu_irq" = "-1" }
+    { "irq" = "9" }
+    { "dma1" = "1" }
+    { "dma2" = "3" }
+    { "enable" = "1" }
+    { "isapnp" = "0" } }
+  { }
+  { "#comment" = "Blacklist" }
+  { "blacklist" = "watchdog_drivers" }
+  { }
+  { "#comment" = "Install commands" }
+  { "install" = "bar echo Installing bar" }
+  { "install" = "foo echo Installing foo" }
+  { "install" = "export_nodep-$BITNESS echo Installing export_nodep" }
+  { }
+  { "#comment" = "Remove commands" }
+  { "remove" = "bar echo Removing bar" }
+  { "remove" = "foo echo Removing foo" }
+  { "remove" = "export_nodep-$BITNESS echo Removing export_nodep" }
+
+test Modprobe.lns get "blacklist brokenmodule # never worked\n" =
+  { "blacklist" = "brokenmodule"
+    { "#comment" = "never worked" } }
diff --git a/lenses/tests/test_modules_conf.aug b/lenses/tests/test_modules_conf.aug
new file mode 100644 (file)
index 0000000..31e72b6
--- /dev/null
@@ -0,0 +1,96 @@
+module Test_modules_conf =
+
+(* Based on 04config.sh from module-init-tools *)
+
+let conf = "# Various aliases
+alias alias_to_foo foo
+alias alias_to_bar bar
+alias alias_to_export_dep-$BITNESS export_dep-$BITNESS
+
+# Various options, including options to aliases.
+options alias_to_export_dep-$BITNESS I am alias to export_dep
+options alias_to_noexport_nodep-$BITNESS_with_tabbed_options index=0 id=\"Thinkpad\" isapnp=0 \\
+\tport=0x530 cport=0x538 fm_port=0x388 \\
+\tmpu_port=-1 mpu_irq=-1 \\
+\tirq=9 dma1=1 dma2=3 \\
+\tenable=1 isapnp=0
+
+# Install commands
+install bar echo Installing bar
+install foo echo Installing foo
+install export_nodep-$BITNESS echo Installing export_nodep
+
+# Pre- and post- install something
+pre-install ide-scsi modprobe ide-cd # load ide-cd before ide-scsi
+post-install serial /etc/init.d/setserial modload > /dev/null 2> /dev/null
+
+# Remove commands
+remove bar echo Removing bar
+remove foo echo Removing foo
+remove export_nodep-$BITNESS echo Removing export_nodep
+
+#Pre- and post- remove something
+pre-remove serial /etc/init.d/setserial modsave  > /dev/null 2> /dev/null
+post-remove bttv rmmod tuner
+
+# Misc other directives
+probeall /dev/cdroms
+keep
+path=/lib/modules/`uname -r`/alsa
+"
+
+test Modules_conf.lns get conf =
+  { "#comment" = "Various aliases" }
+  { "alias" = "alias_to_foo"
+    { "modulename" = "foo" } }
+  { "alias" = "alias_to_bar"
+    { "modulename" = "bar" } }
+  { "alias" = "alias_to_export_dep-$BITNESS"
+    { "modulename" = "export_dep-$BITNESS" } }
+  { }
+  { "#comment" = "Various options, including options to aliases." }
+  { "options" = "alias_to_export_dep-$BITNESS"
+    { "I" }
+    { "am" }
+    { "alias" }
+    { "to" }
+    { "export_dep" } }
+  { "options" = "alias_to_noexport_nodep-$BITNESS_with_tabbed_options"
+    { "index" = "0" }
+    { "id" = "\"Thinkpad\"" }
+    { "isapnp" = "0" }
+    { "port" = "0x530" }
+    { "cport" = "0x538" }
+    { "fm_port" = "0x388" }
+    { "mpu_port" = "-1" }
+    { "mpu_irq" = "-1" }
+    { "irq" = "9" }
+    { "dma1" = "1" }
+    { "dma2" = "3" }
+    { "enable" = "1" }
+    { "isapnp" = "0" } }
+  { }
+  { "#comment" = "Install commands" }
+  { "install" = "bar echo Installing bar" }
+  { "install" = "foo echo Installing foo" }
+  { "install" = "export_nodep-$BITNESS echo Installing export_nodep" }
+  { }
+  { "#comment" = "Pre- and post- install something" }
+  { "pre-install" = "ide-scsi modprobe ide-cd"
+    { "#comment" = "load ide-cd before ide-scsi" }
+  }
+  { "post-install" = "serial /etc/init.d/setserial modload > /dev/null 2> /dev/null" }
+  { }
+  { "#comment" = "Remove commands" }
+  { "remove" = "bar echo Removing bar" }
+  { "remove" = "foo echo Removing foo" }
+  { "remove" = "export_nodep-$BITNESS echo Removing export_nodep" }
+  { }
+  { "#comment" = "Pre- and post- remove something" }
+  { "pre-remove" = "serial /etc/init.d/setserial modsave  > /dev/null 2> /dev/null" }
+  { "post-remove" = "bttv rmmod tuner" }
+  { }
+  { "#comment" = "Misc other directives" }
+  { "probeall" = "/dev/cdroms" }
+  { "keep" }
+  { "path" = "/lib/modules/`uname -r`/alsa" }
diff --git a/lenses/tests/test_monit.aug b/lenses/tests/test_monit.aug
new file mode 100644 (file)
index 0000000..e27974d
--- /dev/null
@@ -0,0 +1,35 @@
+module Test_monit =
+
+let conf = "# Configuration file for monit.
+#
+set alert root@localhost
+include /my/monit/conf
+
+check process sshd
+   start program \"/etc/init.d/ssh start\"
+   if failed port 22 protocol ssh then restart
+
+check process httpd with pidfile /usr/local/apache2/logs/httpd.pid
+   group www-data
+        start program \"/usr/local/apache2/bin/apachectl start\"
+   stop program \"/usr/local/apache2/bin/apachectl stop\"
+"
+
+test Monit.lns get conf =
+   { "#comment"  = "Configuration file for monit." }
+   {}
+   { "set"
+     {"alert"    = "root@localhost" } }
+   { "include"   = "/my/monit/conf" }
+   {}
+   { "check"
+     { "process" = "sshd" }
+     { "start"   = "program \"/etc/init.d/ssh start\"" }
+     { "if"      = "failed port 22 protocol ssh then restart" } }
+   {}
+   { "check"
+     { "process" = "httpd with pidfile /usr/local/apache2/logs/httpd.pid" }
+     { "group"   = "www-data" }
+     { "start"   = "program \"/usr/local/apache2/bin/apachectl start\"" }
+     { "stop"    = "program \"/usr/local/apache2/bin/apachectl stop\"" }
+}
diff --git a/lenses/tests/test_multipath.aug b/lenses/tests/test_multipath.aug
new file mode 100644 (file)
index 0000000..5260337
--- /dev/null
@@ -0,0 +1,153 @@
+module Test_multipath =
+
+  let conf = "# Blacklist all devices by default.
+blacklist {
+        devnode \"*\"
+        wwid    *
+}
+
+# By default, devices with vendor = \"IBM\" and product = \"S/390.*\" are
+# blacklisted. To enable mulitpathing on these devies, uncomment the
+# following lines.
+blacklist_exceptions {
+       device {
+               vendor  \"IBM\"
+               product \"S/390.*\"
+       }
+}
+
+#
+# Here is an example of how to configure some standard options.
+#
+
+defaults {
+       udev_dir                /dev
+       polling_interval        10
+       selector                \"round-robin 0\"
+       path_grouping_policy    multibus
+       getuid_callout          \"/sbin/scsi_id --whitelisted /dev/%n\"
+       prio                    alua
+       path_checker            readsector0
+       rr_min_io               100
+       max_fds                 8192
+       rr_weight               priorities
+       failback                immediate
+       no_path_retry           fail
+       user_friendly_names     yes
+}
+
+# Sections without empty lines in between
+blacklist {
+       wwid 26353900f02796769
+       devnode \"^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*\"
+
+    # Comments and blank lines inside a section
+       devnode \"^hd[a-z]\"
+
+}
+multipaths {
+       multipath {
+               wwid                    3600508b4000156d700012000000b0000
+               alias                   yellow
+               path_grouping_policy    multibus
+               path_checker            readsector0
+               path_selector           \"round-robin 0\"
+               failback                manual
+               rr_weight               priorities
+               no_path_retry           5
+       }
+       multipath {
+               wwid                    1DEC_____321816758474
+               alias                   red
+       }
+}
+devices {
+       device {
+               vendor                  \"COMPAQ  \"
+               product                 \"HSV110 (C)COMPAQ\"
+               path_grouping_policy    multibus
+               getuid_callout          \"/sbin/scsi_id --whitelisted /dev/%n\"
+               path_checker            readsector0
+               path_selector           \"round-robin 0\"
+               hardware_handler        \"0\"
+               failback                15
+               rr_weight               priorities
+               no_path_retry           queue
+       }
+       device {
+               vendor                  \"COMPAQ  \"
+               product                 \"MSA1000         \"
+               path_grouping_policy    multibus
+       }
+}\n"
+
+test Multipath.lns get conf =
+  { "#comment" = "Blacklist all devices by default." }
+  { "blacklist"
+    { "devnode" = "*" }
+    { "wwid"    = "*" } }
+  { }
+  { "#comment" = "By default, devices with vendor = \"IBM\" and product = \"S/390.*\" are" }
+  { "#comment" = "blacklisted. To enable mulitpathing on these devies, uncomment the" }
+  { "#comment" = "following lines." }
+  { "blacklist_exceptions"
+    { "device"
+      { "vendor" = "IBM" }
+      { "product" = "S/390.*" } } }
+  { }
+  { }
+  { "#comment" = "Here is an example of how to configure some standard options." }
+  { }
+  { }
+  { "defaults"
+    { "udev_dir" = "/dev" }
+    { "polling_interval" = "10" }
+    { "selector" = "round-robin 0" }
+    { "path_grouping_policy" = "multibus" }
+    { "getuid_callout" = "/sbin/scsi_id --whitelisted /dev/%n" }
+    { "prio" = "alua" }
+    { "path_checker" = "readsector0" }
+    { "rr_min_io" = "100" }
+    { "max_fds" = "8192" }
+    { "rr_weight" = "priorities" }
+    { "failback" = "immediate" }
+    { "no_path_retry" = "fail" }
+    { "user_friendly_names" = "yes" } }
+  { }
+  { "#comment" = "Sections without empty lines in between" }
+  { "blacklist"
+    { "wwid" = "26353900f02796769" }
+    { "devnode" = "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" }
+    { }
+    { "#comment" = "Comments and blank lines inside a section" }
+    { "devnode" = "^hd[a-z]" }
+    { } }
+  { "multipaths"
+    { "multipath"
+      { "wwid" = "3600508b4000156d700012000000b0000" }
+      { "alias" = "yellow" }
+      { "path_grouping_policy" = "multibus" }
+      { "path_checker" = "readsector0" }
+      { "path_selector" = "round-robin 0" }
+      { "failback" = "manual" }
+      { "rr_weight" = "priorities" }
+      { "no_path_retry" = "5" } }
+    { "multipath"
+      { "wwid" = "1DEC_____321816758474" }
+      { "alias" = "red" } } }
+  { "devices"
+    { "device"
+      { "vendor" = "COMPAQ  " }
+      { "product" = "HSV110 (C)COMPAQ" }
+      { "path_grouping_policy" = "multibus" }
+      { "getuid_callout" = "/sbin/scsi_id --whitelisted /dev/%n" }
+      { "path_checker" = "readsector0" }
+      { "path_selector" = "round-robin 0" }
+      { "hardware_handler" = "0" }
+      { "failback" = "15" }
+      { "rr_weight" = "priorities" }
+      { "no_path_retry" = "queue" } }
+    { "device"
+      { "vendor" = "COMPAQ  " }
+      { "product" = "MSA1000         " }
+      { "path_grouping_policy" = "multibus" } } }
diff --git a/lenses/tests/test_mysql.aug b/lenses/tests/test_mysql.aug
new file mode 100644 (file)
index 0000000..d913399
--- /dev/null
@@ -0,0 +1,277 @@
+module Test_mysql =
+
+   let conf = "# The MySQL database server configuration file.
+#
+# You can copy this to one of:
+# 
+# One can use all long options that the program supports.
+# Run program with --help to get a list of available options and with
+# --print-defaults to see which it would actually understand and use.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+# This will be passed to all mysql clients
+# It has been reported that passwords should be enclosed with ticks/quotes
+# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
+[client]
+port           = 3306
+socket         = /var/run/mysqld/mysqld.sock
+
+# Here is entries for some specific programs
+# The following values assume you have at least 32M ram
+
+# This was formally known as [safe_mysqld]. Both versions are currently parsed.
+   [mysqld_safe]
+socket         = /var/run/mysqld/mysqld.sock
+nice           = 0
+
+[mysqld]
+#
+# * Basic Settings
+#
+user           = mysql
+pid-file       = /var/run/mysqld/mysqld.pid
+socket         = /var/run/mysqld/mysqld.sock
+port           = 3306
+basedir                = /usr
+datadir                = /var/lib/mysql
+tmpdir         = /tmp
+language       = /usr/share/mysql/english
+skip-external-locking
+#
+# Instead of skip-networking the default is now to listen only on
+# localhost which is more compatible and is not less secure.
+bind-address           = 127.0.0.1
+#
+# * Fine Tuning
+#
+key_buffer             = 16M
+max_allowed_packet     = 16M
+thread_stack           = 128K
+thread_cache_size      = 8
+#max_connections        = 100
+#table_cache            = 64
+#thread_concurrency     = 10
+#
+# * Query Cache Configuration
+#
+query_cache_limit       = 1M
+query_cache_size        = 16M
+#
+# * Logging and Replication
+#
+# Both location gets rotated by the cronjob.
+# Be aware that this log type is a performance killer.
+#log           = /var/log/mysql/mysql.log
+#
+# Error logging goes to syslog. This is a Debian improvement :)
+#
+# Here you can see queries with especially long duration
+#log_slow_queries      = /var/log/mysql/mysql-slow.log
+#long_query_time = 2
+#log-queries-not-using-indexes
+#
+# The following can be used as easy to replay backup logs or for replication.
+#server-id             = 1
+#log_bin               = /var/log/mysql/mysql-bin.log
+# WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
+#expire_logs_days      = 10
+#max_binlog_size       = 100M
+#binlog_do_db          = include_database_name
+#binlog_ignore_db      = include_database_name
+#
+# * BerkeleyDB
+#
+# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
+skip-bdb
+#
+# * InnoDB
+#
+# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
+# Read the manual for more InnoDB related options. There are many!
+# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
+#skip-innodb
+#
+# * Security Features
+#
+# Read the manual, too, if you want chroot!
+# chroot = /var/lib/mysql/
+#
+#
+# ssl-ca=/etc/mysql/cacert.pem
+# ssl-cert=/etc/mysql/server-cert.pem
+# ssl-key=/etc/mysql/server-key.pem
+
+
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet     = 16M
+
+[mysql]
+#no-auto-rehash        # faster start of mysql but no tab completition
+
+[isamchk]
+key_buffer             = 16M
+
+#
+# * NDB Cluster
+#
+# See /usr/share/doc/mysql-server-*/README.Debian for more information.
+#
+# The following configuration is read by the NDB Data Nodes (ndbd processes)
+# not from the NDB Management Nodes (ndb_mgmd processes).
+#
+# [MYSQL_CLUSTER]
+# ndb-connectstring=127.0.0.1
+
+
+#
+# * IMPORTANT: Additional settings that can override those from this file!
+#
+!includedir /etc/mysql/conf.d/
+"
+
+
+   test MySQL.lns get conf =   { "#comment" = "The MySQL database server configuration file." }
+  { "#comment" }
+  { "#comment" = "You can copy this to one of:" }
+  { "#comment" }
+  { "#comment" = "One can use all long options that the program supports." }
+  { "#comment" = "Run program with --help to get a list of available options and with" }
+  { "#comment" = "--print-defaults to see which it would actually understand and use." }
+  { "#comment" }
+  { "#comment" = "For explanations see" }
+  { "#comment" = "http://dev.mysql.com/doc/mysql/en/server-system-variables.html" }
+  {  }
+  { "#comment" = "This will be passed to all mysql clients" }
+  { "#comment" = "It has been reported that passwords should be enclosed with ticks/quotes" }
+  { "#comment" = "Remember to edit /etc/mysql/debian.cnf when changing the socket location." }
+  { "target" = "client"
+    { "port" = "3306" }
+    { "socket" = "/var/run/mysqld/mysqld.sock" }
+    {  }
+    { "#comment" = "Here is entries for some specific programs" }
+    { "#comment" = "The following values assume you have at least 32M ram" }
+    {  }
+    { "#comment" = "This was formally known as [safe_mysqld]. Both versions are currently parsed." }
+  }
+  { "target" = "mysqld_safe"
+    { "socket" = "/var/run/mysqld/mysqld.sock" }
+    { "nice" = "0" }
+    {  }
+  }
+  { "target" = "mysqld"
+    { "#comment" }
+    { "#comment" = "* Basic Settings" }
+    { "#comment" }
+    { "user" = "mysql" }
+    { "pid-file" = "/var/run/mysqld/mysqld.pid" }
+    { "socket" = "/var/run/mysqld/mysqld.sock" }
+    { "port" = "3306" }
+    { "basedir" = "/usr" }
+    { "datadir" = "/var/lib/mysql" }
+    { "tmpdir" = "/tmp" }
+    { "language" = "/usr/share/mysql/english" }
+    { "skip-external-locking" = "" }
+    { "#comment" }
+    { "#comment" = "Instead of skip-networking the default is now to listen only on" }
+    { "#comment" = "localhost which is more compatible and is not less secure." }
+    { "bind-address" = "127.0.0.1" }
+    { "#comment" }
+    { "#comment" = "* Fine Tuning" }
+    { "#comment" }
+    { "key_buffer" = "16M" }
+    { "max_allowed_packet" = "16M" }
+    { "thread_stack" = "128K" }
+    { "thread_cache_size" = "8" }
+    { "#comment" = "max_connections        = 100" }
+    { "#comment" = "table_cache            = 64" }
+    { "#comment" = "thread_concurrency     = 10" }
+    { "#comment" }
+    { "#comment" = "* Query Cache Configuration" }
+    { "#comment" }
+    { "query_cache_limit" = "1M" }
+    { "query_cache_size" = "16M" }
+    { "#comment" }
+    { "#comment" = "* Logging and Replication" }
+    { "#comment" }
+    { "#comment" = "Both location gets rotated by the cronjob." }
+    { "#comment" = "Be aware that this log type is a performance killer." }
+    { "#comment" = "log                = /var/log/mysql/mysql.log" }
+    { "#comment" }
+    { "#comment" = "Error logging goes to syslog. This is a Debian improvement :)" }
+    { "#comment" }
+    { "#comment" = "Here you can see queries with especially long duration" }
+    { "#comment" = "log_slow_queries   = /var/log/mysql/mysql-slow.log" }
+    { "#comment" = "long_query_time = 2" }
+    { "#comment" = "log-queries-not-using-indexes" }
+    { "#comment" }
+    { "#comment" = "The following can be used as easy to replay backup logs or for replication." }
+    { "#comment" = "server-id          = 1" }
+    { "#comment" = "log_bin            = /var/log/mysql/mysql-bin.log" }
+    { "#comment" = "WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!" }
+    { "#comment" = "expire_logs_days   = 10" }
+    { "#comment" = "max_binlog_size    = 100M" }
+    { "#comment" = "binlog_do_db               = include_database_name" }
+    { "#comment" = "binlog_ignore_db   = include_database_name" }
+    { "#comment" }
+    { "#comment" = "* BerkeleyDB" }
+    { "#comment" }
+    { "#comment" = "Using BerkeleyDB is now discouraged as its support will cease in 5.1.12." }
+    { "skip-bdb" = "" }
+    { "#comment" }
+    { "#comment" = "* InnoDB" }
+    { "#comment" }
+    { "#comment" = "InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/." }
+    { "#comment" = "Read the manual for more InnoDB related options. There are many!" }
+    { "#comment" = "You might want to disable InnoDB to shrink the mysqld process by circa 100MB." }
+    { "#comment" = "skip-innodb" }
+    { "#comment" }
+    { "#comment" = "* Security Features" }
+    { "#comment" }
+    { "#comment" = "Read the manual, too, if you want chroot!" }
+    { "#comment" = "chroot = /var/lib/mysql/" }
+    { "#comment" }
+    { "#comment" }
+    { "#comment" = "ssl-ca=/etc/mysql/cacert.pem" }
+    { "#comment" = "ssl-cert=/etc/mysql/server-cert.pem" }
+    { "#comment" = "ssl-key=/etc/mysql/server-key.pem" }
+    {  }
+    {  }
+    {  }
+  }
+  { "target" = "mysqldump"
+    { "quick" = "" }
+    { "quote-names" = "" }
+    { "max_allowed_packet" = "16M" }
+    {  }
+  }
+  { "target" = "mysql"
+    { "#comment" = "no-auto-rehash     # faster start of mysql but no tab completition" }
+    {  }
+  }
+  { "target" = "isamchk"
+    { "key_buffer" = "16M" }
+    {  }
+    { "#comment" }
+    { "#comment" = "* NDB Cluster" }
+    { "#comment" }
+    { "#comment" = "See /usr/share/doc/mysql-server-*/README.Debian for more information." }
+    { "#comment" }
+    { "#comment" = "The following configuration is read by the NDB Data Nodes (ndbd processes)" }
+    { "#comment" = "not from the NDB Management Nodes (ndb_mgmd processes)." }
+    { "#comment" }
+    { "#comment" = "[MYSQL_CLUSTER]" }
+    { "#comment" = "ndb-connectstring=127.0.0.1" }
+    {  }
+    {  }
+    { "#comment" }
+    { "#comment" = "* IMPORTANT: Additional settings that can override those from this file!" }
+    { "#comment" }
+    { "!includedir" = "/etc/mysql/conf.d/" }
+  }
+
+
diff --git a/lenses/tests/test_nagioscfg.aug b/lenses/tests/test_nagioscfg.aug
new file mode 100644 (file)
index 0000000..44df2af
--- /dev/null
@@ -0,0 +1,72 @@
+module Test_NagiosCfg =
+    let conf="
+# LOG FILE
+log_file=/var/log/nagios3/nagios.log
+
+# OBJECT CONFIGURATION FILE(S)
+cfg_file=/etc/nagios3/objects/check_commands.cfg
+cfg_file=/etc/nagios3/objects/contact_groups.cfg
+cfg_file=/etc/nagios3/objects/contacts.cfg
+cfg_file=/etc/nagios3/objects/hostgroups.cfg
+cfg_file=/etc/nagios3/objects/hosts.cfg
+cfg_file=/etc/nagios3/objects/services.cfg
+
+# NAGIOS USER
+nagios_user=nagios
+
+# NAGIOS GROUP
+nagios_group=nagios
+
+# DATE FORMAT
+date_format=iso8601
+
+# ILLEGAL OBJECT NAME CHARS
+illegal_object_name_chars=`~!$%^&*|'\"<>?,()'=
+
+# ILLEGAL MACRO OUTPUT CHARS
+illegal_macro_output_chars=`~$&|'\"<>
+
+# MISC DIRECTIVES
+p1_file=/usr/lib/nagios3/p1.pl
+event_broker_options=-1
+use_large_installation_tweaks=1
+broker_module=/usr/lib/nagios3/libNagiosCluster-1.0.so.4.0.0
+broker_module=/usr/sbin/ndomod.o config_file=/etc/nagios3/ndomod.cfg
+"
+
+    test NagiosCfg.lns get conf =
+        {}
+        { "#comment"     = "LOG FILE" }
+        { "log_file"    = "/var/log/nagios3/nagios.log" }
+        {}
+        { "#comment"     = "OBJECT CONFIGURATION FILE(S)" }
+        { "cfg_file"    = "/etc/nagios3/objects/check_commands.cfg" }
+        { "cfg_file"    = "/etc/nagios3/objects/contact_groups.cfg" }
+        { "cfg_file"    = "/etc/nagios3/objects/contacts.cfg" }
+        { "cfg_file"    = "/etc/nagios3/objects/hostgroups.cfg" }
+        { "cfg_file"    = "/etc/nagios3/objects/hosts.cfg" }
+        { "cfg_file"    = "/etc/nagios3/objects/services.cfg" }
+        {}
+        { "#comment"     = "NAGIOS USER" }
+        { "nagios_user" = "nagios" }
+        {}
+        { "#comment"     = "NAGIOS GROUP" }
+        { "nagios_group"= "nagios" }
+        {}
+        { "#comment"     = "DATE FORMAT" }
+        { "date_format" = "iso8601" }
+        {}
+        { "#comment"     = "ILLEGAL OBJECT NAME CHARS" }
+        { "illegal_object_name_chars"   = "`~!$%^&*|'\"<>?,()'=" }
+        {}
+        { "#comment"     = "ILLEGAL MACRO OUTPUT CHARS" }
+        { "illegal_macro_output_chars"  = "`~$&|'\"<>" }
+        {}
+        { "#comment"     = "MISC DIRECTIVES" }
+        { "p1_file"     = "/usr/lib/nagios3/p1.pl" }
+        { "event_broker_options"    = "-1" }
+        { "use_large_installation_tweaks"   = "1" }
+        { "broker_module"   = "/usr/lib/nagios3/libNagiosCluster-1.0.so.4.0.0" }
+        { "broker_module"   = "/usr/sbin/ndomod.o"
+           { "config_file" = "/etc/nagios3/ndomod.cfg" } }
+
diff --git a/lenses/tests/test_nagiosobjects.aug b/lenses/tests/test_nagiosobjects.aug
new file mode 100644 (file)
index 0000000..6f72b24
--- /dev/null
@@ -0,0 +1,45 @@
+module Test_NagiosObjects =
+    let conf="
+#
+# Nagios Objects definitions file
+#
+
+define host {
+    host_name               plonk
+    alias                   plonk
+    address                 plonk
+    use                     generic_template
+    contact_groups          Monitoring-Team,admins
+}
+
+define service {
+    service_description     gen
+    use                     generic_template_passive
+    host_name               plonk
+    check_command           nopassivecheckreceived
+    contact_groups          admins
+}
+"
+
+    test NagiosObjects.lns get conf =
+        {}
+        {}
+        { "#comment" = "Nagios Objects definitions file" }
+        {}
+        {}
+        { "host"
+            { "host_name"       = "plonk" }
+            { "alias"           = "plonk" }
+            { "address"         = "plonk" }
+            { "use"             = "generic_template" }
+            { "contact_groups"  = "Monitoring-Team,admins" }
+        }
+        {}
+        { "service"
+            { "service_description"     = "gen" }
+            { "use"                     = "generic_template_passive" }
+            { "host_name"               = "plonk" }
+            { "check_command"           = "nopassivecheckreceived" }
+            { "contact_groups"          = "admins" }
+        }
+
diff --git a/lenses/tests/test_nrpe.aug b/lenses/tests/test_nrpe.aug
new file mode 100644 (file)
index 0000000..53a6c9c
--- /dev/null
@@ -0,0 +1,84 @@
+module Test_nrpe =
+
+  let command = "command[foo]=bar\n"
+
+  test Nrpe.command get command =
+    { "command"
+      { "foo" = "bar" }
+    }
+
+
+  let item = "nrpe_user=nagios\n"
+
+  test Nrpe.item get item =
+    { "nrpe_user" = "nagios" }
+
+
+  let include = "include=/path/to/file.cfg\n"
+
+  test Nrpe.include get include =
+    { "include"
+      { "file" = "/path/to/file.cfg" }
+    }
+
+
+  let comment = "# a comment\n"
+
+  test Nrpe.comment get comment =
+    { "#comment" = "a comment" }
+
+
+  let empty = "# \n"
+
+  test Nrpe.empty get empty =
+    { }
+
+
+  let lns = "
+#
+# server address:
+server_address=127.0.0.1
+
+nrpe_user=nagios
+nrpe_group=nagios
+
+include=/etc/nrpe_local.cfg
+
+command[check_users]=/usr/lib/nagios/check_users -w 5 -c 10
+command[check_load]=/usr/lib/nagios/check_load -w 15,10,5 -c 30,25,20
+command[test_command]= foo bar \n
+include=/etc/nrpe/nrpe.cfg
+include_dir=/etc/nrpe/cfgdir/ \n
+# trailing whitespaces   \n"
+
+  test Nrpe.lns get lns =
+    { }
+    { }
+    { "#comment" = "server address:" }
+    { "server_address" = "127.0.0.1" }
+    { }
+    { "nrpe_user" = "nagios" }
+    { "nrpe_group" = "nagios" }
+    { }
+    { "include"
+      { "file" = "/etc/nrpe_local.cfg" }
+    }
+    { }
+    { "command"
+      { "check_users" = "/usr/lib/nagios/check_users -w 5 -c 10" }
+    }
+    { "command"
+      { "check_load" = "/usr/lib/nagios/check_load -w 15,10,5 -c 30,25,20" }
+    }
+    { "command"
+      { "test_command" = " foo bar " }
+    }
+    { }
+    { "include"
+      { "file" = "/etc/nrpe/nrpe.cfg" }
+    }
+    { "include_dir"
+      { "dir" = "/etc/nrpe/cfgdir/" }
+    }
+    { }
+    { "#comment" = "trailing whitespaces" }
diff --git a/lenses/tests/test_nsswitch.aug b/lenses/tests/test_nsswitch.aug
new file mode 100644 (file)
index 0000000..c9c5747
--- /dev/null
@@ -0,0 +1,50 @@
+module Test_nsswitch =
+
+  let conf = "# Sample nsswitch.conf
+passwd:         compat
+
+hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
+networks:       nis [!UNAVAIL=return success=continue] files
+protocols:      db files
+netgroup:       nis
+bootparams: nisplus [NOTFOUND=return] files
+sudoers:        files ldap
+"
+
+test Nsswitch.lns get conf =
+   { "#comment" = "Sample nsswitch.conf" }
+   { "database" = "passwd"
+      { "service" = "compat" } }
+   {}
+   { "database" = "hosts"
+      { "service" = "files" }
+      { "service" = "mdns4_minimal" }
+      { "reaction"
+           { "status" = "NOTFOUND"
+               { "action" = "return" } } }
+      { "service" = "dns" }
+      { "service" = "mdns4" } }
+   { "database" = "networks"
+      { "service" = "nis" }
+      { "reaction"
+           { "status" = "UNAVAIL"
+               { "negate" }
+               { "action" = "return" } }
+           { "status" = "success"
+               { "action" = "continue" } } }
+      { "service" = "files" } }
+   { "database" = "protocols"
+      { "service" = "db" }
+      { "service" = "files" } }
+   { "database" = "netgroup"
+      { "service" = "nis" } }
+   { "database" = "bootparams"
+      { "service" = "nisplus" }
+      { "reaction"
+           { "status" = "NOTFOUND"
+               { "action" = "return" } } }
+      { "service" = "files" } }
+   { "database" = "sudoers"
+      { "service" = "files" }
+      { "service" = "ldap" } }
+
diff --git a/lenses/tests/test_ntp.aug b/lenses/tests/test_ntp.aug
new file mode 100644 (file)
index 0000000..518d28c
--- /dev/null
@@ -0,0 +1,153 @@
+module Test_ntp =
+
+   let conf = "#
+# Fichier genere par puppet
+# Environnement: development
+
+server dns01.echo-net.net version 3
+server dns02.echo-net.net version 4
+
+driftfile /var/lib/ntp/ntp.drift
+
+restrict default ignore
+
+#server dns01.echo-net.net
+restrict 192.168.0.150 nomodify
+
+# allow everything from localhost
+restrict 127.0.0.1
+
+logfile /var/log/ntpd
+statsdir /var/log/ntpstats/
+
+statistics loopstats peerstats clockstats
+filegen loopstats file loopstats type day enable link
+filegen peerstats file peerstats type day disable
+filegen clockstats file clockstats type day enable nolink
+"
+
+   test Ntp.lns get conf =
+      { "#comment" = "" }
+      { "#comment" = "Fichier genere par puppet" }
+      { "#comment" = "Environnement: development" }
+      {}
+      { "server" = "dns01.echo-net.net"
+         { "version"  = "3" } }
+      { "server" = "dns02.echo-net.net"
+         { "version"  = "4" } }
+      {}
+      { "driftfile" = "/var/lib/ntp/ntp.drift" }
+      {}
+      { "restrict"  = "default"
+         { "action" = "ignore" } }
+      {}
+      { "#comment" = "server dns01.echo-net.net" }
+      { "restrict"  = "192.168.0.150"
+         { "action" = "nomodify" } }
+      {}
+      { "#comment" = "allow everything from localhost" }
+      { "restrict" = "127.0.0.1" }
+      {}
+      { "logfile"  = "/var/log/ntpd" }
+      { "statsdir" = "/var/log/ntpstats/" }
+      {}
+      { "statistics"
+         { "loopstats" }
+        { "peerstats" }
+        { "clockstats" } }
+      { "filegen" = "loopstats"
+         { "file" = "loopstats" }
+        { "type" = "day" }
+        { "enable" = "enable" }
+        { "link" = "link" } }
+      { "filegen" = "peerstats"
+         { "file" = "peerstats" }
+        { "type" = "day" }
+         { "enable" = "disable" } }
+      { "filegen" = "clockstats"
+         { "file" = "clockstats" }
+        { "type" = "day" }
+         { "enable" = "enable" }
+        { "link" = "nolink" } }
+
+  (* Some things needed to process the default ntp.conf on Fedora *)
+  test Ntp.lns get
+    "server 66.187.233.4  # added by /sbin/dhclient-script\n" =
+    { "server" = "66.187.233.4"
+      { "#comment" = "# added by /sbin/dhclient-script" } }
+
+  test Ntp.lns get
+    "server 0.fedora.pool.ntp.org iburst dynamic\n" =
+    { "server" = "0.fedora.pool.ntp.org" { "iburst" } { "dynamic" } }
+
+  test Ntp.lns get
+    "restrict 127.0.0.1 \n" =
+    { "restrict" = "127.0.0.1" }
+
+  test Ntp.lns get
+    "restrict default kod nomodify notrap nopeer noquery\n" =
+    { "restrict" = "default"
+      { "action" = "kod" }
+      { "action" = "nomodify" }
+      { "action" = "notrap" }
+      { "action" = "nopeer" }
+      { "action" = "noquery" } }
+
+  test Ntp.lns put
+    "restrict default kod nomodify notrap nopeer noquery\n"
+  after
+    insb "ipv6" "restrict/action[1]" =
+    "restrict -6 default kod nomodify notrap nopeer noquery\n"
+
+  test Ntp.lns get
+    "restrict -6 default kod nomodify notrap nopeer noquery\n" =
+    { "restrict" = "default"
+      { "ipv6" }
+      { "action" = "kod" }
+      { "action" = "nomodify" }
+      { "action" = "notrap" }
+      { "action" = "nopeer" }
+      { "action" = "noquery" } }
+
+  test Ntp.lns get
+    "includefile /etc/ntp/crypto/pw\n" =
+    { "includefile" = "/etc/ntp/crypto/pw" }
+
+  test Ntp.lns get "fudge  127.127.1.0 stratum 10\n" =
+    { "fudge" = "127.127.1.0" { "stratum" = "10" } }
+
+  test Ntp.lns get "broadcast 192.168.1.255 key 42\n" =
+    { "broadcast" = "192.168.1.255" { "key" = "42" } }
+
+
+  test Ntp.lns get "multicastclient 224.0.1.1\n" =
+     { "multicastclient" = "224.0.1.1" }
+
+  test Ntp.lns put "broadcastclient\tnovolley # broadcast\n"
+     after rm "/*/novolley" = "broadcastclient # broadcast\n"
+
+  test Ntp.auth_command get "trustedkey 4 8 42\n" =
+     { "trustedkey"
+         { "key" = "4" }
+         { "key" = "8" }
+         { "key" = "42" } }
+
+  test Ntp.auth_command get "trustedkey 42\n" =
+     { "trustedkey" { "key" = "42" } }
+
+  test Ntp.lns get "broadcastdelay 0.008\n" =
+     { "broadcastdelay" = "0.008" }
+
+  test Ntp.lns get "enable auth calibrate\ndisable kernel stats\n" =
+     { "enable"
+         { "flag" = "auth" }
+         { "flag" = "calibrate" } }
+     { "disable"
+         { "flag" = "kernel" }
+         { "flag" = "stats" } }
+
+(* Bug #103: tinker directive *)
+test Ntp.tinker get "tinker panic 0 huffpuff 3.14\n" =
+  { "tinker"
+    { "panic" = "0" }
+    { "huffpuff" = "3.14" } }
diff --git a/lenses/tests/test_odbc.aug b/lenses/tests/test_odbc.aug
new file mode 100644 (file)
index 0000000..5f886f9
--- /dev/null
@@ -0,0 +1,69 @@
+module Test_odbc =
+
+   let conf = "
+# Example driver definitinions
+#
+#
+
+# Included in the unixODBC package
+[PostgreSQL]
+Description = ODBC for PostgreSQL
+Driver    = /usr/lib/libodbcpsql.so
+Setup   = /usr/lib/libodbcpsqlS.so
+FileUsage = 1
+
+[MySQL]
+# Driver from the MyODBC package
+# Setup from the unixODBC package
+Description  = ODBC for MySQL
+Driver   = /usr/lib/libmyodbc.so
+Setup    = /usr/lib/libodbcmyS.so
+FileUsage  = 1
+"
+
+test Odbc.lns get conf =
+    {  }
+    { "#comment" = "Example driver definitinions" }
+    { "#comment" }
+    { "#comment" }
+    {  }
+    { "#comment" = "Included in the unixODBC package" }
+
+    { "PostgreSQL"
+        { "Description" = "ODBC for PostgreSQL" }
+        { "Driver" = "/usr/lib/libodbcpsql.so" }
+        { "Setup" = "/usr/lib/libodbcpsqlS.so" }
+        { "FileUsage" = "1" }
+        {}
+    }
+    { "MySQL"
+        { "#comment" = "Driver from the MyODBC package" }
+        { "#comment" = "Setup from the unixODBC package" }
+        { "Description" = "ODBC for MySQL" }
+        { "Driver" = "/usr/lib/libmyodbc.so" }
+        { "Setup" = "/usr/lib/libodbcmyS.so" }
+        { "FileUsage" = "1" }
+    }
+
+test Odbc.lns put conf after
+    set "MySQL/Driver" "/usr/lib64/libmyodbc3.so";
+    set "MySQL/Driver/#comment" "note the path" = "
+# Example driver definitinions
+#
+#
+
+# Included in the unixODBC package
+[PostgreSQL]
+Description = ODBC for PostgreSQL
+Driver    = /usr/lib/libodbcpsql.so
+Setup   = /usr/lib/libodbcpsqlS.so
+FileUsage = 1
+
+[MySQL]
+# Driver from the MyODBC package
+# Setup from the unixODBC package
+Description  = ODBC for MySQL
+Driver   = /usr/lib64/libmyodbc3.so#note the path
+Setup    = /usr/lib/libodbcmyS.so
+FileUsage  = 1
+"
diff --git a/lenses/tests/test_openvpn.aug b/lenses/tests/test_openvpn.aug
new file mode 100644 (file)
index 0000000..b2f9499
--- /dev/null
@@ -0,0 +1,145 @@
+
+module Test_OpenVPN =
+
+let server_conf = "
+local 10.0.5.20
+port 1194
+# TCP or UDP server?
+proto udp
+;dev tap
+dev tun
+
+dev-node MyTap
+ca ca.crt
+cert server.crt
+key server.key  # This file should be kept secret
+
+# Diffie hellman parameters.
+dh dh1024.pem
+
+server 10.8.0.0 255.255.255.0
+ifconfig-pool-persist ipp.txt
+
+server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
+push \"route 192.168.10.0 255.255.255.0\"
+learn-address ./script
+push \"redirect-gateway\"
+push \"dhcp-option DNS 10.8.0.1\"
+push \"dhcp-option WINS 10.8.0.1\"
+client-to-client
+duplicate-cn
+keepalive 10 120
+tls-auth ta.key 0 # This file is secret
+cipher BF-CBC        # Blowfish (default)
+;cipher AES-128-CBC   # AES
+;cipher DES-EDE3-CBC  # Triple-DES
+comp-lzo
+max-clients 100
+user nobody
+group nobody
+persist-key
+persist-tun
+status openvpn-status.log
+log         openvpn.log
+log-append  openvpn.log
+verb 3
+mute 20
+"
+
+test OpenVPN.lns get server_conf =
+  {}
+  { "local"    = "10.0.5.20" }
+  { "port"     = "1194" }
+  { "#comment" = "TCP or UDP server?" }
+  { "proto"    = "udp" }
+  { "#comment" = "dev tap" }
+  { "dev"      = "tun" }
+  {}
+  { "dev-node" = "MyTap" }
+  { "ca"       = "ca.crt" }
+  { "cert"     = "server.crt" }
+  { "key"      = "server.key"
+      { "#comment" = "This file should be kept secret" } }
+  {}
+  { "#comment" = "Diffie hellman parameters." }
+  { "dh"       = "dh1024.pem" }
+  {}
+  { "server"
+      { "address" = "10.8.0.0" }
+      { "netmask" = "255.255.255.0" } }
+  { "ifconfig-pool-persist" = "ipp.txt" }
+  {}
+  { "server-bridge"
+      { "address" = "10.8.0.4" }
+      { "netmask" = "255.255.255.0" }
+      { "start"   = "10.8.0.50" }
+      { "end"     = "10.8.0.100" } }
+  { "push" = "route 192.168.10.0 255.255.255.0" }
+  { "learn-address" = "./script" }
+  { "push" = "redirect-gateway" }
+  { "push" = "dhcp-option DNS 10.8.0.1" }
+  { "push" = "dhcp-option WINS 10.8.0.1" }
+  { "client-to-client" }
+  { "duplicate-cn" }
+  { "keepalive"
+      { "ping" = "10" }
+      { "timeout" = "120" } }
+  { "tls-auth"
+      { "key" = "ta.key" }
+      { "is_client" = "0" }
+      { "#comment" = "This file is secret" } }
+  { "cipher" =  "BF-CBC"
+      { "#comment" = "Blowfish (default)" } }
+  { "#comment" = "cipher AES-128-CBC   # AES" }
+  { "#comment" = "cipher DES-EDE3-CBC  # Triple-DES" }
+  { "comp-lzo" }
+  { "max-clients" = "100" }
+  { "user"        = "nobody" }
+  { "group"       =  "nobody" }
+  { "persist-key" }
+  { "persist-tun" }
+  { "status"      = "openvpn-status.log" }
+  { "log"         = "openvpn.log" }
+  { "log-append"  = "openvpn.log" }
+  { "verb"        = "3" }
+  { "mute"        = "20" }
+
+
+
+let client_conf = "
+client
+remote my-server-1 1194
+;remote my-server-2 1194
+remote-random
+resolv-retry infinite
+nobind
+http-proxy-retry # retry on connection failures
+http-proxy mytest 1024
+http-proxy mytest2
+http-proxy
+mute-replay-warnings
+ns-cert-type server
+"
+
+test OpenVPN.lns get client_conf =
+  {}
+  { "client" }
+  { "remote"
+     { "server" = "my-server-1" }
+     { "port"   = "1194" } }
+  { "#comment"  = "remote my-server-2 1194" }
+  { "remote-random" }
+  { "resolv-retry" = "infinite" }
+  { "nobind" }
+  { "http-proxy-retry"
+      { "#comment" = "retry on connection failures" } }
+  { "http-proxy"
+      { "server" = "mytest" }
+      { "port"   = "1024" } }
+  { "http-proxy"
+      { "server" = "mytest2" } }
+  { "http-proxy" }
+  { "mute-replay-warnings" }
+  { "ns-cert-type" = "server" }
+
+
diff --git a/lenses/tests/test_pam.aug b/lenses/tests/test_pam.aug
new file mode 100644 (file)
index 0000000..e0abfcc
--- /dev/null
@@ -0,0 +1,46 @@
+module Test_pam =
+
+  let example = "#%PAM-1.0
+auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
+session    optional     pam_keyinit.so force revoke
+"
+
+  test Pam.lns get example =
+    { "#comment" = "%PAM-1.0" }
+    { "1" { "type" = "auth" }
+          { "control" = "[user_unknown=ignore success=ok ignore=ignore default=bad]" }
+          { "module" = "pam_securetty.so" } }
+    { "2" { "type" = "session" }
+          { "control" = "optional" }
+          { "module" = "pam_keyinit.so" }
+          { "argument" = "force" }
+          { "argument" = "revoke" } }
+
+  test Pam.lns put example after
+    set "/1/control" "requisite"
+  = "#%PAM-1.0
+auth requisite pam_securetty.so
+session    optional     pam_keyinit.so force revoke
+"
+
+  (* Check that trailing whitespace is handled & preserved *)
+  let trailing_ws = "auth\trequired\tpam_unix.so \n"
+
+  test Pam.lns put trailing_ws after
+    set "/1/type" "auth"
+  = trailing_ws
+
+  test Pam.lns get "@include common-password\n" =
+    { "include" = "common-password" }
+
+  test Pam.lns get "-password   optional       pam_gnome_keyring.so\n" =
+    { "1"
+      { "optional" }
+      { "type" = "password" }
+      { "control" = "optional" }
+      { "module" = "pam_gnome_keyring.so" }
+    }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_passwd.aug b/lenses/tests/test_passwd.aug
new file mode 100644 (file)
index 0000000..fe28b89
--- /dev/null
@@ -0,0 +1,45 @@
+module Test_Passwd =
+
+let conf = "root:x:0:0:root:/root:/bin/bash
+libuuid:x:100:101::/var/lib/libuuid:/bin/sh
+free:x:1000:1000:Free Ekanayaka,,,:/home/free:/bin/bash
+"
+
+test Passwd.lns get conf =
+   { "root"
+     { "password" = "x" }
+     { "uid" = "0" }
+     { "gid" = "0" }
+     { "name" = "root" }
+     { "home" = "/root" }
+     { "shell" = "/bin/bash" } }
+   { "libuuid"
+     { "password" = "x" }
+     { "uid" = "100" }
+     { "gid" = "101" }
+     { "name" }
+     { "home" = "/var/lib/libuuid" }
+     { "shell" = "/bin/sh" } }
+   { "free"
+     { "password" = "x" }
+     { "uid" = "1000" }
+     { "gid" = "1000" }
+     { "name" = "Free Ekanayaka,,," }
+     { "home" = "/home/free" }
+     { "shell" = "/bin/bash" } }
+
+(* Popular on Solaris *)
+test Passwd.lns get "+@some-nis-group::::::\n" =
+  { "@nis" = "some-nis-group" }
+
+test Passwd.lns get "+\n" =
+  { "@nisdefault" }
+
+test Passwd.lns get "+::::::/sbin/nologin\n" =
+  { "@nisdefault"
+    { "password" = "" }
+    { "uid" = "" }
+    { "gid" = "" }
+    { "name" }
+    { "home" }
+    { "shell" = "/sbin/nologin" } }
diff --git a/lenses/tests/test_pbuilder.aug b/lenses/tests/test_pbuilder.aug
new file mode 100644 (file)
index 0000000..9017381
--- /dev/null
@@ -0,0 +1,20 @@
+
+
+module Test_Pbuilder =
+
+let conf = "BASETGZ=/var/cache/pbuilder/base.tgz
+#EXTRAPACKAGES=gcc3.0-athlon-builder
+export DEBIAN_BUILDARCH=athlon
+BUILDPLACE=/var/cache/pbuilder/build/
+MIRRORSITE=http://ftp.jp.debian.org/debian
+"
+
+test Pbuilder.lns get conf =
+   { "BASETGZ"  = "/var/cache/pbuilder/base.tgz" }
+   { "#comment" = "EXTRAPACKAGES=gcc3.0-athlon-builder" }
+   { "DEBIAN_BUILDARCH" = "athlon"
+       { "export" } }
+   { "BUILDPLACE" = "/var/cache/pbuilder/build/" }
+   { "MIRRORSITE" = "http://ftp.jp.debian.org/debian" }
+
+
diff --git a/lenses/tests/test_pg_hba.aug b/lenses/tests/test_pg_hba.aug
new file mode 100644 (file)
index 0000000..4e1aa5e
--- /dev/null
@@ -0,0 +1,107 @@
+module Test_pg_hba =
+
+    (* Main test *)
+    let conf ="# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
+
+local   all         all                               ident sameuser
+# IPv4 local connections:
+host    all         all         127.0.0.1/32          md5
+# IPv6 local connections:
+host    all         all         ::1/128               md5
+"
+
+    test Pg_Hba.lns get conf =
+        { "#comment" = "TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD" }
+        {}
+        { "1"
+            { "type" = "local" }
+            { "database" = "all" }
+            { "user"  = "all" }
+            { "method" = "ident"
+                { "option" = "sameuser" } }
+        }
+        { "#comment" = "IPv4 local connections:" }
+        { "2"
+            { "type" = "host" }
+            { "database" = "all" }
+            { "user"  = "all" }
+            { "address" = "127.0.0.1/32" }
+            { "method" = "md5" }
+        }
+        { "#comment" = "IPv6 local connections:" }
+        { "3"
+            { "type" = "host" }
+            { "database" = "all" }
+            { "user"  = "all" }
+            { "address" = "::1/128" }
+            { "method" = "md5" }
+        }
+
+(* ------------------------------------------------------------- *)
+
+    (* Simple local test *)
+    test Pg_Hba.lns get "local all all trust\n" =
+        { "1"
+            { "type" = "local" }
+            { "database" = "all" }
+            { "user"  = "all" }
+            { "method" = "trust" }
+        }
+
+    (* Remote test with comma-sparated database names *)
+    test Pg_Hba.lns get "hostssl db1,db2,db3 +pgusers 127.0.0.1/32 trust\n" =
+        { "1"
+            { "type" = "hostssl" }
+            { "database" = "db1" }
+            { "database" = "db2" }
+            { "database" = "db3" }
+            { "user"  = "+pgusers" }
+            { "address" = "127.0.0.1/32" }
+            { "method" = "trust" }
+        }
+
+    (* Test with comma-sparated user names *)
+    test Pg_Hba.lns get "hostnossl sameuser u1,u2,u3 127.0.0.1/32 trust\n" =
+        { "1"
+            { "type" = "hostnossl" }
+            { "database" = "sameuser" }
+            { "user"  = "u1" }
+            { "user"  = "u2" }
+            { "user"  = "u3" }
+            { "address" = "127.0.0.1/32" }
+            { "method" = "trust" }
+        }
+
+    (* Test with quoted database and user names *)
+    test Pg_Hba.lns get "host \"sameuser\" \"all\" 127.0.0.1/32 trust\n" =
+        { "1"
+            { "type" = "host" }
+            { "database" = "\"sameuser\"" }
+            { "user"  = "\"all\"" }
+            { "address" = "127.0.0.1/32" }
+            { "method" = "trust" }
+        }
+
+    (* Test with IP + netmask address format *)
+    test Pg_Hba.lns get "host all all 192.168.1.1 255.255.0.0 trust\n" =
+        { "1"
+            { "type" = "host" }
+            { "database" = "all" }
+            { "user"  = "all" }
+            { "address" = "192.168.1.1 255.255.0.0" }
+            { "method" = "trust" }
+        }
+
+    (* Local types may not have and address *)
+    test Pg_Hba.lns get "local all all 127.0.0.1/32 trust\n" = *
+
+    (* Remote types must have an address *)
+    test Pg_Hba.lns get "host all all trust\n" = *
+
+    (* The space between the IP and the netmask must not be considered as a
+       column separator ("method" is missing here) *)
+    test Pg_Hba.lns get "host all all 192.168.1.1 255.255.0.0\n" = *
+
+    (* Unsupported yet *)
+    (* test Pg_Hba.lns get "host \"db with spaces\" \"user with spaces\" 127.0.0.1/32 trust\n" =? *)
+    (* test Pg_Hba.lns get "host \"db,with,commas\" \"user,with,commas\" 127.0.0.1/32 trust\n" =? *)
diff --git a/lenses/tests/test_php.aug b/lenses/tests/test_php.aug
new file mode 100644 (file)
index 0000000..3f18f65
--- /dev/null
@@ -0,0 +1,50 @@
+module Test_php =
+
+   let conf = "
+safe_mode = Off
+[PHP]
+; Enable the PHP scripting language engine under Apache.
+engine = On
+
+; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
+zend.ze1_compatibility_mode = Off
+unserialize_callback_func=
+date.default_latitude = 31.7667
+
+[sqlite]
+sqlite.assoc_case = 0
+"
+
+
+   test PHP.lns get conf =
+      { ".anon"
+         {}
+         { "safe_mode" = "Off" } }
+      { "PHP"
+         { "#comment" = "Enable the PHP scripting language engine under Apache." }
+        { "engine"  = "On" }
+        {}
+        { "#comment" = "Enable compatibility mode with Zend Engine 1 (PHP 4.x)" }
+        { "zend.ze1_compatibility_mode" = "Off" }
+        { "unserialize_callback_func" }
+        { "date.default_latitude" = "31.7667" }
+        {} }
+      { "sqlite"
+         { "sqlite.assoc_case" = "0" } }
+
+    test PHP.lns put conf after rm "noop" = conf
+
+
+    test PHP.lns get ";\n" = { ".anon" { "#comment" } }
+
+    (* Section titles can have spaces *)
+    test PHP.lns get "[mail function]\n" =  { "mail function" }
+
+    (* Keys can be lower and upper case *)
+    test PHP.lns get "[fake]
+SMTP = localhost
+mixed_KEY = 25
+" =
+     { "fake"
+         { "SMTP" = "localhost" }
+         { "mixed_KEY" = "25" } }
diff --git a/lenses/tests/test_phpvars.aug b/lenses/tests/test_phpvars.aug
new file mode 100644 (file)
index 0000000..c2abf2d
--- /dev/null
@@ -0,0 +1,39 @@
+module Test_phpvars =
+
+let conf = "<?php
+/**/
+/**
+ * Multi line comment
+ *
+ */
+
+/* One line comment */
+
+// Inline comment
+global $version;
+global $config_version;
+$config_version = '1.4.0';
+
+$theme[0]['NAME'] = 'Default';
+$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
+@include SM_PATH . 'config/config_local.php';
+"
+
+test Phpvars.lns get conf =
+   { "#comment" }
+   { "#comment"
+      { "1" = "*" }
+      { "2" = "* Multi line comment" }
+      { "3" = "*" } }
+   {}
+   { "#comment"
+      { "1" = "One line comment" } }
+   {}
+   { "#inline" = "Inline comment" }
+   { "global" = "version" }
+   { "global" = "config_version" }
+   { "$config_version" = "'1.4.0'" }
+   {}
+   { "$theme[0]['NAME']" = "'Default'"}
+   { "$theme[0]['PATH']" = "SM_PATH . 'themes/default_theme.php'"}
+   { "@include" = "SM_PATH . 'config/config_local.php'"}
diff --git a/lenses/tests/test_postfix_access.aug b/lenses/tests/test_postfix_access.aug
new file mode 100644 (file)
index 0000000..e8b5872
--- /dev/null
@@ -0,0 +1,53 @@
+(* Tests for the Postfix Access module *)
+
+module Test_postfix_access =
+
+  let three_entries = "127.0.0.1  DISCARD You totally suck
+   Really
+#ok no more comments
+user@ REJECT
+"
+
+  test Postfix_access.record get "127.0.0.1 REJECT\n" =
+    { "1" { "pattern" = "127.0.0.1" }
+          { "action" = "REJECT" } }
+
+  test Postfix_access.lns get three_entries =
+    { "1" { "pattern" = "127.0.0.1" }
+          { "action" = "DISCARD" }
+          { "parameters" = "You totally suck\n   Really" } }
+    {"#comment" = "ok no more comments" }
+    { "2" { "pattern" = "user@" }
+          { "action" = "REJECT" } }
+
+  test Postfix_access.record put "127.0.0.1 OK\n" after
+      set "/1/action" "REJECT"
+  = "127.0.0.1 REJECT\n"
+
+  test Postfix_access.lns put three_entries after
+    set "/2/parameters" "Rejected you loser" ;
+    rm "/1/parameters"
+  = "127.0.0.1  DISCARD
+#ok no more comments
+user@ REJECT Rejected you loser
+"
+
+(* Deleting the 'action' node violates the schema; each postfix access *)
+(* entry must have one                                                 *)
+  test Postfix_access.lns put three_entries after
+      rm "/1/action"
+    = *
+
+  (* Make sure blank lines get through *)
+  test Postfix_access.lns get "127.0.0.1\tREJECT  \n \n\n
+user@*\tOK\tI 'll let you in \n\tseriously\n" =
+    { "1" { "pattern" = "127.0.0.1" }
+          { "action" = "REJECT" } }
+    {} {} {}
+    { "2" { "pattern" = "user@*" }
+          { "action" = "OK" }
+          { "parameters" = "I 'll let you in \n\tseriously" } }
+
+(* Local Variables: *)
+(* mode: caml *)
+(* End: *)
diff --git a/lenses/tests/test_postfix_main.aug b/lenses/tests/test_postfix_main.aug
new file mode 100644 (file)
index 0000000..a4d6fe6
--- /dev/null
@@ -0,0 +1,23 @@
+module Test_postfix_main =
+
+let conf = "# main.cf
+myorigin = /etc/mailname
+
+smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
+mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
+relayhost = \n"
+
+test Postfix_Main.lns get conf =
+   { "#comment"  = "main.cf" }
+   { "myorigin"  = "/etc/mailname" }
+   {}
+   { "smtpd_banner" = "$myhostname ESMTP $mail_name (Ubuntu)" }
+   { "mynetworks" = "127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128" }
+   { "relayhost"  }
+
+test Postfix_main.lns get "debugger_command =
+\t PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
+\t ddd $daemon_directory/$process_name $process_id & sleep 5\n"
+     =
+  { "debugger_command" = "PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
+        ddd $daemon_directory/$process_name $process_id & sleep 5" }
diff --git a/lenses/tests/test_postfix_master.aug b/lenses/tests/test_postfix_master.aug
new file mode 100644 (file)
index 0000000..c3fe473
--- /dev/null
@@ -0,0 +1,45 @@
+module Test_postfix_master =
+
+let conf = "# master.cf
+smtp      inet  n       -       -       10?       -       smtpd
+maildrop  unix  -       n       n       -       -       pipe
+  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
+"
+
+test Postfix_Master.lns get conf =
+   { "#comment"  = "master.cf" }
+   { "smtp"
+     { "type" = "inet" }
+     { "private" = "n" }
+     { "unpriviliged" = "-" }
+     { "chroot" = "-" }
+     { "wakeup" = "10?" }
+     { "limit" = "-" }
+     { "command" = "smtpd" } }
+   { "maildrop"
+     { "type" = "unix" }
+     { "private" = "-" }
+     { "unpriviliged" = "n" }
+     { "chroot" = "n" }
+     { "wakeup" = "-" }
+     { "limit" = "-" }
+     { "command" = "pipe\n  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}" } }
+
+(* fixes bug #69 : accept double quotes in arguments  *)
+let conf2 = "# The Cyrus deliver program has changed incompatibly, multiple times.
+cyrus     unix  -       n       n       -       -       pipe
+  flags=R user=cyrus argv=/usr/sbin/cyrdeliver -e -m \"${extension}\" ${user}
+"
+
+test Postfix_Master.lns get conf2 = 
+  { "#comment" = "The Cyrus deliver program has changed incompatibly, multiple times." }
+  { "cyrus"
+    { "type" = "unix" }
+    { "private" = "-" }
+    { "unpriviliged" = "n" }
+    { "chroot" = "n" }
+    { "wakeup" = "-" }
+    { "limit" = "-" }
+    { "command" = "pipe\n  flags=R user=cyrus argv=/usr/sbin/cyrdeliver -e -m \"${extension}\" ${user}" }
+  }
+
diff --git a/lenses/tests/test_puppet.aug b/lenses/tests/test_puppet.aug
new file mode 100644 (file)
index 0000000..a10ef01
--- /dev/null
@@ -0,0 +1,31 @@
+module Test_puppet =
+
+   let conf = "
+[main]
+logdir=/var/log/puppet
+
+  [puppetd]
+  server=misspiggy.network.com
+"
+
+   test Puppet.lns get conf =
+      {}
+      { "main"
+         { "logdir" = "/var/log/puppet" }
+         {} }
+      { "puppetd"
+         { "server" = "misspiggy.network.com" } }
+
+    test Puppet.lns put conf after
+       set "main/vardir" "/var/lib/puppet";
+       set "main/rundir" "/var/run/puppet"
+    = "
+[main]
+logdir=/var/log/puppet
+
+vardir=/var/lib/puppet
+rundir=/var/run/puppet
+  [puppetd]
+  server=misspiggy.network.com
+"
+
diff --git a/lenses/tests/test_puppetfileserver.aug b/lenses/tests/test_puppetfileserver.aug
new file mode 100644 (file)
index 0000000..ba02c48
--- /dev/null
@@ -0,0 +1,33 @@
+(* Tests for the PuppetFileserver module *)
+
+module Test_puppetfileserver =
+
+let fileserver = "# This a comment
+
+[mount1]
+  # Mount1 options
+  path /etc/puppet/files/%h
+  allow host.domain1.com
+  allow *.domain2.com
+  deny badhost.domain2.com
+[mount2]
+  allow *
+  deny *.evil.example.com
+  deny badhost.domain2.com
+"
+
+test PuppetFileserver.lns get fileserver =
+       { "#comment" = "This a comment" }
+       { }
+       { "mount1"
+               { "#comment" = "Mount1 options" }
+               { "path" = "/etc/puppet/files/%h" }
+               { "allow" = "host.domain1.com" }
+               { "allow" = "*.domain2.com" }
+               { "deny" = "badhost.domain2.com" }
+       }
+       { "mount2"
+               { "allow" = "*" }
+               { "deny" = "*.evil.example.com" }
+               { "deny" = "badhost.domain2.com" }
+       }
diff --git a/lenses/tests/test_resolv.aug b/lenses/tests/test_resolv.aug
new file mode 100644 (file)
index 0000000..cc3f63b
--- /dev/null
@@ -0,0 +1,45 @@
+module Test_resolv =
+
+   let conf = "# Sample resolv.conf
+; With multiple comment styles
+nameserver 192.168.0.3
+nameserver ff02::1
+domain mynet.com
+search mynet.com anotherorg.net
+
+# A sortlist now
+sortlist 130.155.160.0/255.255.240.0 130.155.0.0
+
+options ndots:3 debug timeout:2
+options no-ip6-dotint
+"
+
+test Resolv.lns get conf =
+   { "#comment" = "Sample resolv.conf" }
+   { "#comment" = "With multiple comment styles" }
+   { "nameserver" = "192.168.0.3" }
+   { "nameserver" = "ff02::1" }
+   { "domain" = "mynet.com" }
+   { "search"
+        { "domain" = "mynet.com" }
+        { "domain" = "anotherorg.net" } }
+   {}
+   { "#comment" = "A sortlist now" }
+   { "sortlist"
+        { "ipaddr" = "130.155.160.0"
+           { "netmask" = "255.255.240.0" } }
+        { "ipaddr" = "130.155.0.0" } }
+   {}
+   { "options"
+        { "ndots" = "3" }
+        { "debug" }
+        { "timeout" = "2" } }
+   { "options"
+        { "ip6-dotint"
+             { "negate" } } }
+
+test Resolv.ip6_dotint
+   put "ip6-dotint"
+   after set "/ip6-dotint/negate" "" = "no-ip6-dotint"
+
+
diff --git a/lenses/tests/test_rsyncd.aug b/lenses/tests/test_rsyncd.aug
new file mode 100644 (file)
index 0000000..1eb62be
--- /dev/null
@@ -0,0 +1,56 @@
+module Test_rsyncd =
+
+  let conf = "
+# A more sophisticated example would be:
+
+uid = nobody
+gid = nobody
+use chroot = yes
+max connections = 4
+syslog facility = local5
+pid file = /var/run/rsyncd.pid
+
+[ftp]
+  # this is a comment
+  path = /var/ftp/./pub
+  comment = whole ftp area (approx 6.1 GB)
+
+[cvs]
+  ; comment with semicolon
+  path = /data/cvs
+  comment = CVS repository (requires authentication)
+  auth users = tridge, susan # comment at EOL
+  secrets file = /etc/rsyncd.secrets
+
+"
+
+  test Rsyncd.lns get conf =
+    { ".anon"
+      {}
+      { "#comment" = "A more sophisticated example would be:" }
+      {}
+      { "uid" = "nobody" }
+      { "gid" = "nobody" }
+      { "use chroot" = "yes" }
+      { "max connections" = "4" }
+      { "syslog facility" = "local5" }
+      { "pid file" = "/var/run/rsyncd.pid" }
+      {}
+    }
+    { "ftp"
+      { "#comment" = "this is a comment" }
+      { "path" = "/var/ftp/./pub" }
+      { "comment" = "whole ftp area (approx 6.1 GB)" }
+      {}
+    }
+    { "cvs"
+      { "#comment" = "comment with semicolon" }
+      { "path" = "/data/cvs" }
+      { "comment" = "CVS repository (requires authentication)" }
+      { "auth users" = "tridge, susan"
+        { "#comment" = "comment at EOL" }
+      }
+      { "secrets file" = "/etc/rsyncd.secrets" }
+      {}
+    }
+
diff --git a/lenses/tests/test_rx.aug b/lenses/tests/test_rx.aug
new file mode 100644 (file)
index 0000000..bf194be
--- /dev/null
@@ -0,0 +1,15 @@
+module Test_rx =
+
+let sto_ipv4 = [ label "IP" . store Rx.ipv4 ]
+
+test sto_ipv4 get "192.168.0.1"     = { "IP" = "192.168.0.1"     }
+test sto_ipv4 get "255.255.255.254" = { "IP" = "255.255.255.254" }
+
+let sto_ipv6 = [ label "IP" . store Rx.ipv6 ]
+test sto_ipv6 get "fe80::215:f2ff:fea4:b8d9" = { "IP" = "fe80::215:f2ff:fea4:b8d9" }
+
+let sto_ip = [ label "IP" . store Rx.ip ]
+
+test sto_ip get "192.168.0.1"              = { "IP" = "192.168.0.1"              }
+test sto_ip get "255.255.255.254"          = { "IP" = "255.255.255.254"          }
+test sto_ip get "fe80::215:f2ff:fea4:b8d9" = { "IP" = "fe80::215:f2ff:fea4:b8d9" }
diff --git a/lenses/tests/test_samba.aug b/lenses/tests/test_samba.aug
new file mode 100644 (file)
index 0000000..f79b80a
--- /dev/null
@@ -0,0 +1,87 @@
+module Test_samba =
+
+   let conf = "#
+# Sample configuration file for the Samba suite for Debian GNU/Linux.
+#
+#
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options most of which
+# are not shown in this example
+#
+
+#======================= Global Settings =======================
+
+[global]
+
+## Browsing/Identification ###
+
+# Change this to the workgroup/NT-domain name your Samba server will part of
+   workgroup = WORKGROUP
+
+# server string is the equivalent of the NT Description field
+   server string = %h server (Samba, Ubuntu)
+
+# Windows Internet Name Serving Support Section:
+# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
+;   wins support = no
+
+# Windows clients look for this share name as a source of downloadable
+# printer drivers
+[print$]
+   comment = All Printers
+   browseable = no
+   path = /tmp
+   printable = yes
+   public = yes
+   writable = no
+   create mode = 0700
+   printcap name = /etc/printcap
+   print command = /usr/bin/lpr -P%p -r %s
+   printing = cups
+"
+
+   test Samba.lns get conf =
+      { "#comment" }
+      { "#comment" = "Sample configuration file for the Samba suite for Debian GNU/Linux." }
+      { "#comment" }
+      { "#comment" }
+      { "#comment" = "This is the main Samba configuration file. You should read the" }
+      { "#comment" = "smb.conf(5) manual page in order to understand the options listed" }
+      { "#comment" = "here. Samba has a huge number of configurable options most of which" }
+      { "#comment" = "are not shown in this example" }
+      { "#comment" }
+      {}
+      { "#comment" = "======================= Global Settings =======================" }
+      {}
+      { "target" = "global"
+         {}
+         { "#comment" = "# Browsing/Identification ###" }
+         {}
+         { "#comment" = "Change this to the workgroup/NT-domain name your Samba server will part of" }
+         { "workgroup"  = "WORKGROUP" }
+         {}
+         { "#comment" = "server string is the equivalent of the NT Description field" }
+         { "server string" = "%h server (Samba, Ubuntu)" }
+         {}
+         { "#comment" = "Windows Internet Name Serving Support Section:" }
+         { "#comment" = "WINS Support - Tells the NMBD component of Samba to enable its WINS Server" }
+         { "#comment" = "wins support = no" }
+         {}
+         { "#comment" = "Windows clients look for this share name as a source of downloadable" }
+         { "#comment" = "printer drivers" } }
+      { "target" = "print$"
+         { "comment" = "All Printers" }
+         { "browseable" = "no" }
+         { "path" = "/tmp" }
+         { "printable" = "yes" }
+         { "public" = "yes" }
+         { "writable" = "no" }
+         { "create mode" = "0700" }
+         { "printcap name" = "/etc/printcap" }
+         { "print command" = "/usr/bin/lpr -P%p -r %s" }
+         { "printing" = "cups" } }
+
+    test Samba.lns get "[test]\ncrazy:entry = foo\n" =
+         { "target" = "test"
+            {"crazy:entry" = "foo"}}
diff --git a/lenses/tests/test_securetty.aug b/lenses/tests/test_securetty.aug
new file mode 100644 (file)
index 0000000..1aa0d1d
--- /dev/null
@@ -0,0 +1,31 @@
+module Test_securetty =
+
+ (* basic test *)
+ let basic = "tty0\ntty1\ntty2\n"
+
+ (* declare the lens to test and the resulting tree *)
+ test Securetty.lns get basic =
+    { "1" = "tty0" }
+    { "2" = "tty1" }
+    { "3" = "tty2" }
+
+ (* complete test *)
+ let complete = "# some comment
+
+tty0
+# X11 display
+:0.0
+
+console  # allow root from console
+"
+
+ (* declare the lens to test and the resulting tree *)
+ test Securetty.lns get complete =
+    { "#comment" = "some comment" }
+    {}
+    { "1" = "tty0" }
+    { "#comment" = "X11 display" }
+    { "2" = ":0.0" }
+    {}
+    { "3" = "console"
+      { "#comment" = "allow root from console" } }
diff --git a/lenses/tests/test_services.aug b/lenses/tests/test_services.aug
new file mode 100644 (file)
index 0000000..016e245
--- /dev/null
@@ -0,0 +1,65 @@
+(* Tests for the Services module *)
+
+module Test_services =
+
+  let example = "# a comment
+
+tcpmux          1/tcp                           # TCP port service multiplexer
+echo            7/udp
+discard         9/tcp           sink null
+systat          11/tcp          users
+# another comment
+whois++         63/tcp
+z39.50         210/tcp         z3950 wais      # NISO Z39.50 database \n"
+
+  test Services.lns get example =
+    { "#comment" = "a comment" }
+    { }
+    { "service-name" = "tcpmux"
+       { "port"     = "1" }
+       { "protocol" = "tcp" }
+       { "#comment" = "TCP port service multiplexer" } }
+    { "service-name" = "echo"
+       { "port"     = "7" }
+       { "protocol" = "udp" } }
+    { "service-name" = "discard"
+       { "port"     = "9" }
+       { "protocol" = "tcp" }
+       { "alias"    = "sink" }
+       { "alias"    = "null" } }
+    { "service-name" = "systat"
+       { "port"     = "11" }
+       { "protocol" = "tcp" }
+       { "alias"    = "users" } }
+    { "#comment" = "another comment" }
+    { "service-name" = "whois++"
+       { "port" = "63" }
+       { "protocol" = "tcp" } }
+    { "service-name" = "z39.50"
+       { "port"     = "210" }
+       { "protocol" = "tcp" }
+       { "alias"    = "z3950" }
+       { "alias"    = "wais" }
+       { "#comment" = "NISO Z39.50 database" } }
+
+  (* We completely suppress empty comments *)
+  test Services.record get "mtp\t\t1911/tcp\t\t\t#\n" =
+    { "service-name" = "mtp"
+       { "port"     = "1911" }
+       { "protocol" = "tcp" } }
+
+  test Services.lns get "sql*net\t\t66/tcp\t\t\t# Oracle SQL*NET\n" =
+    { "service-name" = "sql*net"
+       { "port"     = "66" }
+       { "protocol" = "tcp" }
+       { "#comment" = "Oracle SQL*NET" } }
+
+  (* Fake service to check that we allow enoughspecial characters *)
+  test Services.lns get "special.*+-/chars\t0/proto\n" =
+    { "service-name" = "special.*+-/chars"
+      { "port" = "0" }
+      { "protocol" = "proto" } }
+
+  test Services.lns put "tcpmux          1/tcp # some comment\n"
+    after rm "/service-name/#comment" = "tcpmux          1/tcp\n"
+
diff --git a/lenses/tests/test_shells.aug b/lenses/tests/test_shells.aug
new file mode 100644 (file)
index 0000000..5dceca3
--- /dev/null
@@ -0,0 +1,15 @@
+(* Test for shells lens *)
+
+module Test_shells =
+
+   let conf = "# this is a comment
+
+/bin/bash
+/bin/tcsh
+"
+
+   test Shells.lns get conf =
+      { "#comment" = "this is a comment" }
+      {}
+      { "1" = "/bin/bash" }
+      { "2" = "/bin/tcsh" }
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
new file mode 100644 (file)
index 0000000..11ba8f2
--- /dev/null
@@ -0,0 +1,146 @@
+(* Test for shell lens *)
+module Test_shellvars =
+
+  let eth_static = "# Intel Corporation PRO/100 VE Network Connection
+DEVICE=eth0
+BOOTPROTO=static
+BROADCAST=172.31.0.255
+HWADDR=ab:cd:ef:12:34:56
+export IPADDR=172.31.0.31 # this is our IP
+#DHCP_HOSTNAME=host.example.com
+NETMASK=255.255.255.0
+NETWORK=172.31.0.0
+unset ONBOOT    #   We do not want this var
+"
+  let empty_val = "EMPTY=\nDEVICE=eth0\n"
+
+  let key_brack = "SOME_KEY[1]=\nDEVICE=eth0\n"
+
+  test Shellvars.lns get eth_static =
+    { "#comment" = "Intel Corporation PRO/100 VE Network Connection" }
+    { "DEVICE" = "eth0" }
+    { "BOOTPROTO" = "static" }
+    { "BROADCAST" = "172.31.0.255" }
+    { "HWADDR" = "ab:cd:ef:12:34:56" }
+    { "IPADDR" = "172.31.0.31"
+        { "export" }
+        { "#comment" = "this is our IP" } }
+    { "#comment" = "DHCP_HOSTNAME=host.example.com" }
+    { "NETMASK" = "255.255.255.0" }
+    { "NETWORK" = "172.31.0.0" }
+    { "@unset"   = "ONBOOT"
+        { "#comment" = "We do not want this var" } }
+
+  test Shellvars.lns put eth_static after
+      set "BOOTPROTO" "dhcp" ;
+      rm "IPADDR" ;
+      rm "BROADCAST" ;
+      rm "NETMASK" ;
+      rm "NETWORK"
+  = "# Intel Corporation PRO/100 VE Network Connection
+DEVICE=eth0
+BOOTPROTO=dhcp
+HWADDR=ab:cd:ef:12:34:56
+#DHCP_HOSTNAME=host.example.com
+unset ONBOOT    #   We do not want this var
+"
+  test Shellvars.lns get empty_val =
+    { "EMPTY" = "" } { "DEVICE" = "eth0" }
+
+  test Shellvars.lns get key_brack =
+    { "SOME_KEY[1]" = "" } { "DEVICE" = "eth0" }
+
+  test Shellvars.lns get "smartd_opts=\"-q never\"\n" =
+    { "smartd_opts" = "\"-q never\"" }
+
+  test Shellvars.lns get "var=val  \n" = { "var" = "val" }
+
+  test Shellvars.lns get ". /etc/java/java.conf\n" =
+    { ".source" = "/etc/java/java.conf" }
+
+  (* Quoted strings and other oddities *)
+  test Shellvars.lns get "var=\"foo 'bar'\"\n" =
+    { "var" = "\"foo 'bar'\"" }
+
+  test Shellvars.lns get "var='Some \"funny\" value'\n" =
+    { "var" = "'Some \"funny\" value'" }
+
+  test Shellvars.lns get "var=\"\\\"\"\n" =
+    { "var" = "\"\\\"\"" }
+
+  test Shellvars.lns get "var=\\\"\n" =
+    { "var" = "\\\"" }
+
+  test Shellvars.lns get "var=ab#c\n" =
+    { "var" = "ab"
+        { "#comment" = "c" } }
+
+  test Shellvars.lns get "var='ab#c'\n" =
+    { "var" = "'ab#c'" }
+
+  test Shellvars.lns get "var=\"ab#c\"\n" =
+    { "var" = "\"ab#c\"" }
+
+  (* For some reason, `` conflicts with comment_eol *)
+  test Shellvars.lns get "var=`ab#c`\n" =
+    { "var" = "`ab"
+       { "#comment" = "c`" } }
+
+  test Shellvars.lns get "var=`grep nameserver /etc/resolv.conf | head -1`\n" =
+    { "var" = "`grep nameserver /etc/resolv.conf | head -1`" }
+
+  test Shellvars.lns put "var=ab #c\n"
+    after rm "/var/#comment" = "var=ab\n"
+
+  test Shellvars.lns put "var=ab\n"
+    after set "/var/#comment" "this is a var" =
+       "var=ab # this is a var\n"
+
+  (* Handling of arrays *)
+  test Shellvars.lns get "var=(val1 \"val\\\"2\\\"\" val3)\n" =
+    { "var"
+        { "1" = "val1" }
+        { "2" = "\"val\\\"2\\\"\"" }
+        { "3" = "val3" } }
+
+  test Shellvars.lns get "var=()\n" = { "var" = "()" }
+
+  test Shellvars.lns put "var=()\n" after
+      set "var" "value"
+  = "var=value\n"
+
+  test Shellvars.lns put "var=(v1 v2)\n" after
+      rm "var/*" ;
+      set "var" "value"
+  = "var=value\n"
+
+  test Shellvars.lns put "var=(v1 v2)\n" after
+    set "var/3" "v3"
+  = "var=(v1 v2 v3)\n"
+
+  test Shellvars.lns get "var=(v1 v2   \n    \t v3)\n" =
+  { "var"
+    { "1" = "v1" }
+    { "2" = "v2" }
+    { "3" = "v3" } }
+
+  (* Allow spaces after/before opening/closing parens for array *)
+  test Shellvars.lns get "config_eth1=( \"10.128.0.48/24\" )\n" =
+  { "config_eth1"  { "1" = "\"10.128.0.48/24\"" } }
+
+  (* Bug 109: allow a bare export *)
+  test Shellvars.lns get "export FOO\n" =
+  { "@export" = "FOO" }
+
+  (* Bug 73: allow ulimit builtin *)
+  test Shellvars.lns get "ulimit -c unlimited\n" =
+  { "@builtin" = "ulimit" { "args" = "-c unlimited" } }
+
+  (* Bug 183: segfault on NULL value *)
+  test Shellvars.lns put "" after
+    clear "/key"
+  = *
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_shellvars_list.aug b/lenses/tests/test_shellvars_list.aug
new file mode 100644 (file)
index 0000000..5bc09e0
--- /dev/null
@@ -0,0 +1,119 @@
+(* Test for shell list handling lens *)
+module Test_shellvars_list =
+
+  let list_vals = "# Some comment
+MODULES_LOADED_ON_BOOT=\"ipv6 sunrpc\"
+
+DEFAULT_APPEND=\"showopts noresume console=tty0 console=ttyS0,115200n8 ro\"
+
+LOADER_TYPE=\"grub\"
+"
+
+  test Shellvars_list.lns get list_vals =
+    { "#comment" = "Some comment" }
+    { "MODULES_LOADED_ON_BOOT"
+      { "quote" = "\"" }
+      { "value" = "ipv6" }
+      { "value" = "sunrpc" } }
+    {  }
+    { "DEFAULT_APPEND"
+      { "quote" = "\"" }
+      { "value" = "showopts" }
+      { "value" = "noresume" }
+      { "value" = "console=tty0" }
+      { "value" = "console=ttyS0,115200n8" }
+      { "value" = "ro" } }
+    {  }
+    { "LOADER_TYPE"
+      { "quote" = "\"" }
+      { "value" = "grub" } }
+
+
+  (* append a value *)
+  test Shellvars_list.lns put "VAR=\"test1\t  \ntest2\"\n" after
+    set "VAR/value[last()+1]" "test3"
+    = "VAR=\"test1\t  \ntest2 test3\"\n"
+
+  (* in double quoted lists, single quotes and escaped values are allowed *)
+  test Shellvars_list.lns get "VAR=\"test'1 test2 a\ \\\"longer\\\"\ test\"\n" =
+    { "VAR"
+      { "quote" = "\"" }
+      { "value" = "test'1" }
+      { "value" = "test2" }
+      { "value" = "a\ \\\"longer\\\"\ test" } }
+
+  (* add new value, delete one and append something *)
+  test Shellvars_list.lns put list_vals after
+    set "FAILSAVE_APPEND/quote" "\"" ;
+    set "FAILSAVE_APPEND/value[last()+1]" "console=ttyS0" ;
+    rm "LOADER_TYPE" ;
+    rm "MODULES_LOADED_ON_BOOT/value[1]" ;
+    set "DEFAULT_APPEND/value[last()+1]" "teststring"
+    = "# Some comment
+MODULES_LOADED_ON_BOOT=\"sunrpc\"
+
+DEFAULT_APPEND=\"showopts noresume console=tty0 console=ttyS0,115200n8 ro teststring\"
+
+FAILSAVE_APPEND=\"console=ttyS0\"
+"
+
+  (* test of single quotes (leading/trailing whitespaces are kept *)
+  (* leading/trailing) *)
+  test Shellvars_list.lns put "VAR=' \t test1\t  \ntest2  '\n" after
+    set "VAR/value[last()+1]" "test3"
+    = "VAR=' \t test1\t  \ntest2 test3  '\n"
+
+  (* change quotes (leading/trailing whitespaces are lost *)
+  test Shellvars_list.lns put "VAR=' \t test1\t  \ntest2  '\n" after
+    set "VAR/quote" "\""
+    = "VAR=\"test1\t  \ntest2\"\n"
+
+  (* double quotes are allowed in single quoted lists *)
+  test Shellvars_list.lns get "VAR='test\"1 test2'\n" =
+    { "VAR"
+      { "quote" = "'" }
+      { "value" = "test\"1" }
+      { "value" = "test2" } }
+
+  (* emtpy list with quotes *)
+  test Shellvars_list.lns get "VAR=''\n" =
+    { "VAR"
+      { "quote" = "'" } }
+
+  (* unquoted value *)
+  test Shellvars_list.lns get "VAR=test\n" =
+    { "VAR"
+      { "quote" = "" }
+      { "value" = "test" } }
+
+  (* uquoted value with escaped space etc. *)
+  test Shellvars_list.lns get "VAR=a\\ \\\"long\\\"\\ test\n" =
+    { "VAR"
+      { "quote" = "" }
+      { "value" = "a\\ \\\"long\\\"\\ test" } }
+
+  (* append to unquoted value *)
+  test Shellvars_list.lns put "VAR=test1\n" after
+    set "VAR/quote" "\"";
+    set "VAR/value[last()+1]" "test2"
+    = "VAR=\"test1 test2\"\n"
+
+  (* empty entry *)
+  test Shellvars_list.lns get "VAR=\n" =
+    { "VAR"
+      { "quote" = "" } }
+
+  (* set value w/o quotes to empty value... *)
+  test Shellvars_list.lns put "VAR=\n" after
+    set "VAR/value[last()+1]" "test"
+    = "VAR=test\n"
+
+  (* ... or no value *)
+  test Shellvars_list.lns put "" after
+    set "VAR/quote" "";
+    set "VAR/value[1]" "test"
+    = "VAR=test\n"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_slapd.aug b/lenses/tests/test_slapd.aug
new file mode 100644 (file)
index 0000000..e477342
--- /dev/null
@@ -0,0 +1,65 @@
+module Test_slapd =
+
+let conf = "# This is the main slapd configuration file. See slapd.conf(5) for more
+# info on the configuration options.
+
+#######################################################################
+# Global Directives:
+
+# Features to permit
+#allow bind_v2
+
+# Schema and objectClass definitions
+include         /etc/ldap/schema/core.schema
+
+#######################################################################
+# Specific Directives for database #1, of type hdb:
+# Database specific directives apply to this databasse until another
+# 'database' directive occurs
+database        hdb
+
+# The base of your directory in database #1
+suffix          \"dc=nodomain\"
+
+access to attrs=userPassword,shadowLastChange
+        by dn=\"cn=admin,dc=nodomain\" write
+        by anonymous auth
+        by self write
+        by * none
+"
+
+test Slapd.lns get conf =
+  { "#comment" = "This is the main slapd configuration file. See slapd.conf(5) for more" }
+  { "#comment" = "info on the configuration options." }
+  {}
+  { "#comment" = "######################################################################" }
+  { "#comment" = "Global Directives:"}
+  {}
+  { "#comment" = "Features to permit" }
+  { "#comment" = "allow bind_v2" }
+  {}
+  { "#comment" = "Schema and objectClass definitions" }
+  { "include"  = "/etc/ldap/schema/core.schema" }
+  {}
+  { "#comment" = "######################################################################" }
+  { "#comment" = "Specific Directives for database #1, of type hdb:" }
+  { "#comment" = "Database specific directives apply to this databasse until another" }
+  { "#comment" = "'database' directive occurs" }
+  { "database" = "hdb"
+     {}
+     { "#comment" = "The base of your directory in database #1" }
+     { "suffix"   = "\"dc=nodomain\"" }
+     {}
+     { "access to" = "attrs=userPassword,shadowLastChange"
+        { "by"
+           { "who" = "dn=\"cn=admin,dc=nodomain\"" }
+           { "what" = "write" } }
+        { "by"
+           { "who" = "anonymous" }
+           { "what" = "auth" } }
+        { "by"
+           { "who" = "self" }
+           { "what" = "write" } }
+        { "by"
+           { "who" = "*" }
+           { "what" = "none" } } } }
diff --git a/lenses/tests/test_solaris_system.aug b/lenses/tests/test_solaris_system.aug
new file mode 100644 (file)
index 0000000..511337e
--- /dev/null
@@ -0,0 +1,104 @@
+(* Test for system lens *)
+module Test_solaris_system =
+
+  let conf = "*ident  \"@(#)system 1.18    97/06/27 SMI\" /* SVR4 1.5 */
+*
+* SYSTEM SPECIFICATION FILE
+*
+
+moddir: /kernel /usr/kernel /other/modules
+
+rootfs:ufs
+rootdev:/sbus@1,f8000000/esp@0,800000/sd@3,0:a
+
+include: win
+include: sys/shmsys
+
+exclude: win
+exclude: sys/shmsys
+
+forceload: drv/foo
+forceload: drv/ssd
+
+set nautopush=32
+set noexec_user_stack=1
+set zfs:zfs_arc_max=12884901888
+set test_module:debug = 0x13
+set fcp:ssfcp_enable_auto_configuration=1
+set scsi_options = 0x7F8
+set moddebug & ~0x880
+set moddebug | 0x40
+"
+
+  test Solaris_System.lns get conf =
+    { "#comment" = "ident  \"@(#)system 1.18    97/06/27 SMI\" /* SVR4 1.5 */" }
+    { }
+    { "#comment" = "SYSTEM SPECIFICATION FILE" }
+    { }
+    { }
+    { "moddir"
+        { "1" = "/kernel" }
+        { "2" = "/usr/kernel" }
+        { "3" = "/other/modules" } }
+    { }
+    { "rootfs" = "ufs" }
+    { "rootdev" = "/sbus@1,f8000000/esp@0,800000/sd@3,0:a" }
+    { }
+    { "include" = "win" }
+    { "include" = "sys/shmsys" }
+    { }
+    { "exclude" = "win" }
+    { "exclude" = "sys/shmsys" }
+    { }
+    { "forceload" = "drv/foo" }
+    { "forceload" = "drv/ssd" }
+    { }
+    { "set"
+        { "variable" = "nautopush" }
+        { "operator" = "=" }
+        { "value" = "32" } }
+    { "set"
+        { "variable" = "noexec_user_stack" }
+        { "operator" = "=" }
+        { "value" = "1" } }
+    { "set"
+        { "module" = "zfs" }
+        { "variable" = "zfs_arc_max" }
+        { "operator" = "=" }
+        { "value" = "12884901888" } }
+    { "set"
+        { "module" = "test_module" }
+        { "variable" = "debug" }
+        { "operator" = "=" }
+        { "value" = "0x13" } }
+    { "set"
+        { "module" = "fcp" }
+        { "variable" = "ssfcp_enable_auto_configuration" }
+        { "operator" = "=" }
+        { "value" = "1" } }
+    { "set"
+        { "variable" = "scsi_options" }
+        { "operator" = "=" }
+        { "value" = "0x7F8" } }
+    { "set"
+        { "variable" = "moddebug" }
+        { "operator" = "&" }
+        { "value" = "~0x880" } }
+    { "set"
+        { "variable" = "moddebug" }
+        { "operator" = "|" }
+        { "value" = "0x40" } }
+
+(* Check that moddir supports colons and spaces *)
+  let moddir_colons = "moddir:/kernel:/usr/kernel:/other/modules
+"
+
+  test Solaris_System.lns get moddir_colons =
+    { "moddir"
+        { "1" = "/kernel" }
+        { "2" = "/usr/kernel" }
+        { "3" = "/other/modules" } }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_soma.aug b/lenses/tests/test_soma.aug
new file mode 100644 (file)
index 0000000..5346af6
--- /dev/null
@@ -0,0 +1,15 @@
+module Test_soma =
+
+let conf = "# comment
+User = soma
+
+OptionsItem = \"-msglevel avsync=5 -ao jack -af volnorm -novideo -noconsolecontrols -nojoystick -nolirc -nomouseinput\"
+Debug = 3
+"
+
+test Soma.lns get conf =
+   { "#comment" = "comment" }
+   { "User" = "soma" }
+   {}
+   { "OptionsItem" = "\"-msglevel avsync=5 -ao jack -af volnorm -novideo -noconsolecontrols -nojoystick -nolirc -nomouseinput\"" }
+   { "Debug" = "3" }
diff --git a/lenses/tests/test_spacevars.aug b/lenses/tests/test_spacevars.aug
new file mode 100644 (file)
index 0000000..2eea0be
--- /dev/null
@@ -0,0 +1,21 @@
+module Test_spacevars =
+
+    let conf ="# This a spaced key/value configuration file.
+keyword value
+
+# I like comments
+very.useful-key my=value
+
+
+"
+
+    let lns = Spacevars.lns (Spacevars.entry Spacevars.entry_re)
+
+    test lns get conf =
+        { "#comment" = "This a spaced key/value configuration file."}
+        { "keyword" = "value" }
+        {}
+        { "#comment" = "I like comments"}
+        { "very.useful-key" = "my=value" }
+       {}
+       {}
diff --git a/lenses/tests/test_squid.aug b/lenses/tests/test_squid.aug
new file mode 100644 (file)
index 0000000..0f37ab1
--- /dev/null
@@ -0,0 +1,214 @@
+module Test_squid =
+
+let conf = "# comment at the beginning of the file
+
+auth_param negotiate children 5
+acl many_spaces rep_header Content-Disposition -i [[:space:]]{3,}
+acl CONNECT method CONNECT
+# comment in the middle
+  acl local_network src 192.168.1.0/24
+
+http_access allow manager localhost
+http_access allow local_network
+"
+
+test Squid.lns get conf =
+  { "#comment" = "comment at the beginning of the file" }
+  {}
+  { "auth_param"
+     { "scheme" = "negotiate" }
+     { "parameter" = "children" }
+     { "setting" = "5" } }
+  { "acl"
+     { "many_spaces"
+        { "type" = "rep_header" }
+        { "setting" = "Content-Disposition" }
+        { "parameters"
+           { "1" = "-i"  }
+          { "2" = "[[:space:]]{3,}" } } } }
+  { "acl"
+     { "CONNECT"
+        { "type" = "method" }
+        { "setting" = "CONNECT" } } }
+  { "#comment" = "comment in the middle" }
+  { "acl"
+     { "local_network"
+        { "type" = "src" }
+        { "setting" = "192.168.1.0/24" } } }
+  {}
+  { "http_access"
+     { "allow" = "manager"
+           { "parameters"
+               { "1" = "localhost" } } } }
+  { "http_access"
+     { "allow" = "local_network" } }
+
+(*
+  This tests the Debian lenny default squid.conf
+  Comments were stripped out
+*)
+
+let debian_lenny_default = "acl all src all
+acl manager proto cache_object
+acl localhost src 127.0.0.1/32
+acl to_localhost dst 127.0.0.0/8
+acl purge method PURGE
+acl CONNECT method CONNECT
+http_access allow manager localhost
+http_access deny manager
+http_access allow purge localhost
+http_access deny purge
+http_access deny !Safe_ports
+http_access deny CONNECT !SSL_ports
+http_access allow localhost
+http_access deny all
+icp_access allow localnet
+icp_access deny all
+http_port 3128
+hierarchy_stoplist cgi-bin ?
+access_log /var/log/squid/access.log squid
+refresh_pattern ^ftp:           1440    20%     10080
+refresh_pattern ^gopher:        1440    0%      1440
+refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
+refresh_pattern (Release|Package(.gz)*)$        0       20%     2880
+refresh_pattern .               0       20%     4320   ignore-reload ignore-auth # testing options
+acl shoutcast rep_header X-HTTP09-First-Line ^ICY\s[0-9]
+upgrade_http0.9 deny shoutcast
+acl apache rep_header Server ^Apache
+broken_vary_encoding allow apache
+extension_methods REPORT MERGE MKACTIVITY CHECKOUT
+hosts_file /etc/hosts
+coredump_dir /var/spool/squid
+"
+
+test Squid.lns get debian_lenny_default =
+  { "acl"
+    { "all"
+      { "type" = "src" }
+      { "setting" = "all" }
+    }
+  }
+  { "acl"
+    { "manager"
+      { "type" = "proto" }
+      { "setting" = "cache_object" }
+    }
+  }
+  { "acl"
+    { "localhost"
+      { "type" = "src" }
+      { "setting" = "127.0.0.1/32" }
+    }
+  }
+  { "acl"
+    { "to_localhost"
+      { "type" = "dst" }
+      { "setting" = "127.0.0.0/8" }
+    }
+  }
+  { "acl"
+    { "purge"
+      { "type" = "method" }
+      { "setting" = "PURGE" }
+    }
+  }
+  { "acl"
+    { "CONNECT"
+      { "type" = "method" }
+      { "setting" = "CONNECT" }
+    }
+  }
+  { "http_access"
+    { "allow" = "manager"
+      { "parameters"
+        { "1" = "localhost" }
+      }
+    }
+  }
+  { "http_access"
+    { "deny" = "manager" }
+  }
+  { "http_access"
+    { "allow" = "purge"
+      { "parameters"
+        { "1" = "localhost" }
+      }
+    }
+  }
+  { "http_access"
+    { "deny" = "purge" }
+  }
+  { "http_access"
+    { "deny" = "!Safe_ports" }
+  }
+  { "http_access"
+    { "deny" = "CONNECT"
+      { "parameters"
+        { "1" = "!SSL_ports" }
+      }
+    }
+  }
+  { "http_access"
+    { "allow" = "localhost" }
+  }
+  { "http_access"
+    { "deny" = "all" }
+  }
+  { "icp_access" = "allow localnet" }
+  { "icp_access" = "deny all" }
+  { "http_port" = "3128" }
+  { "hierarchy_stoplist" = "cgi-bin ?" }
+  { "access_log" = "/var/log/squid/access.log squid" }
+  { "refresh_pattern" = "^ftp:"
+       { "min" = "1440" }
+       { "percent" = "20" }
+       { "max" = "10080" } }
+  { "refresh_pattern" = "^gopher:"
+       { "min" = "1440" }
+       { "percent" = "0" }
+       { "max" = "1440" } }
+  { "refresh_pattern" = "(/cgi-bin/|\?)"
+       { "case_insensitive" }
+       { "min" = "0" }
+       { "percent" = "0" }
+       { "max" = "0" } }
+  { "refresh_pattern" = "(Release|Package(.gz)*)$"
+       { "min" = "0" }
+       { "percent" = "20" }
+       { "max" = "2880" } }
+  { "refresh_pattern" = "."
+       { "min" = "0" }
+       { "percent" = "20" }
+       { "max" = "4320" }
+       { "option" = "ignore-reload" }
+       { "option" = "ignore-auth" }
+       { "#comment" = "testing options" } }
+  { "acl"
+    { "shoutcast"
+      { "type" = "rep_header" }
+      { "setting" = "X-HTTP09-First-Line" }
+      { "parameters"
+        { "1" = "^ICY\s[0-9]" }
+      }
+    }
+  }
+  { "upgrade_http0.9"
+      { "deny" = "shoutcast" } }
+  { "acl"
+    { "apache"
+      { "type" = "rep_header" }
+      { "setting" = "Server" }
+      { "parameters"
+        { "1" = "^Apache" }
+      }
+    }
+  }
+  { "broken_vary_encoding"
+      { "allow" = "apache" } }
+  { "extension_methods"
+      { "1" = "REPORT" }
+      { "2" = "MERGE" }
+      { "3" = "MKACTIVITY" }
+      { "4" = "CHECKOUT" } }
+  { "hosts_file" = "/etc/hosts" }
+  { "coredump_dir" = "/var/spool/squid" }
diff --git a/lenses/tests/test_sshd.aug b/lenses/tests/test_sshd.aug
new file mode 100644 (file)
index 0000000..afc74ab
--- /dev/null
@@ -0,0 +1,76 @@
+module Test_sshd =
+
+  let accept_env = "Protocol 2
+AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
+AcceptEnv LC_IDENTIFICATION LC_ALL\n"
+
+  test Sshd.lns get accept_env =
+    { "Protocol" = "2" }
+    { "AcceptEnv"
+        { "1" = "LC_PAPER" }
+        { "2" = "LC_NAME" }
+        { "3" = "LC_ADDRESS" }
+        { "4" = "LC_TELEPHONE" }
+        { "5" = "LC_MEASUREMENT" } }
+    { "AcceptEnv"
+        { "6" = "LC_IDENTIFICATION" }
+        { "7" = "LC_ALL" } }
+
+
+  test Sshd.lns get "HostKey /etc/ssh/ssh_host_rsa_key
+HostKey /etc/ssh/ssh_host_dsa_key\n" =
+    { "HostKey" = "/etc/ssh/ssh_host_rsa_key" }
+    { "HostKey" = "/etc/ssh/ssh_host_dsa_key" }
+
+
+  test Sshd.lns put accept_env after
+      rm "AcceptEnv";
+      rm "AcceptEnv";
+      set "Protocol" "1.5";
+      set "X11Forwarding" "yes"
+   = "Protocol 1.5\nX11Forwarding yes\n"
+
+  test Sshd.lns get "AuthorizedKeysFile  %h/.ssh/authorized_keys\n" =
+    { "AuthorizedKeysFile" = "%h/.ssh/authorized_keys" }
+
+  test Sshd.lns get "Subsystem sftp /usr/lib/openssh/sftp-server\n" =
+    { "Subsystem"
+       { "sftp" = "/usr/lib/openssh/sftp-server" } }
+
+
+
+  let match_blocks = "X11Forwarding yes
+Match User sarko Group pres.*
+  Banner /etc/bienvenue.txt
+  X11Forwarding no
+Match User bush Group pres.* Host white.house.*
+Banner /etc/welcome.txt
+"
+  test Sshd.lns get match_blocks =
+    { "X11Forwarding" = "yes"}
+      { "Match"
+         { "Condition" { "User" = "sarko"   }
+                       { "Group" = "pres.*" } }
+         { "Settings"  { "Banner" = "/etc/bienvenue.txt" }
+                               { "X11Forwarding" = "no" } } }
+      { "Match"
+         { "Condition" { "User" = "bush"    }
+                       { "Group" = "pres.*" }
+                       { "Host"  = "white.house.*" } }
+         { "Settings"  { "Banner" = "/etc/welcome.txt" } } }
+
+  test Sshd.lns put match_blocks after
+    insb "Subsystem" "/Match[1]";
+    set "/Subsystem/sftp" "/usr/libexec/openssh/sftp-server"
+  = "X11Forwarding yes
+Subsystem sftp /usr/libexec/openssh/sftp-server
+Match User sarko Group pres.*
+  Banner /etc/bienvenue.txt
+  X11Forwarding no
+Match User bush Group pres.* Host white.house.*
+Banner /etc/welcome.txt\n"
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_sudoers.aug b/lenses/tests/test_sudoers.aug
new file mode 100644 (file)
index 0000000..1624691
--- /dev/null
@@ -0,0 +1,171 @@
+module Test_sudoers =
+
+   let conf = "
+  Host_Alias LOCALNET = 192.168.0.0/24, localhost
+
+   # User alias specification
+
+User_Alias EXAMPLE_ADMINS = cslack, EXAMPLE\\\\cslack,\
+          EXAMPLE\\\\jmalstrom
+
+# Cmnd alias specification
+
+Cmnd_Alias \
+    DEBIAN_TOOLS \
+    = \
+    /usr/bin/apt-get,\
+    /usr/bin/auto-get,   \
+    /usr/bin/dpkg, /usr/bin/dselect, /usr/sbin/dpkg-reconfigure \
+    : PBUILDER = /usr/sbin/pbuilder
+
+   Cmnd_Alias ICAL = /bin/cat /home/rpinson/.kde/share/apps/korganizer/std.ics
+
+       Defaults@LOCALNET        !lecture, \
+   \t\t tty_tickets,!fqdn, !!env_reset
+
+Defaults:buildd env_keep+=\"APT_CONFIG DEBIAN_FRONTEND SHELL\"
+
+# User privilege specification
+root    ALL=(ALL) ALL
+
+# Members of the admin group may gain root privileges
+%admin  ALL=(ALL) ALL, NOPASSWD  :     NOSETENV: \
+   DEBIAN_TOOLS
+%pbuilder       LOCALNET = NOPASSWD: PBUILDER
+www-data +biglab=(rpinson)NOEXEC: ICAL \
+        : \
+        localhost = NOPASSWD:  /usr/bin/test
+
+       +secretaries           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
+
+@my\ admin\ group ALL=(root) NOPASSWD: /usr/bin/python /usr/local/sbin/filterlog -iu\\=www /var/log/something.log
+#includedir /etc/sudoers.d
+#include /etc/sudoers.d
+"
+
+   test Sudoers.lns get conf =
+      {}
+      { "Host_Alias"
+          { "alias"
+             { "name" = "LOCALNET" }
+              { "host" = "192.168.0.0/24" }
+              { "host" = "localhost" } } }
+      {}
+      { "#comment" = "User alias specification" }
+      {}
+      { "User_Alias"
+          { "alias"
+              { "name" = "EXAMPLE_ADMINS" }
+              { "user" = "cslack" }
+              { "user" = "EXAMPLE\\\\cslack" }
+              { "user" = "EXAMPLE\\\\jmalstrom" } } }
+      {}
+      { "#comment" = "Cmnd alias specification" }
+      {}
+      { "Cmnd_Alias"
+          { "alias"
+              { "name"    = "DEBIAN_TOOLS" }
+              { "command" = "/usr/bin/apt-get" }
+             { "command" = "/usr/bin/auto-get" }
+             { "command" = "/usr/bin/dpkg" }
+             { "command" = "/usr/bin/dselect" }
+             { "command" = "/usr/sbin/dpkg-reconfigure" } }
+          { "alias"
+             { "name" = "PBUILDER" }
+              { "command" = "/usr/sbin/pbuilder" } } }
+      {}
+      { "Cmnd_Alias"
+          { "alias"
+             { "name" = "ICAL" }
+              { "command" = "/bin/cat /home/rpinson/.kde/share/apps/korganizer/std.ics" } } }
+      {}
+      { "Defaults"
+          { "type"      = "@LOCALNET" }
+             { "lecture" { "negate" } }
+          { "tty_tickets" }
+          { "fqdn" { "negate" } }
+          { "env_reset" } }
+      {}
+      { "Defaults"
+          { "type"      = ":buildd" }
+             { "env_keep"
+              { "append" }
+              { "var" = "APT_CONFIG" }
+              { "var" = "DEBIAN_FRONTEND" }
+              { "var" = "SHELL" } } }
+      {}
+      { "#comment" = "User privilege specification" }
+      { "spec"
+          { "user" = "root" }
+          { "host_group"
+             { "host" = "ALL" }
+             { "command" = "ALL"
+                 { "runas_user"  = "ALL" } } } }
+      {}
+      { "#comment" = "Members of the admin group may gain root privileges" }
+      { "spec"
+          { "user"    = "%admin" }
+         { "host_group"
+             { "host" = "ALL" }
+             { "command" = "ALL"
+                 { "runas_user" = "ALL" } }
+             { "command" = "DEBIAN_TOOLS"
+                 { "tag"  = "NOPASSWD" }
+                 { "tag"  = "NOSETENV" } } } }
+      { "spec"
+          { "user"    = "%pbuilder" }
+         { "host_group"
+             { "host" = "LOCALNET" }
+             { "command" = "PBUILDER"
+                 { "tag" = "NOPASSWD" } } } }
+      { "spec"
+          { "user"    = "www-data" }
+         { "host_group"
+             { "host" = "+biglab" }
+             { "command" = "ICAL"
+                 { "runas_user" = "rpinson" }
+                 { "tag" = "NOEXEC" } } }
+         { "host_group"
+             { "host" = "localhost" }
+             { "command" = "/usr/bin/test"
+                 { "tag" = "NOPASSWD" } } } }
+      {}
+      { "spec"
+          { "user"    = "+secretaries" }
+         { "host_group"
+             { "host" = "ALPHA" }
+             { "command" = "/usr/bin/su [!-]*" }
+             { "command" = "!/usr/bin/su *root*" } } }
+      {}
+      { "spec"
+          { "user"    = "@my\ admin\ group" }
+          { "host_group"
+              { "host" = "ALL" }
+              { "command" = "/usr/bin/python /usr/local/sbin/filterlog -iu\\=www /var/log/something.log"
+                  { "runas_user" = "root" }
+                  { "tag" = "NOPASSWD" }
+              }
+          }
+      }
+      { "#includedir" = "/etc/sudoers.d" }
+      { "#include" = "/etc/sudoers.d" }
+
+test Sudoers.parameter_integer_bool
+    put "umask = 022"
+    after set "/umask/negate" ""  = "!umask"
+
+test Sudoers.parameter_integer_bool
+    put "!!!!!umask"
+    after rm "/umask/negate"; set "/umask" "022" = "!!!!umask = 022"
+
+test Sudoers.parameter_integer_bool put "!!!!umask = 022" after
+    set "/umask/negate" "" = "!!!!!umask"
+
+test Sudoers.parameter_integer_bool get "!!!umask = 022" = *
+
+(* BZ 566134 *)
+
+let s = "Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin\n"
+test Sudoers.lns get s =
+  { "Defaults"
+    { "secure_path" = "/sbin:/bin:/usr/sbin:/usr/bin" } }
diff --git a/lenses/tests/test_sysconfig.aug b/lenses/tests/test_sysconfig.aug
new file mode 100644 (file)
index 0000000..ef8abd4
--- /dev/null
@@ -0,0 +1,110 @@
+(* Test for sysconfig lens *)
+module Test_sysconfig =
+
+  let eth_static = "# Intel Corporation PRO/100 VE Network Connection
+DEVICE=eth0
+BOOTPROTO=static
+BROADCAST=172.31.0.255
+HWADDR=ab:cd:ef:12:34:56
+export IPADDR=172.31.0.31
+#DHCP_HOSTNAME=host.example.com
+NETMASK=255.255.255.0
+NETWORK=172.31.0.0
+unset ONBOOT
+"
+  let empty_val = "EMPTY=\nDEVICE=eth0\n"
+
+  let key_brack = "SOME_KEY[1]=\nDEVICE=eth0\n"
+
+  test Sysconfig.lns get eth_static =
+    { "#comment" = "Intel Corporation PRO/100 VE Network Connection" }
+    { "DEVICE" = "eth0" }
+    { "BOOTPROTO" = "static" }
+    { "BROADCAST" = "172.31.0.255" }
+    { "HWADDR" = "ab:cd:ef:12:34:56" }
+    { "IPADDR" = "172.31.0.31"
+        { "export" } }
+    { "#comment" = "DHCP_HOSTNAME=host.example.com" }
+    { "NETMASK" = "255.255.255.0" }
+    { "NETWORK" = "172.31.0.0" }
+    { "@unset"   = "ONBOOT" }
+
+  test Sysconfig.lns put eth_static after
+      set "BOOTPROTO" "dhcp" ;
+      rm "IPADDR" ;
+      rm "BROADCAST" ;
+      rm "NETMASK" ;
+      rm "NETWORK"
+  = "# Intel Corporation PRO/100 VE Network Connection
+DEVICE=eth0
+BOOTPROTO=dhcp
+HWADDR=ab:cd:ef:12:34:56
+#DHCP_HOSTNAME=host.example.com
+unset ONBOOT
+"
+  test Sysconfig.lns get empty_val =
+    { "EMPTY" = "" } { "DEVICE" = "eth0" }
+
+  test Sysconfig.lns get key_brack =
+    { "SOME_KEY[1]" = "" } { "DEVICE" = "eth0" }
+
+  test Sysconfig.lns get "smartd_opts=\"-q never\"\n" =
+    { "smartd_opts" = "-q never" }
+
+  test Sysconfig.lns get "var=val  \n" = { "var" = "val" }
+
+  test Sysconfig.lns get ". /etc/java/java.conf\n" =
+    { ".source" = "/etc/java/java.conf" }
+
+  (* Quoted strings and other oddities *)
+  test Sysconfig.lns get "var=\"foo 'bar'\"\n" =
+    { "var" = "foo 'bar'" }
+
+  test Sysconfig.lns get "var=\"eth0\"\n" =
+    { "var" = "eth0" }
+
+  test Sysconfig.lns get "var='eth0'\n" =
+    { "var" = "eth0" }
+
+  test Sysconfig.lns get "var='Some \"funny\" value'\n" =
+    { "var" = "Some \"funny\" value" }
+
+  test Sysconfig.lns get "var=\"\\\"\"\n" =
+    { "var" = "\\\"" }
+
+  test Sysconfig.lns get "var=\\\"\n" =
+    { "var" = "\\\"" }
+
+  test Sysconfig.lns get "var=ab#c\n" =
+    { "var" = "ab#c" }
+
+  (* We don't handle backticks *)
+  test Sysconfig.lns get
+      "var=`grep nameserver /etc/resolv.conf | head -1`\n" = *
+
+  (* We don't handle comments at the end of a line yet *)
+  test Sysconfig.lns get "var=ab #c\n" = *
+
+  (* Bug 109: allow a bare export *)
+  test Sysconfig.lns get "export FOO\n" =
+  { "@export" = "FOO" }
+
+  (* Check we put quotes in when changes require them *)
+  test Sysconfig.lns put "var=\"v\"\n" after rm "/foo" =
+    "var=\"v\"\n"
+
+  test Sysconfig.lns put "var=v\n" after set "/var" "v w"=
+    "var=\"v w\"\n"
+
+  test Sysconfig.lns put "var='v'\n" after set "/var" "v w"=
+    "var='v w'\n"
+
+  test Sysconfig.lns put "var=v\n" after set "/var" "v'w"=
+    "var=\"v'w\"\n"
+
+  test Sysconfig.lns put "var=v\n" after set "/var" "v\"w"=
+    "var='v\"w'\n"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_sysctl.aug b/lenses/tests/test_sysctl.aug
new file mode 100644 (file)
index 0000000..ea51098
--- /dev/null
@@ -0,0 +1,44 @@
+(* Test for sysctl lens *)
+module Test_sysctl =
+
+  let default_sysctl = "# Kernel sysctl configuration file
+# Controls IP packet forwarding
+net.ipv4.ip_forward = 0
+
+net.ipv4.conf.default.rp_filter = 1
+net.ipv4.conf.default.accept_source_route = \t0
+kernel.sysrq  =  0
+
+; Semicolon comments are also allowed
+net.ipv4.tcp_mem = \t393216 524288 786432
+"
+
+  test Sysctl.lns get default_sysctl =
+    { "#comment" = "Kernel sysctl configuration file" }
+    { "#comment" = "Controls IP packet forwarding"}
+    { "net.ipv4.ip_forward" = "0" }
+    { }
+    { "net.ipv4.conf.default.rp_filter" = "1" }
+    { "net.ipv4.conf.default.accept_source_route" = "0" }
+    { "kernel.sysrq" = "0" }
+    { }
+    { "#comment" = "Semicolon comments are also allowed" }
+    { "net.ipv4.tcp_mem" = "393216 524288 786432" }
+
+  test Sysctl.lns put default_sysctl after
+    set "net.ipv4.ip_forward" "1" ;
+    rm "net.ipv4.conf.default.rp_filter" ;
+    rm "net.ipv4.conf.default.accept_source_route" ;
+    rm "kernel.sysrq"
+  = "# Kernel sysctl configuration file
+# Controls IP packet forwarding
+net.ipv4.ip_forward = 1
+
+
+; Semicolon comments are also allowed
+net.ipv4.tcp_mem = \t393216 524288 786432
+"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_syslog.aug b/lenses/tests/test_syslog.aug
new file mode 100644 (file)
index 0000000..83eb563
--- /dev/null
@@ -0,0 +1,301 @@
+module Test_syslog =
+
+       let conf="# $FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $
+# 
+
+daemon.info                                     /var/log/cvsupd.log
+security.*                                     -/var/log/security
+*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err  /var/log/messages
+uucp,news.crit                                          /var/log/spooler
+*.emerg                                                *
+daemon.!info                                   /var/log/foo
+daemon.<=info                                  /var/log/foo
+daemon.!<=info                                 /var/log/foo
+*.*                                            @syslog.far.away
+*.*                                            @syslog.far.away:123
+*.*                                            foo,bar
+*.*                                            |\"/usr/bin/soft arg\"
+!startslip
+# get that out
+*.*                                            /var/log/slip.log
+!pppd,ppp
+
+*.*                                            /var/log/ppp.log
+!+startslip
+*.*                                            /var/log/slip.log
+!-startslip
+*.*                                            /var/log/slip.log
+#!pppd
+*.*                                            /var/log/ppp.log
++foo.example.com
+daemon.info                                     /var/log/cvsupd.log
++foo.example.com,bar.example.com
+daemon.info                                     /var/log/cvsupd.log
+#+bar.example.com
+daemon.info                                     /var/log/cvsupd.log
+-foo.example.com
+daemon.info                                     /var/log/cvsupd.log
++*
+daemon.info                                     /var/log/cvsupd.log
+!*
+daemon.info                                     /var/log/cvsupd.log
+*.=debug;\
+        auth,authpriv.none;\
+        news.none;mail.none     -/var/log/debug
+"
+
+       test Syslog.lns get conf =
+          { "#comment" = "$FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $" }
+         { }
+         { }
+         { "entry"
+           { "selector" { "facility" = "daemon" } { "level" = "info" } }
+           { "action" { "file" = "/var/log/cvsupd.log" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "security" } { "level" = "*" } }
+           { "action" { "no_sync" } { "file" = "/var/log/security" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "notice" } }
+           { "selector" { "facility" = "authpriv" } { "level" = "none" } }
+           { "selector" { "facility" = "kern" } { "level" = "debug" } }
+           { "selector" { "facility" = "lpr" } { "level" = "info" } }
+           { "selector" { "facility" = "mail" } { "level" = "crit" } }
+           { "selector" { "facility" = "news" } { "level" = "err" } }
+           { "action" { "file" = "/var/log/messages" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "uucp" } { "facility" = "news" } { "level" = "crit" } }
+           { "action" { "file" = "/var/log/spooler" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "emerg" } }
+           { "action" { "user" = "*" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "daemon" } { "comparison" = "!" } { "level" = "info" } }
+           { "action" { "file" = "/var/log/foo" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "daemon" } { "comparison" = "<=" } { "level" = "info" } }
+           { "action" { "file" = "/var/log/foo" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "daemon" } { "comparison" = "!<=" } { "level" = "info" } }
+           { "action" { "file" = "/var/log/foo" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "*" } }
+           { "action" { "hostname" = "syslog.far.away" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "*" } }
+           { "action" { "hostname" = "syslog.far.away" } { "port" = "123" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "*" } }
+           { "action" { "user" = "foo" } { "user" = "bar" } }
+         }
+         { "entry"
+           { "selector" { "facility" = "*" } { "level" = "*" } }
+           { "action" { "program" = "\"/usr/bin/soft arg\"" } }
+         }
+         { "program"
+           { "program" = "startslip" }
+           { "#comment" = "get that out" }
+           { "entry"
+             { "selector" { "facility" = "*" } { "level" = "*" } }
+             { "action" { "file" = "/var/log/slip.log" } }
+           }
+         }
+         { "program"
+           { "program" = "pppd" }
+           { "program" = "ppp" }
+           { }
+           { "entry"
+             { "selector" { "facility" = "*" } { "level" = "*" } }
+             { "action" { "file" = "/var/log/ppp.log" } }
+           }
+         }
+         { "program"
+           { "program" = "startslip" }
+           { "entry"
+             { "selector" { "facility" = "*" } { "level" = "*" } }
+             { "action" { "file" = "/var/log/slip.log" } }
+           }
+         }
+         { "program"
+           { "reverse" }
+           { "program" = "startslip" }
+           { "entry"
+             { "selector" { "facility" = "*" } { "level" = "*" } }
+             { "action" { "file" = "/var/log/slip.log" } }
+           }
+         }
+         { "program"
+           { "program" = "pppd" }
+           { "entry"
+             { "selector" { "facility" = "*" } { "level" = "*" } }
+             { "action" { "file" = "/var/log/ppp.log" } }
+           }
+         }
+         { "hostname"
+           { "hostname" = "foo.example.com" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } }
+           }
+         }
+         { "hostname"
+           { "hostname" = "foo.example.com" }
+           { "hostname" = "bar.example.com" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } }
+           }
+         }
+         { "hostname"
+           { "hostname" = "bar.example.com" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } }
+           }
+         }
+         { "hostname"
+           { "reverse" }
+           { "hostname" = "foo.example.com" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } }
+           }
+         }
+         { "hostname"
+           { "hostname" = "*" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } }
+           }
+         }
+         { "program"
+           { "program" = "*" }
+           { "entry"
+             { "selector" { "facility" = "daemon" } { "level" = "info" } }
+             { "action" { "file" = "/var/log/cvsupd.log" } } }
+            { "entry"
+              { "selector" { "facility" = "*" } { "comparison" = "=" } { "level" = "debug" } }
+              { "selector" { "facility" = "auth" } { "facility" = "authpriv" } { "level" = "none" } }
+              { "selector" { "facility" = "news" } { "level" = "none" } }
+              { "selector" { "facility" = "mail" } { "level" = "none" } }
+             { "action" { "no_sync" } { "file" = "/var/log/debug" } } }
+         }
+
+       (* changing file *)
+       test Syslog.lns put "*.* /var\n" after
+         set "/entry[1]/action/file" "/foo"
+         = "*.* /foo\n"
+
+       (* removing entry *)
+       test Syslog.lns put "*.* /var\n" after
+         rm "/entry[1]"
+         = ""
+
+       (* changing facility and level *)
+       test Syslog.lns put "*.* /var\n" after
+         set "/entry[1]/selector/facility" "daemon" ;
+         set "/entry[1]/selector/level" "info"
+         = "daemon.info /var\n"
+
+       (* insert a facility *)
+       test Syslog.lns put "daemon.* /var\n" after
+         insa "facility" "/entry/selector/facility" ;
+         set "/entry/selector/facility[2]" "mail"
+         = "daemon,mail.* /var\n"
+
+       (* creating an entry *)
+       test Syslog.lns put "" after
+         set "/entry/selector/facility" "daemon" ;
+         set "/entry/selector/level" "info" ;
+         set "/entry/action/file" "/var"
+         = "daemon.info\t/var\n"
+
+       (* inserting an entry before *)
+       test Syslog.lns put "*.* /var\n" after
+         insb "entry" "/entry" ;
+         set "/entry[1]/selector/facility" "daemon" ;
+         set "/entry[1]/selector/level" "info" ;
+         set "/entry[1]/action/file" "/foo"
+         = "daemon.info /foo\n*.*\t/var\n"
+
+       (* inserting an entry after *)
+       test Syslog.lns put "*.* /var\n" after
+         insa "entry" "/entry" ;
+         set "/entry[2]/selector/facility" "daemon" ;
+         set "/entry[2]/selector/level" "info" ;
+         set "/entry[2]/action/file" "/foo"
+         = "*.* /var\ndaemon.info\t/foo\n"
+
+       (* insert sync on a file *)
+       test Syslog.lns put "*.* /var\n" after
+         insb "no_sync" "/entry/action/file"
+         = "*.* -/var\n"
+
+       (* changing file to remote host *)
+       test Syslog.lns put "*.* /var\n" after
+         rm "/entry/action/file" ;
+         set "/entry/action/hostname" "far.far.away"
+         = "*.* @far.far.away\n"
+
+       (* changing file to * *)
+       test Syslog.lns put "*.* /var\n" after
+         rm "/entry/action/file" ;
+         set "/entry/action/user" "*"
+         = "*.* *\n"
+
+       (* changing file to users *)
+       test Syslog.lns put "*.* /var\n" after
+         rm "/entry/action/file" ;
+         set "/entry/action/user[1]" "john" ;
+         set "/entry/action/user[2]" "paul" ;
+         set "/entry/action/user[3]" "george" ;
+         set "/entry/action/user[4]" "ringo"
+         = "*.* john,paul,george,ringo\n"
+
+       (* changing file to program *)
+       test Syslog.lns put "*.* /var\n" after
+         rm "/entry/action/file" ;
+         set "/entry/action/program" "/usr/bin/foo"
+         = "*.* |/usr/bin/foo\n"
+
+       (* inserting a matching program *)
+       test Syslog.lns put "" after
+         insa "program" "/" ;
+         set "/program/program" "foo"
+         = "!foo\n"
+
+       (* inserting an entry to a matching program *)
+       test Syslog.lns put "!foo\n" after
+         set "/program/entry/selector/facility" "*" ;
+         set "/program/entry/selector/level" "*" ;
+         set "/program/entry/action/file" "/foo"
+         = "!foo\n*.*\t/foo\n"
+
+       (* inserting a matching hostname *)
+       test Syslog.lns put "" after
+         insa "hostname" "/" ;
+         set "/hostname/hostname" "foo.foo.away"
+         = "+foo.foo.away\n"
+
+       (* inserting an entry to a matching hostname *)
+       test Syslog.lns put "+foo.foo.away\n" after
+         set "/hostname/entry/selector/facility" "*" ;
+         set "/hostname/entry/selector/level" "*" ;
+         set "/hostname/entry/action/file" "/foo"
+         = "+foo.foo.away\n*.*\t/foo\n"
+
+       (* inserting a reverse matching hostname *)
+       test Syslog.lns put "" after
+         insa "hostname" "/" ;
+         set "/hostname/reverse" "" ;
+         set "/hostname/hostname" "foo.foo.away"
+         = "-foo.foo.away\n"
diff --git a/lenses/tests/test_vsftpd.aug b/lenses/tests/test_vsftpd.aug
new file mode 100644 (file)
index 0000000..278910e
--- /dev/null
@@ -0,0 +1,72 @@
+module Test_vsftpd =
+
+test Vsftpd.lns get "listen=YES\nmdtm_write=false\n" =
+  { "listen" = "YES" }
+  { "mdtm_write" = "false" }
+
+test Vsftpd.lns get "listen=on\n" = *
+
+test Vsftpd.lns get "local_umask=0777\n" = { "local_umask" = "0777" }
+
+test Vsftpd.lns get "listen_port=ftp\n" = *
+
+test Vsftpd.lns get "ftp_username=ftp_user\n" = { "ftp_username" = "ftp_user" }
+
+(* There must not be spaces around the '=' *)
+test Vsftpd.lns get "anon_root = /var/lib/vsftpd/anon" = *
+
+
+let conf = "# Example config file /etc/vsftpd/vsftpd.conf
+#
+# The default compiled in settings are fairly paranoid. This sample file
+# loosens things up a bit, to make the ftp daemon more usable.
+# Please see vsftpd.conf.5 for all compiled in defaults.
+#
+# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
+anonymous_enable=YES
+#
+# Default umask for local users is 077. You may wish to change this to 022,
+# if your users expect that (022 is used by most other ftpd's)
+local_umask=022
+#
+# You may specify an explicit list of local users to chroot() to their home
+# directory. If chroot_local_user is YES, then this list becomes a list of
+# users to NOT chroot().
+chroot_list_enable=YES
+# (default follows)
+chroot_list_file=/etc/vsftpd/chroot_list
+#
+
+pam_service_name=vsftpd
+userlist_enable=YES
+tcp_wrappers=YES
+
+"
+
+test Vsftpd.lns get conf =
+  { "#comment" = "Example config file /etc/vsftpd/vsftpd.conf" }
+  {}
+  { "#comment" = "The default compiled in settings are fairly paranoid. This sample file" }
+  { "#comment" = "loosens things up a bit, to make the ftp daemon more usable." }
+  { "#comment" = "Please see vsftpd.conf.5 for all compiled in defaults." }
+  {}
+  { "#comment" = "Allow anonymous FTP? (Beware - allowed by default if you comment this out)." }
+  { "anonymous_enable" = "YES" }
+  {}
+  { "#comment" = "Default umask for local users is 077. You may wish to change this to 022," }
+  { "#comment" = "if your users expect that (022 is used by most other ftpd's)" }
+  { "local_umask" = "022" }
+  {}
+  { "#comment" = "You may specify an explicit list of local users to chroot() to their home" }
+  { "#comment" = "directory. If chroot_local_user is YES, then this list becomes a list of" }
+  { "#comment" = "users to NOT chroot()." }
+  { "chroot_list_enable" = "YES" }
+  { "#comment" = "(default follows)" }
+  { "chroot_list_file" = "/etc/vsftpd/chroot_list" }
+  {}
+  {}
+  { "pam_service_name" = "vsftpd" }
+  { "userlist_enable" = "YES" }
+  { "tcp_wrappers" = "YES" }
+  {}
+
diff --git a/lenses/tests/test_webmin.aug b/lenses/tests/test_webmin.aug
new file mode 100644 (file)
index 0000000..a61dc38
--- /dev/null
@@ -0,0 +1,11 @@
+module Test_webmin =
+
+let conf = "port=10000
+realm=Webmin Server
+denyfile=\.pl$
+"
+
+test Webmin.lns get conf =
+   { "port" = "10000" }
+   { "realm" = "Webmin Server" }
+   { "denyfile" = "\.pl$" }
diff --git a/lenses/tests/test_wine.aug b/lenses/tests/test_wine.aug
new file mode 100644 (file)
index 0000000..3faf31f
--- /dev/null
@@ -0,0 +1,163 @@
+module Test_wine =
+
+let s1 = "WINE REGISTRY Version 2
+;; All keys relative to \\Machine
+
+[Software\\Borland\\Database Engine\\Settings\\SYSTEM\\INIT] 1255960431
+\"SHAREDMEMLOCATION\"=\"9000\"
+
+[Software\\Classes\\.gif] 1255960430
+@=\"giffile\"
+\"Content Type\"=\"image/gif\"
+
+[Software\\Classes\\CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}] 1255960430
+\"CLSID\"=\"{1B544C20-FD0B-11CE-8C63-00AA0044B51E}\"
+\"FilterData\"=hex:02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
+  9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
+  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
+\"FriendlyName\"=\"AVI Splitter\"
+
+[Software\\Classes\\CLSID\\{0AFACED1-E828-11D1-9187-B532F1E9575D}\\ShellFolder] 1255960429
+\"Attributes\"=dword:60010000
+\"CallForAttributes\"=dword:f0000000
+"
+
+test Wine.lns get s1 =
+  { "registry" = "WINE REGISTRY" }
+  { "version" = "2" }
+  { "#comment" = "All keys relative to \Machine" }
+  { }
+  { "section" = "Software\Borland\Database Engine\Settings\SYSTEM\INIT"
+    { "timestamp" = "1255960431" }
+    { "entry"
+      { "key" = "SHAREDMEMLOCATION" }
+      { "value" = "9000" } }
+    { } }
+  { "section" = "Software\Classes\.gif"
+    { "timestamp" = "1255960430" }
+    { "anon" { "value" = "giffile" } }
+    { "entry"
+      { "key" = "Content Type" }
+      { "value" = "image/gif" } }
+    { } }
+  { "section" = "Software\Classes\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}"
+    { "timestamp" = "1255960430" }
+    { "entry"
+      { "key" = "CLSID" }
+      { "value" = "{1B544C20-FD0B-11CE-8C63-00AA0044B51E}" } }
+    { "entry"
+      { "key" = "FilterData" }
+      { "type" = "hex" }
+      { "value" = "02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
+  9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
+  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00" } }
+    { "entry"
+      { "key" = "FriendlyName" }
+      { "value" = "AVI Splitter" } }
+    { } }
+  { "section" = "Software\Classes\CLSID\{0AFACED1-E828-11D1-9187-B532F1E9575D}\ShellFolder"
+    { "timestamp" = "1255960429" }
+    { "entry"
+      { "key" = "Attributes" }
+      { "type" = "dword" }
+      { "value" = "60010000" } }
+    { "entry"
+      { "key" = "CallForAttributes" }
+      { "type" = "dword" }
+      { "value" = "f0000000" } } }
+
+(* The weird 'str(2)' type *)
+let s2 = "[Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders] 1248768928
+\"AppData\"=str(2):\"%USERPROFILE%\\Application Data\"
+\"Cache\"=str(2):\"%USERPROFILE%\\Local Settings\\Temporary Internet Files\"
+\"Cookies\"=str(2):\"%USERPROFILE%\\Cookies\"
+\"Desktop\"=str(2):\"%USERPROFILE%\\Desktop\"
+"
+
+test Wine.section get s2 =
+  { "section" =
+    "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
+    { "timestamp" = "1248768928" }
+    { "entry"
+      { "key" = "AppData" }
+      { "type" = "str(2)" }
+      { "value" = "%USERPROFILE%\Application Data" } }
+    { "entry"
+      { "key" = "Cache" }
+      { "type" = "str(2)" }
+      { "value" = "%USERPROFILE%\Local Settings\Temporary Internet Files" } }
+    { "entry"
+      { "key" = "Cookies" }
+      { "type" = "str(2)" }
+      { "value" = "%USERPROFILE%\Cookies" } }
+    { "entry"
+      { "key" = "Desktop" }
+      { "type" = "str(2)" }
+      { "value" = "%USERPROFILE%\Desktop" } } }
+
+(* Quoted doublequotes embedded in the string *)
+let s3 = "[Software\\Classes\\CLSID\\Shell\\OpenHomePage\\Command] 1248768931
+@=\"\\\"C:\\Program Files\\Internet Explorer\\iexplore.exe\\\"\"\n"
+
+test Wine.section get s3 =
+  { "section" = "Software\Classes\CLSID\Shell\OpenHomePage\Command"
+    { "timestamp" = "1248768931" }
+    { "anon"
+      { "value" = "\\\"C:\Program Files\Internet Explorer\iexplore.exe\\\"" } } }
+
+(* There's a str(7) type, too *)
+let s4 = "[Software\\Microsoft\\Cryptography\\OID\\EncodingType 1\\CertDllVerifyRevocation\\DEFAULT] 1248768928
+\"Dll\"=str(7):\"cryptnet.dll\0\"\n"
+
+test Wine.section get s4 =
+  { "section" = "Software\Microsoft\Cryptography\OID\EncodingType 1\CertDllVerifyRevocation\DEFAULT"
+    { "timestamp" = "1248768928" }
+    { "entry"
+      { "key" = "Dll" }
+      { "type" = "str(7)" }
+      { "value" = "cryptnet.dll\0" } } }
+
+(* The Windows Registry Editor header *)
+test Wine.header get "Windows Registry Editor Version 5.00\n" =
+  { "registry" = "Windows Registry Editor" }
+  { "version" = "5.00" }
+
+(* The type hex(7) *)
+let s5 = "[HKEY_LOCAL_MACHINE\SOFTWARE\ADFS]
+\"Patches\"=hex(7):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
+  64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
+  00,00,00,00,f8
+"
+test Wine.section get s5 =
+  { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\ADFS"
+    { "entry"
+      { "key" = "Patches" }
+      { "type" = "hex(7)" }
+      { "value" = "25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
+  64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
+  00,00,00,00,f8" } } }
+
+(* Test DOS line endings *)
+let s6 = "Windows Registry Editor Version 5.00\r\n\r
+[HKEY_LOCAL_MACHINE\SOFTWARE\C07ft5Y\WinXP]\r
+\"@\"=\"\"\r
+\r
+[HKEY_LOCAL_MACHINE\SOFTWARE\Classes]\r\n"
+
+test Wine.lns get s6 =
+  { "registry" = "Windows Registry Editor" }
+  { "version" = "5.00" }
+  { }
+  { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\C07ft5Y\WinXP"
+    { "anon" { "value" = "" } }
+    { } }
+  { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes" }
+
+(* Keys can contain '/' *)
+let s7 =
+"\"application/vnd.ms-xpsdocument\"=\"{c18d5e87-12b4-46a3-ae40-67cf39bc6758}\"\n"
+
+test Wine.entry get s7 =
+  { "entry"
+    { "key" = "application/vnd.ms-xpsdocument" }
+    { "value" = "{c18d5e87-12b4-46a3-ae40-67cf39bc6758}" } }
diff --git a/lenses/tests/test_xinetd.aug b/lenses/tests/test_xinetd.aug
new file mode 100644 (file)
index 0000000..d728d73
--- /dev/null
@@ -0,0 +1,79 @@
+module Test_xinetd =
+
+let eol_ws = "defaults \t \n{\n  enabled = cvs echo  \n}\n\n"
+
+let cvs = "# default: off
+# description: The CVS service can record the history of your source
+#              files. CVS stores all the versions of a file in a single
+#              file in a clever way that only stores the differences
+#              between versions.
+service cvspserver
+{
+        disable                 = yes
+        port                    = 2401
+        socket_type             = stream
+        protocol                = tcp
+        wait                    = no
+        user                    = root
+        passenv                 = PATH
+        server                  = /usr/bin/cvs
+        env                    -= HOME=/var/cvs
+        server_args             = -f --allow-root=/var/cvs pserver
+#       bind                    = 127.0.0.1
+        log_on_failure         += HOST
+}
+"
+
+let lst_add = "service svc_add
+{
+   log_on_failure += HOST
+}
+"
+
+test Xinetd.lns get eol_ws =
+  { "defaults" { "enabled"
+                 { "value" = "cvs" }
+                 { "value" = "echo" } } }
+  {}
+
+test Xinetd.lns put eol_ws after rm "/defaults/enabled/value[last()]" =
+  "defaults \t \n{\n  enabled = cvs  \n}\n\n"
+
+test Xinetd.lns get cvs =
+  { "#comment" = "default: off" }
+  { "#comment" = "description: The CVS service can record the history of your source" }
+  { "#comment" = "files. CVS stores all the versions of a file in a single" }
+  { "#comment" = "file in a clever way that only stores the differences" }
+  { "#comment" = "between versions." }
+  { "service" = "cvspserver"
+      { "disable" = "yes" }
+      { "port" = "2401" }
+      { "socket_type" = "stream" }
+      { "protocol" = "tcp" }
+      { "wait" = "no" }
+      { "user" = "root" }
+      { "passenv" { "value" = "PATH" } }
+      { "server" = "/usr/bin/cvs" }
+      { "env" { "del" } { "value" = "HOME=/var/cvs" } }
+      { "server_args"
+          { "value" = "-f" }
+          { "value" = "--allow-root=/var/cvs" }
+          { "value" = "pserver" } }
+      { "#comment" = "bind                    = 127.0.0.1" }
+      { "log_on_failure" { "add" } { "value" = "HOST" } } }
+
+(* Switch the '+=' to a simple '=' *)
+test Xinetd.lns put lst_add after rm "/service/log_on_failure/add" =
+  "service svc_add\n{\n   log_on_failure = HOST\n}\n"
+
+test Xinetd.lns put "" after
+  set "/service" "svc";
+  set "/service/instances" "UNLIMITED" = "service svc
+{
+\tinstances = UNLIMITED
+}
+"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/tests/test_xml.aug b/lenses/tests/test_xml.aug
new file mode 100644 (file)
index 0000000..6c6bf66
--- /dev/null
@@ -0,0 +1,698 @@
+module Test_xml =
+
+let knode (r:regexp) = [ key r ]
+
+(************************************************************************
+ *                           Utilities lens
+ *************************************************************************)
+(*
+let _ = print_regexp(lens_ctype(Xml.text))
+let _ = print_endline ""
+*)
+
+test Xml.comment get "<!-- declarations for <head> & <body> -->" =
+  { "#comment" = " declarations for <head> & <body> " }
+
+test Xml.comment get "<!-- B+, B, or B--->" = *
+
+test Xml.prolog get "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" =
+  { "#declaration"
+    { "#attribute"
+      { "version" = "1.0" }
+      { "encoding" = "UTF-8" }
+    }
+  }
+
+test Xml.decl_def_item get "<!ELEMENT greeting (#PCDATA)>" =
+  { "!ELEMENT" = "greeting"
+    { "#decl" = "(#PCDATA)" }
+  }
+
+test Xml.decl_def_item get "<!ENTITY da \"&#xD;&#xA;\">" =
+  { "!ENTITY" = "da"
+    { "#decl" = "&#xD;&#xA;" }
+  }
+
+test Xml.doctype get "<!DOCTYPE greeting SYSTEM \"hello.dtd\">" =
+  { "!DOCTYPE" = "greeting"
+    { "SYSTEM" = "hello.dtd" }
+  }
+
+test Xml.doctype get "<!DOCTYPE foo [
+<!ELEMENT bar (#PCDATA)>
+<!ELEMENT baz (bar)* >
+]>" =
+  { "!DOCTYPE" = "foo"
+    { "!ELEMENT" = "bar"
+      { "#decl" = "(#PCDATA)" }
+    }
+    { "!ELEMENT" = "baz"
+      { "#decl" = "(bar)*" }
+    }
+  }
+
+let att_def1 = "<!ATTLIST termdef
+id      ID      #REQUIRED
+name    CDATA   #IMPLIED>"
+let att_def2 = "<!ATTLIST list
+type    (bullets|ordered|glossary)  \"ordered\">"
+let att_def3 = "<!ATTLIST form
+method  CDATA   #FIXED \"POST\">"
+
+test Xml.att_list_def get att_def1 =
+  { "!ATTLIST" = "termdef"
+    { "1"
+      { "#name" = "id" }
+      { "#type" = "ID" }
+      { "#REQUIRED" }
+    }
+    { "2"
+      { "#name" = "name" }
+      { "#type" = "CDATA" }
+      { "#IMPLIED" }
+    }
+  }
+
+test Xml.att_list_def get att_def2 =
+  { "!ATTLIST" = "list"
+    { "1"
+      { "#name" = "type" }
+      { "#type" = "(bullets|ordered|glossary)" }
+      { "#FIXED" = "ordered" }
+    }
+  }
+
+test Xml.att_list_def get att_def3 =
+  { "!ATTLIST" = "form"
+    { "1"
+      { "#name" = "method" }
+      { "#type" = "CDATA" }
+      { "#FIXED" = "POST" }
+    }
+  }
+
+test Xml.notation_def get "<!NOTATION not3 SYSTEM \"\">" =
+  { "!NOTATION" = "not3"
+    { "SYSTEM" = "" }
+  }
+
+let cdata1 = "<![CDATA[testing]]>"
+test Xml.cdata get cdata1 = { "#CDATA" = "testing" }
+
+let attr1 = " attr1=\"value1\" attr2=\"value2\""
+let attr2 = " attr2=\"foo\""
+test Xml.attributes get attr1 =
+  { "#attribute"
+    { "attr1" = "value1" }
+    { "attr2" = "value2" }
+  }
+
+test Xml.attributes get " refs=\"A1\nA2  A3\"" =
+  { "#attribute"
+    { "refs" = "A1\nA2  A3" }
+  }
+
+test Xml.attributes put attr1 after rm "/#attribute[1]";
+                                    set "/#attribute/attr2" "foo" = attr2
+
+let empty1 = "<a/>"
+let empty2 = "<a foo=\"bar\"/>"
+let empty3 = "<a foo=\"bar\"></a>\n"
+let empty4 = "<a foo=\"bar\" far=\"baz\"/>"
+test Xml.empty_element get empty1 = { "a" = "#empty" }
+test Xml.empty_element get empty2 =
+  { "a" = "#empty" { "#attribute" { "foo" = "bar"} } }
+
+test Xml.empty_element put empty1 after set "/a/#attribute/foo" "bar" = empty2
+
+(* the attribute node must be the first child of the element *)
+test Xml.empty_element put empty1 after set "/a/#attribute/foo" "bar";
+                                        set "/a/#attribute/far" "baz" = empty4
+
+test Xml.content put "<a><b/></a>" after clear "/a/b" = "<a><b></b>\n</a>"
+
+test Xml.lns put "<a></a >" after set "/a/#text[1]" "foo";
+                                 set "/a/#text[2]" "bar" = "<a>foobar</a >"
+
+test Xml.lns get "<?xml version=\"1.0\"?>
+<!DOCTYPE catalog PUBLIC \"-//OASIS//DTD XML Catalogs V1.0//EN\"
+  \"file:///usr/share/xml/schema/xml-core/catalog.dtd\">
+  <doc/>" =
+  { "#declaration"
+  { "#attribute"
+    { "version" = "1.0" }
+  }
+  }
+  { "!DOCTYPE" = "catalog"
+    { "PUBLIC"
+      { "#literal" = "-//OASIS//DTD XML Catalogs V1.0//EN" }
+      { "#literal" = "file:///usr/share/xml/schema/xml-core/catalog.dtd" }
+    }
+  }
+  { "doc" = "#empty" }
+
+test Xml.lns get "<oor:component-data xmlns:oor=\"http://openoffice.org/2001/registry\"/>
+" =
+  { "oor:component-data" = "#empty"
+    { "#attribute"
+      { "xmlns:oor" = "http://openoffice.org/2001/registry" }
+    }
+  }
+
+let input1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<html>
+    <head>
+        <title>Wiki</title>
+    </head>
+    <body>
+        <h1>Augeas</h1>
+        <p class=\"main\">Augeas is now able to parse XML files!</p>
+        <ul>
+            <li>Translate from XML to a tree syntax</li>
+            <li>Translate from the tree back to XML</li> <!-- this is some comment -->
+            <li>this</li>
+        </ul>
+    </body>
+</html>
+"
+
+test Xml.doc get input1 =
+  { "#declaration"
+    { "#attribute"
+      { "version" = "1.0" }
+      { "encoding" = "UTF-8" }
+    }
+  }
+  { "html"
+    { "#text" = "\n    " }
+    { "head"
+      { "#text" = "\n        " }
+      { "title"
+        { "#text" = "Wiki" }
+      }
+      { "#text" = "    " }
+    }
+    { "#text" = "    " }
+    { "body"
+      { "#text" = "
+        " }
+      { "h1"
+        { "#text" = "Augeas" }
+      }
+      { "#text" = "        " }
+      { "p"
+        { "#attribute"
+          { "class" = "main" }
+        }
+        { "#text" = "Augeas is now able to parse XML files!" }
+      }
+      { "#text" = "        " }
+      { "ul"
+        { "#text" = "\n            " }
+        { "li"
+          { "#text" = "Translate from XML to a tree syntax" }
+        }
+        { "#text" = "            " }
+        { "li"
+          { "#text" = "Translate from the tree back to XML" }
+        }
+        { "#text" = " " }
+        { "#comment" = " this is some comment " }
+        { "#text" = "
+            " }
+        { "li"
+          { "#text" = "this" }
+        }
+        { "#text" = "        " }
+      }
+      { "#text" = "    " }
+    }
+  }
+
+test Xml.doc put input1 after rm "/html/body" =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<html>
+    <head>
+        <title>Wiki</title>
+    </head>
+    </html>
+"
+
+
+let ul1 = "
+<ul>
+ <li>test1</li>
+  <li>test2</li>
+   <li>test3</li>
+    <li>test4</li>
+</ul>
+"
+
+test Xml.doc get ul1 =
+  { "ul"
+    { "#text" = "
+ " }
+    { "li"
+      { "#text" = "test1" }
+    }
+    { "#text" = "  " }
+    { "li"
+      { "#text" = "test2" }
+    }
+    { "#text" = "   " }
+    { "li"
+      { "#text" = "test3" }
+    }
+    { "#text" = "    " }
+    { "li"
+      { "#text" = "test4" }
+    }
+  }
+
+
+test Xml.doc put ul1 after set "/ul/li[3]/#text" "bidon" = "
+<ul>
+ <li>test1</li>
+  <li>test2</li>
+   <li>bidon</li>
+    <li>test4</li>
+</ul>
+"
+
+test Xml.doc put ul1 after rm "/ul/li[2]" = "
+<ul>
+ <li>test1</li>
+     <li>test3</li>
+    <li>test4</li>
+</ul>
+"
+
+
+(* #text nodes don't move when inserting a node, the result depends on where the node is added *)
+test Xml.doc put ul1 after insb "a" "/ul/li[2]" = "
+<ul>
+ <li>test1</li>
+  <a></a>
+<li>test2</li>
+   <li>test3</li>
+    <li>test4</li>
+</ul>
+"
+
+test Xml.doc put ul1 after insa "a" "/ul/li[1]" = "
+<ul>
+ <li>test1</li>
+<a></a>
+  <li>test2</li>
+   <li>test3</li>
+    <li>test4</li>
+</ul>
+"
+
+(* Attributes must be added before text nodes *)
+test Xml.doc put ul1 after insb "#attribute" "/ul/li[2]/#text";
+                           set "/ul/li[2]/#attribute/bidon" "gazou";
+                           set "/ul/li[2]/#attribute/foo" "bar" = "
+<ul>
+ <li>test1</li>
+  <li bidon=\"gazou\" foo=\"bar\">test2</li>
+   <li>test3</li>
+    <li>test4</li>
+</ul>
+"
+
+(* if empty element is allowed to be as root, this test triggers error *)
+test Xml.lns get "<doc>
+<a><c/><b><c/></b><c/><c/><a></a></a>
+</doc>" =
+  { "doc"
+    { "#text" = "\n" }
+    { "a"
+      { "c" = "#empty" }
+      { "b"
+        { "c" = "#empty" }
+      }
+      { "c" = "#empty" }
+      { "c" = "#empty" }
+      { "a" }
+    }
+  }
+
+let p01pass2 = "<?PI before document element?>
+<!-- comment after document element-->
+<?PI before document element?>
+<!-- comment after document element-->
+<?PI before document element?>
+<!-- comment after document element-->
+<?PI before document element?>
+<!DOCTYPE doc
+[
+<!ELEMENT doc ANY>
+<!ELEMENT a ANY>
+<!ELEMENT b ANY>
+<!ELEMENT c ANY>
+]>
+<doc>
+<a><b><c/></b></a>
+</doc>
+<!-- comment after document element-->
+<?PI after document element?>
+<!-- comment after document element-->
+<?PI after document element?>
+<!-- comment after document element-->
+<?PI after document element?>
+"
+
+test Xml.lns get p01pass2 =
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "before document element" }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "before document element" }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "before document element" }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "before document element" }
+  }
+  { "!DOCTYPE" = "doc"
+    { "!ELEMENT" = "doc"
+      { "#decl" = "ANY" }
+    }
+    { "!ELEMENT" = "a"
+      { "#decl" = "ANY" }
+    }
+    { "!ELEMENT" = "b"
+      { "#decl" = "ANY" }
+    }
+    { "!ELEMENT" = "c"
+      { "#decl" = "ANY" }
+    }
+  }
+  { "doc"
+    { "#text" = "
+" }
+    { "a"
+      { "b"
+        { "c" = "#empty" }
+      }
+    }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "after document element" }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "after document element" }
+  }
+  { "#comment" = " comment after document element" }
+  { "#pi"
+    { "#target" = "PI" }
+    { "#instruction" = "after document element" }
+  }
+
+
+(* various valid Name constructions *)
+test Xml.lns get "<doc>\n<A:._-0/>\n<::._-0/>\n<_:._-0/>\n<A/>\n<_/>\n<:/>\n</doc>" =
+  { "doc"
+    { "#text" = "\n" }
+    { "A:._-0" = "#empty" }
+    { "::._-0" = "#empty" }
+    { "_:._-0" = "#empty" }
+    { "A" = "#empty" }
+    { "_" = "#empty" }
+    { ":" = "#empty" }
+  }
+
+test Xml.lns get "<doc>
+<abcdefghijklmnopqrstuvwxyz/>
+<ABCDEFGHIJKLMNOPQRSTUVWXYZ/>
+<A01234567890/>
+<A.-:/>
+</doc>" =
+  { "doc"
+    { "#text" = "\n" }
+    { "abcdefghijklmnopqrstuvwxyz" = "#empty" }
+    { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" = "#empty" }
+    { "A01234567890" = "#empty" }
+    { "A.-:" = "#empty" }
+  }
+
+
+let p06fail1 = "<!--non-validating processors may pass this instance because they don't check the IDREFS attribute type-->
+<!DOCTYPE doc
+[
+<!ELEMENT doc (a|refs)*>
+<!ELEMENT a EMPTY>
+<!ELEMENT refs EMPTY>
+<!ATTLIST refs refs IDREFS #REQUIRED>
+<!ATTLIST a id ID #REQUIRED>
+]>
+<doc>
+<a id=\"A1\"/><a id=\"A2\"/><a id=\"A3\"/>
+<refs refs=\"\"/>
+</doc>"
+
+(* we accept this test because we do not verify XML references *)
+test Xml.lns get p06fail1 =
+  { "#comment" = "non-validating processors may pass this instance because they don't check the IDREFS attribute type" }
+  { "!DOCTYPE" = "doc"
+    { "!ELEMENT" = "doc"
+      { "#decl" = "(a|refs)*" }
+    }
+    { "!ELEMENT" = "a"
+      { "#decl" = "EMPTY" }
+    }
+    { "!ELEMENT" = "refs"
+      { "#decl" = "EMPTY" }
+    }
+    { "!ATTLIST" = "refs"
+      { "1"
+        { "#name" = "refs" }
+        { "#type" = "IDREFS" }
+        { "#REQUIRED" }
+      }
+    }
+    { "!ATTLIST" = "a"
+      { "1"
+        { "#name" = "id" }
+        { "#type" = "ID" }
+        { "#REQUIRED" }
+      }
+    }
+  }
+  { "doc"
+    { "#text" = "
+" }
+    { "a" = "#empty"
+      { "#attribute"
+        { "id" = "A1" }
+      }
+    }
+    { "a" = "#empty"
+      { "#attribute"
+        { "id" = "A2" }
+      }
+    }
+    { "a" = "#empty"
+      { "#attribute"
+        { "id" = "A3" }
+      }
+    }
+    { "refs" = "#empty"
+      { "#attribute"
+        { "refs" = "" }
+      }
+    }
+  }
+
+(* we accept dquote, but not single quotes, because of resulting ambiguity *)
+let p10pass1_1 = "<doc><A a=\"asdf>'&#34;>\nasdf\n    ?>%\"/></doc>"
+let p10pass1_2 = "<doc><A a='\"\">&#39;&#34;'/></doc>"
+
+test Xml.lns get p10pass1_1 =
+  { "doc"
+    { "A" = "#empty"
+      { "#attribute"
+        { "a" = "asdf>'&#34;>\nasdf\n    ?>%" }
+      }
+    }
+  }
+
+test Xml.lns get p10pass1_2 = *
+
+(* here again, test exclude single quote *)
+let p11pass1 = "<!--Inability to resolve a notation should not be reported as an error-->
+<!DOCTYPE doc
+[
+<!ELEMENT doc EMPTY>
+<!NOTATION not1 SYSTEM \"a%a&b&#0<!ELEMENT<!--<?</>?>/\''\">
+<!NOTATION not3 SYSTEM \"\">
+]>
+<doc></doc>"
+
+test Xml.lns get p11pass1 =
+  { "#comment" = "Inability to resolve a notation should not be reported as an error" }
+  { "!DOCTYPE" = "doc"
+    { "!ELEMENT" = "doc"
+      { "#decl" = "EMPTY" }
+    }
+    { "!NOTATION" = "not1"
+      { "SYSTEM" = "a%a&b&#0<!ELEMENT<!--<?</>?>/\''" }
+    }
+    { "!NOTATION" = "not3"
+      { "SYSTEM" = "" }
+    }
+  }
+  { "doc" }
+
+test Xml.lns get "<doc>a%b%&lt;/doc>&#60;/doc>]]&lt;&amp;</doc>" =
+  { "doc"
+    { "#text" = "a%b%&lt;/doc>&#60;/doc>]]&lt;&amp;" }
+  }
+
+let p15pass1 = "<!--a
+<!DOCTYPE
+<?-
+]]>-<[ CDATA [
+\"- -'-
+-<doc>-->
+<!---->
+<doc></doc>"
+
+test Xml.lns get p15pass1 =
+  { "#comment" = "a
+<!DOCTYPE
+<?-
+]]>-<[ CDATA [
+\"- -'-
+-<doc>" }
+  { "#comment" = "" }
+  { "doc" }
+
+let p22pass3 = "<?xml version=\"1.0\"?>
+<!--comment--> <?pi some instruction ?>
+<doc><?pi?></doc>"
+
+test Xml.lns get p22pass3 =
+  { "#declaration"
+    { "#attribute"
+      { "version" = "1.0" }
+    }
+  }
+  { "#comment" = "comment" }
+  { "#pi"
+    { "#target" = "pi" }
+    { "#instruction" = "some instruction" }
+  }
+  { "doc"
+    { "#pi"
+      { "#target" = "pi" }
+    }
+  }
+
+let p25pass2 = "<?xml version
+
+     
+=
+  
+
+\"1.0\"?>
+<doc></doc>"
+
+test Xml.lns get p25pass2 =
+  { "#declaration"
+    { "#attribute"
+      { "version" = "1.0" }
+    }
+  }
+  { "doc" }
+
+
+test Xml.lns get "<!DOCTYPE 
+
+doc
+
+[
+<!ELEMENT doc EMPTY>
+]>
+<doc></doc>" =
+  { "!DOCTYPE" = "doc"
+    { "!ELEMENT" = "doc"
+      { "#decl" = "EMPTY" }
+    }
+  }
+  { "doc" }
+
+test Xml.lns get "<doc></doc  \n>" = { "doc" }
+
+test Xml.lns get "<a><doc att=\"val\" \natt2=\"val2\" att3=\"val3\"/></a>" =
+  { "a"
+    { "doc" = "#empty"
+      { "#attribute"
+        { "att" = "val" }
+        { "att2" = "val2" }
+        { "att3" = "val3" }
+      }
+    }
+  }
+
+test Xml.lns get "<doc/>" = { "doc" = "#empty" }
+
+(* failure tests *)
+(* only one document element *)
+test Xml.lns get "<doc></doc><bad/>" = *
+
+(* document element must be complete *)
+test Xml.lns get "<doc>" = *
+
+(* emtpy document is rejected *)
+test Xml.lns get "" = *
+
+(* malformed element *)
+test Xml.lns get "<a><A@/></a>" = *
+
+(* a Name cannot start with a digit *)
+test Xml.lns get "<a><0A/></a>" = *
+
+(* no space before "CDATA" *)
+test Xml.lns get "<doc><![ CDATA[a]]></doc>" = *
+
+(* no space after "CDATA" *)
+test Xml.lns get "<doc><![CDATA [a]]></doc>" = *
+
+(* CDSect's can't nest *)
+test Xml.lns get "<doc>
+<![CDATA[
+<![CDATA[XML doesn't allow CDATA sections to nest]]>
+]]>
+</doc>" = *
+
+(* Comment is illegal in VersionInfo *)
+test Xml.lns get "<?xml version <!--bad comment--> =\"1.0\"?>
+<doc></doc>" = *
+
+(* only declarations in DTD *)
+test Xml.lns get "<!DOCTYPE doc [
+<!ELEMENT doc EMPTY>
+<doc></doc>
+]>" = *
+
+(* we do not support external entities *)
+test Xml.lns get "<!DOCTYPE doc [
+<!ENTITY % eldecl \"<!ELEMENT doc EMPTY>\">
+%eldecl;
+]>
+<doc></doc>" = *
+
diff --git a/lenses/tests/test_xorg.aug b/lenses/tests/test_xorg.aug
new file mode 100644 (file)
index 0000000..4fd937f
--- /dev/null
@@ -0,0 +1,78 @@
+(* Tests for the Xorg module *)
+
+module Test_xorg =
+
+  let conf = "
+# xorg.conf
+
+Section \"ServerLayout\"
+        Identifier     \"single head configuration\"
+        Screen      0  \"Screen0\" 0 0
+        InputDevice    \"Generic Keyboard\" \"CoreKeyboard\"
+EndSection
+
+Section \"InputDevice\"
+       Identifier      \"Generic Keyboard\"
+        # that's a driver
+       Driver          \"kbd\"
+       Option          \"XkbOptions\"  \"lv3:ralt_switch\"
+EndSection
+
+Section \"Device\"
+       Identifier      \"Configured Video Device\"
+       Option          \"MonitorLayout\" \"LVDS,VGA\"
+       VideoRam        229376
+        Option          \"NoAccel\"
+EndSection
+
+Section \"Screen\"
+        Identifier \"Screen0\"
+        Device     \"Configured Video Device\"
+        DefaultDepth     24
+        SubSection \"Display\"
+                Viewport   0 0
+                Depth     24
+                Modes    \"1280x1024\" \"1280x960\" \"1280x800\"
+        EndSubSection
+EndSection
+"
+
+  test Xorg.lns get conf =
+     { }
+     { "#comment" = "xorg.conf" }
+     { }
+     { "ServerLayout"
+        { "Identifier" = "single head configuration" }
+        { "Screen"     = "Screen0"
+           { "num"      = "0" }
+           { "position" = "0 0" } }
+        { "InputDevice" = "Generic Keyboard"
+           { "option"   = "CoreKeyboard" } } }
+     { }
+     { "InputDevice"
+        { "Identifier" = "Generic Keyboard" }
+        { "#comment"   = "that's a driver" }
+        { "Driver"     = "kbd" }
+        { "Option"     = "XkbOptions"
+             { "value"  = "lv3:ralt_switch" } } }
+     { }
+     { "Device"
+        { "Identifier" = "Configured Video Device" }
+        { "Option"     = "MonitorLayout"
+             { "value"  = "LVDS,VGA" } }
+        { "VideoRam"   = "229376" }
+        { "Option"     = "NoAccel" } }
+     { }
+     { "Screen"
+        { "Identifier" = "Screen0" }
+        { "Device"     = "Configured Video Device" }
+        { "DefaultDepth" = "24" }
+        { "Display"
+           { "ViewPort"
+              { "x" = "0" }
+              { "y" = "0" } }
+           { "Depth"    = "24" }
+           { "Modes"
+              { "mode" = "1280x1024" }
+              { "mode" = "1280x960" }
+              { "mode" = "1280x800" } } } }
diff --git a/lenses/tests/test_yum.aug b/lenses/tests/test_yum.aug
new file mode 100644 (file)
index 0000000..bfb7743
--- /dev/null
@@ -0,0 +1,191 @@
+module Test_yum =
+
+  let yum_simple = "[sec1]
+# comment
+key=value
+[sec-two]
+key1=value1
+# comment
+key2=value2
+"
+
+  let yum_conf = "[main]
+cachedir=/var/cache/yum
+keepcache=0
+debuglevel=2
+logfile=/var/log/yum.log
+exactarch=1
+obsoletes=1
+gpgcheck=1
+plugins=1
+metadata_expire=1800
+
+installonly_limit=100
+
+# PUT YOUR REPOS HERE OR IN separate files named file.repo
+# in /etc/yum.repos.d
+"
+
+  let yum_repo1 = "[fedora]
+name=Fedora $releasever - $basearch
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+[fedora-debuginfo]
+name=Fedora $releasever - $basearch - Debug
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+[fedora-source]
+name=Fedora $releasever - Source
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+"
+  let yum_repo2 = "[remi]
+name=Les RPM de remi pour FC$releasever - $basearch
+baseurl=http://remi.collet.free.fr/rpms/fc$releasever.$basearch/
+    http://iut-info.ens.univ-reims.fr/remirpms/fc$releasever.$basearch/
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
+
+[remi-test]
+name=Les RPM de remi en test pour FC$releasever - $basearch
+baseurl=http://remi.collet.free.fr/rpms/test-fc$releasever.$basearch/
+    http://iut-info.ens.univ-reims.fr/remirpms/test-fc$releasever.$basearch/
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
+"
+
+  let cont = "[main]\nbaseurl=url1\n   url2 , url3\n   \n"
+
+  test Yum.lns get yum_simple =
+    { "sec1" {} { "key" = "value" } }
+    { "sec-two" { "key1" = "value1" } {} { "key2" = "value2" } }
+
+  test Yum.lns put yum_conf after
+      rm "main"
+    = ""
+
+  test Yum.lns put yum_simple after
+      set "sec1/key" "othervalue"
+    = "[sec1]\n# comment\nkey=othervalue\n[sec-two]\nkey1=value1\n# comment\nkey2=value2\n"
+
+  test Yum.lns put yum_simple after
+      rm "sec1" ;
+      rm "sec-two/key1"
+  = "[sec-two]\n# comment\nkey2=value2\n"
+
+  test Yum.lns put yum_simple after
+      rm "sec1" ;
+      rm "sec-two/key1" ;
+      set "sec-two/newkey" "newvalue"
+  = "[sec-two]\n# comment\nkey2=value2\nnewkey=newvalue\n"
+
+  test Yum.lns put yum_simple after
+      rm "sec1" ;
+      set "sec-two/key1" "newvalue"
+   = "[sec-two]\nkey1=newvalue\n# comment\nkey2=value2\n"
+
+  test Yum.lns get cont =
+    { "main"
+        { "baseurl" = "url1" }
+        { "baseurl" = "url2" }
+        { "baseurl" = "url3" }
+        {}
+    }
+
+  test Yum.lns put cont after
+      set "main/gpgcheck" "1"
+  =
+    cont . "gpgcheck=1\n"
+
+  (* We are actually stricter than yum in checking syntax. The yum.conf *)
+  (* man page mentions that it is illegal to have multiple baseurl keys *)
+  (* in the same section, but yum will just carry on, usually with      *)
+  (* results that surpise the unsuspecting user                         *)
+  test Yum.lns get "[repo]\nbaseurl=url1\nbaseurl=url2\n" = *
+
+  (* This checks that we take the right branch in the section lens.     *)
+  test Yum.section get "[repo]\nname=A name\nbaseurl=url1\n" =
+    { "repo"
+        { "name" = "A name" }
+        { "baseurl" = "url1" } }
+
+  (* Handle continuation lines for gpgkey; bug #132 *)
+  test Yum.lns get "[main]\ngpgkey=key1\n  key2\n" =
+    { "main"
+        { "gpgkey" = "key1" }
+        { "gpgkey" = "key2" } }
+
+  test Yum.lns get yum_repo1 =
+  { "fedora"
+    { "name" = "Fedora $releasever - $basearch" }
+    { "failovermethod" = "priority" }
+    {  }
+    { "mirrorlist" = "http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch" }
+    { "enabled" = "1" }
+    { "gpgcheck" = "1" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY" }
+    {  }
+  }
+  { "fedora-debuginfo"
+    { "name" = "Fedora $releasever - $basearch - Debug" }
+    { "failovermethod" = "priority" }
+    {  }
+    { "mirrorlist" = "http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch" }
+    { "enabled" = "0" }
+    { "gpgcheck" = "1" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY" }
+    {  }
+  }
+  { "fedora-source"
+    { "name" = "Fedora $releasever - Source" }
+    { "failovermethod" = "priority" }
+    {  }
+    { "mirrorlist" = "http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch" }
+    { "enabled" = "0" }
+    { "gpgcheck" = "1" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY" }
+  }
+
+
+
+  test Yum.lns get yum_repo2 =
+  { "remi"
+    { "name" = "Les RPM de remi pour FC$releasever - $basearch" }
+    { "baseurl" = "http://remi.collet.free.fr/rpms/fc$releasever.$basearch/" }
+    { "baseurl" = "http://iut-info.ens.univ-reims.fr/remirpms/fc$releasever.$basearch/" }
+    { "enabled" = "0" }
+    { "gpgcheck" = "1" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi" }
+    {  }
+  }
+  { "remi-test"
+    { "name" = "Les RPM de remi en test pour FC$releasever - $basearch" }
+    { "baseurl" = "http://remi.collet.free.fr/rpms/test-fc$releasever.$basearch/" }
+    { "baseurl" = "http://iut-info.ens.univ-reims.fr/remirpms/test-fc$releasever.$basearch/" }
+    { "enabled" = "0" }
+    { "gpgcheck" = "1" }
+    { "gpgkey" = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi" }
+  }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/util.aug b/lenses/util.aug
new file mode 100644 (file)
index 0000000..cef5b15
--- /dev/null
@@ -0,0 +1,148 @@
+(*
+Module: Util
+  Generic module providing useful primitives
+
+Author: David Lutterkort
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+*)
+
+
+module Util =
+
+
+(*
+Variable: del_str
+  Delete a string and default to it
+
+  Parameters:
+     s:string - the string to delete and default to
+*)
+  let del_str (s:string) = del s s
+
+(*
+Variable: del_ws
+  Delete mandatory whitespace
+*)
+  let del_ws = del /[ \t]+/
+
+(*
+Variable: del_ws_spc
+  Delete mandatory whitespace, default to single space
+*)
+  let del_ws_spc = del_ws " "
+
+(*
+Variable: del_ws_tab
+  Delete mandatory whitespace, default to single tab
+*)
+  let del_ws_tab = del_ws "\t"
+
+
+(*
+Variable: del_opt_ws
+  Delete optional whitespace
+*)
+  let del_opt_ws = del /[ \t]*/
+
+
+(*
+Variable: eol
+  Delete end of line, including optional trailing whitespace
+*)
+  let eol = del /[ \t]*\n/ "\n"
+
+(*
+Variable: indent
+  Delete indentation, including leading whitespace
+*)
+  let indent = del /[ \t]*/ ""
+
+(* Group: Comment
+     This is a general definition of comment
+     It allows indentation for comments, removes the leading and trailing spaces
+     of comments and stores them in nodes, except for empty comments which are
+     ignored together with empty lines
+
+View: comment_generic
+  Map comments and set default comment sign
+*)
+
+  let comment_generic (r:regexp) (d:string) =
+    [ label "#comment" . del r d
+        . store /([^ \t\n].*[^ \t\n]|[^ \t\n])/ . eol ]
+
+(* View: comment
+  Map comments into "#comment" nodes
+*)
+  let comment = comment_generic /[ \t]*#[ \t]*/ "# "
+
+(* View: comment_eol
+  Map eol comments into "#comment" nodes
+  Add a space before # for end of line comments
+*)
+  let comment_eol = comment_generic /[ \t]*#[ \t]*/ " # "
+
+(* View: comment_or_eol
+    A <comment_eol> or <eol> *)
+ let comment_or_eol = comment_eol | (del /[ \t]*#?\n/ "\n")
+
+(* View: comment_multiline
+    A C-style multiline comment *)
+  let comment_multiline =
+     let mline_re = (/[^ \t\n].*[^ \t\n]|[^ \t\n]/ - /.*\*\/.*/) in
+     let mline = [ seq "mline"
+                 . store mline_re ] in
+     [ label "#mcomment" . del /[ \t]*\/\*[ \t\n]*/ "/*\n"
+       . counter "mline"
+       . (mline . (eol . mline)*)
+       . del /[ \t\n]*\*\/[ \t]*\n/ "\n*/\n" ]
+
+(* View: comment_c_style
+    A comment line, C-style *)
+  let comment_c_style =
+    comment_generic /[ \t]*\/\/[ \t]*/ "// "
+
+(* View: empty_generic
+  A generic definition of <empty>
+  Map empty lines, including empty comments *)
+  let empty_generic (r:regexp) =
+    [ del r "" . del_str "\n" ]
+
+(* View: empty
+  Map empty lines, including empty comments *)
+  let empty = empty_generic /[ \t]*#?[ \t]*/
+
+(* View: empty_c_style
+  Map empty lines, including C-style empty comment *)
+  let empty_c_style =
+    empty_generic /[ \t]*((\/\/)|(\/\*[ \t]*\*\/))?[ \t]*/
+
+
+(* View: Split *)
+(* Split (SEP . ELT)* into an array-like tree where each match for ELT *)
+(* appears in a separate subtree. The labels for the subtrees are      *)
+(* consecutive numbers, starting at 0                                  *)
+  let split (elt:lens) (sep:lens) =
+    let sym = gensym "split" in
+    counter sym . ( [ seq sym . sep . elt ] ) *
+
+(* Group: Exclusions
+
+Variable: stdexcl
+  Exclusion for files that are commonly not wanted/needed
+*)
+  let stdexcl = (excl "*~") .
+    (excl "*.rpmnew") .
+    (excl "*.rpmsave") .
+    (excl "*.dpkg-old") .
+    (excl "*.dpkg-new") .
+    (excl "*.dpkg-bak") .
+    (excl "*.dpkg-dist") .
+    (excl "*.augsave") .
+    (excl "*.augnew")
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/vsftpd.aug b/lenses/vsftpd.aug
new file mode 100644 (file)
index 0000000..f95bdd0
--- /dev/null
@@ -0,0 +1,31 @@
+(* Parse vsftpd.conf *)
+module Vsftpd =
+  autoload xfm
+
+(* The code in parseconf.c does not seem to allow for trailing whitespace *)
+(* in the config file                                                     *)
+let eol = Util.del_str "\n"
+let empty = Util.empty
+let comment = Util.comment
+
+let bool_option_re = /anonymous_enable|local_enable|pasv_enable|port_enable|chroot_local_user|write_enable|anon_upload_enable|anon_mkdir_write_enable|anon_other_write_enable|chown_uploads|connect_from_port_20|xferlog_enable|dirmessage_enable|anon_world_readable_only|async_abor_enable|ascii_upload_enable|ascii_download_enable|one_process_model|xferlog_std_format|pasv_promiscuous|deny_email_enable|chroot_list_enable|setproctitle_enable|text_userdb_names|ls_recurse_enable|log_ftp_protocol|guest_enable|userlist_enable|userlist_deny|use_localtime|check_shell|hide_ids|listen|port_promiscuous|passwd_chroot_enable|no_anon_password|tcp_wrappers|use_sendfile|force_dot_files|listen_ipv6|dual_log_enable|syslog_enable|background|virtual_use_local_privs|session_support|download_enable|dirlist_enable|chmod_enable|secure_email_list_enable|run_as_launching_user|no_log_lock|ssl_enable|allow_anon_ssl|force_local_logins_ssl|force_local_data_ssl|ssl_sslv2|ssl_sslv3|ssl_tlsv1|tilde_user_enable|force_anon_logins_ssl|force_anon_data_ssl|mdtm_write|lock_upload_files|pasv_addr_resolve|debug_ssl|require_cert|validate_cert/
+
+let uint_option_re = /accept_timeout|connect_timeout|local_umask|anon_umask|ftp_data_port|idle_session_timeout|data_connection_timeout|pasv_min_port|pasv_max_port|anon_max_rate|local_max_rate|listen_port|max_clients|file_open_mode|max_per_ip|trans_chunk_size|delay_failed_login|delay_successful_login|max_login_fails|chown_upload_mode/
+
+let str_option_re = /secure_chroot_dir|ftp_username|chown_username|xferlog_file|vsftpd_log_file|message_file|nopriv_user|ftpd_banner|banned_email_file|chroot_list_file|pam_service_name|guest_username|userlist_file|anon_root|local_root|banner_file|pasv_address|listen_address|user_config_dir|listen_address6|cmds_allowed|hide_file|deny_file|user_sub_token|email_password_file|rsa_cert_file|dsa_cert_file|ssl_ciphers|rsa_private_key_file|dsa_private_key_file|ca_certs_file/
+
+let bool_value_re = /[yY][eE][sS]|[tT][rR][uU][eE]|1|[nN][oO]|[fF][aA][lL][sS][eE]|0/
+
+let option (k:regexp) (v:regexp) = [ key k . Util.del_str "=" . store v . eol ]
+
+let bool_option = option bool_option_re bool_value_re
+
+let str_option = option str_option_re /[^\n]+/
+
+let uint_option = option uint_option_re /[0-9]+/
+
+let lns = (bool_option|str_option|uint_option|comment|empty)*
+
+let filter = (incl "/etc/vsftpd.conf") . (incl "/etc/vsftpd/vsftpd.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/webmin.aug b/lenses/webmin.aug
new file mode 100644 (file)
index 0000000..8899d71
--- /dev/null
@@ -0,0 +1,48 @@
+(* Webmin module for Augeas
+ Author: Free Ekanayaka <free@64studio.com>
+
+ Reference:
+
+*)
+
+module Webmin =
+
+   autoload xfm
+
+(************************************************************************
+ *                           USEFUL PRIMITIVES
+ *************************************************************************)
+
+let eol        = Util.eol
+let comment    = Util.comment
+let empty      = Util.empty
+
+let sep_eq     = del /=/ "="
+
+let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+let word       = /[A-Za-z0-9_.-]+/
+
+(************************************************************************
+ *                               ENTRIES
+ *************************************************************************)
+
+let entry     = [ key word
+                . sep_eq
+                . sto_to_eol?
+                . eol ]
+
+(************************************************************************
+ *                                LENS
+ *************************************************************************)
+
+let lns        = (comment|empty|entry) *
+
+let wm_incl (n:string)
+               = (incl ("/etc/webmin/" . n))
+let filter
+               = wm_incl "miniserv.conf"
+               . wm_incl "ldap-useradmin/config"
+               . Util.stdexcl
+
+let xfm        = transform lns filter
diff --git a/lenses/wine.aug b/lenses/wine.aug
new file mode 100644 (file)
index 0000000..bd43a17
--- /dev/null
@@ -0,0 +1,46 @@
+(* Lens for the textual representation of Windows registry files, as used *)
+(* by wine etc.                                                           *)
+(* This is pretty quick and dirty, as it doesn't put a lot of finesse on  *)
+(* splitting up values that have structure, e.g. hex arrays or            *)
+(* collections of paths.                                                  *)
+module Wine =
+
+(* We handle Unix and DOS line endings, though we can only add one or the *)
+(* other to new lines. Maybe provide a function to gather that from the   *)
+(* current file ?                                                         *)
+let eol = del /[ \t]*\r?\n/ "\n"
+let comment = [ label "#comment" . del /[ \t]*;;[ \t]*/ ";; "
+                        . store /([^ \t\r\n].*[^ \t\r\n]|[^ \t\r\n])/ . eol ]
+let empty = [ eol ]
+let dels = Util.del_str
+let del_ws = Util.del_ws_spc
+
+let header =
+  [ label "registry" . store /[a-zA-Z0-9 \t]*[a-zA-Z0-9]/ ] .
+    del /[ \t]*Version[ \t]*/ " Version " .
+  [ label "version" . store /[0-9.]+/ ] . eol
+
+let qstr =
+  let re = /([^"\n]|\\\\.)*/ - /@|"@"/ in    (* " Relax, emacs *)
+    dels "\"" . store re . dels "\""
+
+let typed_val =
+  ([ label "type" . store /dword|hex(\\([0-9]+\\))?/ ] . dels ":" .
+    [ label "value" . store /[a-zA-Z0-9,()]+(\\\\\r?\n[ \t]*[a-zA-Z0-9,]+)*/])
+  |([ label "type" . store /str\\([0-9]+\\)/ ] . dels ":" .
+      dels "\"" . [ label "value" . store /[^"\n]*/ ] . dels "\"")   (* " Relax, emacs *)
+
+let entry =
+  let qkey = [ label "key" . qstr ] in
+  let eq = del /[ \t]*=[ \t]*/ "=" in
+  let qstore = [ label "value" . qstr ] in
+  [ label "entry" . qkey . eq . (qstore|typed_val) . eol ]
+  |[label "anon" . del /"?@"?/ "@" . eq . (qstore|typed_val) .eol ]
+
+let section =
+  let ts = [ label "timestamp" . store Rx.integer ] in
+  [ label "section" . del /[ \t]*\\[/ "[" .
+    store /[^]\n]+/ . dels "]" . (del_ws . ts)? . eol .
+    (entry|empty|comment)* ]
+
+let lns = header . (empty|comment)* . section*
diff --git a/lenses/xinetd.aug b/lenses/xinetd.aug
new file mode 100644 (file)
index 0000000..07748f8
--- /dev/null
@@ -0,0 +1,120 @@
+(*
+ * Module: Xinetd
+ *   Parses xinetd configuration files
+ *
+ *  The structure of the lens and allowed attributes are ripped directly
+ *  from xinetd's parser in xinetd/parse.c in xinetd's source checkout
+ *  The downside of being so precise here is that if attributes are added
+ *  they need to be added here, too. Writing a catchall entry, and getting
+ *  to typecheck correctly would be a huge pain.
+ *
+ *  A really enterprising soul could tighten this down even further by
+ *  restricting the acceptable values for each attribute.
+ *
+ * Author: David Lutterkort
+ *)
+
+module Xinetd =
+  autoload xfm
+
+  let comment = Util.comment
+  let empty   = Util.empty
+
+  let name = key /[^ \t\n\/=+-]+/
+  let bol_spc = del /[ \t]*/ "\t"
+  let spc = del /[ \t]+/ " "
+  let eol = del /[ \t]*\n/ "\n"
+
+  let op_delim (op:string) = del (/[ \t]*/ . op . /[ \t]*/) (" " . op . " ")
+  let eq       = op_delim "="
+
+  let op = ([ label "add" . op_delim "+=" ]
+           |[ label "del" . op_delim "-=" ]
+           | eq)
+
+  let value = store /[^ \t\n]+/
+
+  let attr_one (n:regexp) =
+    [ bol_spc . key n . eq . value . eol ]
+
+  let attr_lst (n:regexp) (op_eq: lens) =
+    [ bol_spc . key n . op_eq .
+        [label "value" . value] . [label "value" . spc . value]* .
+      eol ]
+
+  let attr_lst_eq (n:regexp) = attr_lst n eq
+
+  let attr_lst_op (n:regexp) = attr_lst n op
+
+  (* Variable: service_attr
+   *   Note:
+   *      It is much faster to combine, for example, all the attr_one
+   *      attributes into one regexp and pass that to a lens instead of
+   *      using lens union (attr_one "a" | attr_one "b"|..) because the latter
+   *      causes the type checker to work _very_ hard.
+   *)
+
+  let service_attr =
+    attr_one ("socket_type" | "protocol" | "wait" | "user" | "group"
+             |"server" | "instances"  | "rpc_version" | "rpc_number"
+             | "id" | "port" | "nice" | "banner" | "bind" | "interface"
+             | "per_source" | "groups" | "banner_success" | "banner_fail"
+             | "disable" | "max_load" | "rlimit_as" | "rlimit_cpu"
+             | "rlimit_data" | "rlimit_rss" | "rlimit_stack" | "v6only"
+             | "deny_time" | "umask" | "mdns" | "libwrap")
+   (* redirect and cps aren't really lists, they take exactly two values *)
+   |attr_lst_eq ("server_args" | "log_type" |  "access_times" | "type"
+                | "flags" | "redirect" | "cps")
+   |attr_lst_op ( "log_on_success" | "log_on_failure"| "only_from"
+                | "no_access" | "env" | "passenv")
+
+  let default_attr =
+    attr_one ( "instances" | "banner" | "bind" | "interface" | "per_source"
+             | "groups" | "banner_success" | "banner_fail" | "max_load"
+             | "v6only" | "umask" | "mdns")
+   |attr_lst_eq "cps"       (* really only two values, not a whole list *)
+   |attr_lst_op ( "log_type" | "log_on_success" | "log_on_failure" | "disabled"
+                | "no_access" | "only_from" | "passenv" | "enabled" )
+
+  (* View: body
+   *   Note:
+   *       We would really like to say "the body can contain any of a list
+   *       of a list of attributes, each of them at most once"; but that
+   *       would require that we build a lens that matches the permutation
+   *       of all attributes; with around 40 individual attributes, that's
+   *       not computationally feasible, even if we didn't have to worry
+   *       about how to write that down. The resulting regular expressions
+   *       would simply be prohibitively large.
+   *)
+  let body (attr:lens) = Util.del_str "\n{\n"
+                       . (empty|comment|attr)*
+                       . del /[ \t]*}[ \t]*\n/ "}\n"
+
+  (* View: includes
+   *  Note:
+   *   It would be nice if we could use the directories given in include and
+   *   includedir directives to parse additional files instead of hardcoding
+   *   all the places where xinetd config files can be found; but that is
+   *   currently not possible, and implementing that has a good amount of
+   *   hairy corner cases to consider.
+   *)
+  let includes = [ key /include|includedir/
+                     . Util.del_ws_spc . store /[^ \t\n]+/ . eol ]
+
+  let service =
+     let sto_re = /[^# \t\n\/]+/ in
+     [ key "service" . Sep.space . store sto_re . body service_attr ]
+
+  let defaults = [ key "defaults" . del /[ \t]*/ "" . body default_attr ]
+
+  let lns = ( empty | comment | includes | defaults | service )*
+
+  let filter = incl "/etc/xinetd.d/*"
+             . incl "/etc/xinetd.conf"
+             . Util.stdexcl
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/lenses/xml.aug b/lenses/xml.aug
new file mode 100644 (file)
index 0000000..d153b9c
--- /dev/null
@@ -0,0 +1,143 @@
+(* XML lens for Augeas
+   Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
+
+   Reference: http://www.w3.org/TR/2006/REC-xml11-20060816/
+*)
+
+module Xml =
+
+autoload xfm
+
+(************************************************************************
+ *                           Utilities lens
+ *************************************************************************)
+
+let dels (s:string)   = del s s
+let spc               = /[ \t\n]+/
+let osp               = /[ \t\n]*/
+let sep_spc           = del /[ \t\n]+/ " "
+let sep_osp           = del /[ \t\n]*/ ""
+let sep_eq            = del /[ \t\n]*=[ \t\n]*/ "="
+
+let nmtoken             = /[a-zA-Z:_][a-zA-Z0-9:_\.-]*/
+let word                = /[a-zA-Z][a-zA-Z0-9\._\-]*/
+let char                = /.|\n/
+(* if we hide the quotes, then we can only accept single or double quotes *)
+(* otherwise a put ambiguity is raised *)
+let sto_dquote          = dels "\"" . store /[^"]*/ . dels "\""
+let sto_squote          = dels "'" . store /[^']*/ . dels "'"
+
+let comment             = [ label "#comment" .
+                            dels "<!--" .
+                            store /([^-]|-[^-])*/ .
+                            dels "-->" ]
+
+let pi_target           = nmtoken - /[Xx][Mm][Ll]/
+let empty               = Util.empty
+let del_end             = del />[\n]?/ ">\n"
+let del_end_simple      = dels ">"
+
+(* This is siplified version of processing instruction
+ * pi has to not start or end with a white space and the string
+ * must not contain "?>". We restrict too much by not allowing any
+ * "?" nor ">" in PI
+ *)
+let pi                  = /[^ \n\t]|[^ \n\t][^?>]*[^ \n\t]/
+
+(************************************************************************
+ *                            Attributes
+ *************************************************************************)
+
+
+let decl          = [ label "#decl" . sep_spc .
+                      store /[^> \t\n\r]|[^> \t\n\r][^>\t\n\r]*[^> \t\n\r]/ ]
+
+let decl_def (r:regexp) (b:lens) = [ dels "<" . key r .
+                                     sep_spc . store word .
+                                     b . sep_osp . del_end_simple ]
+
+let elem_def      = decl_def /!ELEMENT/ decl
+
+let enum          = "(" . osp . nmtoken . ( osp . "|" . osp . nmtoken )* . osp . ")"
+
+let att_type      = /CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/ |
+                     enum
+
+let id_def        = [ sep_spc . key /PUBLIC/ .
+                      [ label "#literal" . sep_spc . sto_dquote ]* ] |
+                    [ sep_spc . key /SYSTEM/ . sep_spc . sto_dquote ]
+
+let notation_def  = decl_def /!NOTATION/ id_def
+
+let att_def       = counter "att_id" .
+                    [ sep_spc . seq "att_id" .
+                      [ label "#name" . store word . sep_spc ] .
+                      [ label "#type" . store att_type . sep_spc ] .
+                      ([ key   /#REQUIRED|#IMPLIED/ ] |
+                       [ label "#FIXED" . del /#FIXED[ \n\t]*|/ "" . sto_dquote ]) ]*
+
+let att_list_def = decl_def /!ATTLIST/ att_def
+
+let entity_def    = decl_def /!ENTITY/ ([sep_spc . label "#decl" . sto_dquote ])
+
+let decl_def_item = elem_def | entity_def | att_list_def | notation_def
+
+let decl_outer    = sep_osp . del /\[[ \n\t\r]*/ "[\n" .
+                    (decl_def_item . sep_osp )* . dels "]"
+
+(* let dtd_def       = [ sep_spc . key "SYSTEM" . sep_spc . sto_dquote ] *)
+
+let doctype       = decl_def /!DOCTYPE/ (decl_outer|id_def)
+
+let attributes    = [ label "#attribute" .
+                      [ sep_spc . key nmtoken . sep_eq . sto_dquote ]+ ]
+
+let prolog        = [ label "#declaration" .
+                      dels "<?xml" .
+                      attributes .
+                      sep_osp .
+                      dels "?>" ]
+
+
+(************************************************************************
+ *                            Tags
+ *************************************************************************)
+
+(* we consider entities as simple text *)
+let text_re   = /[^<]+/ - /([^<]*\]\]>[^<]*)/
+let text      = [ label "#text" . store text_re ]
+let cdata     = [ label "#CDATA" . dels "<![CDATA[" .
+                  store (char* - (char* . "]]>" . char*)) . dels "]]>" ]
+
+let element (body:lens) =
+    let h = attributes? . sep_osp . dels ">" . body* . dels "</" in
+        [ dels "<" . square nmtoken h . sep_osp . del_end ]
+
+let empty_element = [ dels "<" . key nmtoken . value "#empty" .
+                      attributes? . sep_osp . del /\/>[\n]?/ "/>\n" ]
+
+let pi_instruction = [ dels "<?" . label "#pi" .
+                       [ label "#target" . store pi_target ] .
+                       [ sep_spc . label "#instruction" . store pi ]? .
+                       sep_osp . del /\?>/ "?>" ]
+
+(* Typecheck is weaker on rec lens, detected by unfolding *)
+(*
+let content1 = element text
+let rec content2 = element (content1|text|comment)
+*)
+
+let rec content = element (text|comment|content|empty_element|pi_instruction)
+
+(* Constraints are weaker here, but it's better than being too strict *)
+let doc = (sep_osp . (prolog  | comment | doctype | pi_instruction))* .
+          ((sep_osp . content) | (sep_osp . empty_element)) .
+          (sep_osp . (comment | pi_instruction ))* . sep_osp
+
+let lns = doc
+
+let filter = (incl "/etc/xml/*.xml")
+    . (incl "/etc/xml/catalog")
+    . Util.stdexcl
+
+let xfm = transform lns filter
diff --git a/lenses/xorg.aug b/lenses/xorg.aug
new file mode 100644 (file)
index 0000000..840eb25
--- /dev/null
@@ -0,0 +1,293 @@
+(*
+Module: Xorg
+ Parses /etc/X11/xorg.conf
+
+Authors: Raphael Pinson <raphink@gmail.com>
+         Matthew Booth <mbooth@redhat.com>
+
+About: Reference
+ This lens tries to keep as close as possible to `man xorg.conf` where
+ possible.
+
+The definitions from `man xorg.conf` are put as commentaries for reference
+throughout the file. More information can be found in the manual.
+
+About: License
+  This file is licensed under the LGPLv2+, like the rest of Augeas.
+
+About: Lens Usage
+  Sample usage of this lens in augtool
+
+    * Get the identifier of the devices with a "Clone" option:
+      > match "/files/etc/X11/xorg.conf/Device[Option = 'Clone']/Identifier"
+
+About: Configuration files
+  This lens applies to /etc/X11/xorg.conf. See <filter>.
+*)
+
+module Xorg =
+  autoload xfm
+
+(************************************************************************
+ * Group:                 USEFUL PRIMITIVES
+ *************************************************************************)
+
+(* Group: Generic primitives *)
+
+(* Variable: eol *)
+let eol     = Util.eol
+
+(* Variable: to_eol
+ * Match everything from here to eol, cropping whitespace at both ends
+ *)
+let to_eol  = /[^ \t\n](.*[^ \t\n])?/
+
+(* Variable: indent *)
+let indent  = Util.indent
+
+(* Variable: comment *)
+let comment = Util.comment
+
+(* Variable: empty *)
+let empty   = Util.empty
+
+
+(* Group: Separators *)
+
+(* Variable: sep_spc *)
+let sep_spc = Util.del_ws_spc
+
+(* Variable: sep_dquote *)
+let sep_dquote  = Util.del_str "\""
+
+
+(* Group: Fields and values *)
+
+(* Variable: entries_re
+ * This is a list of all patterns which have specific handlers, and should
+ * therefore not be matched by the generic handler
+ *)
+let entries_re  = /([oO]ption|[sS]creen|[iI]nput[dD]evice|[dD]river|[sS]ub[sS]ection|[dD]isplay|[iI]dentifier|[vV]ideo[rR]am|[dD]efault[dD]epth|[dD]evice)/
+
+(* Variable: generic_entry_re *)
+let generic_entry_re = /[^# \t\n\/]+/ - entries_re
+
+(* Variable: quoted_string_val *)
+let quoted_string_val = del "\"" "\"" . store /[^"\n]+/ . del "\"" "\""
+                                              (* " relax, emacs *)
+
+(* Variable: int *)
+let int = /[0-9]+/
+
+
+(************************************************************************
+ * Group:                          ENTRIES AND OPTIONS
+ *************************************************************************)
+
+
+(* View: entry_int
+ * This matches an entry which takes a single integer for an argument
+ *)
+let entry_int (canon:string) (re:regexp) =
+        [ indent . del re canon . label canon . sep_spc . store int . eol ]
+
+(* View: entry_rgb
+ * This matches an entry which takes 3 integers as arguments representing red,
+ * green and blue components
+ *)
+let entry_rgb (canon:string) (re:regexp) =
+        [ indent . del re canon . label canon
+          . [ label "red"   . sep_spc . store int ]
+          . [ label "green" . sep_spc . store int ]
+          . [ label "blue"  . sep_spc . store int ]
+          . eol ]
+
+(* View: entry_xy
+ * This matches an entry which takes 2 integers as arguments representing X and
+ * Y coordinates
+ *)
+let entry_xy (canon:string) (re:regexp) =
+        [ indent . del re canon . label canon
+          . [ label "x" . sep_spc . store int ]
+          . [ label "y" . sep_spc . store int ]
+          . eol ]
+
+(* View: entry_str
+ * This matches an entry which takes a single quoted string
+ *)
+let entry_str (canon:string) (re:regexp) =
+        [ indent . del re canon . label canon
+          . sep_spc . quoted_string_val . eol ]
+
+(* View: entry_generic
+ * An entry without a specific handler. Store everything after the keyword,
+ * cropping whitespace at both ends.
+ *)
+let entry_generic  = [ indent . key generic_entry_re
+                       . sep_spc . store to_eol . eol ]
+
+(* View: option *)
+let option = [ indent . del /[oO]ption/ "Option" . label "Option" . sep_spc
+               . quoted_string_val
+               . [ label "value" . sep_spc . quoted_string_val ]*
+               . eol ]
+
+(* View: screen
+ * The Screen entry of ServerLayout
+ *)
+let screen = [ indent . del /[sS]creen/ "Screen" . label "Screen" . sep_spc
+               . [ label "num" . store int . sep_spc ]?
+               . quoted_string_val
+               . [ sep_spc . label "position" . store to_eol ]?
+               . eol ]
+
+(* View: input_device *)
+let input_device = [ indent . del /[iI]nput[dD]evice/ "InputDevice"
+                     . label "InputDevice" . sep_spc . quoted_string_val
+                     . [ label "option" . sep_spc . quoted_string_val ]*
+                     . eol ]
+
+(* View: driver *)
+let driver = entry_str "Driver" /[dD]river/
+
+(* View: identifier *)
+let identifier = entry_str "Identifier" /[iI]dentifier/
+
+(* View: videoram *)
+let videoram = entry_int "VideoRam" /[vV]ideo[rR]am/
+
+(* View: default_depth *)
+let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
+
+(* View: device *)
+let device = entry_str "Device" /[dD]evice/
+
+(************************************************************************
+ * Group:                          DISPLAY SUBSECTION
+ *************************************************************************)
+
+
+(* View: display_modes *)
+let display_modes = [ indent . del /[mM]odes/ "Modes" . label "Modes"
+                      . [ label "mode" . sep_spc . quoted_string_val ]+
+                      . eol ]
+
+(*************************************************************************
+ * View: display_entry
+ *   Known values for entries in the Display subsection
+ *
+ *   Definition:
+ *     > Depth    depth
+ *     > FbBpp    bpp
+ *     > Weight   red-weight green-weight blue-weight
+ *     > Virtual  xdim ydim
+ *     > ViewPort x0 y0
+ *     > Modes    "mode-name" ...
+ *     > Visual   "visual-name"
+ *     > Black    red green blue
+ *     > White    red green blue
+ *     > Options
+ *)
+
+let display_entry = entry_int "Depth"    /[dD]epth/ |
+                    entry_int "FbBpp"    /[fF]b[bB]pp/ |
+                    entry_rgb "Weight"   /[wW]eight/ |
+                    entry_xy  "Virtual"  /[vV]irtual/ |
+                    entry_xy  "ViewPort" /[vV]iew[pP]ort/ |
+                    display_modes |
+                    entry_str "Visual"   /[vV]isual/ |
+                    entry_rgb "Black"    /[bB]lack/ |
+                    entry_rgb "White"    /[wW]hite/ |
+                    entry_str "Options"  /[oO]ptions/ |
+                    empty |
+                    comment
+
+(* View: display *)
+let display = [ indent . del "SubSection" "SubSection" . sep_spc
+                       . sep_dquote . key "Display" . sep_dquote
+                       . eol
+                       . display_entry*
+                       . indent . del "EndSubSection" "EndSubSection" . eol ]
+
+
+(************************************************************************
+ * Group:                       SECTIONS
+ *************************************************************************)
+
+
+(************************************************************************
+ * Variable: section_re
+ *   Known values for Section names
+ *
+ *   Definition:
+ *     >   The section names are:
+ *     >
+ *     >   Files          File pathnames
+ *     >   ServerFlags    Server flags
+ *     >   Module         Dynamic module loading
+ *     >   InputDevice    Input device description
+ *     >   Device         Graphics device description
+ *     >   VideoAdaptor   Xv video adaptor description
+ *     >   Monitor        Monitor description
+ *     >   Modes          Video modes descriptions
+ *     >   Screen         Screen configuration
+ *     >   ServerLayout   Overall layout
+ *     >   DRI            DRI-specific configuration
+ *     >   Vendor         Vendor-specific configuration
+ *************************************************************************)
+let section_re = /(Extensions|Files|ServerFlags|Module|InputDevice|Device|VideoAdaptor|Monitor|Modes|Screen|ServerLayout|DRI|Vendor)/
+
+
+(************************************************************************
+ * Variable: secton_re_obsolete
+ *   The  following obsolete section names are still recognised for
+ *   compatibility purposes.  In new config files, the InputDevice
+ *   section should be used instead.
+ *
+ *   Definition:
+ *     >  Keyboard       Keyboard configuration
+ *     >  Pointer        Pointer/mouse configuration
+ *************************************************************************)
+let section_re_obsolete = /(Keyboard|Pointer)/
+
+(* View: section_entry *)
+let section_entry = option |
+                    screen |
+                    display |
+                    input_device |
+                    driver |
+                    identifier |
+                    videoram |
+                    default_depth |
+                    device |
+                    entry_generic |
+                    empty | comment
+
+(************************************************************************
+ * View: section
+ *   A section in xorg.conf
+ *
+ *   Definition:
+ *     > Section  "SectionName"
+ *     >    SectionEntry
+ *     >    ...
+ *     > EndSection
+ *************************************************************************)
+let section = [ indent . del "Section" "Section"
+                       . sep_spc . sep_dquote
+                       . key (section_re|section_re_obsolete) . sep_dquote
+                       . eol
+                .  section_entry*
+                . indent . del "EndSection" "EndSection" . eol ]
+
+(*
+ * View: lns
+ *   The xorg.conf lens
+ *)
+let lns = ( empty | comment | section )*
+
+
+(* Variable: filter *)
+let filter = (incl "/etc/X11/xorg.conf")
+
+let xfm = transform lns filter
diff --git a/lenses/yum.aug b/lenses/yum.aug
new file mode 100644 (file)
index 0000000..d6eeb81
--- /dev/null
@@ -0,0 +1,62 @@
+(* Parsing yum's config files *)
+module Yum =
+  autoload xfm
+
+  let eol = Util.del_str "\n"
+
+  let key_re = /[^#;:= \t\n[\/]+/ - /baseurl|gpgkey/
+
+  let eq = del /[ \t]*[:=][ \t]*/ "="
+  let secname = /[^]\/]+/
+
+  let value = /[^ \t\n][^\n]*/
+
+  (* We really need to allow comments starting with REM and rem but that     *)
+  (* leads to ambiguities with keys 'rem=' and 'REM=' The regular expression *)
+  (* to do that cleanly is somewhat annoying to craft by hand; we'd need to  *)
+  (* define KEY_RE as /[A-Za-z0-9]+/ - "REM" - "rem"                         *)
+  let comment = [ del /([;#].*)?[ \t]*\n/ "\n" ]
+
+  let list_sep = del /([ \t]*(,[ \t]*|\n[ \t]+))|[ \t]+/ "\n\t"
+  let list_value = store /[^ \t\n,]+/
+
+  let kv_list(s:string) =
+    [ key s . eq . list_value ] .
+      [ list_sep . label s . list_value ]* . eol
+
+  let kv = [ key key_re . eq . store value . eol ]
+
+  let sechead = Util.del_str "[" . key secname . Util.del_str "]"
+      . del /[ \t]*[;#]?.*/ ""
+      . eol
+
+  let entry = comment | kv
+
+  (* A section is a section head, followed by any number of key value    *)
+  (* entries, with comments and blank lines freely interspersed. The     *)
+  (* continuation lines allowed for baseurl entries make this a little   *)
+  (* more interesting: there can be at most one baseurl entry in each    *)
+  (* section (more precisely, yum will only obey one of them, but we act *)
+  (* as if yum would actually barf)                                      *)
+  let section =
+    let list_baseurl = kv_list "baseurl" in
+      let list_gpgkey = kv_list "gpgkey" in
+    [ sechead . (  entry*
+                 | entry* . list_baseurl . entry*
+                 | entry* . list_gpgkey . entry*
+                 | entry* . list_baseurl . entry* . list_gpgkey . entry*
+                 | entry* . list_gpgkey . entry* . list_baseurl . entry*)]
+
+  let lns = (comment) * . (section) *
+
+  let filter = (incl "/etc/yum.conf")
+      . (incl "/etc/yum.repos.d/*")
+      . (incl "/etc/yum/pluginconf.d/*")
+      . (excl "/etc/yum/pluginconf.d/versionlock.list")
+      . Util.stdexcl
+
+  let xfm = transform lns filter
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644 (file)
index 0000000..b0efbb8
--- /dev/null
@@ -0,0 +1,7 @@
+
+EXTRA_DIST=$(wildcard *.pod) $(wildcard *.[0-9])
+
+man1_MANS=augtool.1 augparse.1
+
+%.1: %.pod
+       pod2man -c "Augeas" -r "Augeas $(VERSION)" $< > $@
diff --git a/man/Makefile.in b/man/Makefile.in
new file mode 100644 (file)
index 0000000..494e3d3
--- /dev/null
@@ -0,0 +1,1176 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = man
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+am__installdirs = "$(DESTDIR)$(man1dir)"
+NROFF = nroff
+MANS = $(man1_MANS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = $(wildcard *.pod) $(wildcard *.[0-9])
+man1_MANS = augtool.1 augparse.1
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu man/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man1: $(man1_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(MANS)
+installdirs:
+       for dir in "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+       distclean distclean-generic distclean-libtool distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man install-man1 \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       uninstall uninstall-am uninstall-man uninstall-man1
+
+
+%.1: %.pod
+       pod2man -c "Augeas" -r "Augeas $(VERSION)" $< > $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/man/augparse.1 b/man/augparse.1
new file mode 100644 (file)
index 0000000..33e3a2f
--- /dev/null
@@ -0,0 +1,216 @@
+.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sh \" Subsection heading
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
+.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.el \{\
+.    de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "AUGPARSE 1"
+.TH AUGPARSE 1 "2010-04-19" "Augeas 0.7.0" "Augeas"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+augparse \- execute an Augeas module
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+augparse [\s-1OPTIONS\s0] \s-1MODULE\s0
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+Execute an Augeas module, most commonly to evaluate the tests it contains.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+.IP "\fB\-I\fR \fI\s-1DIR\s0\fR" 4
+.IX Item "-I DIR"
+Add \s-1DIR\s0 to the module loadpath. Can be given multiple times. The
+directories set here are searched before any directories specified in the
+\&\s-1AUGEAS_LENS_LIB\s0 environment variable, and before the default directory
+\&\fI/usr/share/augeas/lenses\fR.
+.IP "\fB\-\-nostdinc\fR" 4
+.IX Item "--nostdinc"
+Do not search any of the default directories for modules. When this option
+is set, only directories specified explicitly with \fB\-I\fR or specified in
+\&\fB\s-1AUGEAS_LENS_LIB\s0\fR will be searched for modules.
+.IP "\fB\-\-notypecheck\fR" 4
+.IX Item "--notypecheck"
+Do not perform lens type checks. Only use this option during lens
+development and make sure you typecheck lenses when you are done developing
+\&\- you should never use a lens that hasn't been typechecked. This option is
+sometimes useful when you are working on unit tests for a lens to speed up
+the time it takes to repeatedly run and fix tests.
+.IP "\fB\-\-version\fR" 4
+.IX Item "--version"
+Print version information and exit.
+.IP "\fB\-h\fR" 4
+.IX Item "-h"
+Display this help and exit
+.SH "EXAMPLES"
+.IX Header "EXAMPLES"
+To run the tests in \fIlenses/tests/test_foo.aug\fR and use modules from the
+directory \fIlenses\fR, run
+.Sp
+.RS 4
+augparse \-I lenses lenses/tests/test_foo.aug
+.RE
+.SH "TESTS"
+.IX Header "TESTS"
+Tests can appear as top-level forms anywhere in a module. Generally, the
+tests for a module \fIlenses/foo.aug\fR are kept in a separate file, usually
+in \fIlenses/tests/test_foo.aug\fR.
+.PP
+There are two different kinds of tests that Augeas can run: \fBget\fR and
+\&\fBput\fR tests. The syntax for \fBget\fR tests is
+.Sp
+.RS 4
+test \s-1LENS\s0 get \s-1STRING\s0 = \s-1RESULT\s0
+.RE
+.PP
+which applies the \fIget\fR direction of the lens \s-1LENS\s0 to \s-1STRING\s0 and compares
+it with the given \s-1RESULT\s0. \s-1RESULT\s0 can either be a tree literal, the symbol
+\&\fB?\fR to print the result of applying \s-1LENS\s0 to \s-1STRING\s0, or the symbol \fB*\fR to
+indicate that the test should produce an exception.
+.PP
+The syntax for \fBput\fR tests is
+.Sp
+.RS 4
+test \s-1LENS\s0 put \s-1STRING\s0 after \s-1COMMANDS\s0 = \s-1RESULT\s0
+.RE
+.PP
+which first applies the \fIget\fR direction of the lens \s-1LENS\s0 to \s-1STRING\s0, then
+applies the given \s-1COMMANDS\s0 to the resulting tree, and finally transforms
+the modified tree back to a string using the \fIput\fR direction of \s-1LENS\s0. The
+resulting string is then compared to \s-1RESULT\s0, which can be a string, the
+symbol \fB?\fR to print the result of applying \s-1LENS\s0 to \s-1STRING\s0, or the symbol
+\&\fB*\fR to indicate that the test should produce an exception.
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+\&\fBAugeas\fR project homepage <http://www.augeas.net/>
+.PP
+augtool
diff --git a/man/augparse.pod b/man/augparse.pod
new file mode 100644 (file)
index 0000000..15e84f0
--- /dev/null
@@ -0,0 +1,98 @@
+=head1 NAME
+
+augparse - execute an Augeas module
+
+=head1 SYNOPSIS
+
+augparse [OPTIONS] MODULE
+
+=head1 DESCRIPTION
+
+Execute an Augeas module, most commonly to evaluate the tests it contains.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-I> I<DIR>
+
+Add DIR to the module loadpath. Can be given multiple times. The
+directories set here are searched before any directories specified in the
+AUGEAS_LENS_LIB environment variable, and before the default directory
+F</usr/share/augeas/lenses>.
+
+=item B<--nostdinc>
+
+Do not search any of the default directories for modules. When this option
+is set, only directories specified explicitly with B<-I> or specified in
+B<AUGEAS_LENS_LIB> will be searched for modules.
+
+=item B<--notypecheck>
+
+Do not perform lens type checks. Only use this option during lens
+development and make sure you typecheck lenses when you are done developing
+- you should never use a lens that hasn't been typechecked. This option is
+sometimes useful when you are working on unit tests for a lens to speed up
+the time it takes to repeatedly run and fix tests.
+
+=item B<--version>
+
+Print version information and exit.
+
+=item B<-h>
+
+Display this help and exit
+
+=back
+
+=head1 EXAMPLES
+
+To run the tests in F<lenses/tests/test_foo.aug> and use modules from the
+directory F<lenses>, run
+
+=over 4
+
+augparse -I lenses lenses/tests/test_foo.aug
+
+=back
+
+=head1 TESTS
+
+Tests can appear as top-level forms anywhere in a module. Generally, the
+tests for a module F<lenses/foo.aug> are kept in a separate file, usually
+in F<lenses/tests/test_foo.aug>.
+
+There are two different kinds of tests that Augeas can run: B<get> and
+B<put> tests. The syntax for B<get> tests is
+
+=over 4
+
+test LENS get STRING = RESULT
+
+=back
+
+which applies the I<get> direction of the lens LENS to STRING and compares
+it with the given RESULT. RESULT can either be a tree literal, the symbol
+B<?> to print the result of applying LENS to STRING, or the symbol B<*> to
+indicate that the test should produce an exception.
+
+The syntax for B<put> tests is
+
+=over 4
+
+test LENS put STRING after COMMANDS = RESULT
+
+=back
+
+which first applies the I<get> direction of the lens LENS to STRING, then
+applies the given COMMANDS to the resulting tree, and finally transforms
+the modified tree back to a string using the I<put> direction of LENS. The
+resulting string is then compared to RESULT, which can be a string, the
+symbol B<?> to print the result of applying LENS to STRING, or the symbol
+B<*> to indicate that the test should produce an exception.
+
+=head1 SEE ALSO
+
+B<Augeas> project homepage L<http://www.augeas.net/>
+
+L<augtool>
diff --git a/man/augtool.1 b/man/augtool.1
new file mode 100644 (file)
index 0000000..62884d4
--- /dev/null
@@ -0,0 +1,331 @@
+.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
+.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.el \{\
+.    de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "AUGTOOL 1"
+.TH AUGTOOL 1 "2011-02-21" "Augeas 0.8.0" "Augeas"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+augtool \- inspect and modify configuration files
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+augtool [\s-1OPTIONS\s0] [\s-1COMMAND\s0]
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+Augeas is a configuration editing tool. It parses configuration files
+in their native formats and transforms them into a tree. Configuration
+changes are made by manipulating this tree and saving it back into
+native config files.
+.PP
+augtool provides a command line interface to the generated tree. \s-1COMMAND\s0
+can be a single command as described under \*(L"\s-1COMMANDS\s0\*(R". When called with
+no \s-1COMMAND\s0, it reads commands from standard input until an end-of-file is
+encountered.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+.IP "\fB\-c\fR, \fB\-\-typecheck\fR" 4
+.IX Item "-c, --typecheck"
+Typecheck lenses. This can be very slow, and is therefore not done by
+default, but is highly recommended during development.
+.IP "\fB\-b\fR, \fB\-\-backup\fR" 4
+.IX Item "-b, --backup"
+When files are changed, preserve the originals in a file with extension
+\&'.augsave'
+.IP "\fB\-n\fR, \fB\-\-new\fR" 4
+.IX Item "-n, --new"
+Save changes in files with extension '.augnew', do not modify the original
+files
+.IP "\fB\-r\fR, \fB\-\-root\fR=\fI\s-1ROOT\s0\fR" 4
+.IX Item "-r, --root=ROOT"
+Use directory \s-1ROOT\s0 as the root of the filesystem. Takes precedence over a
+root set with the \s-1AUGEAS_ROOT\s0 environment variable.
+.IP "\fB\-I\fR, \fB\-\-include\fR=\fI\s-1DIR\s0\fR" 4
+.IX Item "-I, --include=DIR"
+Add \s-1DIR\s0 to the module loadpath. Can be given multiple times. The
+directories set here are searched before any directories specified in the
+\&\s-1AUGEAS_LENS_LIB\s0 environment variable, and before the default directory
+\&\fI/usr/share/augeas/lenses\fR.
+.IP "\fB\-f\fR, \fB\-\-file\fR=\fI\s-1FILE\s0\fR" 4
+.IX Item "-f, --file=FILE"
+Read commands from \s-1FILE\s0.
+.IP "\fB\-i\fR, \fB\-\-interactive\fR" 4
+.IX Item "-i, --interactive"
+Read commands from the terminal. When combined with \fB\-f\fR or redirection of
+stdin, drop into an interactive session after executing the commands from
+the file.
+.IP "\fB\-e\fR" 4
+.IX Item "-e"
+When reading commands from a file via stdin, echo the commands before
+printing their output.
+.IP "\fB\-s\fR, \fB\-\-autosave\fR" 4
+.IX Item "-s, --autosave"
+Automatically save all changes at the end of the session.
+.IP "\fB\-S\fR, \fB\-\-nostdinc\fR" 4
+.IX Item "-S, --nostdinc"
+Do not search any of the default directories for modules. When this option
+is set, only directories specified explicitly with \fB\-I\fR or specified in
+\&\fB\s-1AUGEAS_LENS_LIB\s0\fR will be searched for modules.
+.IP "\fB\-L\fR, \fB\-\-noload\fR" 4
+.IX Item "-L, --noload"
+Do not load any files on startup. This is generally used to fine-tune which
+files to load by modifying the entries in \f(CW\*(C`/augeas/load\*(C'\fR and then issuing
+a \f(CW\*(C`load\*(C'\fR command.
+.IP "\fB\-A\fR, \fB\-\-noautoload\fR" 4
+.IX Item "-A, --noautoload"
+Do not load any lens modules, and therefore no files, on startup. This
+creates no entries under \f(CW\*(C`/augeas/load\*(C'\fR whatsoever; to read any files,
+they need to be set up manually and loading must be initiated with a
+\&\f(CW\*(C`load\*(C'\fR command. Using this option gives the fastest startup.
+.IP "\fB\-\-version\fR" 4
+.IX Item "--version"
+Print version information and exit. The version is also in the tree under
+\&\f(CW\*(C`/augeas/version\*(C'\fR.
+.SH "COMMANDS"
+.IX Header "COMMANDS"
+In interactive mode, commands and paths can be completed by pressing \f(CW\*(C`TAB\*(C'\fR.
+.PP
+The paths accepted as arguments by commands use a small subset of XPath
+path expressions. A path expression consists of a number of segments,
+separated by \f(CW\*(C`/\*(C'\fR. In each segment, the character \f(CW\*(C`*\*(C'\fR can be used to match
+every node regardless of its label. Sibling nodes with identical labels can
+be distinguished by appending \f(CW\*(C`[N]\*(C'\fR to their label to match the N\-th
+sibling with such a label. The last sibling with a specific label can be
+reached as \f(CW\*(C`[last()]\*(C'\fR. See \*(L"\s-1EXAMPLES\s0\*(R" for some examples of this.
+.IP "\fBquit\fR" 4
+.IX Item "quit"
+Exit the program
+.IP "\fBls\fR <\s-1PATH\s0>" 4
+.IX Item "ls <PATH>"
+List the direct children of \s-1PATH\s0
+.IP "\fBmatch\fR <\s-1PATTERN\s0> [<\s-1VALUE\s0>]" 4
+.IX Item "match <PATTERN> [<VALUE>]"
+Find all paths that match \s-1PATTERN\s0. If \s-1VALUE\s0 is given, only the matching
+paths whose value equals \s-1VALUE\s0 are printed
+.IP "\fBrm\fR <\s-1PATH\s0>" 4
+.IX Item "rm <PATH>"
+Delete \s-1PATH\s0 and all its children from the tree
+.IP "\fBmv\fR <\s-1SRC\s0> <\s-1DST\s0>" 4
+.IX Item "mv <SRC> <DST>"
+Move node \s-1SRC\s0 to \s-1DST\s0. \s-1SRC\s0 must match exactly one node in the tree.  \s-1DST\s0
+must either match exactly one node in the tree, or may not exist yet. If
+\&\s-1DST\s0 exists already, it and all its descendants are deleted. If \s-1DST\s0 does not
+exist yet, it and all its missing ancestors are created.
+.IP "\fBset\fR <\s-1PATH\s0> <\s-1VALUE\s0>" 4
+.IX Item "set <PATH> <VALUE>"
+Associate \s-1VALUE\s0 with \s-1PATH\s0. If \s-1PATH\s0 is not in the tree yet,
+it and all its ancestors will be created.
+.IP "\fBclear\fR <\s-1PATH\s0>" 4
+.IX Item "clear <PATH>"
+Set the value for \s-1PATH\s0 to \s-1NULL\s0. If \s-1PATH\s0 is not in the tree yet, it and all
+its ancestors will be created.
+.IP "\fBget\fR <\s-1PATH\s0>" 4
+.IX Item "get <PATH>"
+Print the value associated with \s-1PATH\s0
+.IP "\fBprint\fR \fI[<\s-1PATH\s0>]\fR" 4
+.IX Item "print [<PATH>]"
+Print entries in the tree. If \s-1PATH\s0 is given, printing starts there,
+otherwise the whole tree is printed
+.IP "\fBins\fR \fI<\s-1LABEL\s0>\fR \fI<\s-1WHERE\s0>\fR \fI<\s-1PATH\s0>\fR" 4
+.IX Item "ins <LABEL> <WHERE> <PATH>"
+Insert a new node with label \s-1LABEL\s0 right before or after \s-1PATH\s0 into the
+tree. \s-1WHERE\s0 must be either 'before' or 'after'.
+.IP "\fBsave\fR" 4
+.IX Item "save"
+Save all pending changes to disk. Unless either the \fB\-b\fR or \fB\-n\fR
+command line options are given, files are changed in place.
+.IP "\fBload\fR" 4
+.IX Item "load"
+Load files according to the transforms in \f(CW\*(C`/augeas/load\*(C'\fR.
+.IP "\fBdefvar\fR <\s-1NAME\s0> <\s-1EXPR\s0>" 4
+.IX Item "defvar <NAME> <EXPR>"
+Define the variable \s-1NAME\s0 to the result of evaluating \s-1EXPR\s0. The variable
+can be used in path expressions as \f(CW$NAME\fR. Note that \s-1EXPR\s0 is evaluated when
+the variable is defined, not when it is used.
+.IP "\fBdefnode\fR <\s-1NAME\s0> <\s-1EXPR\s0> [<\s-1VALUE\s0>]" 4
+.IX Item "defnode <NAME> <EXPR> [<VALUE>]"
+Define the variable \s-1NAME\s0 to the result of evaluating \s-1EXPR\s0, which must be a
+nodeset. If no node matching \s-1EXPR\s0 exists yet, one is created and \s-1NAME\s0 will
+refer to it. If \s-1VALUE\s0 is given, this is the same as 'set \s-1EXPR\s0 \s-1VALUE\s0'; if
+\&\s-1VALUE\s0 is not given, the node is created as if with 'clear \s-1EXPR\s0' would and
+\&\s-1NAME\s0 refers to that node.
+.IP "\fBhelp\fR" 4
+.IX Item "help"
+Print this help text
+.SH "ENVIRONMENT VARIABLES"
+.IX Header "ENVIRONMENT VARIABLES"
+.IP "\fB\s-1AUGEAS_ROOT\s0\fR" 4
+.IX Item "AUGEAS_ROOT"
+The file system root, defaults to '/'. Can be overridden with
+the \fB\-r\fR command line option
+.IP "\fB\s-1AUGEAS_LENS_LIB\s0\fR" 4
+.IX Item "AUGEAS_LENS_LIB"
+Colon separated list of directories with lenses. Directories specified here
+are searched after any directories set with the \fB\-I\fR command line option,
+but before the default directory \fI/usr/share/augeas/lenses\fR
+.SH "DIAGNOSTICS"
+.IX Header "DIAGNOSTICS"
+Normally, exit status is 0. If one or more commands fail, the exit status
+is set to a non-zero value.
+.SH "EXAMPLES"
+.IX Header "EXAMPLES"
+.Vb 2
+\&  # command line mode
+\&  augtool print /files/etc/hosts/
+\&
+\&  # interactive mode
+\&  augtool
+\&  augtool> help
+\&  augtool> print /files/etc/hosts/
+\&
+\&  # Print the third entry from the second AcceptEnv line
+\&  augtool print \*(Aq/files/etc/ssh/sshd_config/AcceptEnv[2]/3\*(Aq
+\&
+\&  # Find the entry in inittab with action \*(Aqinitdefault\*(Aq
+\&  augtool> match /files/etc/inittab/*/action initdefault
+\&
+\&  # Print the last alias for each entry in /etc/hosts
+\&  augtool> print /files/etc/hosts/*/alias[last()]
+.Ve
+.SH "FILES"
+.IX Header "FILES"
+Lenses and schema definitions in \fI/usr/share/augeas/lenses\fR
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+.Vb 1
+\&  David Lutterkort <dlutter@redhat.com>
+.Ve
+.SH "COPYRIGHT AND LICENSE"
+.IX Header "COPYRIGHT AND LICENSE"
+Copyright 2007, 2008 Red Hat Inc.
+.PP
+Augeas (and augtool) are distributed under the \s-1GNU\s0 Lesser General Public
+License (\s-1LGPL\s0)
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+\&\fBAugeas\fR project homepage <http://www.augeas.net/>
+.PP
+augparse
diff --git a/man/augtool.pod b/man/augtool.pod
new file mode 100644 (file)
index 0000000..5fbb873
--- /dev/null
@@ -0,0 +1,248 @@
+=head1 NAME
+
+augtool - inspect and modify configuration files
+
+=head1 SYNOPSIS
+
+augtool [OPTIONS] [COMMAND]
+
+=head1 DESCRIPTION
+
+Augeas is a configuration editing tool. It parses configuration files
+in their native formats and transforms them into a tree. Configuration
+changes are made by manipulating this tree and saving it back into
+native config files.
+
+augtool provides a command line interface to the generated tree. COMMAND
+can be a single command as described under L</COMMANDS>. When called with
+no COMMAND, it reads commands from standard input until an end-of-file is
+encountered.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-c>, B<--typecheck>
+
+Typecheck lenses. This can be very slow, and is therefore not done by
+default, but is highly recommended during development.
+
+=item B<-b>, B<--backup>
+
+When files are changed, preserve the originals in a file with extension
+'.augsave'
+
+=item B<-n>, B<--new>
+
+Save changes in files with extension '.augnew', do not modify the original
+files
+
+=item B<-r>, B<--root>=I<ROOT>
+
+Use directory ROOT as the root of the filesystem. Takes precedence over a
+root set with the AUGEAS_ROOT environment variable.
+
+=item B<-I>, B<--include>=I<DIR>
+
+Add DIR to the module loadpath. Can be given multiple times. The
+directories set here are searched before any directories specified in the
+AUGEAS_LENS_LIB environment variable, and before the default directory
+F</usr/share/augeas/lenses>.
+
+=item B<-f>, B<--file>=I<FILE>
+
+Read commands from FILE.
+
+=item B<-i>, B<--interactive>
+
+Read commands from the terminal. When combined with B<-f> or redirection of
+stdin, drop into an interactive session after executing the commands from
+the file.
+
+=item B<-e>
+
+When reading commands from a file via stdin, echo the commands before
+printing their output.
+
+=item B<-s>, B<--autosave>
+
+Automatically save all changes at the end of the session.
+
+=item B<-S>, B<--nostdinc>
+
+Do not search any of the default directories for modules. When this option
+is set, only directories specified explicitly with B<-I> or specified in
+B<AUGEAS_LENS_LIB> will be searched for modules.
+
+=item B<-L>, B<--noload>
+
+Do not load any files on startup. This is generally used to fine-tune which
+files to load by modifying the entries in C</augeas/load> and then issuing
+a C<load> command.
+
+=item B<-A>, B<--noautoload>
+
+Do not load any lens modules, and therefore no files, on startup. This
+creates no entries under C</augeas/load> whatsoever; to read any files,
+they need to be set up manually and loading must be initiated with a
+C<load> command. Using this option gives the fastest startup.
+
+=item B<--version>
+
+Print version information and exit. The version is also in the tree under
+C</augeas/version>.
+
+=back
+
+=head1 COMMANDS
+
+In interactive mode, commands and paths can be completed by pressing C<TAB>.
+
+The paths accepted as arguments by commands use a small subset of XPath
+path expressions. A path expression consists of a number of segments,
+separated by C</>. In each segment, the character C<*> can be used to match
+every node regardless of its label. Sibling nodes with identical labels can
+be distinguished by appending C<[N]> to their label to match the N-th
+sibling with such a label. The last sibling with a specific label can be
+reached as C<[last()]>. See L</EXAMPLES> for some examples of this.
+
+=over 4
+
+=item B<quit>
+
+Exit the program
+
+=item B<ls> E<lt>PATHE<gt>
+
+List the direct children of PATH
+
+=item B<match> E<lt>PATTERNE<gt> [E<lt>VALUEE<gt>]
+
+Find all paths that match PATTERN. If VALUE is given, only the matching
+paths whose value equals VALUE are printed
+
+=item B<rm> E<lt>PATHE<gt>
+
+Delete PATH and all its children from the tree
+
+=item B<mv> E<lt>SRCE<gt> E<lt>DSTE<gt>
+
+Move node SRC to DST. SRC must match exactly one node in the tree.  DST
+must either match exactly one node in the tree, or may not exist yet. If
+DST exists already, it and all its descendants are deleted. If DST does not
+exist yet, it and all its missing ancestors are created.
+
+=item B<set> E<lt>PATHE<gt> E<lt>VALUEE<gt>
+
+Associate VALUE with PATH. If PATH is not in the tree yet,
+it and all its ancestors will be created.
+
+=item B<clear> E<lt>PATHE<gt>
+
+Set the value for PATH to NULL. If PATH is not in the tree yet, it and all
+its ancestors will be created.
+
+=item B<get> E<lt>PATHE<gt>
+
+Print the value associated with PATH
+
+=item B<print> I<[E<lt>PATHE<gt>]>
+
+Print entries in the tree. If PATH is given, printing starts there,
+otherwise the whole tree is printed
+
+=item B<ins> I<E<lt>LABELE<gt>> I<E<lt>WHEREE<gt>> I<E<lt>PATHE<gt>>
+
+Insert a new node with label LABEL right before or after PATH into the
+tree. WHERE must be either 'before' or 'after'.
+
+=item B<save>
+
+Save all pending changes to disk. Unless either the B<-b> or B<-n>
+command line options are given, files are changed in place.
+
+=item B<load>
+
+Load files according to the transforms in C</augeas/load>.
+
+=item B<defvar> E<lt>NAMEE<gt> E<lt>EXPRE<gt>
+
+Define the variable NAME to the result of evaluating EXPR. The variable
+can be used in path expressions as $NAME. Note that EXPR is evaluated when
+the variable is defined, not when it is used.
+
+=item B<defnode> E<lt>NAMEE<gt> E<lt>EXPRE<gt> [E<lt>VALUEE<gt>]
+
+Define the variable NAME to the result of evaluating EXPR, which must be a
+nodeset. If no node matching EXPR exists yet, one is created and NAME will
+refer to it. If VALUE is given, this is the same as 'set EXPR VALUE'; if
+VALUE is not given, the node is created as if with 'clear EXPR' would and
+NAME refers to that node.
+
+=item B<help>
+
+Print this help text
+
+=back
+
+=head1 ENVIRONMENT VARIABLES
+
+=over 4
+
+=item B<AUGEAS_ROOT>
+
+The file system root, defaults to '/'. Can be overridden with
+the B<-r> command line option
+
+=item B<AUGEAS_LENS_LIB>
+
+Colon separated list of directories with lenses. Directories specified here
+are searched after any directories set with the B<-I> command line option,
+but before the default directory F</usr/share/augeas/lenses>
+
+=back
+
+=head1 DIAGNOSTICS
+
+Normally, exit status is 0. If one or more commands fail, the exit status
+is set to a non-zero value.
+
+=head1 EXAMPLES
+
+  # command line mode
+  augtool print /files/etc/hosts/
+
+  # interactive mode
+  augtool
+  augtool> help
+  augtool> print /files/etc/hosts/
+
+  # Print the third entry from the second AcceptEnv line
+  augtool print '/files/etc/ssh/sshd_config/AcceptEnv[2]/3'
+
+  # Find the entry in inittab with action 'initdefault'
+  augtool> match /files/etc/inittab/*/action initdefault
+
+  # Print the last alias for each entry in /etc/hosts
+  augtool> print /files/etc/hosts/*/alias[last()]
+
+=head1 FILES
+
+Lenses and schema definitions in F</usr/share/augeas/lenses>
+
+=head1 AUTHOR
+
+  David Lutterkort <dlutter@redhat.com>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007, 2008 Red Hat Inc.
+
+Augeas (and augtool) are distributed under the GNU Lesser General Public
+License (LGPL)
+
+=head1 SEE ALSO
+
+B<Augeas> project homepage L<http://www.augeas.net/>
+
+L<augparse>
diff --git a/packaging/augeas.changes b/packaging/augeas.changes
new file mode 100644 (file)
index 0000000..5c7095d
--- /dev/null
@@ -0,0 +1,15 @@
+* Thu May 26 2011 Junfeng Dong <junfeng.dong@intel.com> - 0.8.1
+- Update to latest version 0.8.1 to work with gcc 4.6 
+  (failure caused by -Wunused-but-set-variable).
+
+* Sat Sep 04 2010 Anas Nashif <nashif@linux.intel.com> - 0.7.2
+- Fixed dependencies: libs should not require augeas
+
+* Mon Jul 12 2010 Yu <yu.a.wang@intel.com> - 0.7.2
+- Update to 0.7.2, use spectacle
+
+* Wed Jan 27 2010 Peter J Zhu <peter.j.zhu@intel.com> - 0.7.0
+- Update to 0.7
+
+* Fri Aug 14 2009 Anas Nashif <anas.nashif@intel.com> - 0.5.2
+- Initial import into Moblin
diff --git a/packaging/augeas.spec b/packaging/augeas.spec
new file mode 100644 (file)
index 0000000..cdcedd2
--- /dev/null
@@ -0,0 +1,92 @@
+
+Name:       augeas
+Summary:    A library for changing configuration files
+Version:    0.8.1
+Release:    1
+Group:      System/Libraries
+License:    LGPLv2+
+URL:        http://augeas.net/
+Source0:    http://augeas.net/download/%{name}-%{version}.tar.gz
+BuildRequires:  readline-devel
+
+
+%description
+A library for programmatically editing configuration files. Augeas parses
+configuration files into a tree structure, which it exposes through its
+public API. Changes made through the API are written back to the initially
+read files.
+
+The transformation works very hard to preserve comments and formatting
+details. It is controlled by ``lens'' definitions that describe the file
+format and the transformation into a tree.
+
+
+
+%package libs
+Summary:    Libraries for %{name}
+Group:      System/Libraries
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description libs
+The libraries for %{name}.
+
+%package devel
+Summary:    Development files for %{name}
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+The %{name}-devel package contains libraries and header files for
+developing applications that use %{name}.
+
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+
+%build
+
+%configure --disable-static
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
+
+
+
+
+
+
+
+
+%post libs -p /sbin/ldconfig
+
+%postun libs -p /sbin/ldconfig
+
+
+%docs_package
+
+
+%files
+%{_bindir}/augtool
+%{_bindir}/augparse
+%{_bindir}/fadot
+%{_datadir}/vim/vimfiles/syntax/augeas.vim
+%{_datadir}/vim/vimfiles/ftdetect/augeas.vim
+
+
+%files libs
+%{_datadir}/augeas
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/augeas.pc
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..adfd9bf
--- /dev/null
@@ -0,0 +1,67 @@
+GNULIB= ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
+
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS)
+
+AM_YFLAGS=-d -p spec_
+
+EXTRA_DIST = try augeas_sym.version fa_sym.version
+
+BUILT_SOURCES = datadir.h
+
+DISTCLEANFILES = datadir.h
+
+lib_LTLIBRARIES = libfa.la libaugeas.la
+noinst_LTLIBRARIES = liblexer.la
+
+bin_PROGRAMS = augtool augparse
+
+include_HEADERS = augeas.h fa.h
+
+libaugeas_la_SOURCES = augeas.h augeas.c pathx.c \
+       internal.h internal.c \
+       memory.h memory.c ref.h ref.c \
+    syntax.c syntax.h parser.y builtin.c lens.c lens.h regexp.c regexp.h \
+       transform.h transform.c ast.c get.c put.c list.h \
+    info.c info.h errcode.c errcode.h jmt.h jmt.c
+
+if USE_VERSION_SCRIPT
+  AUGEAS_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/augeas_sym.version
+  FA_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/fa_sym.version
+else
+  AUGEAS_VERSION_SCRIPT =
+  FA_VERSION_SCRIPT =
+endif
+
+libaugeas_la_LDFLAGS = $(AUGEAS_VERSION_SCRIPT) \
+    -version-info $(LIBAUGEAS_VERSION_INFO)
+libaugeas_la_LIBADD = liblexer.la libfa.la $(LIB_SELINUX) $(GNULIB)
+
+augtool_SOURCES = augtool.c
+augtool_LDADD = libaugeas.la $(READLINE_LIBS) $(GNULIB)
+
+augparse_SOURCES = augparse.c
+augparse_LDADD = libaugeas.la $(GNULIB)
+
+libfa_la_SOURCES = fa.c fa.h hash.c hash.h memory.c memory.h ref.h ref.c
+libfa_la_LIBADD = $(LIB_SELINUX) $(GNULIB)
+libfa_la_LDFLAGS = $(FA_VERSION_SCRIPT) -version-info $(LIBFA_VERSION_INFO)
+
+liblexer_la_SOURCES = lexer.l
+liblexer_la_CFLAGS = $(AM_CFLAGS) -Wno-error
+
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./augtool
+
+include $(top_srcdir)/Makefile.inc
+
+# Generate datadir.h. AUGEAS_LENS_DIR in internal.h depends on
+# the value of DATADIR
+internal.h: datadir.h
+
+FORCE-datadir.h: Makefile
+       echo '#define DATADIR "$(datadir)"' > datadir.h1
+       $(top_srcdir)/build/aux/move-if-change datadir.h1 datadir.h
+
+datadir.h: FORCE-datadir.h
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644 (file)
index 0000000..9480f8e
--- /dev/null
@@ -0,0 +1,1527 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# -*- Makefile-automake -*-
+#
+# Support for running programs with failmalloc preloaded. Include in other
+# automake files and make sure the following variables are set:
+#
+# FAILMALLOC_START - number of first FAILMALLOC_INTERVAL
+# FAILMALLOC_REP   - how often to repeat with increasing FAILMALLOC_INTERVAL
+# FAILMALLOC_PROG  - the program to run with linfailmalloc preloaded
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = augtool$(EXEEXT) augparse$(EXEEXT)
+DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(top_srcdir)/Makefile.inc lexer.c \
+       parser.c parser.h
+subdir = src
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+       "$(DESTDIR)$(includedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libaugeas_la_DEPENDENCIES = liblexer.la libfa.la $(am__DEPENDENCIES_1) \
+       $(GNULIB)
+am_libaugeas_la_OBJECTS = augeas.lo pathx.lo internal.lo memory.lo \
+       ref.lo syntax.lo parser.lo builtin.lo lens.lo regexp.lo \
+       transform.lo ast.lo get.lo put.lo info.lo errcode.lo jmt.lo
+libaugeas_la_OBJECTS = $(am_libaugeas_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libaugeas_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libaugeas_la_LDFLAGS) $(LDFLAGS) -o $@
+libfa_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(GNULIB)
+am_libfa_la_OBJECTS = fa.lo hash.lo memory.lo ref.lo
+libfa_la_OBJECTS = $(am_libfa_la_OBJECTS)
+libfa_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libfa_la_LDFLAGS) $(LDFLAGS) -o $@
+liblexer_la_LIBADD =
+am_liblexer_la_OBJECTS = liblexer_la-lexer.lo
+liblexer_la_OBJECTS = $(am_liblexer_la_OBJECTS)
+liblexer_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(liblexer_la_CFLAGS) \
+       $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+PROGRAMS = $(bin_PROGRAMS)
+am_augparse_OBJECTS = augparse.$(OBJEXT)
+augparse_OBJECTS = $(am_augparse_OBJECTS)
+augparse_DEPENDENCIES = libaugeas.la $(GNULIB)
+am_augtool_OBJECTS = augtool.$(OBJEXT)
+augtool_OBJECTS = $(am_augtool_OBJECTS)
+augtool_DEPENDENCIES = libaugeas.la $(am__DEPENDENCIES_1) $(GNULIB)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+LTLEXCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS)
+AM_V_LEX = $(am__v_LEX_$(V))
+am__v_LEX_ = $(am__v_LEX_$(AM_DEFAULT_VERBOSITY))
+am__v_LEX_0 = @echo "  LEX   " $@;
+YLWRAP = $(top_srcdir)/build/aux/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS)
+AM_V_YACC = $(am__v_YACC_$(V))
+am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY))
+am__v_YACC_0 = @echo "  YACC  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libaugeas_la_SOURCES) $(libfa_la_SOURCES) \
+       $(liblexer_la_SOURCES) $(augparse_SOURCES) $(augtool_SOURCES)
+DIST_SOURCES = $(libaugeas_la_SOURCES) $(libfa_la_SOURCES) \
+       $(liblexer_la_SOURCES) $(augparse_SOURCES) $(augtool_SOURCES)
+HEADERS = $(include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+GNULIB = ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS = -I $(top_srcdir)/gnulib/lib
+AM_CFLAGS = @AUGEAS_CFLAGS@ @WARN_CFLAGS@ $(GNULIB_CFLAGS)
+AM_YFLAGS = -d -p spec_
+EXTRA_DIST = try augeas_sym.version fa_sym.version
+BUILT_SOURCES = datadir.h
+DISTCLEANFILES = datadir.h
+lib_LTLIBRARIES = libfa.la libaugeas.la
+noinst_LTLIBRARIES = liblexer.la
+include_HEADERS = augeas.h fa.h
+libaugeas_la_SOURCES = augeas.h augeas.c pathx.c \
+       internal.h internal.c \
+       memory.h memory.c ref.h ref.c \
+    syntax.c syntax.h parser.y builtin.c lens.c lens.h regexp.c regexp.h \
+       transform.h transform.c ast.c get.c put.c list.h \
+    info.c info.h errcode.c errcode.h jmt.h jmt.c
+
+@USE_VERSION_SCRIPT_FALSE@AUGEAS_VERSION_SCRIPT = 
+@USE_VERSION_SCRIPT_TRUE@AUGEAS_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/augeas_sym.version
+@USE_VERSION_SCRIPT_FALSE@FA_VERSION_SCRIPT = 
+@USE_VERSION_SCRIPT_TRUE@FA_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/fa_sym.version
+libaugeas_la_LDFLAGS = $(AUGEAS_VERSION_SCRIPT) \
+    -version-info $(LIBAUGEAS_VERSION_INFO)
+
+libaugeas_la_LIBADD = liblexer.la libfa.la $(LIB_SELINUX) $(GNULIB)
+augtool_SOURCES = augtool.c
+augtool_LDADD = libaugeas.la $(READLINE_LIBS) $(GNULIB)
+augparse_SOURCES = augparse.c
+augparse_LDADD = libaugeas.la $(GNULIB)
+libfa_la_SOURCES = fa.c fa.h hash.c hash.h memory.c memory.h ref.h ref.c
+libfa_la_LIBADD = $(LIB_SELINUX) $(GNULIB)
+libfa_la_LDFLAGS = $(FA_VERSION_SCRIPT) -version-info $(LIBFA_VERSION_INFO)
+liblexer_la_SOURCES = lexer.l
+liblexer_la_CFLAGS = $(AM_CFLAGS) -Wno-error
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .l .lo .o .obj .y
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/Makefile.inc $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+       }
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+parser.h: parser.c
+       @if test ! -f $@; then \
+         rm -f parser.c; \
+         $(MAKE) $(AM_MAKEFLAGS) parser.c; \
+       else :; fi
+libaugeas.la: $(libaugeas_la_OBJECTS) $(libaugeas_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(libaugeas_la_LINK) -rpath $(libdir) $(libaugeas_la_OBJECTS) $(libaugeas_la_LIBADD) $(LIBS)
+libfa.la: $(libfa_la_OBJECTS) $(libfa_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(libfa_la_LINK) -rpath $(libdir) $(libfa_la_OBJECTS) $(libfa_la_LIBADD) $(LIBS)
+liblexer.la: $(liblexer_la_OBJECTS) $(liblexer_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(liblexer_la_LINK)  $(liblexer_la_OBJECTS) $(liblexer_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+augparse$(EXEEXT): $(augparse_OBJECTS) $(augparse_DEPENDENCIES) 
+       @rm -f augparse$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(augparse_OBJECTS) $(augparse_LDADD) $(LIBS)
+augtool$(EXEEXT): $(augtool_OBJECTS) $(augtool_DEPENDENCIES) 
+       @rm -f augtool$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(augtool_OBJECTS) $(augtool_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ast.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/augeas.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/augparse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/augtool.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/builtin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errcode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fa.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/internal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jmt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lens.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblexer_la-lexer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pathx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/put.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ref.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syntax.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transform.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+liblexer_la-lexer.lo: lexer.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblexer_la_CFLAGS) $(CFLAGS) -MT liblexer_la-lexer.lo -MD -MP -MF $(DEPDIR)/liblexer_la-lexer.Tpo -c -o liblexer_la-lexer.lo `test -f 'lexer.c' || echo '$(srcdir)/'`lexer.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/liblexer_la-lexer.Tpo $(DEPDIR)/liblexer_la-lexer.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='lexer.c' object='liblexer_la-lexer.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblexer_la_CFLAGS) $(CFLAGS) -c -o liblexer_la-lexer.lo `test -f 'lexer.c' || echo '$(srcdir)/'`lexer.c
+
+.l.c:
+       $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+       $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+       @$(NORMAL_INSTALL)
+       test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+       @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+         $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+       done
+
+uninstall-includeHEADERS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+install-binPROGRAMS: install-libLTLIBRARIES
+
+installdirs:
+       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+       -rm -f lexer.c
+       -rm -f parser.c
+       -rm -f parser.h
+       -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+       clean-libtool clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
+       uninstall-libLTLIBRARIES
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libLTLIBRARIES clean-libtool \
+       clean-noinstLTLIBRARIES ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-includeHEADERS install-info \
+       install-info-am install-libLTLIBRARIES install-man install-pdf \
+       install-pdf-am install-ps install-ps-am install-strip \
+       installcheck installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags uninstall uninstall-am uninstall-binPROGRAMS \
+       uninstall-includeHEADERS uninstall-libLTLIBRARIES
+
+
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./augtool
+
+@WITH_FAILMALLOC_TRUE@failmalloc: failmalloc-run
+@WITH_FAILMALLOC_FALSE@failmalloc: failmalloc-error
+
+failmalloc-run: $(FAILMALLOC_PROG)
+       @(echo "Running $(FAILMALLOC_PROG) with failmalloc";    \
+      for i in $$(seq $(FAILMALLOC_START) $$(expr $(FAILMALLOC_START) + $(FAILMALLOC_REP) - 1)) ; do \
+         resp=$$(libtool --mode=execute env LD_PRELOAD=$(LIBFAILMALLOC) FAILMALLOC_INTERVAL=$$i $(FAILMALLOC_PROG));        \
+         status=$$?;                                          \
+         if [ $$status -ne 0 -a $$status -ne 2 ] ;     then       \
+           printf "%5d FAIL %3d %s\n" $$i $$status "$$resp" ; \
+         elif [ x$(V) = x1 -o $$(( $$i % 100 )) -eq 0 ] ; then \
+           printf "%5d PASS %s\n" $$i "$$resp" ;              \
+         fi                                                   \
+       done)
+
+failmalloc-error:
+       @(echo "You need to turn on failmalloc support with --with-failmalloc"; \
+         exit 1)
+
+# Generate datadir.h. AUGEAS_LENS_DIR in internal.h depends on
+# the value of DATADIR
+internal.h: datadir.h
+
+FORCE-datadir.h: Makefile
+       echo '#define DATADIR "$(datadir)"' > datadir.h1
+       $(top_srcdir)/build/aux/move-if-change datadir.h1 datadir.h
+
+datadir.h: FORCE-datadir.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/ast.c b/src/ast.c
new file mode 100644 (file)
index 0000000..6efcc3e
--- /dev/null
+++ b/src/ast.c
@@ -0,0 +1,225 @@
+/*
+ * ast.c: Support routines for put/get
+ *
+ * Copyright (C) 2008-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <stdint.h>
+
+#include "internal.h"
+#include "memory.h"
+#include "lens.h"
+
+/* A dictionary that maps key to a list of (skel, dict) */
+struct dict_entry {
+    struct dict_entry *next;
+    struct skel *skel;
+    struct dict *dict;
+};
+
+/* Associates a KEY with a list of skel/dict pairs.
+
+   Dicts are used in two phases: first they are constructed, through
+   repeated calls to dict_append. In the second phase, items are looked up
+   and removed from the dict.
+
+   During construction, MARK points to the end of the list ENTRY. Once
+   construction is done, MARK points to the head of that list, and ENTRY is
+   moved towards the tail everytime an item is looked up.
+*/
+struct dict_node {
+    char *key;
+    struct dict_entry *entry; /* This will change as entries are looked up */
+    struct dict_entry *mark;  /* Pointer to initial entry, will never change */
+};
+
+/* Nodes are kept sorted by their key, with NULL being smaller than any
+   string */
+struct dict {
+    struct dict_node **nodes;
+    uint32_t          size;
+    uint32_t          used;
+    bool              marked;
+};
+
+static const int dict_initial_size = 2;
+static const int dict_max_expansion = 128;
+static const uint32_t dict_max_size = (1<<24) - 1;
+
+struct dict *make_dict(char *key, struct skel *skel, struct dict *subdict) {
+    struct dict *dict = NULL;
+    if (ALLOC(dict) < 0)
+        goto error;
+    if (ALLOC_N(dict->nodes, dict_initial_size) < 0)
+        goto error;
+    if (ALLOC(dict->nodes[0]) < 0)
+        goto error;
+    if (ALLOC(dict->nodes[0]->entry) < 0)
+        goto error;
+
+    dict->size = dict_initial_size;
+    dict->used = 1;
+    dict->nodes[0]->key = key;
+    dict->nodes[0]->entry->skel = skel;
+    dict->nodes[0]->entry->dict = subdict;
+    dict->nodes[0]->mark = dict->nodes[0]->entry;
+
+    return dict;
+ error:
+    if (dict->nodes) {
+        if (dict->nodes[0])
+            FREE(dict->nodes[0]->entry);
+        FREE(dict->nodes[0]);
+    }
+    FREE(dict->nodes);
+    FREE(dict);
+    return NULL;
+}
+
+void free_dict(struct dict *dict) {
+    if (dict == NULL)
+        return;
+
+    for (int i=0; i < dict->used; i++) {
+        struct dict_node *node = dict->nodes[i];
+        if (! dict->marked)
+            node->mark = node->entry;
+        while (node->mark != NULL) {
+            struct dict_entry *del = node->mark;
+            node->mark = del->next;
+            free_skel(del->skel);
+            free_dict(del->dict);
+            free(del);
+        }
+        free(node->key);
+        FREE(node);
+    }
+    FREE(dict->nodes);
+    FREE(dict);
+}
+
+/* Return the position of KEY in DICT as an integer between 0 and
+   DICT->USED.  If KEY is not in DICT, return a negative number P such that
+   -(P + 1) is the position at which KEY must be inserted to keep the keys
+   of the nodes in DICT sorted.
+*/
+static int dict_pos(struct dict *dict, const char *key) {
+    if (key == NULL) {
+        return (dict->nodes[0]->key == NULL) ? 0 : -1;
+    }
+
+    int l = dict->nodes[0]->key == NULL ? 1 : 0;
+    int h = dict->used;
+    while (l < h) {
+        int m = (l + h)/2;
+        int cmp = strcmp(dict->nodes[m]->key, key);
+        if (cmp > 0)
+            h = m;
+        else if (cmp < 0)
+            l = m + 1;
+        else
+            return m;
+    }
+    return -(l + 1);
+}
+
+static int dict_expand(struct dict *dict) {
+    uint32_t size = dict->size;
+
+    if (size == dict_max_size)
+        return -1;
+    if (size > dict_max_expansion)
+        size += dict_max_expansion;
+    else
+        size *= 2;
+    if (size > dict_max_size)
+        size = dict_max_size;
+    dict->size = size;
+    return REALLOC_N(dict->nodes, dict->size);
+}
+
+int dict_append(struct dict **dict, struct dict *d2) {
+    if (d2 == NULL)
+        return 0;
+
+    if (*dict == NULL) {
+        *dict = d2;
+        return 0;
+    }
+
+    struct dict *d1 = *dict;
+    for (int i2 = 0; i2 < d2->used; i2++) {
+        struct dict_node *n2 = d2->nodes[i2];
+        int i1 = dict_pos(d1, n2->key);
+        if (i1 < 0) {
+            i1 = - i1 - 1;
+            if (d1->size == d1->used) {
+                if (dict_expand(d1) < 0)
+                    return -1;
+            }
+            memmove(d1->nodes + i1 + 1, d1->nodes + i1,
+                    sizeof(*d1->nodes) * (d1->used - i1));
+            d1->nodes[i1] = n2;
+            d1->used += 1;
+        } else {
+            struct dict_node *n1 = d1->nodes[i1];
+            list_tail_cons(n1->entry, n1->mark, n2->entry);
+            FREE(n2->key);
+            FREE(n2);
+        }
+    }
+    FREE(d2->nodes);
+    FREE(d2);
+    return 0;
+}
+
+void dict_lookup(const char *key, struct dict *dict,
+                 struct skel **skel, struct dict **subdict) {
+    *skel = NULL;
+    *subdict = NULL;
+    if (dict != NULL) {
+        if (! dict->marked) {
+            for (int i=0; i < dict->used; i++) {
+                dict->nodes[i]->mark = dict->nodes[i]->entry;
+            }
+            dict->marked = 1;
+        }
+        int p = dict_pos(dict, key);
+        if (p >= 0) {
+            struct dict_node *node = dict->nodes[p];
+            if (node->entry != NULL) {
+                *skel = node->entry->skel;
+                *subdict = node->entry->dict;
+                node->entry = node->entry->next;
+            }
+        }
+    }
+}
+
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/augeas.c b/src/augeas.c
new file mode 100644 (file)
index 0000000..8d6de28
--- /dev/null
@@ -0,0 +1,1505 @@
+/*
+ * augeas.c: the core data structure for storing key/value pairs
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include "augeas.h"
+#include "internal.h"
+#include "memory.h"
+#include "syntax.h"
+#include "transform.h"
+#include "errcode.h"
+
+#include <fnmatch.h>
+#include <argz.h>
+#include <string.h>
+#include <stdarg.h>
+#include <locale.h>
+
+/* Some popular labels that we use in /augeas */
+static const char *const s_augeas = "augeas";
+static const char *const s_files  = "files";
+static const char *const s_load   = "load";
+static const char *const s_pathx  = "pathx";
+static const char *const s_error  = "error";
+static const char *const s_pos    = "pos";
+static const char *const s_vars   = "variables";
+
+#define TREE_HIDDEN(tree) ((tree)->label == NULL)
+
+static const char *const static_nodes[][2] = {
+    { AUGEAS_META_TREE "/version", PACKAGE_VERSION },
+    { AUGEAS_META_TREE "/version/save/mode[1]", AUG_SAVE_BACKUP_TEXT },
+    { AUGEAS_META_TREE "/version/save/mode[2]", AUG_SAVE_NEWFILE_TEXT },
+    { AUGEAS_META_TREE "/version/save/mode[3]", AUG_SAVE_NOOP_TEXT },
+    { AUGEAS_META_TREE "/version/save/mode[4]", AUG_SAVE_OVERWRITE_TEXT },
+    { AUGEAS_META_TREE "/version/defvar/expr", NULL }
+};
+
+static const char *const errcodes[] = {
+    "No error",                                         /* AUG_NOERROR */
+    "Cannot allocate memory",                           /* AUG_ENOMEM */
+    "Internal error (please file a bug)",               /* AUG_EINTERNAL */
+    "Invalid path expression",                          /* AUG_EPATHX */
+    "No match for path expression",                     /* AUG_ENOMATCH */
+    "Too many matches for path expression",             /* AUG_EMMATCH */
+    "Syntax error in lens definition",                  /* AUG_ESYNTAX */
+    "Lens not found",                                   /* AUG_ENOLENS */
+    "Multiple transforms",                              /* AUG_EMXFM */
+    "Node has no span info"                             /* AUG_ENOSPAN */
+};
+
+static void tree_mark_dirty(struct tree *tree) {
+    do {
+        tree->dirty = 1;
+        tree = tree->parent;
+    } while (tree != tree->parent && !tree->dirty);
+    tree->dirty = 1;
+}
+
+void tree_clean(struct tree *tree) {
+    if (tree->dirty) {
+        list_for_each(c, tree->children)
+            tree_clean(c);
+    }
+    tree->dirty = 0;
+}
+
+struct tree *tree_child(struct tree *tree, const char *label) {
+    if (tree == NULL)
+        return NULL;
+
+    list_for_each(child, tree->children) {
+        if (streqv(label, child->label))
+            return child;
+    }
+    return NULL;
+}
+
+struct tree *tree_child_cr(struct tree *tree, const char *label) {
+    static struct tree *child = NULL;
+
+    if (tree == NULL)
+        return NULL;
+
+    child = tree_child(tree, label);
+    if (child == NULL) {
+        char *l = strdup(label);
+        if (l == NULL)
+            return NULL;
+        child = tree_append(tree, l, NULL);
+    }
+    return child;
+}
+
+struct tree *tree_path_cr(struct tree *tree, int n, ...) {
+    va_list ap;
+
+    va_start(ap, n);
+    for (int i=0; i < n; i++) {
+        const char *l = va_arg(ap, const char *);
+        tree = tree_child_cr(tree, l);
+    }
+    va_end(ap);
+    return tree;
+}
+
+struct tree *tree_find(struct augeas *aug, const char *path) {
+    struct pathx *p = NULL;
+    struct tree *result = NULL;
+    int r;
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    r = pathx_find_one(p, &result);
+    BUG_ON(r > 1, aug,
+           "Multiple matches for %s when only one was expected",
+           path);
+ done:
+    free_pathx(p);
+    return result;
+ error:
+    result = NULL;
+    goto done;
+}
+
+struct tree *tree_find_cr(struct augeas *aug, const char *path) {
+    struct pathx *p = NULL;
+    struct tree *result = NULL;
+    int r;
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    r = pathx_expand_tree(p, &result);
+    ERR_BAIL(aug);
+    ERR_THROW(r < 0, aug, AUG_EINTERNAL, "pathx_expand_tree failed");
+ error:
+    free_pathx(p);
+    return result;
+}
+
+void tree_store_value(struct tree *tree, char **value) {
+    if (streqv(tree->value, *value)) {
+        free(*value);
+        *value = NULL;
+        return;
+    }
+    if (tree->value != NULL) {
+        free(tree->value);
+        tree->value = NULL;
+    }
+    if (*value != NULL) {
+        tree->value = *value;
+        *value = NULL;
+    }
+    tree_mark_dirty(tree);
+}
+
+int tree_set_value(struct tree *tree, const char *value) {
+    char *v = NULL;
+
+    if (streqv(tree->value, value))
+        return 0;
+    if (value != NULL) {
+        v = strdup(value);
+        if (v == NULL)
+            return -1;
+    }
+    tree_store_value(tree, &v);
+    return 0;
+}
+
+/* Report pathx errors in /augeas/pathx/error */
+static void store_pathx_error(const struct augeas *aug) {
+    if (aug->error->code != AUG_EPATHX)
+        return;
+
+    struct tree *error =
+        tree_path_cr(aug->origin, 3, s_augeas, s_pathx, s_error);
+    if (error == NULL)
+        return;
+    tree_set_value(error, aug->error->minor_details);
+
+    struct tree *tpos = tree_child_cr(error, s_pos);
+    if (tpos == NULL)
+        return;
+    tree_set_value(tpos, aug->error->details);
+}
+
+struct pathx *pathx_aug_parse(const struct augeas *aug,
+                              struct tree *tree,
+                              const char *path, bool need_nodeset) {
+    struct pathx *result;
+    struct error *err = err_of_aug(aug);
+
+    if (tree == NULL)
+        tree = aug->origin;
+
+    pathx_parse(tree, err, path, need_nodeset, aug->symtab, &result);
+    return result;
+}
+
+static const char *init_root(const char *root0) {
+    char *root;
+
+    if (root0 == NULL)
+        root0 = getenv(AUGEAS_ROOT_ENV);
+    if (root0 == NULL || root0[0] == '\0')
+        root0 = "/";
+    root = strdup(root0);
+    if (root == NULL)
+        return NULL;
+    if (root[strlen(root)-1] != SEP) {
+        if (REALLOC_N(root, strlen(root) + 2) == -1) {
+            FREE(root);
+            return NULL;
+        }
+        strcat(root, "/");
+    }
+    return root;
+}
+
+struct tree *tree_append(struct tree *parent,
+                         char *label, char *value) {
+    struct tree *result = make_tree(label, value, parent, NULL);
+    if (result != NULL)
+        list_append(parent->children, result);
+    return result;
+}
+
+static struct tree *tree_from_transform(struct augeas *aug,
+                                        const char *modname,
+                                        struct transform *xfm) {
+    struct tree *meta = tree_child_cr(aug->origin, s_augeas);
+    struct tree *load = NULL, *txfm = NULL;
+    char *m = NULL, *q = NULL;
+
+    if (meta == NULL)
+        goto error;
+
+    load = tree_child_cr(meta, s_load);
+    if (load == NULL)
+            goto error;
+    if (modname != NULL) {
+        m = strdup(modname);
+        if (m == NULL)
+            goto error;
+    } else {
+        m = strdup("_");
+    }
+    txfm = tree_append(load, m, NULL);
+    if (txfm == NULL)
+        goto error;
+
+    if (asprintf(&q, "@%s", modname) < 0)
+        goto error;
+
+    m = strdup("lens");
+    tree_append(txfm, m, q);
+    list_for_each(f, xfm->filter) {
+        char *glob = strdup(f->glob->str);
+        char *l = f->include ? strdup("incl") : strdup("excl");
+        tree_append(txfm, l, glob);
+    }
+    return txfm;
+ error:
+    tree_unlink(txfm);
+    return NULL;
+}
+
+/* Save user locale and switch to C locale */
+#if HAVE_USELOCALE
+static void save_locale(struct augeas *aug) {
+    if (aug->c_locale == NULL) {
+        aug->c_locale = newlocale(LC_ALL_MASK, "C", NULL);
+        ERR_NOMEM(aug->c_locale == NULL, aug);
+    }
+
+    aug->user_locale = uselocale(aug->c_locale);
+ error:
+    return;
+}
+#else
+static void save_locale(ATTRIBUTE_UNUSED struct augeas *aug) { }
+#endif
+
+#if HAVE_USELOCALE
+static void restore_locale(struct augeas *aug) {
+    uselocale(aug->user_locale);
+    aug->user_locale = NULL;
+}
+#else
+static void restore_locale(ATTRIBUTE_UNUSED struct augeas *aug) { }
+#endif
+
+/* Clean up old error messages every time we enter through the public
+ * API. Since we make internal calls through the public API, we keep a
+ * count of how many times a public API call was made, and only reset when
+ * that count is 0. That requires that all public functions enclose their
+ * work within a matching pair of api_entry/api_exit calls.
+ */
+static void api_entry(const struct augeas *aug) {
+    struct error *err = ((struct augeas *) aug)->error;
+
+    ((struct augeas *) aug)->api_entries += 1;
+
+    if (aug->api_entries > 1)
+        return;
+
+    reset_error(err);
+    save_locale((struct augeas *) aug);
+}
+
+static void api_exit(const struct augeas *aug) {
+    assert(aug->api_entries > 0);
+    ((struct augeas *) aug)->api_entries -= 1;
+    if (aug->api_entries == 0) {
+        store_pathx_error(aug);
+        restore_locale((struct augeas *) aug);
+    }
+}
+
+struct augeas *aug_init(const char *root, const char *loadpath,
+                        unsigned int flags) {
+    struct augeas *result;
+    struct tree *tree_root = make_tree(NULL, NULL, NULL, NULL);
+    int r;
+
+    if (tree_root == NULL)
+        return NULL;
+
+    if (ALLOC(result) < 0)
+        goto error;
+    if (ALLOC(result->error) < 0)
+        goto error;
+    result->error->aug = result;
+
+    result->origin = make_tree_origin(tree_root);
+    if (result->origin == NULL) {
+        free_tree(tree_root);
+        goto error;
+    }
+
+    api_entry(result);
+
+    result->flags = flags;
+
+    result->root = init_root(root);
+
+    result->origin->children->label = strdup(s_augeas);
+
+    result->modpathz = NULL;
+    result->nmodpath = 0;
+    if (loadpath != NULL) {
+        r = argz_add_sep(&result->modpathz, &result->nmodpath,
+                         loadpath, PATH_SEP_CHAR);
+        ERR_NOMEM(r != 0, result);
+    }
+    char *env = getenv(AUGEAS_LENS_ENV);
+    if (env != NULL) {
+        r = argz_add_sep(&result->modpathz, &result->nmodpath,
+                         env, PATH_SEP_CHAR);
+        ERR_NOMEM(r != 0, result);
+    }
+    if (!(flags & AUG_NO_STDINC)) {
+        r = argz_add(&result->modpathz, &result->nmodpath, AUGEAS_LENS_DIR);
+        ERR_NOMEM(r != 0, result);
+        r = argz_add(&result->modpathz, &result->nmodpath,
+                     AUGEAS_LENS_DIST_DIR);
+        ERR_NOMEM(r != 0, result);
+    }
+    /* Clean up trailing slashes */
+    if (result->nmodpath > 0) {
+        argz_stringify(result->modpathz, result->nmodpath, PATH_SEP_CHAR);
+        char *s, *t;
+        const char *e = result->modpathz + strlen(result->modpathz);
+        for (s = result->modpathz, t = result->modpathz; s < e; s++) {
+            char *p = s;
+            if (*p == '/') {
+                while (*p == '/') p += 1;
+                if (*p == '\0' || *p == PATH_SEP_CHAR)
+                    s = p;
+            }
+            if (t != s)
+                *t++ = *s;
+            else
+                t += 1;
+        }
+        if (t != s) {
+            *t = '\0';
+        }
+        s = result->modpathz;
+        r = argz_create_sep(s, PATH_SEP_CHAR, &result->modpathz,
+                            &result->nmodpath);
+        free(s);
+        ERR_NOMEM(r != 0, result);
+    }
+
+    /* We report the root dir in AUGEAS_META_ROOT, but we only use the
+       value we store internally, to avoid any problems with
+       AUGEAS_META_ROOT getting changed. */
+    aug_set(result, AUGEAS_META_ROOT, result->root);
+
+    for (int i=0; i < ARRAY_CARDINALITY(static_nodes); i++)
+        aug_set(result, static_nodes[i][0], static_nodes[i][1]);
+
+    if (flags & AUG_SAVE_NEWFILE) {
+        aug_set(result, AUGEAS_META_SAVE_MODE, AUG_SAVE_NEWFILE_TEXT);
+    } else if (flags & AUG_SAVE_BACKUP) {
+        aug_set(result, AUGEAS_META_SAVE_MODE, AUG_SAVE_BACKUP_TEXT);
+    } else if (flags & AUG_SAVE_NOOP) {
+        aug_set(result, AUGEAS_META_SAVE_MODE, AUG_SAVE_NOOP_TEXT);
+    } else {
+        aug_set(result, AUGEAS_META_SAVE_MODE, AUG_SAVE_OVERWRITE_TEXT);
+    }
+
+    if (flags & AUG_ENABLE_SPAN) {
+        aug_set(result, AUGEAS_SPAN_OPTION, AUG_ENABLE);
+    } else {
+        aug_set(result, AUGEAS_SPAN_OPTION, AUG_DISABLE);
+    }
+
+    /* Make sure we always have /files and /augeas/variables */
+    tree_path_cr(result->origin, 1, s_files);
+    tree_path_cr(result->origin, 2, s_augeas, s_vars);
+
+    if (interpreter_init(result) == -1)
+        goto error;
+
+    list_for_each(modl, result->modules) {
+        struct transform *xform = modl->autoload;
+        if (xform == NULL)
+            continue;
+        tree_from_transform(result, modl->name, xform);
+    }
+    if (!(result->flags & AUG_NO_LOAD))
+        if (aug_load(result) < 0)
+            goto error;
+
+    api_exit(result);
+    return result;
+
+ error:
+    api_exit(result);
+    aug_close(result);
+    return NULL;
+}
+
+void tree_unlink_children(struct augeas *aug, struct tree *tree) {
+    if (tree == NULL)
+        return;
+
+    pathx_symtab_remove_descendants(aug->symtab, tree);
+
+    while (tree->children != NULL)
+        tree_unlink(tree->children);
+}
+
+static void tree_mark_files(struct tree *tree) {
+    if (tree_child(tree, "path") != NULL) {
+        tree_mark_dirty(tree);
+    } else {
+        list_for_each(c, tree->children) {
+            tree_mark_files(c);
+        }
+    }
+}
+
+static void tree_rm_dirty_files(struct augeas *aug, struct tree *tree) {
+    struct tree *p;
+
+    if (!tree->dirty)
+        return;
+
+    if ((p = tree_child(tree, "path")) != NULL) {
+        aug_rm(aug, p->value);
+        tree_unlink(tree);
+    } else {
+        struct tree *c = tree->children;
+        while (c != NULL) {
+            struct tree *next = c->next;
+            tree_rm_dirty_files(aug, c);
+            c = next;
+        }
+    }
+}
+
+static void tree_rm_dirty_leaves(struct augeas *aug, struct tree *tree,
+                                 struct tree *protect) {
+    if (! tree->dirty)
+        return;
+
+    struct tree *c = tree->children;
+    while (c != NULL) {
+        struct tree *next = c->next;
+        tree_rm_dirty_leaves(aug, c, protect);
+        c = next;
+    }
+
+    if (tree != protect && tree->children == NULL)
+        tree_unlink(tree);
+}
+
+int aug_load(struct augeas *aug) {
+    const char *option = NULL;
+    struct tree *meta = tree_child_cr(aug->origin, s_augeas);
+    struct tree *meta_files = tree_child_cr(meta, s_files);
+    struct tree *files = tree_child_cr(aug->origin, s_files);
+    struct tree *load = tree_child_cr(meta, s_load);
+    struct tree *vars = tree_child_cr(meta, s_vars);
+
+    api_entry(aug);
+
+    ERR_NOMEM(load == NULL, aug);
+
+    /* To avoid unnecessary loads of files, we reload an existing file in
+     * several steps:
+     * (1) mark all file nodes under /augeas/files as dirty (and only those)
+     * (2) process all files matched by a lens; we check (in
+     *     transform_load) if the file has been modified. If it has, we
+     *     reparse it. Either way, we clear the dirty flag. We also need to
+     *     reread the file if part or all of it has been modified in the
+     *     tree but not been saved yet
+     * (3) remove all files from the tree that still have a dirty entry
+     *     under /augeas/files. Those files are not processed by any lens
+     *     anymore
+     * (4) Remove entries from /augeas/files and /files that correspond
+     *     to directories without any files of interest
+     */
+
+    /* update flags according to option value */
+    if (aug_get(aug, AUGEAS_SPAN_OPTION, &option) == 1) {
+        if (strcmp(option, AUG_ENABLE) == 0) {
+            aug->flags |= AUG_ENABLE_SPAN;
+        } else {
+            aug->flags &= ~AUG_ENABLE_SPAN;
+        }
+    }
+
+    tree_clean(meta_files);
+    tree_mark_files(meta_files);
+
+    list_for_each(xfm, load->children) {
+        if (transform_validate(aug, xfm) == 0)
+            transform_load(aug, xfm);
+    }
+
+    /* This makes it possible to spot 'directories' that are now empty
+     * because we removed their file contents */
+    tree_clean(files);
+
+    tree_rm_dirty_files(aug, meta_files);
+    tree_rm_dirty_leaves(aug, meta_files, meta_files);
+    tree_rm_dirty_leaves(aug, files, files);
+
+    tree_clean(aug->origin);
+
+    list_for_each(v, vars->children) {
+        aug_defvar(aug, v->label, v->value);
+        ERR_BAIL(aug);
+    }
+
+    api_exit(aug);
+    return 0;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+static int find_one_node(struct pathx *p, struct tree **match) {
+    struct error *err = err_of_pathx(p);
+    int r = pathx_find_one(p, match);
+
+    if (r == 1)
+        return 0;
+
+    if (r == 0) {
+        report_error(err, AUG_ENOMATCH, NULL);
+    } else {
+        /* r > 1 */
+        report_error(err, AUG_EMMATCH, NULL);
+    }
+
+    return -1;
+}
+
+int aug_get(const struct augeas *aug, const char *path, const char **value) {
+    struct pathx *p = NULL;
+    struct tree *match;
+    int r;
+
+    api_entry(aug);
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    if (value != NULL)
+        *value = NULL;
+
+    r = pathx_find_one(p, &match);
+    ERR_BAIL(aug);
+    ERR_THROW(r > 1, aug, AUG_EMMATCH, "There are %d nodes matching %s",
+              r, path);
+
+    if (r == 1 && value != NULL)
+        *value = match->value;
+    free_pathx(p);
+
+    api_exit(aug);
+    return r;
+ error:
+    free_pathx(p);
+    api_exit(aug);
+    return -1;
+}
+
+static void record_var_meta(struct augeas *aug, const char *name,
+                            const char *expr) {
+    /* Record the definition of the variable */
+    struct tree *tree = tree_path_cr(aug->origin, 2, s_augeas, s_vars);
+    ERR_NOMEM(tree == NULL, aug);
+    if (expr == NULL) {
+        tree = tree_child(tree, name);
+        if (tree != NULL)
+            tree_unlink(tree);
+    } else {
+        tree = tree_child_cr(tree, name);
+        ERR_NOMEM(tree == NULL, aug);
+        tree_set_value(tree, expr);
+    }
+ error:
+    return;
+}
+
+int aug_defvar(augeas *aug, const char *name, const char *expr) {
+    struct pathx *p = NULL;
+    int result = -1;
+
+    api_entry(aug);
+
+    if (expr == NULL) {
+        result = pathx_symtab_undefine(&(aug->symtab), name);
+    } else {
+        p = pathx_aug_parse(aug, aug->origin, expr, false);
+        ERR_BAIL(aug);
+        result = pathx_symtab_define(&(aug->symtab), name, p);
+    }
+    ERR_BAIL(aug);
+
+    record_var_meta(aug, name, expr);
+    ERR_BAIL(aug);
+ error:
+    free_pathx(p);
+    api_exit(aug);
+    return result;
+}
+
+int aug_defnode(augeas *aug, const char *name, const char *expr,
+                const char *value, int *created) {
+    struct pathx *p;
+    int result = -1;
+    int r, cr;
+    struct tree *tree;
+
+    api_entry(aug);
+
+    if (expr == NULL)
+        goto error;
+    if (created == NULL)
+        created = &cr;
+
+    p = pathx_aug_parse(aug, aug->origin, expr, false);
+    ERR_BAIL(aug);
+
+    if (pathx_first(p) == NULL) {
+        r = pathx_expand_tree(p, &tree);
+        if (r < 0)
+            goto done;
+        *created = 1;
+    } else {
+        *created = 0;
+    }
+
+    if (*created) {
+        r = tree_set_value(tree, value);
+        if (r < 0)
+            goto done;
+        result = pathx_symtab_assign_tree(&(aug->symtab), name, tree);
+        char *e = path_of_tree(tree);
+        ERR_NOMEM(e == NULL, aug)
+        record_var_meta(aug, name, e);
+        free(e);
+        ERR_BAIL(aug);
+    } else {
+        result = pathx_symtab_define(&(aug->symtab), name, p);
+        record_var_meta(aug, name, expr);
+        ERR_BAIL(aug);
+    }
+
+ done:
+    free_pathx(p);
+    api_exit(aug);
+    return result;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+struct tree *tree_set(struct pathx *p, const char *value) {
+    struct tree *tree;
+    int r;
+
+    r = pathx_expand_tree(p, &tree);
+    if (r == -1)
+        return NULL;
+
+    r = tree_set_value(tree, value);
+    if (r < 0)
+        return NULL;
+    return tree;
+}
+
+int aug_set(struct augeas *aug, const char *path, const char *value) {
+    struct pathx *p;
+    int result;
+
+    api_entry(aug);
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    result = tree_set(p, value) == NULL ? -1 : 0;
+    free_pathx(p);
+
+    api_exit(aug);
+    return result;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+int aug_setm(struct augeas *aug, const char *base,
+             const char *sub, const char *value) {
+    struct pathx *bx = NULL, *sx = NULL;
+    struct tree *bt, *st;
+    int result, r;
+
+    api_entry(aug);
+
+    bx = pathx_aug_parse(aug, aug->origin, base, true);
+    ERR_BAIL(aug);
+
+    if (sub != NULL && STREQ(sub, "."))
+        sub = NULL;
+
+    result = 0;
+    for (bt = pathx_first(bx); bt != NULL; bt = pathx_next(bx)) {
+        if (sub != NULL) {
+            /* Handle subnodes of BT */
+            sx = pathx_aug_parse(aug, bt, sub, true);
+            ERR_BAIL(aug);
+            if (pathx_first(sx) != NULL) {
+                /* Change existing subnodes matching SUB */
+                for (st = pathx_first(sx); st != NULL; st = pathx_next(sx)) {
+                    r = tree_set_value(st, value);
+                    ERR_NOMEM(r < 0, aug);
+                    result += 1;
+                }
+            } else {
+                /* Create a new subnode matching SUB */
+                r = pathx_expand_tree(sx, &st);
+                if (r == -1)
+                    goto error;
+                r = tree_set_value(st, value);
+                ERR_NOMEM(r < 0, aug);
+                result += 1;
+            }
+            free_pathx(sx);
+            sx = NULL;
+        } else {
+            /* Set nodes matching BT directly */
+            r = tree_set_value(bt, value);
+            ERR_NOMEM(r < 0, aug);
+            result += 1;
+        }
+    }
+
+ done:
+    api_exit(aug);
+    return result;
+ error:
+    result = -1;
+    goto done;
+}
+
+int tree_insert(struct pathx *p, const char *label, int before) {
+    struct tree *new = NULL, *match;
+
+    if (strchr(label, SEP) != NULL)
+        return -1;
+
+    if (find_one_node(p, &match) < 0)
+        goto error;
+
+    new = make_tree(strdup(label), NULL, match->parent, NULL);
+    if (new == NULL || new->label == NULL)
+        goto error;
+
+    if (before) {
+        list_insert_before(new, match, new->parent->children);
+    } else {
+        new->next = match->next;
+        match->next = new;
+    }
+    return 0;
+ error:
+    free_tree(new);
+    return -1;
+}
+
+int aug_insert(struct augeas *aug, const char *path, const char *label,
+               int before) {
+    struct pathx *p = NULL;
+    int result = -1;
+
+    api_entry(aug);
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    result = tree_insert(p, label, before);
+ error:
+    free_pathx(p);
+    api_exit(aug);
+    return result;
+}
+
+struct tree *make_tree(char *label, char *value, struct tree *parent,
+                       struct tree *children) {
+    struct tree *tree;
+    if (ALLOC(tree) < 0)
+        return NULL;
+
+    tree->label = label;
+    tree->value = value;
+    tree->parent = parent;
+    tree->children = children;
+    list_for_each(c, tree->children)
+        c->parent = tree;
+    if (parent != NULL)
+        tree_mark_dirty(tree);
+    else
+        tree->dirty = 1;
+    return tree;
+}
+
+struct tree *make_tree_origin(struct tree *root) {
+    struct tree *origin = NULL;
+
+    origin = make_tree(NULL, NULL, NULL, root);
+    if (origin == NULL)
+        return NULL;
+
+    origin->parent = origin;
+    return origin;
+}
+
+/* Free one tree node */
+static void free_tree_node(struct tree *tree) {
+    if (tree == NULL)
+        return;
+
+    if (tree->span != NULL)
+        free_span(tree->span);
+    free(tree->label);
+    free(tree->value);
+    free(tree);
+}
+
+/* Recursively free the whole tree TREE and all its siblings */
+int free_tree(struct tree *tree) {
+    int cnt = 0;
+
+    while (tree != NULL) {
+        struct tree *del = tree;
+        tree = del->next;
+        cnt += free_tree(del->children);
+        free_tree_node(del);
+        cnt += 1;
+    }
+
+    return cnt;
+}
+
+int tree_unlink(struct tree *tree) {
+    int result = 0;
+
+    assert (tree->parent != NULL);
+    list_remove(tree, tree->parent->children);
+    tree_mark_dirty(tree->parent);
+    result = free_tree(tree->children) + 1;
+    free_tree_node(tree);
+    return result;
+}
+
+int tree_rm(struct pathx *p) {
+    struct tree *tree, **del;
+    int cnt = 0, ndel = 0, i;
+
+    for (tree = pathx_first(p); tree != NULL; tree = pathx_next(p)) {
+        if (! TREE_HIDDEN(tree))
+            ndel += 1;
+    }
+
+    if (ndel == 0)
+        return 0;
+
+    if (ALLOC_N(del, ndel) < 0) {
+        free(del);
+        return -1;
+    }
+
+    for (i = 0, tree = pathx_first(p); tree != NULL; tree = pathx_next(p)) {
+        if (TREE_HIDDEN(tree))
+            continue;
+        pathx_symtab_remove_descendants(pathx_get_symtab(p), tree);
+        del[i] = tree;
+        i += 1;
+    }
+
+    for (i = 0; i < ndel; i++)
+        cnt += tree_unlink(del[i]);
+    free(del);
+
+    return cnt;
+}
+
+int aug_rm(struct augeas *aug, const char *path) {
+    struct pathx *p = NULL;
+    int result;
+
+    api_entry(aug);
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    result = tree_rm(p);
+    free_pathx(p);
+    ERR_BAIL(aug);
+
+    api_exit(aug);
+    return result;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+int aug_span(struct augeas *aug, const char *path, char **filename,
+        uint *label_start, uint *label_end, uint *value_start, uint *value_end,
+        uint *span_start, uint *span_end) {
+    struct pathx *p = NULL;
+    int result = -1;
+    struct tree *tree = NULL;
+    struct span *span;
+
+    api_entry(aug);
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    tree = pathx_first(p);
+    ERR_BAIL(aug);
+
+    ERR_THROW(tree == NULL, aug, AUG_ENOMATCH, "No node matching %s", path);
+    ERR_THROW(tree->span == NULL, aug, AUG_ENOSPAN, "No span info for %s", path);
+    ERR_THROW(pathx_next(p) != NULL, aug, AUG_EMMATCH, "Multiple nodes match %s", path);
+
+    span = tree->span;
+
+    if (label_start != NULL)
+        *label_start = span->label_start;
+
+    if (label_end != NULL)
+        *label_end = span->label_end;
+
+    if (value_start != NULL)
+        *value_start = span->value_start;
+
+    if (value_end != NULL)
+        *value_end = span->value_end;
+
+    if (span_start != NULL)
+        *span_start = span->span_start;
+
+    if (span_end != NULL)
+        *span_end = span->span_end;
+
+    /* We are safer here, make sure we have a filename */
+    if (filename != NULL) {
+        if (span->filename == NULL || span->filename->str == NULL) {
+            *filename = strdup("");
+        } else {
+            *filename = strdup(span->filename->str);
+        }
+        ERR_NOMEM(*filename == NULL, aug);
+    }
+
+    result = 0;
+ error:
+    free_pathx(p);
+    api_exit(aug);
+    return result;
+}
+
+int tree_replace(struct augeas *aug, const char *path, struct tree *sub) {
+    struct tree *parent;
+    struct pathx *p = NULL;
+    int r;
+
+    p = pathx_aug_parse(aug, aug->origin, path, true);
+    ERR_BAIL(aug);
+
+    r = tree_rm(p);
+    if (r == -1)
+        goto error;
+
+    parent = tree_set(p, NULL);
+    if (parent == NULL)
+        goto error;
+
+    list_append(parent->children, sub);
+    list_for_each(s, sub) {
+        s->parent = parent;
+    }
+    free_pathx(p);
+    return 0;
+ error:
+    free_pathx(p);
+    return -1;
+}
+
+int aug_mv(struct augeas *aug, const char *src, const char *dst) {
+    struct pathx *s = NULL, *d = NULL;
+    struct tree *ts, *td, *t;
+    int r, ret;
+
+    api_entry(aug);
+
+    ret = -1;
+    s = pathx_aug_parse(aug, aug->origin, src, true);
+    ERR_BAIL(aug);
+
+    d = pathx_aug_parse(aug, aug->origin, dst, true);
+    ERR_BAIL(aug);
+
+    r = find_one_node(s, &ts);
+    if (r < 0)
+        goto error;
+
+    r = pathx_expand_tree(d, &td);
+    if (r == -1)
+        goto error;
+
+    /* Don't move SRC into its own descendent */
+    t = td;
+    do {
+        if (t == ts)
+            goto error;
+        t = t->parent;
+    } while (! ROOT_P(t));
+
+    free_tree(td->children);
+
+    td->children = ts->children;
+    list_for_each(c, td->children) {
+        c->parent = td;
+    }
+    free(td->value);
+    td->value = ts->value;
+
+    ts->value = NULL;
+    ts->children = NULL;
+
+    tree_unlink(ts);
+    tree_mark_dirty(td);
+
+    ret = 0;
+ error:
+    free_pathx(s);
+    free_pathx(d);
+    api_exit(aug);
+    return ret;
+}
+
+int aug_match(const struct augeas *aug, const char *pathin, char ***matches) {
+    struct pathx *p = NULL;
+    struct tree *tree;
+    int cnt = 0;
+
+    api_entry(aug);
+
+    if (matches != NULL)
+        *matches = NULL;
+
+    if (STREQ(pathin, "/")) {
+        pathin = "/*";
+    }
+
+    p = pathx_aug_parse(aug, aug->origin, pathin, true);
+    ERR_BAIL(aug);
+
+    for (tree = pathx_first(p); tree != NULL; tree = pathx_next(p)) {
+        if (! TREE_HIDDEN(tree))
+            cnt += 1;
+    }
+    ERR_BAIL(aug);
+
+    if (matches == NULL)
+        goto done;
+
+    if (ALLOC_N(*matches, cnt) < 0)
+        goto error;
+
+    int i = 0;
+    for (tree = pathx_first(p); tree != NULL; tree = pathx_next(p)) {
+        if (TREE_HIDDEN(tree))
+            continue;
+        (*matches)[i] = path_of_tree(tree);
+        if ((*matches)[i] == NULL) {
+            goto error;
+        }
+        i += 1;
+    }
+    ERR_BAIL(aug);
+ done:
+    free_pathx(p);
+    api_exit(aug);
+    return cnt;
+
+ error:
+    if (matches != NULL) {
+        if (*matches != NULL) {
+            for (i=0; i < cnt; i++)
+                free((*matches)[i]);
+            free(*matches);
+        }
+    }
+    free_pathx(p);
+    api_exit(aug);
+    return -1;
+}
+
+static int tree_save(struct augeas *aug, struct tree *tree,
+                     const char *path) {
+    int result = 0;
+    struct tree *meta = tree_child_cr(aug->origin, s_augeas);
+    struct tree *load = tree_child_cr(meta, s_load);
+
+    // FIXME: We need to detect subtrees that aren't saved by anything
+
+    if (load == NULL)
+        return -1;
+
+    list_for_each(t, tree) {
+        if (t->dirty) {
+            char *tpath = NULL;
+            struct tree *transform = NULL;
+            if (asprintf(&tpath, "%s/%s", path, t->label) == -1) {
+                result = -1;
+                continue;
+            }
+            list_for_each(xfm, load->children) {
+                if (transform_applies(xfm, tpath)) {
+                    if (transform == NULL || transform == xfm) {
+                        transform = xfm;
+                    } else {
+                        const char *filename =
+                            tpath + strlen(AUGEAS_FILES_TREE) + 1;
+                        transform_file_error(aug, "mxfm_save", filename,
+                           "Lenses %s and %s could be used to save this file",
+                                             xfm_lens_name(transform),
+                                             xfm_lens_name(xfm));
+                        ERR_REPORT(aug, AUG_EMXFM,
+                                   "Path %s transformable by lens %s and %s",
+                                   tpath,
+                                   xfm_lens_name(transform),
+                                   xfm_lens_name(xfm));
+                        result = -1;
+                    }
+                }
+            }
+            if (transform != NULL) {
+                int r = transform_save(aug, transform, tpath, t);
+                if (r == -1)
+                    result = -1;
+            } else {
+                if (tree_save(aug, t->children, tpath) == -1)
+                    result = -1;
+            }
+            free(tpath);
+        }
+    }
+    return result;
+}
+
+/* Reset the flags based on what is set in the tree. */
+static int update_save_flags(struct augeas *aug) {
+    const char *savemode ;
+
+    aug_get(aug, AUGEAS_META_SAVE_MODE, &savemode);
+    if (savemode == NULL)
+        return -1;
+
+    aug->flags &= ~(AUG_SAVE_BACKUP|AUG_SAVE_NEWFILE|AUG_SAVE_NOOP);
+    if (STREQ(savemode, AUG_SAVE_NEWFILE_TEXT)) {
+        aug->flags |= AUG_SAVE_NEWFILE;
+    } else if (STREQ(savemode, AUG_SAVE_BACKUP_TEXT)) {
+        aug->flags |= AUG_SAVE_BACKUP;
+    } else if (STREQ(savemode, AUG_SAVE_NOOP_TEXT)) {
+        aug->flags |= AUG_SAVE_NOOP ;
+    } else if (STRNEQ(savemode, AUG_SAVE_OVERWRITE_TEXT)) {
+        return -1;
+    }
+
+    return 0;
+}
+
+static int unlink_removed_files(struct augeas *aug,
+                                struct tree *files, struct tree *meta) {
+    /* Find all nodes that correspond to a file and might have to be
+     * unlinked. A node corresponds to a file if it has a child labelled
+     * 'path', and we only consider it if there are no errors associated
+     * with it */
+    static const char *const file_nodes =
+        "descendant-or-self::*[path][count(error) = 0]";
+
+    int result = 0;
+
+    if (! files->dirty)
+        return 0;
+
+    for (struct tree *tm = meta->children; tm != NULL;) {
+        struct tree *tf = tree_child(files, tm->label);
+        struct tree *next = tm->next;
+        if (tf == NULL) {
+            /* Unlink all files in tm */
+            struct pathx *px = NULL;
+            if (pathx_parse(tm, err_of_aug(aug), file_nodes, true,
+                            aug->symtab, &px) != PATHX_NOERROR) {
+                result = -1;
+                continue;
+            }
+            for (struct tree *t = pathx_first(px);
+                 t != NULL;
+                 t = pathx_next(px)) {
+                remove_file(aug, t);
+            }
+            free_pathx(px);
+        } else if (tf->dirty && ! tree_child(tm, "path")) {
+            if (unlink_removed_files(aug, tf, tm) < 0)
+                result = -1;
+        }
+        tm = next;
+    }
+    return result;
+}
+
+int aug_save(struct augeas *aug) {
+    int ret = 0;
+    struct tree *meta = tree_child_cr(aug->origin, s_augeas);
+    struct tree *meta_files = tree_child_cr(meta, s_files);
+    struct tree *files = tree_child_cr(aug->origin, s_files);
+    struct tree *load = tree_child_cr(meta, s_load);
+
+    api_entry(aug);
+
+    if (update_save_flags(aug) < 0)
+        goto error;
+
+    if (files == NULL || meta == NULL || load == NULL)
+        goto error;
+
+    aug_rm(aug, AUGEAS_EVENTS_SAVED);
+
+    list_for_each(xfm, load->children)
+        transform_validate(aug, xfm);
+
+    if (files->dirty) {
+        list_for_each(t, files->children) {
+            if (tree_save(aug, t, AUGEAS_FILES_TREE) == -1)
+                ret = -1;
+        }
+        /* Remove files whose entire subtree was removed. */
+        if (meta_files != NULL) {
+            if (unlink_removed_files(aug, files, meta_files) < 0)
+                ret = -1;
+        }
+    }
+    if (!(aug->flags & AUG_SAVE_NOOP)) {
+        tree_clean(aug->origin);
+    }
+
+    api_exit(aug);
+    return ret;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+static int print_one(FILE *out, const char *path, const char *value) {
+    int r;
+
+    r = fprintf(out, "%s", path);
+    if (r < 0)
+        return -1;
+    if (value != NULL) {
+        char *val = escape(value, -1);
+        r = fprintf(out, " = \"%s\"", val);
+        free(val);
+        if (r < 0)
+            return -1;
+    }
+    r = fputc('\n', out);
+    if (r == EOF)
+        return -1;
+    return 0;
+}
+
+/* PATH is the path up to TREE's parent */
+static int print_rec(FILE *out, struct tree *start, const char *ppath,
+                     int pr_hidden) {
+    int r;
+    char *path = NULL;
+
+    list_for_each(tree, start) {
+        if (TREE_HIDDEN(tree) && ! pr_hidden)
+            continue;
+
+        path = path_expand(tree, ppath);
+        if (path == NULL)
+            goto error;
+
+        r = print_one(out, path, tree->value);
+        if (r < 0)
+            goto error;
+        r = print_rec(out, tree->children, path, pr_hidden);
+        free(path);
+        path = NULL;
+        if (r < 0)
+            goto error;
+    }
+    return 0;
+ error:
+    free(path);
+    return -1;
+}
+
+static int print_tree(FILE *out, struct pathx *p, int pr_hidden) {
+    char *path = NULL;
+    struct tree *tree;
+    int r;
+
+    for (tree = pathx_first(p); tree != NULL; tree = pathx_next(p)) {
+        if (TREE_HIDDEN(tree) && ! pr_hidden)
+            continue;
+
+        path = path_of_tree(tree);
+        if (path == NULL)
+            goto error;
+        r = print_one(out, path, tree->value);
+        if (r < 0)
+            goto error;
+        r = print_rec(out, tree->children, path, pr_hidden);
+        if (r < 0)
+            goto error;
+        free(path);
+        path = NULL;
+    }
+    return 0;
+ error:
+    free(path);
+    return -1;
+}
+
+int dump_tree(FILE *out, struct tree *tree) {
+    struct pathx *p;
+    int result;
+
+    if (pathx_parse(tree, NULL, "/*", true, NULL, &p) != PATHX_NOERROR)
+        return -1;
+
+    result = print_tree(out, p, 1);
+    free_pathx(p);
+    return result;
+}
+
+int aug_print(const struct augeas *aug, FILE *out, const char *pathin) {
+    struct pathx *p;
+    int result;
+
+    api_entry(aug);
+
+    if (pathin == NULL || strlen(pathin) == 0) {
+        pathin = "/*";
+    }
+
+    p = pathx_aug_parse(aug, aug->origin, pathin, true);
+    ERR_BAIL(aug);
+
+    result = print_tree(out, p, 0);
+    free_pathx(p);
+
+    api_exit(aug);
+    return result;
+ error:
+    api_exit(aug);
+    return -1;
+}
+
+void aug_close(struct augeas *aug) {
+    if (aug == NULL)
+        return;
+
+    /* There's no point in bothering with api_entry/api_exit here */
+    free_tree(aug->origin);
+    unref(aug->modules, module);
+    free((void *) aug->root);
+    free(aug->modpathz);
+    free_symtab(aug->symtab);
+    free(aug->error->details);
+    free(aug->error);
+    free(aug);
+}
+
+int __aug_load_module_file(struct augeas *aug, const char *filename) {
+    api_entry(aug);
+    int r = load_module_file(aug, filename);
+    api_exit(aug);
+    return r;
+}
+
+int tree_equal(const struct tree *t1, const struct tree *t2) {
+    while (t1 != NULL && t2 != NULL) {
+        if (!streqv(t1->label, t2->label))
+            return 0;
+        if (!streqv(t1->value, t2->value))
+            return 0;
+        if (! tree_equal(t1->children, t2->children))
+            return 0;
+        t1 = t1->next;
+        t2 = t2->next;
+    }
+    return t1 == t2;
+}
+
+/*
+ * Error reporting API
+ */
+int aug_error(struct augeas *aug) {
+    return aug->error->code;
+}
+
+const char *aug_error_message(struct augeas *aug) {
+    aug_errcode_t errcode = aug->error->code;
+
+    if (errcode > ARRAY_CARDINALITY(errcodes))
+        errcode = AUG_EINTERNAL;
+    return errcodes[errcode];
+}
+
+const char *aug_error_minor_message(struct augeas *aug) {
+    return aug->error->minor_details;
+}
+
+const char *aug_error_details(struct augeas *aug) {
+    return aug->error->details;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/augeas.h b/src/augeas.h
new file mode 100644 (file)
index 0000000..813b7a6
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * augeas.h: public headers for augeas
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <stdio.h>
+
+#ifndef AUGEAS_H_
+#define AUGEAS_H_
+
+typedef struct augeas augeas;
+
+/* Enum: aug_flags
+ *
+ * Flags to influence the behavior of Augeas. Pass a bitmask of these flags
+ * to AUG_INIT.
+ */
+enum aug_flags {
+    AUG_NONE = 0,
+    AUG_SAVE_BACKUP  = (1 << 0),  /* Keep the original file with a
+                                     .augsave extension */
+    AUG_SAVE_NEWFILE = (1 << 1),  /* Save changes into a file with
+                                     extension .augnew, and do not
+                                     overwrite the original file. Takes
+                                     precedence over AUG_SAVE_BACKUP */
+    AUG_TYPE_CHECK   = (1 << 2),  /* Typecheck lenses; since it can be very
+                                     expensive it is not done by default */
+    AUG_NO_STDINC    = (1 << 3),   /* Do not use the builtin load path for
+                                     modules */
+    AUG_SAVE_NOOP    = (1 << 4),  /* Make save a no-op process, just record
+                                     what would have changed */
+    AUG_NO_LOAD      = (1 << 5),  /* Do not load the tree from AUG_INIT */
+    AUG_NO_MODL_AUTOLOAD = (1 << 6),
+    AUG_ENABLE_SPAN  = (1 << 7)   /* Track the span in the input of nodes */
+};
+
+/* Function: aug_init
+ *
+ * Initialize the library.
+ *
+ * Use ROOT as the filesystem root. If ROOT is NULL, use the value of the
+ * environment variable AUGEAS_ROOT. If that doesn't exist eitehr, use "/".
+ *
+ * LOADPATH is a colon-spearated list of directories that modules should be
+ * searched in. This is in addition to the standard load path and the
+ * directories in AUGEAS_LENS_LIB
+ *
+ * FLAGS is a bitmask made up of values from AUG_FLAGS.
+ *
+ * Returns:
+ * a handle to the Augeas tree upon success. If initialization fails,
+ * returns NULL.
+ */
+augeas *aug_init(const char *root, const char *loadpath, unsigned int flags);
+
+/* Function: aug_defvar
+ *
+ * Define a variable NAME whose value is the result of evaluating EXPR. If
+ * a variable NAME already exists, its name will be replaced with the
+ * result of evaluating EXPR.
+ *
+ * If EXPR is NULL, the variable NAME will be removed if it is defined.
+ *
+ * Path variables can be used in path expressions later on by prefixing
+ * them with '$'.
+ *
+ * Returns -1 on error; on success, returns 0 if EXPR evaluates to anything
+ * other than a nodeset, and the number of nodes if EXPR evaluates to a
+ * nodeset
+ */
+int aug_defvar(augeas *aug, const char *name, const char *expr);
+
+/* Function: aug_defnode
+ *
+ * Define a variable NAME whose value is the result of evaluating EXPR,
+ * which must be non-NULL and evaluate to a nodeset. If a variable NAME
+ * already exists, its name will be replaced with the result of evaluating
+ * EXPR.
+ *
+ * If EXPR evaluates to an empty nodeset, a node is created, equivalent to
+ * calling AUG_SET(AUG, EXPR, VALUE) and NAME will be the nodeset containing
+ * that single node.
+ *
+ * If CREATED is non-NULL, it is set to 1 if a node was created, and 0 if
+ * it already existed.
+ *
+ * Returns -1 on error; on success, returns the number of nodes in the
+ * nodeset
+ */
+int aug_defnode(augeas *aug, const char *name, const char *expr,
+                const char *value, int *created);
+
+/* Function: aug_get
+ *
+ * Lookup the value associated with PATH. VALUE can be NULL, in which case
+ * it is ignored. If VALUE is not NULL, it is used to return a pointer to
+ * the value associated with PATH if PATH matches exactly one node. If PATH
+ * matches no nodes or more than one node, *VALUE is set to NULL. Note that
+ * it is perfectly legal for nodes to have a NULL value, and that that by
+ * itself does not indicate an error.
+ *
+ * The string *VALUE must not be freed by the caller, and is valid as long
+ * as its node remains unchanged.
+ *
+ * Returns:
+ * 1 if there is exactly one node matching PATH, 0 if there is none,
+ * and a negative value if there is more than one node matching PATH, or if
+ * PATH is not a legal path expression.
+ */
+int aug_get(const augeas *aug, const char *path, const char **value);
+
+/* Function: aug_set
+ *
+ * Set the value associated with PATH to VALUE. VALUE is copied into the
+ * internal data structure, and the caller is responsible for freeing
+ * it. Intermediate entries are created if they don't exist.
+ *
+ * Returns:
+ * 0 on success, -1 on error. It is an error if more than one node
+ * matches PATH.
+ */
+int aug_set(augeas *aug, const char *path, const char *value);
+
+/* Function: aug_setm
+ *
+ * Set the value of multiple nodes in one operation. Find or create a node
+ * matching SUB by interpreting SUB as a path expression relative to each
+ * node matching BASE. SUB may be NULL, in which case all the nodes
+ * matching BASE will be modified.
+ *
+ * Returns:
+ * number of modified nodes on success, -1 on error
+ */
+int aug_setm(augeas *aug, const char *base, const char *sub, const char *value);
+
+/* Function: aug_span
+ *
+ * Get the span according to input file of the node associated with PATH. If
+ * the node is associated with a file, the filename, label and value start and
+ * end positions are set, and return value is 0. The caller is responsible for
+ * freeing returned filename. If an argument for return value is NULL, then the
+ * corresponding value is not set. If the node associated with PATH doesn't
+ * belong to a file or is doesn't exists, filename and span are not set and
+ * return value is -1.
+ *
+ * Returns:
+ * 0 on success with filename, label_start, label_stop, value_start, value_end,
+ *   span_start, span_end
+ * -1 on error
+ */
+
+int aug_span(augeas *aug, const char *path, char **filename,
+        unsigned int *label_start, unsigned int *label_end,
+        unsigned int *value_start, unsigned int *value_end,
+        unsigned int *span_start, unsigned int *span_end);
+
+/* Function: aug_insert
+ *
+ * Create a new sibling LABEL for PATH by inserting into the tree just
+ * before PATH if BEFORE == 1 or just after PATH if BEFORE == 0.
+ *
+ * PATH must match exactly one existing node in the tree, and LABEL must be
+ * a label, i.e. not contain a '/', '*' or end with a bracketed index
+ * '[N]'.
+ *
+ * Returns:
+ * 0 on success, and -1 if the insertion fails.
+ */
+int aug_insert(augeas *aug, const char *path, const char *label, int before);
+
+/* Function: aug_rm
+ *
+ * Remove path and all its children. Returns the number of entries removed.
+ * All nodes that match PATH, and their descendants, are removed.
+ */
+int aug_rm(augeas *aug, const char *path);
+
+/* Function: aug_mv
+ *
+ * Move the node SRC to DST. SRC must match exactly one node in the
+ * tree. DST must either match exactly one node in the tree, or may not
+ * exist yet. If DST exists already, it and all its descendants are
+ * deleted. If DST does not exist yet, it and all its missing ancestors are
+ * created.
+ *
+ * Note that the node SRC always becomes the node DST: when you move /a/b
+ * to /x, the node /a/b is now called /x, no matter whether /x existed
+ * initially or not.
+ *
+ * Returns:
+ * 0 on success and -1 on failure.
+ */
+int aug_mv(augeas *aug, const char *src, const char *dst);
+
+/* Function: aug_match
+ *
+ * Returns:
+ * the number of matches of the path expression PATH in AUG. If
+ * MATCHES is non-NULL, an array with the returned number of elements will
+ * be allocated and filled with the paths of the matches. The caller must
+ * free both the array and the entries in it. The returned paths are
+ * sufficiently qualified to make sure that they match exactly one node in
+ * the current tree.
+ *
+ * If MATCHES is NULL, nothing is allocated and only the number
+ * of matches is returned.
+ *
+ * Returns -1 on error, or the total number of matches (which might be 0).
+ *
+ * Path expressions:
+ * Path expressions use a very simple subset of XPath: the path PATH
+ * consists of a number of segments, separated by '/'; each segment can
+ * either be a '*', matching any tree node, or a string, optionally
+ * followed by an index in brackets, matching tree nodes labelled with
+ * exactly that string. If no index is specified, the expression matches
+ * all nodes with that label; the index can be a positive number N, which
+ * matches exactly the Nth node with that label (counting from 1), or the
+ * special expression 'last()' which matches the last node with the given
+ * label. All matches are done in fixed positions in the tree, and nothing
+ * matches more than one path segment.
+ *
+ */
+int aug_match(const augeas *aug, const char *path, char ***matches);
+
+/* Function: aug_save
+ *
+ * Write all pending changes to disk.
+ *
+ * Returns:
+ * -1 if an error is encountered,
+ * 0 on success. Only files that had any changes made to them are written.
+ *
+ * If AUG_SAVE_NEWFILE is set in the FLAGS passed to AUG_INIT, create
+ * changed files as new files with the extension ".augnew", and leave teh
+ * original file unmodified.
+ *
+ * Otherwise, if AUG_SAVE_BACKUP is set in the FLAGS passed to AUG_INIT,
+ * move the original file to a new file with extension ".augsave".
+ *
+ * If neither of these flags is set, overwrite the original file.
+ */
+int aug_save(augeas *aug);
+
+/* Function: aug_load
+ *
+ * Load files into the tree. Which files to load and what lenses to use on
+ * them is specified under /augeas/load in the tree; each entry
+ * /augeas/load/NAME specifies a 'transform', by having itself exactly one
+ * child 'lens' and any number of children labelled 'incl' and 'excl'. The
+ * value of NAME has no meaning.
+ *
+ * The 'lens' grandchild of /augeas/load specifies which lens to use, and
+ * can either be the fully qualified name of a lens 'Module.lens' or
+ * '@Module'. The latter form means that the lens from the transform marked
+ * for autoloading in MODULE should be used.
+ *
+ * The 'incl' and 'excl' grandchildren of /augeas/load indicate which files
+ * to transform. Their value are used as glob patterns. Any file that
+ * matches at least one 'incl' pattern and no 'excl' pattern is
+ * transformed. The order of 'incl' and 'excl' entries is irrelevant.
+ *
+ * When AUG_INIT is first called, it populates /augeas/load with the
+ * transforms marked for autoloading in all the modules it finds.
+ *
+ * Before loading any files, AUG_LOAD will remove everything underneath
+ * /augeas/files and /files, regardless of whether any entries have been
+ * modified or not.
+ *
+ * Returns -1 on error, 0 on success. Note that success includes the case
+ * where some files could not be loaded. Details of such files can be found
+ * as '/augeas//error'.
+ */
+int aug_load(augeas *aug);
+
+/* Function: aug_print
+ *
+ * Print each node matching PATH and its descendants to OUT.
+ *
+ * Returns:
+ * 0 on success, or a negative value on failure
+ */
+int aug_print(const augeas *aug, FILE *out, const char *path);
+
+/* Function: aug_close
+ *
+ * Close this Augeas instance and free any storage associated with
+ * it. After running AUG_CLOSE, AUG is invalid and can not be used for any
+ * more operations.
+ */
+void aug_close(augeas *aug);
+
+/*
+ * Error reporting
+ */
+
+typedef enum {
+    AUG_NOERROR,        /* No error */
+    AUG_ENOMEM,         /* Out of memory */
+    AUG_EINTERNAL,      /* Internal error (bug) */
+    AUG_EPATHX,         /* Invalid path expression */
+    AUG_ENOMATCH,       /* No match for path expression */
+    AUG_EMMATCH,        /* Too many matches for path expression */
+    AUG_ESYNTAX,        /* Syntax error in lens file */
+    AUG_ENOLENS,        /* Lens lookup failed */
+    AUG_EMXFM,          /* Multiple transforms */
+    AUG_ENOSPAN         /* No span for this node */
+} aug_errcode_t;
+
+/* Return the error code from the last API call */
+int aug_error(augeas *aug);
+
+/* Return a human-readable message for the error code */
+const char *aug_error_message(augeas *aug);
+
+/* Return a human-readable message elaborating the error code; might be
+ * NULL. For example, when the error code is AUG_EPATHX, this will explain
+ * how the path expression is invalid */
+const char *aug_error_minor_message(augeas *aug);
+
+/* Return details about the error, which might be NULL. For example, for
+ * AUG_EPATHX, indicates where in the path expression the error
+ * occurred. The returned value can only be used until the next API call
+ */
+const char *aug_error_details(augeas *aug);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/augeas_sym.version b/src/augeas_sym.version
new file mode 100644 (file)
index 0000000..3f065f1
--- /dev/null
@@ -0,0 +1,41 @@
+AUGEAS_0.1.0 {
+    global:
+      aug_init;
+      aug_close;
+      aug_get;
+      aug_set;
+      aug_insert;
+      aug_rm;
+      aug_mv;
+      aug_match;
+      aug_save;
+      aug_print;
+      # Symbols with __ are private
+      __aug_load_module_file;
+    local: *;
+};
+
+AUGEAS_0.8.0 {
+    global:
+      aug_defvar;
+      aug_defnode;
+      aug_load;
+} AUGEAS_0.1.0;
+
+AUGEAS_0.10.0 {
+    global:
+      aug_error;
+      aug_error_message;
+      aug_error_minor_message;
+      aug_error_details;
+} AUGEAS_0.8.0;
+
+AUGEAS_0.11.0 {
+    global:
+      aug_setm;
+} AUGEAS_0.10.0;
+
+AUGEAS_0.12.0 {
+    global:
+      aug_span;
+} AUGEAS_0.11.0;
diff --git a/src/augparse.c b/src/augparse.c
new file mode 100644 (file)
index 0000000..73954ca
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * augparse.c: utility for parsing config files and seeing what's happening
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <argz.h>
+#include <getopt.h>
+
+#include "list.h"
+#include "syntax.h"
+#include "augeas.h"
+#include <locale.h>
+
+const char *progname;
+bool print_version = false;
+
+__attribute__((noreturn))
+static void usage(void) {
+    fprintf(stderr, "Usage: %s [OPTIONS] MODULE\n", progname);
+    fprintf(stderr, "Evaluate MODULE. Generally, MODULE should contain unit tests.\n");
+    fprintf(stderr, "\nOptions:\n\n");
+    fprintf(stderr, "  -I, --include DIR  search DIR for modules; can be given mutiple times\n");
+    fprintf(stderr, "  --nostdinc         do not search the builtin default directories for modules\n");
+    fprintf(stderr, "  --notypecheck      do not typecheck lenses\n");
+    fprintf(stderr, "  --version          print version information and exit\n");
+
+    exit(EXIT_FAILURE);
+}
+
+static void print_version_info(struct augeas *aug) {
+    const char *version;
+    int r;
+
+    r = aug_get(aug, "/augeas/version", &version);
+    if (r != 1)
+        goto error;
+
+    fprintf(stderr, "augparse %s <http://augeas.net/>\n", version);
+    fprintf(stderr, "Copyright (C) 2009-2010 David Lutterkort\n");
+    fprintf(stderr, "License LGPLv2+: GNU LGPL version 2.1 or later\n");
+    fprintf(stderr, "                 <http://www.gnu.org/licenses/lgpl-2.1.html>\n");
+    fprintf(stderr, "This is free software: you are free to change and redistribute it.\n");
+    fprintf(stderr, "There is NO WARRANTY, to the extent permitted by law.\n\n");
+    fprintf(stderr, "Written by David Lutterkort\n");
+    return;
+ error:
+    fprintf(stderr, "Something went terribly wrong internally - please file a bug\n");
+}
+
+int main(int argc, char **argv) {
+    int opt;
+    struct augeas *aug;
+    char *loadpath = NULL;
+    size_t loadpathlen = 0;
+    enum {
+        VAL_NO_STDINC = CHAR_MAX + 1,
+        VAL_NO_TYPECHECK = VAL_NO_STDINC + 1,
+        VAL_VERSION = VAL_NO_TYPECHECK + 1
+    };
+    struct option options[] = {
+        { "help",      0, 0, 'h' },
+        { "include",   1, 0, 'I' },
+        { "nostdinc",  0, 0, VAL_NO_STDINC },
+        { "notypecheck",  0, 0, VAL_NO_TYPECHECK },
+        { "version",  0, 0, VAL_VERSION },
+        { 0, 0, 0, 0}
+    };
+    int idx;
+    unsigned int flags = AUG_TYPE_CHECK|AUG_NO_MODL_AUTOLOAD;
+    progname = argv[0];
+
+    setlocale(LC_ALL, "");
+    while ((opt = getopt_long(argc, argv, "hI:", options, &idx)) != -1) {
+        switch(opt) {
+        case 'I':
+            argz_add(&loadpath, &loadpathlen, optarg);
+            break;
+        case 'h':
+            usage();
+            break;
+        case VAL_NO_STDINC:
+            flags |= AUG_NO_STDINC;
+            break;
+        case VAL_NO_TYPECHECK:
+            flags &= ~(AUG_TYPE_CHECK);
+            break;
+        case VAL_VERSION:
+            print_version = true;
+            break;
+        default:
+            usage();
+            break;
+        }
+    }
+
+    if (!print_version && optind >= argc) {
+        fprintf(stderr, "Expected .aug file\n");
+        usage();
+    }
+
+    argz_stringify(loadpath, loadpathlen, PATH_SEP_CHAR);
+    aug = aug_init(NULL, loadpath, flags);
+    if (aug == NULL) {
+        fprintf(stderr, "Memory exhausted\n");
+        return 2;
+    }
+
+    if (print_version) {
+        print_version_info(aug);
+        return EXIT_SUCCESS;
+    }
+
+    if (__aug_load_module_file(aug, argv[optind]) == -1) {
+        fprintf(stderr, "%s\n", aug_error_message(aug));
+        const char *s = aug_error_details(aug);
+        if (s != NULL) {
+            fprintf(stderr, "%s\n", s);
+        }
+        exit(EXIT_FAILURE);
+    }
+
+    aug_close(aug);
+    free(loadpath);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/augtool.c b/src/augtool.c
new file mode 100644 (file)
index 0000000..b199380
--- /dev/null
@@ -0,0 +1,1368 @@
+/*
+ * augtool.c:
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include "augeas.h"
+#include "internal.h"
+#include "safe-alloc.h"
+
+#include <readline/readline.h>
+#include <readline/history.h>
+#include <argz.h>
+#include <getopt.h>
+#include <limits.h>
+#include <ctype.h>
+#include <locale.h>
+
+/* Global variables */
+
+static const struct command_def const *commands[];
+static augeas *aug = NULL;
+static const char *const progname = "augtool";
+static unsigned int flags = AUG_NONE;
+const char *root = NULL;
+char *loadpath = NULL;
+const char *inputfile = NULL;
+int echo = 0;         /* Gets also changed in main_loop */
+bool print_version = false;
+bool auto_save = false;
+bool interactive = false;
+
+/*
+ * General utilities
+ */
+static char *cleanstr(char *path, const char sep) {
+    if (path == NULL || strlen(path) == 0)
+        return path;
+    char *e = path + strlen(path) - 1;
+    while (e >= path && (*e == sep || isspace(*e)))
+        *e-- = '\0';
+    return path;
+}
+
+static char *cleanpath(char *path) {
+    if (path == NULL || strlen(path) == 0)
+        return path;
+    if (STREQ(path, "/"))
+        return path;
+    return cleanstr(path, SEP);
+}
+
+/*
+ * Command handling infrastructure
+ */
+enum command_opt_type {
+    CMD_NONE,
+    CMD_STR,           /* String argument */
+    CMD_PATH           /* Path expression */
+};
+
+struct command_opt_def {
+    bool                  optional; /* Optional or mandatory */
+    enum command_opt_type type;
+    const char           *name;
+    const char           *help;
+};
+
+#define CMD_OPT_DEF_LAST { .type = CMD_NONE, .name = NULL }
+
+#define AUGTOOL_PROMPT "augtool> "
+
+/* Handlers return one of these */
+enum command_result {
+    CMD_RES_OK,
+    CMD_RES_ERR,
+    CMD_RES_ENOMEM,
+    CMD_RES_QUIT
+};
+
+struct command {
+    const struct command_def *def;
+    struct command_opt       *opt;
+    enum command_result       result;
+};
+
+typedef void (*cmd_handler)(struct command*);
+
+struct command_def {
+    const char                   *name;
+    const struct command_opt_def *opts;
+    cmd_handler                   handler;
+    const char                   *synopsis;
+    const char                   *help;
+};
+
+static const struct command_def cmd_def_last =
+    { .name = NULL, .opts = NULL, .handler = NULL,
+      .synopsis = NULL, .help = NULL };
+
+struct command_opt {
+    struct command_opt           *next;
+    const struct command_opt_def *def;
+    char                         *value;
+};
+
+static const struct command_def *lookup_cmd_def(const char *name) {
+    for (int i = 0; commands[i]->name != NULL; i++) {
+        if (STREQ(name, commands[i]->name))
+            return commands[i];
+    }
+    return NULL;
+}
+
+static const struct command_opt_def *
+find_def(const struct command *cmd, const char *name) {
+    const struct command_opt_def *def;
+    for (def = cmd->def->opts; def->name != NULL; def++) {
+        if (STREQ(def->name, name))
+            return def;
+    }
+    return NULL;
+}
+
+static struct command_opt *
+find_opt(const struct command *cmd, const char *name) {
+    const struct command_opt_def *def = find_def(cmd, name);
+    assert(def != NULL);
+
+    for (struct command_opt *opt = cmd->opt; opt != NULL; opt = opt->next) {
+        if (opt->def == def)
+            return opt;
+    }
+    assert(def->optional);
+    return NULL;
+}
+
+static const char *arg_value(const struct command *cmd, const char *name) {
+    struct command_opt *opt = find_opt(cmd, name);
+
+    return (opt == NULL) ? NULL : opt->value;
+}
+
+static char *nexttoken(char **line, bool path) {
+    char *r, *s;
+    char quot = '\0';
+    int nbracket = 0;
+
+    s = *line;
+
+    while (*s && isblank(*s)) s+= 1;
+    if (*s == '\'' || *s == '"') {
+        quot = *s;
+        s += 1;
+    }
+    r = s;
+    while (*s) {
+        if (*s == '[') nbracket += 1;
+        if (*s == ']') nbracket -= 1;
+        if (nbracket < 0) {
+            fprintf(stderr, "unmatched [\n");
+            return NULL;
+        }
+        if ((quot && *s == quot)
+            || (!quot && isblank(*s) && (!path || nbracket == 0)))
+            break;
+        s += 1;
+    }
+    if (*s == '\0' && path && nbracket > 0) {
+        fprintf(stderr, "unmatched [\n");
+        return NULL;
+    }
+    if (*s)
+        *s++ = '\0';
+    *line = s;
+    return r;
+}
+
+static struct command_opt *
+make_command_opt(struct command *cmd, const struct command_opt_def *def) {
+    struct command_opt *copt = NULL;
+    if (ALLOC(copt) < 0) {
+        fprintf(stderr, "Allocation failed\n");
+        return NULL;
+    }
+    copt->def = def;
+    list_append(cmd->opt, copt);
+    return copt;
+}
+
+static int parseline(struct command *cmd, char *line) {
+    char *tok;
+    int narg = 0, nopt = 0;
+    const struct command_opt_def *def;
+
+    MEMZERO(cmd, 1);
+    tok = nexttoken(&line, false);
+    if (tok == NULL)
+        return -1;
+    cmd->def = lookup_cmd_def(tok);
+    if (cmd->def == NULL) {
+        fprintf(stderr, "Unknown command '%s'\n", tok);
+        return -1;
+    }
+
+    for (def = cmd->def->opts; def->name != NULL; def++) {
+        narg += 1;
+        if (def->optional)
+            nopt += 1;
+    }
+
+    int curarg = 0;
+    def = cmd->def->opts;
+    while (*line != '\0') {
+        while (*line && isblank(*line)) line += 1;
+
+        if (curarg >= narg) {
+            fprintf(stderr,
+                 "Too many arguments. Command %s takes only %d arguments\n",
+                  cmd->def->name, narg);
+                return -1;
+        }
+
+        struct command_opt *opt = make_command_opt(cmd, def);
+        if (opt == NULL)
+            return -1;
+
+        if (def->type == CMD_PATH) {
+            tok = nexttoken(&line, true);
+            cleanpath(tok);
+        } else {
+            tok = nexttoken(&line, false);
+        }
+        if (tok == NULL)
+            return -1;
+        opt->value = tok;
+        curarg += 1;
+        def += 1;
+    }
+
+    if (curarg < narg - nopt) {
+        fprintf(stderr, "Not enough arguments for %s\n", cmd->def->name);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int err_check(struct command *cmd) {
+    if (aug_error(aug) != AUG_NOERROR) {
+        const char *minor = aug_error_minor_message(aug);
+        const char *details = aug_error_details(aug);
+
+        cmd->result = CMD_RES_ERR;
+        fprintf(stderr, "error: %s\n", aug_error_message(aug));
+        if (minor != NULL)
+            fprintf(stderr, "error: %s\n", minor);
+        if (details != NULL)
+            fprintf(stderr, "error: %s\n", details);
+        return -1;
+    }
+    return 0;
+}
+
+#define ERR_CHECK(cmd) if (err_check(cmd) < 0) return;
+
+#define ERR_RET(cmd) if ((cmd)->result != CMD_RES_OK) return;
+
+#define ERR_EXIT(cond, cmd, code)                \
+    if (cond) {                                  \
+        (cmd)->result = code;                    \
+        return;                                  \
+    }
+
+/*
+ * Commands
+ */
+static void format_desc(const char *d) {
+    printf("    ");
+    for (const char *s = d; *s; s++) {
+        if (*s == '\n')
+            printf("\n   ");
+        else
+            putchar(*s);
+    }
+    printf("\n\n");
+}
+
+static void format_defname(char *buf, const struct command_opt_def *def,
+                           bool mark_optional) {
+    char *p;
+    if (mark_optional && def->optional)
+        p = stpcpy(buf, " [<");
+    else
+        p = stpcpy(buf, " <");
+    for (int i=0; i < strlen(def->name); i++)
+        *p++ = toupper(def->name[i]);
+    *p++ = '>';
+    if (mark_optional && def->optional)
+        *p++ = ']';
+    *p = '\0';
+}
+
+static void cmd_help(struct command *cmd) {
+    const char *name = arg_value(cmd, "command");
+    char buf[100];
+
+    if (name == NULL) {
+        printf("Commands:\n\n");
+        for (int i=0; commands[i]->name != NULL; i++) {
+            const struct command_def *def = commands[i];
+            printf("    %-10s - %s\n", def->name, def->synopsis);
+        }
+        printf("\nType 'help <command>' for more information on a command\n\n");
+    } else {
+        const struct command_def *def = lookup_cmd_def(name);
+        const struct command_opt_def *odef = NULL;
+        if (def == NULL) {
+            fprintf(stderr, "unknown command %s\n", name);
+            cmd->result = CMD_RES_ERR;
+            return;
+        }
+        printf("  COMMAND\n");
+        printf("    %s - %s\n\n", name, def->synopsis);
+        printf("  SYNOPSIS\n");
+        printf("    %s", name);
+
+        for (odef = def->opts; odef->name != NULL; odef++) {
+            format_defname(buf, odef, true);
+            printf("%s", buf);
+        }
+        printf("\n\n");
+        printf("  DESCRIPTION\n");
+        format_desc(def->help);
+        if (def->opts->name != NULL) {
+            printf("  OPTIONS\n");
+            for (odef = def->opts; odef->name != NULL; odef++) {
+                const char *help = odef->help;
+                if (help == NULL)
+                    help = "";
+                format_defname(buf, odef, false);
+                printf("    %-10s %s\n", buf, help);
+            }
+        }
+        printf("\n");
+    }
+}
+
+static const struct command_opt_def cmd_help_opts[] = {
+    { .type = CMD_STR, .name = "command", .optional = true,
+      .help = "print help for this command only" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_help_def = {
+    .name = "help",
+    .opts = cmd_help_opts,
+    .handler = cmd_help,
+    .synopsis = "print help",
+    .help = "list all commands or print details about one command"
+};
+
+static void cmd_quit(ATTRIBUTE_UNUSED struct command *cmd) {
+    cmd->result = CMD_RES_QUIT;
+}
+
+static const struct command_opt_def cmd_quit_opts[] = {
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_quit_def = {
+    .name = "quit",
+    .opts = cmd_quit_opts,
+    .handler = cmd_quit,
+    .synopsis = "exit the program",
+    .help = "Exit the program"
+};
+
+static char *ls_pattern(struct command *cmd, const char *path) {
+    char *q;
+    int r;
+
+    if (path[strlen(path)-1] == SEP)
+        r = asprintf(&q, "%s*", path);
+    else
+        r = asprintf(&q, "%s/*", path);
+    if (r < 0) {
+        cmd->result = CMD_RES_ENOMEM;
+        return NULL;
+    }
+    return q;
+}
+
+static int child_count(struct command *cmd, const char *path) {
+    char *q = ls_pattern(cmd, path);
+    int cnt;
+
+    if (q == NULL)
+        return 0;
+    cnt = aug_match(aug, q, NULL);
+    err_check(cmd);
+    free(q);
+    return cnt;
+}
+
+static void cmd_ls(struct command *cmd) {
+    int cnt;
+    const char *path = arg_value(cmd, "path");
+    char **paths;
+
+    path = ls_pattern(cmd, path);
+    if (path == NULL)
+        ERR_RET(cmd);
+    cnt = aug_match(aug, path, &paths);
+    ERR_CHECK(cmd);
+    for (int i=0; i < cnt; i++) {
+        const char *val;
+        const char *basnam = strrchr(paths[i], SEP);
+        int dir = child_count(cmd, paths[i]);
+        aug_get(aug, paths[i], &val);
+        err_check(cmd);
+        basnam = (basnam == NULL) ? paths[i] : basnam + 1;
+        if (val == NULL)
+            val = "(none)";
+        printf("%s%s= %s\n", basnam, dir ? "/ " : " ", val);
+        free(paths[i]);
+    }
+    if (cnt > 0)
+        free(paths);
+}
+
+static const struct command_opt_def cmd_ls_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "the node whose children to list" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_ls_def = {
+    .name = "ls",
+    .opts = cmd_ls_opts,
+    .handler = cmd_ls,
+    .synopsis = "list children of a node",
+    .help = "list the direct children of a node"
+};
+
+static void cmd_match(struct command *cmd) {
+    int cnt;
+    const char *pattern = arg_value(cmd, "path");
+    const char *value = arg_value(cmd, "value");
+    char **matches;
+    bool filter = (value != NULL) && (strlen(value) > 0);
+
+    cnt = aug_match(aug, pattern, &matches);
+    err_check(cmd);
+    if (cnt < 0) {
+        printf("  (error matching %s)\n", pattern);
+        cmd->result = CMD_RES_ERR;
+        goto done;
+    }
+    if (cnt == 0) {
+        printf("  (no matches)\n");
+        goto done;
+    }
+
+    for (int i=0; i < cnt; i++) {
+        const char *val;
+        aug_get(aug, matches[i], &val);
+        err_check(cmd);
+        if (val == NULL)
+            val = "(none)";
+        if (filter) {
+            if (STREQ(value, val))
+                printf("%s\n", matches[i]);
+        } else {
+            printf("%s = %s\n", matches[i], val);
+        }
+    }
+ done:
+    for (int i=0; i < cnt; i++)
+        free(matches[i]);
+    free(matches);
+}
+
+static const struct command_opt_def cmd_match_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "the path expression to match" },
+    { .type = CMD_STR, .name = "value", .optional = true,
+      .help = "only show matches with this value" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_match_def = {
+    .name = "match",
+    .opts = cmd_match_opts,
+    .handler = cmd_match,
+    .synopsis = "print matches for a path expression",
+    .help = "Find all paths that match the path expression PATH. "
+            "If VALUE is given,\n only the matching paths whose value equals "
+            "VALUE are printed"
+};
+
+static void cmd_rm(struct command *cmd) {
+    int cnt;
+    const char *path = arg_value(cmd, "path");
+    if (echo)
+        printf("rm : %s", path);
+    cnt = aug_rm(aug, path);
+    err_check(cmd);
+    if (echo)
+        printf(" %d\n", cnt);
+}
+
+static const struct command_opt_def cmd_rm_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "remove all nodes matching this path expression" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_rm_def = {
+    .name = "rm",
+    .opts = cmd_rm_opts,
+    .handler = cmd_rm,
+    .synopsis = "delete nodes and subtrees",
+    .help = "Delete PATH and all its children from the tree"
+};
+
+static void cmd_mv(struct command *cmd) {
+    const char *src = arg_value(cmd, "src");
+    const char *dst = arg_value(cmd, "dst");
+    int r;
+
+    r = aug_mv(aug, src, dst);
+    err_check(cmd);
+    if (r < 0)
+        printf("Failed\n");
+}
+
+static const struct command_opt_def cmd_mv_opts[] = {
+    { .type = CMD_PATH, .name = "src", .optional = false,
+      .help = "the tree to move" },
+    { .type = CMD_PATH, .name = "dst", .optional = false,
+      .help = "where to put the source tree" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_mv_def = {
+    .name = "mv",
+    .opts = cmd_mv_opts,
+    .handler = cmd_mv,
+    .synopsis = "move a subtree",
+    .help = "Move node  SRC to DST.  SRC must match  exactly one node in  "
+    "the tree.\n DST  must either  match  exactly one  node  in the  tree,  "
+    "or may  not\n exist  yet. If  DST exists  already, it  and all  its  "
+    "descendants are\n deleted.  If  DST  does  not   exist  yet,  it  and  "
+    "all  its  missing\n ancestors are created."
+};
+
+static void cmd_set(struct command *cmd) {
+    const char *path = arg_value(cmd, "path");
+    const char *val = arg_value(cmd, "value");
+    int r;
+
+    r = aug_set(aug, path, val);
+    err_check(cmd);
+    if (r == -1)
+        printf ("Failed\n");
+}
+
+static const struct command_opt_def cmd_set_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "set the value of this node" },
+    { .type = CMD_STR, .name = "value", .optional = false,
+      .help = "the new value for the node" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_set_def = {
+    .name = "set",
+    .opts = cmd_set_opts,
+    .handler = cmd_set,
+    .synopsis = "set the value of a node",
+    .help = "Associate VALUE with PATH.  If PATH is not in the tree yet, "
+    "it and all\n its ancestors will be created. These new tree entries "
+    "will appear last\n amongst their siblings"
+};
+
+static void cmd_setm(struct command *cmd) {
+    const char *base = arg_value(cmd, "base");
+    const char *sub  = arg_value(cmd, "sub");
+    const char *val  = arg_value(cmd, "value");
+    int r;
+
+    r = aug_setm(aug, base, sub, val);
+    err_check(cmd);
+    if (r == -1)
+        printf ("Failed\n");
+}
+
+static const struct command_opt_def cmd_setm_opts[] = {
+    { .type = CMD_PATH, .name = "base", .optional = false,
+      .help = "the base node" },
+    { .type = CMD_PATH, .name = "sub", .optional = false,
+      .help = "the subtree relative to the base" },
+    { .type = CMD_STR, .name = "value", .optional = false,
+      .help = "the value for the nodes" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_setm_def = {
+    .name = "setm",
+    .opts = cmd_setm_opts,
+    .handler = cmd_setm,
+    .synopsis = "set the value of multiple nodes",
+    .help = "Set multiple nodes in one operation.  Find or create a node"
+    " matching SUB\n by interpreting SUB as a  path expression relative"
+    " to each node matching\n BASE. If SUB is '.', the nodes matching "
+    "BASE will be modified."
+};
+
+static void cmd_clearm(struct command *cmd) {
+    const char *base = arg_value(cmd, "base");
+    const char *sub  = arg_value(cmd, "sub");
+    int r;
+
+    r = aug_setm(aug, base, sub, NULL);
+    err_check(cmd);
+    if (r == -1)
+        printf ("Failed\n");
+}
+
+static const struct command_opt_def cmd_clearm_opts[] = {
+    { .type = CMD_PATH, .name = "base", .optional = false,
+      .help = "the base node" },
+    { .type = CMD_PATH, .name = "sub", .optional = false,
+      .help = "the subtree relative to the base" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_clearm_def = {
+    .name = "clearm",
+    .opts = cmd_clearm_opts,
+    .handler = cmd_clearm,
+    .synopsis = "clear the value of multiple nodes",
+    .help = "Clear multiple nodes values in one operation. Find or create a"
+    " node matching SUB\n by interpreting SUB as a path expression relative"
+    " to each node matching\n BASE. If SUB is '.', the nodes matching "
+    "BASE will be modified."
+};
+
+static void cmd_span(struct command *cmd) {
+    const char *path = arg_value(cmd, "path");
+    int r;
+    uint label_start, label_end, value_start, value_end, span_start, span_end;
+    char *filename;
+    const char *option;
+    // FIXME: add check to see if AUG_ENABLE_SPAN is set
+
+    if (aug_get(aug, AUGEAS_SPAN_OPTION, &option) != 1) {
+        printf("Error: option " AUGEAS_SPAN_OPTION " not found\n");
+        return;
+    }
+    if (strcmp(AUG_DISABLE, option) == 0) {
+        printf("Span is not enabled. To enable, run commands:\n");
+        printf("set %s %s\n", AUGEAS_SPAN_OPTION, AUG_ENABLE);
+        printf("rm %s\n", AUGEAS_FILES_TREE);
+        printf("load\n");
+        return;
+    } else if (strcmp(AUG_ENABLE, option) != 0) {
+        printf("Error: option %s must be %s or %s\n", AUGEAS_SPAN_OPTION,
+               AUG_ENABLE, AUG_DISABLE);
+        return;
+    }
+    r = aug_span(aug, path, &filename, &label_start, &label_end, &value_start,
+                 &value_end, &span_start, &span_end);
+    err_check(cmd);
+    if (r == -1){
+        printf ("Failed\n");
+        return;
+    }
+    printf("%s label=(%i:%i) value=(%i:%i) span=(%i,%i)\n", filename,
+           label_start, label_end, value_start, value_end, span_start, span_end);
+}
+
+static const struct command_opt_def cmd_span_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "node path" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_span_def = {
+    .name = "span",
+    .opts = cmd_span_opts,
+    .handler = cmd_span,
+    .synopsis = "get the filename, label and value position in the text of this node",
+    .help = "get the filename, label and value position in the text of this node"
+};
+
+static void cmd_defvar(struct command *cmd) {
+    const char *name = arg_value(cmd, "name");
+    const char *path = arg_value(cmd, "expr");
+    int r;
+
+    r = aug_defvar(aug, name, path);
+    err_check(cmd);
+    if (r == -1)
+        printf("Failed\n");
+}
+
+static const struct command_opt_def cmd_defvar_opts[] = {
+    { .type = CMD_STR, .name = "name", .optional = false,
+      .help = "the name of the variable" },
+    { .type = CMD_PATH, .name = "expr", .optional = false,
+      .help = "the path expression" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_defvar_def = {
+    .name = "defvar",
+    .opts = cmd_defvar_opts,
+    .handler = cmd_defvar,
+    .synopsis = "set a variable",
+    .help = "Evaluate EXPR and set the variable NAME to the resulting "
+    "nodeset. The\n variable can be used in path expressions as $NAME.  "
+    "Note that EXPR is\n evaluated when the variable is defined, not when "
+    "it is used."
+};
+
+static void cmd_defnode(struct command *cmd) {
+    const char *name = arg_value(cmd, "name");
+    const char *path = arg_value(cmd, "expr");
+    const char *value = arg_value(cmd, "value");
+    int r;
+
+    /* Our simple minded line parser treats non-existant and empty values
+     * the same. We choose to take the empty string to mean NULL */
+    if (value != NULL && strlen(value) == 0)
+        value = NULL;
+    r = aug_defnode(aug, name, path, value, NULL);
+    err_check(cmd);
+    if (r == -1)
+        printf ("Failed\n");
+}
+
+static const struct command_opt_def cmd_defnode_opts[] = {
+    { .type = CMD_STR, .name = "name", .optional = false,
+      .help = "the name of the variable" },
+    { .type = CMD_PATH, .name = "expr", .optional = false,
+      .help = "the path expression" },
+    { .type = CMD_STR, .name = "value", .optional = true,
+      .help = "the value for the new node" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_defnode_def = {
+    .name = "defnode",
+    .opts = cmd_defnode_opts,
+    .handler = cmd_defnode,
+    .synopsis = "set a variable, possibly creating a new node",
+    .help = "Define the variable NAME to the result of evalutating EXPR, "
+    " which must\n be a nodeset.  If no node matching EXPR exists yet,  one "
+    "is created and\n NAME will refer to it.   When a node is created and "
+    "VALUE is given, the\n new node's value is set to VALUE."
+};
+
+static void cmd_clear(struct command *cmd) {
+    const char *path = arg_value(cmd, "path");
+    int r;
+
+    r = aug_set(aug, path, NULL);
+    err_check(cmd);
+    if (r == -1)
+        printf ("Failed\n");
+}
+
+static const struct command_opt_def cmd_clear_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "clear the value of this node" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_clear_def = {
+    .name = "clear",
+    .opts = cmd_clear_opts,
+    .handler = cmd_clear,
+    .synopsis = "clear the value of a node",
+    .help = "Set the value for PATH to NULL. If PATH is not in the tree yet, "
+    "it and\n all its ancestors will be created.  These new tree entries "
+    "will appear\n last amongst their siblings"
+};
+
+static void cmd_get(struct command *cmd) {
+    const char *path = arg_value(cmd, "path");
+    const char *val;
+    int r;
+
+    r = aug_get(aug, path, &val);
+    ERR_CHECK(cmd);
+    printf("%s", path);
+    if (r == 0) {
+        printf(" (o)\n");
+    } else if (val == NULL) {
+        printf(" (none)\n");
+    } else {
+        printf(" = %s\n", val);
+    }
+    err_check(cmd);
+}
+
+static const struct command_opt_def cmd_get_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "get the value of this node" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_get_def = {
+    .name = "get",
+    .opts = cmd_get_opts,
+    .handler = cmd_get,
+    .synopsis = "get the value of a node",
+    .help = "Get and print the value associated with PATH"
+};
+
+static void cmd_print(struct command *cmd) {
+    const char *path = arg_value(cmd, "path");
+
+    aug_print(aug, stdout, path);
+    err_check(cmd);
+}
+
+static const struct command_opt_def cmd_print_opts[] = {
+    { .type = CMD_PATH, .name = "path", .optional = true,
+      .help = "print this subtree" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_print_def = {
+    .name = "print",
+    .opts = cmd_print_opts,
+    .handler = cmd_print,
+    .synopsis = "print a subtree",
+    .help = "Print entries in the tree.  If PATH is given, printing starts there,\n otherwise the whole tree is printed"
+};
+
+static void cmd_save(struct command *cmd) {
+    int r;
+    r = aug_save(aug);
+    err_check(cmd);
+    if (r == -1) {
+        printf("Saving failed\n");
+        cmd->result = CMD_RES_ERR;
+    } else {
+        r = aug_match(aug, "/augeas/events/saved", NULL);
+        if (r > 0) {
+            if (echo)
+                printf("Saved %d file(s)\n", r);
+        } else if (r < 0) {
+            printf("Error during match: %d\n", r);
+        }
+    }
+}
+
+static const struct command_opt_def cmd_save_opts[] = {
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_save_def = {
+    .name = "save",
+    .opts = cmd_save_opts,
+    .handler = cmd_save,
+    .synopsis = "save all pending changes",
+    .help = "Save all pending changes to disk. How exactly that is done depends on\n the value of the node /augeas/save, which can be changed by the user.\n The possible values for it are\n \n   noop      - do not write files; useful for finding errors that\n               might happen during a save\n   backup    - save the original file in a file by appending the extension\n               '.augsave' and overwrite the original with new content\n   newfile   - leave the original file untouched and write new content to\n               a file with extension '.augnew' next to the original file\n   overwrite - overwrite the original file with new content\n \n Save always tries to save all files for which entries in the tree have\n changed. When saving fails, some files will be written.  Details about\n why a save failed can by found by issuing the command 'print\n /augeas//error' (note the double slash)"
+};
+
+static void cmd_load(struct command *cmd) {
+    int r;
+    r = aug_load(aug);
+    err_check(cmd);
+    if (r == -1) {
+        printf("Loading failed\n");
+    }
+}
+
+static const struct command_opt_def cmd_load_opts[] = {
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_load_def = {
+    .name = "load",
+    .opts = cmd_load_opts,
+    .handler = cmd_load,
+    .synopsis = "(re)load files under /files",
+    .help = "Load files  according to the  transforms in /augeas/load.  "
+    "A transform\n Foo  is  represented  with  a  subtree  /augeas/load/Foo."
+    "   Underneath\n /augeas/load/Foo, one node labelled  'lens' must exist,"
+    " whose value is\n the  fully  qualified name  of  a  lens,  for example  "
+    "'Foo.lns',  and\n multiple nodes 'incl' and 'excl' whose values are "
+    "globs that determine\n which files are  transformed by that lens. It "
+    "is an  error if one file\n can be processed by multiple transforms."
+};
+
+static void cmd_ins(struct command *cmd) {
+    const char *label = arg_value(cmd, "label");
+    const char *where = arg_value(cmd, "where");
+    const char *path = arg_value(cmd, "path");
+    int before;
+
+    if (STREQ(where, "after"))
+        before = 0;
+    else if (STREQ(where, "before"))
+        before = 1;
+    else {
+        printf("The <WHERE> argument must be either 'before' or 'after'.");
+        cmd->result = CMD_RES_ERR;
+        return;
+    }
+
+    aug_insert(aug, path, label, before);
+    err_check(cmd);
+}
+
+static const struct command_opt_def cmd_ins_opts[] = {
+    { .type = CMD_STR, .name = "label", .optional = false,
+      .help = "the label for the new node" },
+    { .type = CMD_STR, .name = "where", .optional = false,
+      .help = "either 'before' or 'after'" },
+    { .type = CMD_PATH, .name = "path", .optional = false,
+      .help = "the node before/after which to insert" },
+    CMD_OPT_DEF_LAST
+};
+
+static const struct command_def cmd_ins_def = {
+    .name = "ins",
+    .opts = cmd_ins_opts,
+    .handler = cmd_ins,
+    .synopsis = "insert new node before/after and existing node",
+    .help = "Insert a new node with label LABEL right before or after "
+    "PATH into the\n tree. WHERE must be either 'before' or 'after'."
+};
+
+static char *readline_path_generator(const char *text, int state) {
+    static int current = 0;
+    static char **children = NULL;
+    static int nchildren = 0;
+    struct command fake;  /* Used only for the result field */
+
+    MEMZERO(&fake, 1);
+    if (state == 0) {
+        char *end = strrchr(text, SEP);
+        char *path;
+        if (end == NULL) {
+            if ((path = strdup("/*")) == NULL)
+                return NULL;
+        } else {
+            end += 1;
+            CALLOC(path, end - text + 2);
+            if (path == NULL)
+                return NULL;
+            strncpy(path, text, end - text);
+            strcat(path, "*");
+        }
+
+        for (;current < nchildren; current++)
+            free((void *) children[current]);
+        free((void *) children);
+        nchildren = aug_match(aug, path, &children);
+        current = 0;
+        free(path);
+    }
+
+    while (current < nchildren) {
+        char *child = children[current];
+        current += 1;
+        if (STREQLEN(child, text, strlen(text))) {
+            if (child_count(&fake, child) > 0) {
+                char *c = realloc(child, strlen(child)+2);
+                if (c == NULL)
+                    return NULL;
+                child = c;
+                strcat(child, "/");
+            }
+            rl_filename_completion_desired = 1;
+            rl_completion_append_character = '\0';
+            return child;
+        } else {
+            free(child);
+        }
+    }
+    return NULL;
+}
+
+static const struct command_def const *commands[] = {
+    &cmd_quit_def,
+    &cmd_clear_def,
+    &cmd_defnode_def,
+    &cmd_defvar_def,
+    &cmd_get_def,
+    &cmd_ins_def,
+    &cmd_load_def,
+    &cmd_ls_def,
+    &cmd_match_def,
+    &cmd_mv_def,
+    &cmd_print_def,
+    &cmd_rm_def,
+    &cmd_save_def,
+    &cmd_set_def,
+    &cmd_setm_def,
+    &cmd_clearm_def,
+    &cmd_span_def,
+    &cmd_help_def,
+    &cmd_def_last
+};
+
+static char *readline_command_generator(const char *text, int state) {
+    static int current = 0;
+    const char *name;
+
+    if (state == 0)
+        current = 0;
+
+    rl_completion_append_character = ' ';
+    while ((name = commands[current]->name) != NULL) {
+        current += 1;
+        if (STREQLEN(text, name, strlen(text)))
+            return strdup(name);
+    }
+    return NULL;
+}
+
+#ifndef HAVE_RL_COMPLETION_MATCHES
+typedef char *rl_compentry_func_t(const char *, int);
+static char **rl_completion_matches(ATTRIBUTE_UNUSED const char *text,
+                           ATTRIBUTE_UNUSED rl_compentry_func_t *func) {
+    return NULL;
+}
+#endif
+
+static char **readline_completion(const char *text, int start,
+                                  ATTRIBUTE_UNUSED int end) {
+    if (start == 0)
+        return rl_completion_matches(text, readline_command_generator);
+    else
+        return rl_completion_matches(text, readline_path_generator);
+
+    return NULL;
+}
+
+static void readline_init(void) {
+    rl_readline_name = "augtool";
+    rl_attempted_completion_function = readline_completion;
+    rl_completion_entry_function = readline_path_generator;
+}
+
+__attribute__((noreturn))
+static void usage(void) {
+    fprintf(stderr, "Usage: %s [OPTIONS] [COMMAND]\n", progname);
+    fprintf(stderr, "Load the Augeas tree and modify it. If no COMMAND is given, run interactively\n");
+    fprintf(stderr, "Run '%s help' to get a list of possible commands.\n",
+            progname);
+    fprintf(stderr, "\nOptions:\n\n");
+    fprintf(stderr, "  -c, --typecheck    typecheck lenses\n");
+    fprintf(stderr, "  -b, --backup       preserve originals of modified files with\n"
+                    "                     extension '.augsave'\n");
+    fprintf(stderr, "  -n, --new          save changes in files with extension '.augnew',\n"
+                    "                     leave original unchanged\n");
+    fprintf(stderr, "  -r, --root ROOT    use ROOT as the root of the filesystem\n");
+    fprintf(stderr, "  -I, --include DIR  search DIR for modules; can be given mutiple times\n");
+    fprintf(stderr, "  -e, --echo         echo commands when reading from a file\n");
+    fprintf(stderr, "  -f, --file FILE    read commands from FILE\n");
+    fprintf(stderr, "  -s, --autosave     automatically save at the end of instructions\n");
+    fprintf(stderr, "  -i, --interactive  run an interactive shell after evaluating the commands in STDIN and FILE\n");
+    fprintf(stderr, "  -S, --nostdinc     do not search the builtin default directories for modules\n");
+    fprintf(stderr, "  -L, --noload       do not load any files into the tree on startup\n");
+    fprintf(stderr, "  -A, --noautoload   do not autoload modules from the search path\n");
+    fprintf(stderr, "  --span             load span positions for nodes related to a file\n");
+    fprintf(stderr, "  --version          print version information and exit.\n");
+
+    exit(EXIT_FAILURE);
+}
+
+static void parse_opts(int argc, char **argv) {
+    int opt;
+    size_t loadpathlen = 0;
+    enum {
+        VAL_VERSION = CHAR_MAX + 1,
+        VAL_SPAN = VAL_VERSION + 1
+    };
+    struct option options[] = {
+        { "help",      0, 0, 'h' },
+        { "typecheck", 0, 0, 'c' },
+        { "backup",    0, 0, 'b' },
+        { "new",       0, 0, 'n' },
+        { "root",      1, 0, 'r' },
+        { "include",   1, 0, 'I' },
+        { "echo",      0, 0, 'e' },
+        { "file",      1, 0, 'f' },
+        { "autosave",  0, 0, 's' },
+        { "interactive",  0, 0, 'i' },
+        { "nostdinc",  0, 0, 'S' },
+        { "noload",    0, 0, 'L' },
+        { "noautoload", 0, 0, 'A' },
+        { "span",      0, 0, VAL_SPAN },
+        { "version",   0, 0, VAL_VERSION },
+        { 0, 0, 0, 0}
+    };
+    int idx;
+
+    while ((opt = getopt_long(argc, argv, "hnbcr:I:ef:siSLA", options, &idx)) != -1) {
+        switch(opt) {
+        case 'c':
+            flags |= AUG_TYPE_CHECK;
+            break;
+        case 'b':
+            flags |= AUG_SAVE_BACKUP;
+            break;
+        case 'n':
+            flags |= AUG_SAVE_NEWFILE;
+            break;
+        case 'h':
+            usage();
+            break;
+        case 'r':
+            root = optarg;
+            break;
+        case 'I':
+            argz_add(&loadpath, &loadpathlen, optarg);
+            break;
+        case 'e':
+            echo = 1;
+            break;
+        case 'f':
+            inputfile = optarg;
+            break;
+        case 's':
+            auto_save = true;
+            break;
+        case 'i':
+            interactive = true;
+            break;
+        case 'S':
+            flags |= AUG_NO_STDINC;
+            break;
+        case 'L':
+            flags |= AUG_NO_LOAD;
+            break;
+        case 'A':
+            flags |= AUG_NO_MODL_AUTOLOAD;
+            break;
+        case VAL_VERSION:
+            flags |= AUG_NO_MODL_AUTOLOAD;
+            print_version = true;
+            break;
+        case VAL_SPAN:
+            flags |= AUG_ENABLE_SPAN;
+            break;
+        default:
+            usage();
+            break;
+        }
+    }
+    argz_stringify(loadpath, loadpathlen, PATH_SEP_CHAR);
+}
+
+static void print_version_info(void) {
+    const char *version;
+    int r;
+
+    r = aug_get(aug, "/augeas/version", &version);
+    if (r != 1)
+        goto error;
+
+    fprintf(stderr, "augtool %s <http://augeas.net/>\n", version);
+    fprintf(stderr, "Copyright (C) 2009-2010 David Lutterkort\n");
+    fprintf(stderr, "License LGPLv2+: GNU LGPL version 2.1 or later\n");
+    fprintf(stderr, "                 <http://www.gnu.org/licenses/lgpl-2.1.html>\n");
+    fprintf(stderr, "This is free software: you are free to change and redistribute it.\n");
+    fprintf(stderr, "There is NO WARRANTY, to the extent permitted by law.\n\n");
+    fprintf(stderr, "Written by David Lutterkort\n");
+    return;
+ error:
+    fprintf(stderr, "Something went terribly wrong internally - please file a bug\n");
+}
+
+static enum command_result
+run_command(const char *line) {
+    char *dup_line = strdup(line);
+    struct command cmd;
+
+    if (dup_line == NULL) {
+        fprintf(stderr, "Out of memory\n");
+        return CMD_RES_ENOMEM;
+    }
+
+    MEMZERO(&cmd, 1);
+    if (parseline(&cmd, dup_line) == 0) {
+        cmd.def->handler(&cmd);
+        if (isatty(fileno(stdin)))
+            add_history(line);
+    } else {
+        cmd.result = CMD_RES_ERR;
+    }
+    free(dup_line);
+    return cmd.result;
+}
+
+static int main_loop(void) {
+    char *line = NULL;
+    int ret = 0;
+    char inputline [128];
+    enum command_result code;
+    bool end_reached = false;
+    bool get_line = true;
+    bool in_interactive = false;
+    // make readline silent by default
+    rl_outstream = fopen("/dev/null", "w");
+
+    if (inputfile) {
+        if (freopen(inputfile, "r", stdin) == NULL) {
+            char *msg = NULL;
+            if (asprintf(&msg, "Failed to open %s", inputfile) < 0)
+                perror("Failed to open input file");
+            else
+                perror(msg);
+            return CMD_RES_ERR;
+        }
+    }
+
+    echo = echo || isatty(fileno(stdin));
+
+    if (echo)
+        rl_outstream = NULL;
+
+    while(1) {
+        if (get_line) {
+            line = readline(AUGTOOL_PROMPT);
+        } else {
+            line = NULL;
+        }
+
+        if (line == NULL) {
+            if (!isatty(fileno(stdin)) && interactive && !in_interactive) {
+               in_interactive = true;
+               echo = true;
+               // reopen in and out streams
+               if ((rl_instream = fopen("/dev/tty", "r")) == NULL) {
+                   perror("Failed to open terminal for reading");
+                   return CMD_RES_ERR;
+               }
+               if (rl_outstream != NULL) {
+                   fclose(rl_outstream);
+                   rl_outstream = NULL;
+               }
+               if ((rl_outstream = fopen("/dev/stdout", "w")) == NULL) {
+                   perror("Failed to reopen stdout");
+                   return CMD_RES_ERR;
+               }
+               continue;
+            }
+
+            if (auto_save) {
+                strncpy(inputline, "save", sizeof(inputline));
+                line = inputline;
+                if (echo)
+                    printf("%s\n", line);
+                auto_save = false;
+            } else {
+                end_reached = true;
+            }
+            get_line = false;
+        }
+
+        cleanstr(line, '\n');
+
+        if (end_reached) {
+            if (echo)
+                printf("\n");
+            return ret;
+        }
+
+        if (*line == '\0' || *line == '#')
+            continue;
+
+        code = run_command(line);
+        if (code == CMD_RES_QUIT)
+            return 0;
+        if (code == CMD_RES_ERR)
+            ret = -1;
+        if (code == CMD_RES_ENOMEM) {
+            fprintf(stderr, "Out of memory.\n");
+            return -1;
+        }
+        if (isatty(fileno(stdin)))
+            add_history(line);
+    }
+}
+
+static int run_args(int argc, char **argv) {
+    size_t len = 0;
+    char *line = NULL;
+    enum command_result code;
+
+    for (int i=0; i < argc; i++)
+        len += strlen(argv[i]) + 1;
+    if (ALLOC_N(line, len + 1) < 0)
+        return -1;
+    for (int i=0; i < argc; i++) {
+        strcat(line, argv[i]);
+        strcat(line, " ");
+    }
+    code = run_command(line);
+    free(line);
+    if (code == CMD_RES_OK && auto_save)
+        code = run_command("save");
+    return (code == CMD_RES_OK || code == CMD_RES_QUIT) ? 0 : -1;
+}
+
+int main(int argc, char **argv) {
+    int r;
+
+    setlocale(LC_ALL, "");
+
+    parse_opts(argc, argv);
+
+    aug = aug_init(root, loadpath, flags);
+    if (aug == NULL) {
+        fprintf(stderr, "Failed to initialize Augeas\n");
+        exit(EXIT_FAILURE);
+    }
+    if (print_version) {
+        print_version_info();
+        return EXIT_SUCCESS;
+    }
+    readline_init();
+    if (optind < argc) {
+        // Accept one command from the command line
+        r = run_args(argc - optind, argv+optind);
+    } else {
+        r = main_loop();
+    }
+
+    return r == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/builtin.c b/src/builtin.c
new file mode 100644 (file)
index 0000000..1b339e3
--- /dev/null
@@ -0,0 +1,607 @@
+/*
+ * builtin.c: builtin primitives
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "syntax.h"
+#include "memory.h"
+#include "transform.h"
+#include "errcode.h"
+
+#define UNIMPL_BODY(name)                       \
+    {                                           \
+        FIXME(#name " called");                 \
+        abort();                                \
+    }
+
+/*
+ * Lenses
+ */
+
+/* V_REGEXP -> V_STRING -> V_LENS */
+static struct value *lns_del(struct info *info,
+                             struct value *rxp, struct value *dflt) {
+    assert(rxp->tag == V_REGEXP);
+    assert(dflt->tag == V_STRING);
+    return lns_make_prim(L_DEL, ref(info),
+                         ref(rxp->regexp), ref(dflt->string));
+}
+
+/* V_REGEXP -> V_LENS */
+static struct value *lns_store(struct info *info, struct value *rxp) {
+    assert(rxp->tag == V_REGEXP);
+    return lns_make_prim(L_STORE, ref(info), ref(rxp->regexp), NULL);
+}
+
+/* V_STRING -> V_LENS */
+static struct value *lns_value(struct info *info, struct value *str) {
+    assert(str->tag == V_STRING);
+    return lns_make_prim(L_VALUE, ref(info), NULL, ref(str->string));
+}
+
+/* V_REGEXP -> V_LENS */
+static struct value *lns_key(struct info *info, struct value *rxp) {
+    assert(rxp->tag == V_REGEXP);
+    return lns_make_prim(L_KEY, ref(info), ref(rxp->regexp), NULL);
+}
+
+/* V_STRING -> V_LENS */
+static struct value *lns_label(struct info *info, struct value *str) {
+    assert(str->tag == V_STRING);
+    return lns_make_prim(L_LABEL, ref(info), NULL, ref(str->string));
+}
+
+/* V_STRING -> V_LENS */
+static struct value *lns_seq(struct info *info, struct value *str) {
+    assert(str->tag == V_STRING);
+    return lns_make_prim(L_SEQ, ref(info), NULL, ref(str->string));
+}
+
+/* V_STRING -> V_LENS */
+static struct value *lns_counter(struct info *info, struct value *str) {
+    assert(str->tag == V_STRING);
+    return lns_make_prim(L_COUNTER, ref(info), NULL, ref(str->string));
+}
+
+/* V_REGEXP -> V_LENS -> V_LENS */
+static struct value *lns_square(struct info *info, struct value *rxp,
+                                struct value *lns) {
+    assert(rxp->tag == V_REGEXP);
+    assert(lns->tag == V_LENS);
+    int check = info->error->aug->flags & AUG_TYPE_CHECK;
+
+    return lns_make_square(ref(info), ref(rxp->regexp), ref(lns->lens), check);
+}
+
+static struct value *make_exn_lns_error(struct info *info,
+                                        struct lns_error *err,
+                                        const char *text) {
+    struct value *v;
+
+    if (HAS_ERR(info))
+        return exn_error();
+
+    v = make_exn_value(ref(info), "%s", err->message);
+    if (err->lens != NULL) {
+        char *s = format_info(err->lens->info);
+        exn_printf_line(v, "Lens: %s", s);
+        free(s);
+    }
+    if (err->pos >= 0) {
+        char *pos = format_pos(text, err->pos);
+        size_t line, ofs;
+        calc_line_ofs(text, err->pos, &line, &ofs);
+        exn_printf_line(v,
+                     "Error encountered at %d:%d (%d characters into string)",
+                        (int) line, (int) ofs, err->pos);
+        if (pos != NULL)
+            exn_printf_line(v, "%s", pos);
+        free(pos);
+    } else {
+        exn_printf_line(v, "Error encountered at path %s", err->path);
+    }
+
+    return v;
+}
+
+static void exn_print_tree(struct value *exn, struct tree *tree) {
+    struct memstream ms;
+
+    init_memstream(&ms);
+    dump_tree(ms.stream, tree);
+    close_memstream(&ms);
+    exn_printf_line(exn, "%s", ms.buf);
+    FREE(ms.buf);
+}
+
+static struct value *make_pathx_exn(struct info *info, struct pathx *p) {
+    struct value *v;
+    char *msg;
+    const char *txt;
+    int pos;
+
+    msg = strdup(pathx_error(p, &txt, &pos));
+    if (msg == NULL)
+        return NULL;
+
+    v = make_exn_value(ref(info), "syntax error in path expression: %s", msg);
+    if (ALLOC_N(msg, strlen(txt) + 4) >= 0) {
+        strncpy(msg, txt, pos);
+        strcat(msg, "|=|");
+        strcat(msg, txt + pos);
+        exn_add_lines(v, 1, msg);
+    }
+    return v;
+}
+
+static struct value *pathx_parse_glue(struct info *info, struct value *tree,
+                                      struct value *path, struct pathx **p) {
+    assert(path->tag == V_STRING);
+    assert(tree->tag == V_TREE);
+
+    if (pathx_parse(tree->origin, info->error, path->string->str, true,
+                    NULL, p) != PATHX_NOERROR) {
+        return make_pathx_exn(ref(info), *p);
+    } else {
+        return NULL;
+    }
+}
+
+/* V_LENS -> V_STRING -> V_TREE */
+static struct value *lens_get(struct info *info, struct value *l,
+                              struct value *str) {
+    assert(l->tag == V_LENS);
+    assert(str->tag == V_STRING);
+    struct lns_error *err;
+    struct value *v;
+    const char *text = str->string->str;
+
+    struct tree *tree = lns_get(info, l->lens, text, &err);
+    if (err == NULL && ! HAS_ERR(info)) {
+        v = make_value(V_TREE, ref(info));
+        v->origin = make_tree_origin(tree);
+    } else {
+        struct tree *t = make_tree_origin(tree);
+        if (t == NULL)
+            free_tree(tree);
+        tree = t;
+
+        v = make_exn_lns_error(info, err, text);
+        if (tree != NULL) {
+            exn_printf_line(v, "Tree generated so far:");
+            exn_print_tree(v, tree);
+            free_tree(tree);
+        }
+        free_lns_error(err);
+    }
+    return v;
+}
+
+
+/* V_LENS -> V_TREE -> V_STRING -> V_STRING */
+static struct value *lens_put(struct info *info, struct value *l,
+                              struct value *tree, struct value *str) {
+    assert(l->tag == V_LENS);
+    assert(tree->tag == V_TREE);
+    assert(str->tag == V_STRING);
+
+    struct memstream ms;
+    struct value *v;
+    struct lns_error *err;
+
+    init_memstream(&ms);
+    lns_put(ms.stream, l->lens, tree->origin->children,
+            str->string->str, &err);
+    close_memstream(&ms);
+
+    if (err == NULL && ! HAS_ERR(info)) {
+        v = make_value(V_STRING, ref(info));
+        v->string = make_string(ms.buf);
+    } else {
+        v = make_exn_lns_error(info, err, str->string->str);
+        free_lns_error(err);
+        FREE(ms.buf);
+    }
+    return v;
+}
+
+/* V_STRING -> V_STRING -> V_TREE -> V_TREE */
+static struct value *tree_set_glue(struct info *info, struct value *path,
+                                   struct value *val, struct value *tree) {
+    // FIXME: This only works if TREE is not referenced more than once;
+    // otherwise we'll have some pretty weird semantics, and would really
+    // need to copy TREE first
+    assert(path->tag == V_STRING);
+    assert(val->tag == V_STRING);
+    assert(tree->tag == V_TREE);
+
+    struct tree *fake = NULL;
+    struct pathx *p = NULL;
+    struct value *result = NULL;
+
+    if (tree->origin->children == NULL) {
+        tree->origin->children = make_tree(NULL, NULL, tree->origin, NULL);
+        fake = tree->origin->children;
+    }
+
+    result = pathx_parse_glue(info, tree, path, &p);
+    if (result != NULL)
+        goto done;
+
+    if (tree_set(p, val->string->str) == NULL) {
+        result = make_exn_value(ref(info),
+                                "Tree set of %s to '%s' failed",
+                                path->string->str, val->string->str);
+        goto done;
+    }
+    if (fake != NULL) {
+        list_remove(fake, tree->origin->children);
+        free_tree(fake);
+    }
+    result = ref(tree);
+
+ done:
+    free_pathx(p);
+    return result;
+}
+
+/* V_STRING -> V_TREE -> V_TREE */
+static struct value *tree_clear_glue(struct info *info, struct value *path,
+                                     struct value *tree) {
+    // FIXME: This only works if TREE is not referenced more than once;
+    // otherwise we'll have some pretty weird semantics, and would really
+    // need to copy TREE first
+    assert(path->tag == V_STRING);
+    assert(tree->tag == V_TREE);
+
+    struct tree *fake = NULL;
+    struct pathx *p = NULL;
+    struct value *result = NULL;
+
+    if (tree->origin->children == NULL) {
+        tree->origin->children = make_tree(NULL, NULL, tree->origin, NULL);
+        fake = tree->origin->children;
+    }
+
+    result = pathx_parse_glue(info, tree, path, &p);
+    if (result != NULL)
+        goto done;
+
+    if (tree_set(p, NULL) == NULL) {
+        result = make_exn_value(ref(info),
+                                "Tree set of %s to NULL failed",
+                                path->string->str);
+        goto done;
+    }
+    if (fake != NULL) {
+        list_remove(fake, tree->origin->children);
+        free_tree(fake);
+    }
+    result = ref(tree);
+
+ done:
+    free_pathx(p);
+    return result;
+}
+
+static struct value *tree_insert_glue(struct info *info, struct value *label,
+                                      struct value *path, struct value *tree,
+                                      int before) {
+    // FIXME: This only works if TREE is not referenced more than once;
+    // otherwise we'll have some pretty weird semantics, and would really
+    // need to copy TREE first
+    assert(label->tag == V_STRING);
+    assert(path->tag == V_STRING);
+    assert(tree->tag == V_TREE);
+
+    int r;
+    struct pathx *p = NULL;
+    struct value *result = NULL;
+
+    result = pathx_parse_glue(info, tree, path, &p);
+    if (result != NULL)
+        goto done;
+
+    r = tree_insert(p, label->string->str, before);
+    if (r != 0) {
+        result = make_exn_value(ref(info),
+                                "Tree insert of %s at %s failed",
+                                label->string->str, path->string->str);
+        goto done;
+    }
+
+    result = ref(tree);
+ done:
+    free_pathx(p);
+    return result;
+}
+
+/* Insert after */
+/* V_STRING -> V_STRING -> V_TREE -> V_TREE */
+static struct value *tree_insa_glue(struct info *info, struct value *label,
+                                    struct value *path, struct value *tree) {
+    return tree_insert_glue(info, label, path, tree, 0);
+}
+
+/* Insert before */
+/* V_STRING -> V_STRING -> V_TREE -> V_TREE */
+static struct value *tree_insb_glue(struct info *info, struct value *label,
+                                    struct value *path, struct value *tree) {
+    return tree_insert_glue(info, label, path, tree, 1);
+}
+
+/* V_STRING -> V_TREE -> V_TREE */
+static struct value *tree_rm_glue(struct info *info,
+                                  struct value *path,
+                                  struct value *tree) {
+    // FIXME: This only works if TREE is not referenced more than once;
+    // otherwise we'll have some pretty weird semantics, and would really
+    // need to copy TREE first
+    assert(path->tag == V_STRING);
+    assert(tree->tag == V_TREE);
+
+    struct pathx *p = NULL;
+    struct value *result = NULL;
+
+    result = pathx_parse_glue(info, tree, path, &p);
+    if (result != NULL)
+        goto done;
+
+    if (tree_rm(p) == -1) {
+        result = make_exn_value(ref(info), "Tree rm of %s failed",
+                                path->string->str);
+        goto done;
+    }
+    result = ref(tree);
+ done:
+    free_pathx(p);
+    return result;
+}
+
+/* V_STRING -> V_STRING */
+static struct value *gensym(struct info *info, struct value *prefix) {
+    assert(prefix->tag == V_STRING);
+    static unsigned int count = 0;
+    struct value *v;
+    char *s;
+    int r;
+
+    r = asprintf(&s, "%s%u", prefix->string->str, count);
+    if (r == -1)
+        return NULL;
+    v = make_value(V_STRING, ref(info));
+    v->string = make_string(s);
+    return v;
+}
+
+/* V_STRING -> V_FILTER */
+static struct value *xform_incl(struct info *info, struct value *s) {
+    assert(s->tag == V_STRING);
+    struct value *v = make_value(V_FILTER, ref(info));
+    v->filter = make_filter(ref(s->string), 1);
+    return v;
+}
+
+/* V_STRING -> V_FILTER */
+static struct value *xform_excl(struct info *info, struct value *s) {
+    assert(s->tag == V_STRING);
+    struct value *v = make_value(V_FILTER, ref(info));
+    v->filter = make_filter(ref(s->string), 0);
+    return v;
+}
+
+/* V_LENS -> V_FILTER -> V_TRANSFORM */
+static struct value *xform_transform(struct info *info, struct value *l,
+                                     struct value *f) {
+    assert(l->tag == V_LENS);
+    assert(f->tag == V_FILTER);
+    if (l->lens->value || l->lens->key) {
+        return make_exn_value(ref(info), "Can not build a transform "
+                              "from a lens that leaves a %s behind",
+                              l->lens->key ? "key" : "value");
+    }
+    struct value *v = make_value(V_TRANSFORM, ref(info));
+    v->transform = make_transform(ref(l->lens), ref(f->filter));
+    return v;
+}
+
+static struct value *sys_getenv(struct info *info, struct value *n) {
+    assert(n->tag == V_STRING);
+    struct value *v = make_value(V_STRING, ref(info));
+    v->string = dup_string(getenv(n->string->str));
+    return v;
+}
+
+static struct value *sys_read_file(struct info *info, struct value *n) {
+    assert(n->tag == V_STRING);
+    char *str = NULL;
+
+    str = xread_file(n->string->str);
+    if (str == NULL) {
+        char error_buf[1024];
+        const char *errmsg;
+        errmsg = xstrerror(errno, error_buf, sizeof(error_buf));
+        struct value *exn = make_exn_value(ref(info),
+             "reading file %s failed:", n->string->str);
+        exn_printf_line(exn, "%s", errmsg);
+        return exn;
+    }
+    struct value *v = make_value(V_STRING, ref(info));
+    v->string = make_string(str);
+    return v;
+}
+
+/* V_LENS -> V_LENS */
+static struct value *lns_check_rec_glue(struct info *info,
+                                        struct value *l, struct value *r) {
+    assert(l->tag == V_LENS);
+    assert(r->tag == V_LENS);
+    int check = info->error->aug->flags & AUG_TYPE_CHECK;
+
+    return lns_check_rec(info, l->lens, r->lens, check);
+}
+
+/*
+ * Print functions
+ */
+
+/* V_STRING -> V_UNIT */
+static struct value *pr_string(struct info *info, struct value *s) {
+    printf("%s", s->string->str);
+    return make_unit(ref(info));
+}
+
+/* V_REGEXP -> V_UNIT */
+static struct value *pr_regexp(struct info *info, struct value *r) {
+    print_regexp(stdout, r->regexp);
+    return make_unit(ref(info));
+}
+
+/* V_STRING -> V_UNIT */
+static struct value *pr_endline(struct info *info, struct value *s) {
+    printf("%s\n", s->string->str);
+    return make_unit(ref(info));
+}
+
+/*
+ * Lens inspection
+ */
+
+static struct value *lns_value_of_type(struct info *info, struct regexp *rx) {
+    struct value *result = make_value(V_REGEXP, ref(info));
+    if (rx)
+        result->regexp = ref(rx);
+    else
+        result->regexp = regexp_make_empty(ref(info));
+    return result;
+}
+
+/* V_LENS -> V_REGEXP */
+static struct value *lns_ctype(struct info *info, struct value *l) {
+    return lns_value_of_type(info, l->lens->ctype);
+}
+
+/* V_LENS -> V_REGEXP */
+static struct value *lns_atype(struct info *info, struct value *l) {
+    return lns_value_of_type(info, l->lens->atype);
+}
+
+/* V_LENS -> V_REGEXP */
+static struct value *lns_vtype(struct info *info, struct value *l) {
+    return lns_value_of_type(info, l->lens->vtype);
+}
+
+/* V_LENS -> V_REGEXP */
+static struct value *lns_ktype(struct info *info, struct value *l) {
+    return lns_value_of_type(info, l->lens->ktype);
+}
+
+/* V_LENS -> V_STRING */
+static struct value *lns_fmt_atype(struct info *info, struct value *l) {
+    struct value *result = NULL;
+    char *s = NULL;
+    int r;
+
+    r = lns_format_atype(l->lens, &s);
+    if (r < 0)
+        return exn_error();
+    result = make_value(V_STRING, ref(info));
+    result->string = make_string(s);
+    return result;
+}
+
+struct module *builtin_init(struct error *error) {
+    struct module *modl = module_create("Builtin");
+    int r;
+
+#define DEFINE_NATIVE(modl, name, nargs, impl, types ...)               \
+    r = define_native(error, modl, name, nargs, impl, ##types);         \
+    if (r < 0) goto error;
+
+    DEFINE_NATIVE(modl, "gensym", 1, gensym, T_STRING, T_STRING);
+
+    /* Primitive lenses */
+    DEFINE_NATIVE(modl, "del",     2, lns_del, T_REGEXP, T_STRING, T_LENS);
+    DEFINE_NATIVE(modl, "store",   1, lns_store, T_REGEXP, T_LENS);
+    DEFINE_NATIVE(modl, "value",   1, lns_value, T_STRING, T_LENS);
+    DEFINE_NATIVE(modl, "key",     1, lns_key, T_REGEXP, T_LENS);
+    DEFINE_NATIVE(modl, "label",   1, lns_label, T_STRING, T_LENS);
+    DEFINE_NATIVE(modl, "seq",     1, lns_seq, T_STRING, T_LENS);
+    DEFINE_NATIVE(modl, "counter", 1, lns_counter, T_STRING, T_LENS);
+    DEFINE_NATIVE(modl, "square",  2, lns_square, T_REGEXP, T_LENS, T_LENS);
+    /* Applying lenses (mostly for tests) */
+    DEFINE_NATIVE(modl, "get",     2, lens_get, T_LENS, T_STRING, T_TREE);
+    DEFINE_NATIVE(modl, "put",     3, lens_put, T_LENS, T_TREE, T_STRING,
+                  T_STRING);
+    /* Tree manipulation used by the PUT tests */
+    DEFINE_NATIVE(modl, "set", 3, tree_set_glue, T_STRING, T_STRING, T_TREE,
+                                                 T_TREE);
+    DEFINE_NATIVE(modl, "clear", 2, tree_clear_glue, T_STRING, T_TREE,
+                                                 T_TREE);
+    DEFINE_NATIVE(modl, "rm", 2, tree_rm_glue, T_STRING, T_TREE, T_TREE);
+    DEFINE_NATIVE(modl, "insa", 3, tree_insa_glue, T_STRING, T_STRING, T_TREE,
+                                                   T_TREE);
+    DEFINE_NATIVE(modl, "insb", 3, tree_insb_glue, T_STRING, T_STRING, T_TREE,
+                                                   T_TREE);
+    /* Transforms and filters */
+    DEFINE_NATIVE(modl, "incl", 1, xform_incl, T_STRING, T_FILTER);
+    DEFINE_NATIVE(modl, "excl", 1, xform_excl, T_STRING, T_FILTER);
+    DEFINE_NATIVE(modl, "transform", 2, xform_transform, T_LENS, T_FILTER,
+                                                         T_TRANSFORM);
+    DEFINE_NATIVE(modl, LNS_CHECK_REC_NAME,
+                  2, lns_check_rec_glue, T_LENS, T_LENS, T_LENS);
+    /* Printing */
+    DEFINE_NATIVE(modl, "print_string", 1, pr_string, T_STRING, T_UNIT);
+    DEFINE_NATIVE(modl, "print_regexp", 1, pr_regexp, T_REGEXP, T_UNIT);
+    DEFINE_NATIVE(modl, "print_endline", 1, pr_endline, T_STRING, T_UNIT);
+
+    /* Lens inspection */
+    DEFINE_NATIVE(modl, "lens_ctype", 1, lns_ctype, T_LENS, T_REGEXP);
+    DEFINE_NATIVE(modl, "lens_atype", 1, lns_atype, T_LENS, T_REGEXP);
+    DEFINE_NATIVE(modl, "lens_vtype", 1, lns_vtype, T_LENS, T_REGEXP);
+    DEFINE_NATIVE(modl, "lens_ktype", 1, lns_ktype, T_LENS, T_REGEXP);
+    DEFINE_NATIVE(modl, "lens_format_atype", 1, lns_fmt_atype,
+                  T_LENS, T_STRING);
+
+    /* System functions */
+    struct module *sys = module_create("Sys");
+    modl->next = sys;
+    DEFINE_NATIVE(sys, "getenv", 1, sys_getenv, T_STRING, T_STRING);
+    DEFINE_NATIVE(sys, "read_file", 1, sys_read_file, T_STRING, T_STRING);
+    return modl;
+ error:
+    unref(modl, module);
+    return NULL;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/errcode.c b/src/errcode.c
new file mode 100644 (file)
index 0000000..6c495b7
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * errcode.c: internal interface for error reporting
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "errcode.h"
+#include "memory.h"
+#include <stdarg.h>
+
+static void vreport_error(struct error *err, aug_errcode_t errcode,
+                   const char *format, va_list ap) {
+    /* We only remember the first error */
+    if (err->code != AUG_NOERROR)
+        return;
+    assert(err->details == NULL);
+
+    err->code = errcode;
+    if (format != NULL) {
+        if (vasprintf(&err->details, format, ap) < 0)
+            err->details = NULL;
+    }
+}
+
+void report_error(struct error *err, aug_errcode_t errcode,
+                  const char *format, ...) {
+    va_list ap;
+
+    va_start(ap, format);
+    vreport_error(err, errcode, format, ap);
+    va_end(ap);
+}
+
+void bug_on(struct error *err, const char *srcfile, int srclineno,
+            const char *format, ...) {
+    char *msg = NULL;
+    int r;
+    va_list ap;
+
+    if (err->code != AUG_NOERROR)
+        return;
+
+    va_start(ap, format);
+    vreport_error(err, AUG_EINTERNAL, format, ap);
+    va_end(ap);
+
+    if (err->details == NULL) {
+        xasprintf(&err->details, "%s:%d:internal error", srcfile, srclineno);
+    } else {
+        r = xasprintf(&msg, "%s:%d:%s", srcfile, srclineno, err->details);
+        if (r >= 0) {
+            free(err->details);
+            err->details = msg;
+        }
+    }
+}
+
+void reset_error(struct error *err) {
+    err->code = AUG_NOERROR;
+    err->minor = 0;
+    FREE(err->details);
+    err->minor_details = NULL;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/errcode.h b/src/errcode.h
new file mode 100644 (file)
index 0000000..cef33e4
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * errcode.h: internal interface for error reporting
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#ifndef ERRCODE_H_
+#define ERRCODE_H_
+
+#include "internal.h"
+/* Include augeas.h for the error codes */
+#include "augeas.h"
+
+/*
+ * Error details in a separate struct that we can pass around
+ */
+struct error {
+    aug_errcode_t  code;
+    int            minor;
+    char          *details;       /* Human readable explanation */
+    const char    *minor_details; /* Human readable version of MINOR */
+    /* Bit of a kludge to get at struct augeas, but since struct error
+     * is now available in a lot of places (through struct info), this
+     * gives a convenient way to get at the overall state
+     */
+    const struct augeas *aug;
+};
+
+void report_error(struct error *err, aug_errcode_t errcode,
+                  const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 3, 4);
+
+void bug_on(struct error *err, const char *srcfile, int srclineno,
+            const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 4, 5);
+
+void reset_error(struct error *err);
+
+#define HAS_ERR(obj) ((obj)->error->code != AUG_NOERROR)
+
+#define ERR_BAIL(obj) if ((obj)->error->code != AUG_NOERROR) goto error;
+
+#define ERR_RET(obj) if ((obj)->error->code != AUG_NOERROR) return;
+
+#define ERR_NOMEM(cond, obj)                             \
+    if (cond) {                                          \
+        report_error((obj)->error, AUG_ENOMEM, NULL);    \
+        goto error;                                      \
+    }
+
+#define ERR_REPORT(obj, code, fmt ...)          \
+    report_error((obj)->error, code, ## fmt)
+
+#define ERR_THROW(cond, obj, code, fmt ...)             \
+    do {                                                \
+        if (cond) {                                     \
+            report_error((obj)->error, code, ## fmt);   \
+            goto error;                                 \
+        }                                               \
+    } while(0)
+
+/* A variant of assert that uses our error reporting infrastructure
+ * instead of aborting
+ */
+#ifdef NDEBUG
+# define ensure(cond, obj) if (0) goto error
+# define ensure0(cond, obj) if (0) return NULL
+#else
+# define ensure(cond, obj)                                           \
+    if (!(cond)) {                                                   \
+        bug_on((obj)->error, __FILE__, __LINE__, NULL);              \
+        goto error;                                                  \
+    }
+# define ensure0(cond, obj)                                          \
+    if (!(cond)) {                                                   \
+        bug_on((obj)->error, __FILE__, __LINE__, NULL);              \
+        return NULL;                                                 \
+    }
+#endif
+
+#define BUG_ON(cond, obj, fmt ...)                                  \
+    if (cond) {                                                     \
+        bug_on((obj)->error, __FILE__, __LINE__, ## fmt);           \
+        goto error;                                                 \
+    }
+
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/fa.c b/src/fa.c
new file mode 100644 (file)
index 0000000..6683d54
--- /dev/null
+++ b/src/fa.c
@@ -0,0 +1,4375 @@
+/*
+ * fa.c: finite automata
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+/*
+ * This implementation follows closely the Java dk.brics.automaton package
+ * by Anders Moeller. The project's website is
+ * http://www.brics.dk/automaton/.
+ *
+ * It is by no means a complete reimplementation of that package; only a
+ * subset of what Automaton provides is implemented here.
+ */
+
+#include <config.h>
+#include <limits.h>
+#include <ctype.h>
+#include <stdbool.h>
+
+#include "internal.h"
+#include "memory.h"
+#include "ref.h"
+#include "hash.h"
+#include "fa.h"
+
+#define UCHAR_NUM (UCHAR_MAX+1)
+#define UCHAR_MIN 0
+typedef unsigned char uchar;
+
+#define E(cond) if (cond) goto error
+#define F(expr) if ((expr) < 0) goto error
+
+/* Which algorithm to use in FA_MINIMIZE */
+int fa_minimization_algorithm = FA_MIN_HOPCROFT;
+
+/* A finite automaton. INITIAL is both the initial state and the head of
+ * the list of all states. Any state that is allocated for this automaton
+ * is put on this list. Dead/unreachable states are cleared from the list
+ * at opportune times (e.g., during minimization) It's poor man's garbage
+ * collection
+ *
+ * Normally, transitions are on a character range [min..max]; in
+ * fa_as_regexp, we store regexps on transitions in the re field of each
+ * transition. TRANS_RE indicates that we do that, and is used by fa_dot to
+ * produce proper graphs of an automaton transitioning on regexps.
+ */
+struct fa {
+    struct state *initial;
+    int           deterministic : 1;
+    int           minimal : 1;
+    unsigned int  nocase : 1;
+    int           trans_re : 1;
+};
+
+/* A state in a finite automaton. Transitions are never shared between
+   states so that we can free the list when we need to free the state */
+struct state {
+    struct state *next;
+    hash_val_t    hash;
+    unsigned int  accept : 1;
+    unsigned int  live : 1;
+    unsigned int  reachable : 1;
+    /* Array of transitions. The TUSED first entries are used, the array
+       has allocated room for TSIZE */
+    size_t        tused;
+    size_t        tsize;
+    struct trans *trans;
+};
+
+/* A transition. If the input has a character in the inclusive
+ * range [MIN, MAX], move to TO
+ */
+struct trans {
+    struct state *to;
+    union {
+        struct {
+            uchar         min;
+            uchar         max;
+        };
+        struct re *re;
+    };
+};
+
+/*
+ * Bitsets
+ */
+#define UINT_BIT (sizeof(unsigned int) * CHAR_BIT)
+
+typedef unsigned int bitset;
+
+static bitset *bitset_init(size_t nbits) {
+    bitset *bs;
+    if (ALLOC_N(bs, (nbits + UINT_BIT) / UINT_BIT) == -1)
+        return NULL;
+    return bs;
+}
+
+static inline void bitset_clr(bitset *bs, unsigned int bit) {
+    bs[bit/UINT_BIT] &= ~(1 << (bit % UINT_BIT));
+}
+
+static inline void bitset_set(bitset *bs, unsigned int bit) {
+    bs[bit/UINT_BIT] |= 1 << (bit % UINT_BIT);
+}
+
+ATTRIBUTE_PURE
+static inline int bitset_get(const bitset * const bs, unsigned int bit) {
+    return (bs[bit/UINT_BIT] >> bit % UINT_BIT) & 1;
+}
+
+ATTRIBUTE_PURE
+static inline bool bitset_disjoint(const bitset *const bs1,
+                                   const bitset *const bs2,
+                                   size_t nbits) {
+    for (int i=0; i < (nbits + UINT_BIT) / UINT_BIT; i++) {
+        if (bs1[i] & bs2[i])
+            return false;
+    }
+    return true;
+}
+
+static void bitset_free(bitset *bs) {
+    free(bs);
+}
+
+static void bitset_negate(bitset *bs, size_t nbits) {
+    for (int i=0; i < (nbits + UINT_BIT) / UINT_BIT; i++)
+        bs[i] = ~ bs[i];
+}
+
+/*
+ * Representation of a parsed regular expression. The regular expression is
+ * parsed according to the following grammar by PARSE_REGEXP:
+ *
+ * regexp:        concat_exp ('|' regexp)?
+ * concat_exp:    repeated_exp concat_exp?
+ * repeated_exp:  simple_exp
+ *              | simple_exp '*'
+ *              | simple_exp '+'
+ *              | simple_exp '?'
+ *              | simple_exp '{' INT (',' INT '}')?
+ * simple_exp:  char_class
+ *            | '.'
+ *            |  '(' regexp ')'
+ *            |  CHAR
+ * char_class: '[' char_exp ']'
+ *           | '[' '^' char_exp ']'
+ * char_exp:   CHAR '-' CHAR
+ *           | CHAR
+ */
+
+enum re_type {
+    UNION,
+    CONCAT,
+    CSET,
+    CHAR,
+    ITER,
+    EPSILON
+};
+
+#define re_unref(r) unref(r, re)
+
+struct re {
+    ref_t        ref;
+    enum re_type type;
+    union {
+        struct {                  /* UNION, CONCAT */
+            struct re *exp1;
+            struct re *exp2;
+        };
+        struct {                  /* CSET */
+            bool    negate;
+            bitset *cset;
+            /* Whether we can use character ranges when converting back
+             * to a string */
+            unsigned int no_ranges:1;
+        };
+        struct {                  /* CHAR */
+            uchar c;
+        };
+        struct {                  /* ITER */
+            struct re *exp;
+            int min;
+            int max;
+        };
+    };
+};
+
+/* Used to keep state of the regex parse; RX may contain NUL's */
+struct re_parse {
+    const char *rx;          /* Current position in regex */
+    const char *rend;        /* Last char of rx+ 1 */
+    int         error;       /* error code */
+    /* Whether new CSET's should have the no_ranges flag set */
+    unsigned int no_ranges:1;
+};
+
+/* String with explicit length, used when converting re to string */
+struct re_str {
+    char  *rx;
+    size_t len;
+};
+
+static struct re *parse_regexp(struct re_parse *parse);
+
+/* A map from a set of states to a state. */
+typedef hash_t state_set_hash;
+
+static hash_val_t ptr_hash(const void *p);
+
+static const int array_initial_size = 4;
+static const int array_max_expansion   = 128;
+
+enum state_set_init_flags {
+    S_NONE   = 0,
+    S_SORTED = (1 << 0),
+    S_DATA   = (1 << 1)
+};
+
+struct state_set {
+    size_t            size;
+    size_t            used;
+    unsigned int      sorted : 1;
+    unsigned int      with_data : 1;
+    struct state    **states;
+    void            **data;
+};
+
+struct state_set_list {
+    struct state_set_list *next;
+    struct state_set      *set;
+};
+
+/* Clean up FA by removing dead transitions and states and reducing
+ * transitions. Unreachable states are freed. The return value is the same
+ * as FA; returning it is merely a convenience.
+ *
+ * Only automata in this state should be returned to the user
+ */
+ATTRIBUTE_RETURN_CHECK
+static int collect(struct fa *fa);
+
+ATTRIBUTE_RETURN_CHECK
+static int totalize(struct fa *fa);
+
+/* Print an FA into a (fairly) fixed file if the environment variable
+ * FA_DOT_DIR is set. This code is only used for debugging
+ */
+#define FA_DOT_DIR "FA_DOT_DIR"
+
+ATTRIBUTE_UNUSED
+static void fa_dot_debug(struct fa *fa, const char *tag) {
+    const char *dot_dir;
+    static int count = 0;
+    int r;
+    char *fname;
+    FILE *fp;
+
+    if ((dot_dir = getenv(FA_DOT_DIR)) == NULL)
+        return;
+
+    r = asprintf(&fname, "%s/fa_%02d_%s.dot", dot_dir, count++, tag);
+    if (r == -1)
+        return;
+
+    fp = fopen(fname, "w");
+    fa_dot(fp, fa);
+    fclose(fp);
+    free(fname);
+}
+
+static void print_char_set(struct re *set) {
+    int from, to;
+
+    if (set->negate)
+        printf("[^");
+    else
+        printf("[");
+    for (from = UCHAR_MIN; from <= UCHAR_MAX; from = to+1) {
+        while (bitset_get(set->cset, from) == set->negate)
+            from += 1;
+        if (from > UCHAR_MAX)
+            break;
+        for (to = from;
+             to < UCHAR_MAX && (bitset_get(set->cset, to+1) == !set->negate);
+             to++);
+        if (to == from) {
+            printf("%c", from);
+        } else {
+            printf("%c-%c", from, to);
+        }
+    }
+    printf("]");
+}
+
+ATTRIBUTE_UNUSED
+static void print_re(struct re *re) {
+    switch(re->type) {
+    case UNION:
+        print_re(re->exp1);
+        printf("|");
+        print_re(re->exp2);
+        break;
+    case CONCAT:
+        print_re(re->exp1);
+        printf(".");
+        print_re(re->exp2);
+        break;
+    case CSET:
+        print_char_set(re);
+        break;
+    case CHAR:
+        printf("%c", re->c);
+        break;
+    case ITER:
+        printf("(");
+        print_re(re->exp);
+        printf("){%d,%d}", re->min, re->max);
+        break;
+    case EPSILON:
+        printf("<>");
+        break;
+    default:
+        printf("(**)");
+        break;
+    }
+}
+
+/*
+ * struct re_str
+ */
+static void release_re_str(struct re_str *str) {
+    if (str == NULL)
+        return;
+    FREE(str->rx);
+    str->len = 0;
+}
+
+static void free_re_str(struct re_str *str) {
+    if (str == NULL)
+        return;
+    release_re_str(str);
+    FREE(str);
+}
+
+static struct re_str *make_re_str(const char *s) {
+    struct re_str *str;
+
+    if (ALLOC(str) < 0)
+        return NULL;
+    if (s != NULL) {
+        str->rx = strdup(s);
+        str->len = strlen(s);
+        if (str->rx == NULL) {
+            FREE(str);
+            return NULL;
+        }
+    }
+    return str;
+}
+
+static int re_str_alloc(struct re_str *str) {
+    return ALLOC_N(str->rx, str->len + 1);
+}
+
+/*
+ * Memory management
+ */
+
+static void free_trans(struct state *s) {
+    free(s->trans);
+    s->trans = NULL;
+    s->tused = s->tsize = 0;
+}
+
+static void gut(struct fa *fa) {
+    list_for_each(s, fa->initial) {
+        free_trans(s);
+    }
+    list_free(fa->initial);
+    fa->initial = NULL;
+}
+
+void fa_free(struct fa *fa) {
+    if (fa == NULL)
+        return;
+    gut(fa);
+    free(fa);
+}
+
+static struct state *make_state(void) {
+    struct state *s;
+    if (ALLOC(s) == -1)
+        return NULL;
+    s->hash = ptr_hash(s);
+    return s;
+}
+
+static struct state *add_state(struct fa *fa, int accept) {
+    struct state *s = make_state();
+    if (s) {
+        s->accept = accept;
+        if (fa->initial == NULL) {
+            fa->initial = s;
+        } else {
+            list_cons(fa->initial->next, s);
+        }
+    }
+    return s;
+}
+
+#define last_trans(s)  ((s)->trans + (s)->tused - 1)
+
+#define for_each_trans(t, s)                                            \
+    for (struct trans *t = (s)->trans;                                  \
+         (t - (s)->trans) < (s)->tused;                                 \
+         t++)
+
+ATTRIBUTE_RETURN_CHECK
+static int add_new_trans(struct state *from, struct state *to,
+                         uchar min, uchar max) {
+    assert(to != NULL);
+
+    if (from->tused == from->tsize) {
+        size_t tsize = from->tsize;
+        if (tsize == 0)
+            tsize = array_initial_size;
+        else if (from->tsize > array_max_expansion)
+            tsize += array_max_expansion;
+        else
+            tsize *= 2;
+        if (REALLOC_N(from->trans, tsize) == -1)
+            return -1;
+        from->tsize = tsize;
+    }
+    from->trans[from->tused].to  = to;
+    from->trans[from->tused].min = min;
+    from->trans[from->tused].max = max;
+    from->tused += 1;
+    return 0;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int add_epsilon_trans(struct state *from,
+                             struct state *to) {
+    int r;
+    from->accept |= to->accept;
+    for_each_trans(t, to) {
+        r = add_new_trans(from, t->to, t->min, t->max);
+        if (r < 0)
+            return -1;
+    }
+    return 0;
+}
+
+static void set_initial(struct fa *fa, struct state *s) {
+    list_remove(s, fa->initial);
+    list_cons(fa->initial, s);
+}
+
+/* Merge automaton FA2 into FA1. This simply adds FA2's states to FA1
+   and then frees FA2. It has no influence on the language accepted by FA1
+*/
+static void fa_merge(struct fa *fa1, struct fa **fa2) {
+    list_append(fa1->initial, (*fa2)->initial);
+    free(*fa2);
+    *fa2 = NULL;
+}
+
+/*
+ * Operations on STATE_SET
+ */
+static void state_set_free(struct state_set *set) {
+    if (set == NULL)
+        return;
+    free(set->states);
+    free(set->data);
+    free(set);
+}
+
+static int state_set_init_data(struct state_set *set) {
+    set->with_data = 1;
+    if (set->data == NULL)
+        return ALLOC_N(set->data, set->size);
+    else
+        return 0;
+}
+
+/* Create a new STATE_SET with an initial size of SIZE. If SIZE is -1, use
+   the default size ARRAY_INITIAL_SIZE. FLAGS is a bitmask indicating
+   some options:
+   - S_SORTED: keep the states in the set sorted by their address, and use
+     binary search for lookups. If it is not set, entries are kept in the
+     order in which they are added and lookups scan linearly through the
+     set of states.
+   - S_DATA: allocate the DATA array in the set, and keep its size in sync
+     with the size of the STATES array.
+*/
+static struct state_set *state_set_init(int size, int flags) {
+    struct state_set *set = NULL;
+
+    F(ALLOC(set));
+
+    set->sorted = (flags & S_SORTED) ? 1 : 0;
+    set->with_data = (flags & S_DATA) ? 1 : 0;
+    if (size > 0) {
+        set->size = size;
+        F(ALLOC_N(set->states, set->size));
+        if (set->with_data)
+            F(state_set_init_data(set));
+    }
+    return set;
+ error:
+    state_set_free(set);
+    return NULL;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int state_set_expand(struct state_set *set) {
+    if (set->size == 0)
+        set->size = array_initial_size;
+    else if (set->size > array_max_expansion)
+        set->size += array_max_expansion;
+    else
+        set->size *= 2;
+    if (REALLOC_N(set->states, set->size) < 0)
+        goto error;
+    if (set->with_data)
+        if (REALLOC_N(set->data, set->size) < 0)
+            goto error;
+    return 0;
+ error:
+    /* We do this to provoke a SEGV as early as possible */
+    FREE(set->states);
+    FREE(set->data);
+    return -1;
+}
+
+/* Return the index where S belongs in SET->STATES to keep it sorted.  S
+   may not be in SET->STATES. The returned index is in the interval [0
+   .. SET->USED], with the latter indicating that S is larger than all
+   values in SET->STATES
+*/
+static int state_set_pos(const struct state_set *set, const struct state *s) {
+    int l = 0, h = set->used;
+    while (l < h) {
+        int m = (l + h)/2;
+        if (set->states[m] > s)
+            h = m;
+        else if (set->states[m] < s)
+            l = m + 1;
+        else
+            return m;
+    }
+    return l;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int state_set_push(struct state_set *set, struct state *s) {
+    if (set->size == set->used)
+        if (state_set_expand(set) < 0)
+            return -1;
+    if (set->sorted) {
+        int p = state_set_pos(set, s);
+        if (set->size == set->used)
+            if (state_set_expand(set) < 0)
+                return -1;
+        while (p < set->used && set->states[p] <= s)
+            p += 1;
+        if (p < set->used) {
+            memmove(set->states + p + 1, set->states + p,
+                    sizeof(*set->states) * (set->used - p));
+            if (set->data != NULL)
+                memmove(set->data + p + 1, set->data + p,
+                        sizeof(*set->data) * (set->used - p));
+        }
+        set->states[p] = s;
+        set->used += 1;
+        return p;
+    } else {
+        set->states[set->used++] = s;
+        return set->used - 1;
+    }
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int state_set_push_data(struct state_set *set, struct state *s,
+                               void *d) {
+    int i = state_set_push(set, s);
+    if (i == -1)
+        return -1;
+    set->data[i] = d;
+    return i;
+}
+
+static int state_set_index(const struct state_set *set,
+                           const struct state *s) {
+    if (set->sorted) {
+        int p = state_set_pos(set, s);
+        return (p < set->used && set->states[p] == s) ? p : -1;
+    } else {
+        for (int i=0; i < set->used; i++) {
+            if (set->states[i] == s)
+                return i;
+        }
+    }
+    return -1;
+}
+
+static void state_set_remove(struct state_set *set,
+                             const struct state *s) {
+   if (set->sorted) {
+       int p = state_set_index(set, s);
+       if (p == -1) return;
+       memmove(set->states + p, set->states + p + 1,
+               sizeof(*set->states) * (set->used - p - 1));
+       if (set->data != NULL)
+           memmove(set->data + p, set->data + p + 1,
+                   sizeof(*set->data) * (set->used - p - 1));
+   } else {
+       int p = state_set_index(set, s);
+       if (p >= 0) {
+           set->states[p] = set->states[--set->used];
+       }
+   }
+}
+
+/* Only add S if it's not in SET yet. Return 1 if S was added, 0 if it was
+   already in the set and -1 on error. */
+ATTRIBUTE_RETURN_CHECK
+static int state_set_add(struct state_set *set, struct state *s) {
+    if (set->sorted) {
+        int p = state_set_pos(set, s);
+        if (p < set->used && set->states[p] == s)
+            return 0;
+        if (set->size == set->used)
+            if (state_set_expand(set) < 0)
+                return -1;
+        while (p < set->used && set->states[p] <= s)
+            p += 1;
+        if (p < set->used) {
+            memmove(set->states + p + 1, set->states + p,
+                    sizeof(*set->states) * (set->used - p));
+            if (set->data != NULL)
+                memmove(set->data + p + 1, set->data + p,
+                        sizeof(*set->data) * (set->used - p));
+        }
+        set->states[p] = s;
+        set->used += 1;
+    } else {
+        if (state_set_index(set, s) >= 0)
+            return 0;
+        if (state_set_push(set, s) < 0)
+            goto error;
+    }
+    return 1;
+ error:
+    /* We do this to provoke a SEGV as early as possible */
+    FREE(set->states);
+    FREE(set->data);
+    return -1;
+}
+
+static struct state *state_set_pop(struct state_set *set) {
+    struct state *s = NULL;
+    if (set->used > 0)
+        s = set->states[--set->used];
+    return s;
+}
+
+static struct state *state_set_pop_data(struct state_set *set, void **d) {
+    struct state *s = NULL;
+    s = state_set_pop(set);
+    *d = set->data[set->used];
+    return s;
+}
+
+static void *state_set_find_data(struct state_set *set, struct state *s) {
+    int i = state_set_index(set, s);
+    if (i >= 0)
+        return set->data[i];
+    else
+        return NULL;
+}
+
+static int state_set_equal(const struct state_set *set1,
+                           const struct state_set *set2) {
+    if (set1->used != set2->used)
+        return 0;
+    if (set1->sorted && set2->sorted) {
+        for (int i = 0; i < set1->used; i++)
+            if (set1->states[i] != set2->states[i])
+                return 0;
+        return 1;
+    } else {
+        for (int i=0; i < set1->used; i++)
+            if (state_set_index(set2, set1->states[i]) == -1)
+                return 0;
+        return 1;
+    }
+}
+
+#if 0
+static void state_set_compact(struct state_set *set) {
+    while (set->used > 0 && set->states[set->used] == NULL)
+        set->used -= 1;
+    for (int i=0; i < set->used; i++) {
+        if (set->states[i] == NULL) {
+            set->used -= 1;
+            set->states[i] = set->states[set->used];
+            if (set->data)
+                set->data[i] = set->data[set->used];
+        }
+        while (set->used > 0 && set->states[set->used] == NULL)
+            set->used -= 1;
+    }
+}
+#endif
+
+/* Add an entry (FST, SND) to SET. FST is stored in SET->STATES, and SND is
+   stored in SET->DATA at the same index.
+*/
+ATTRIBUTE_RETURN_CHECK
+static int state_pair_push(struct state_set **set,
+                           struct state *fst, struct state *snd) {
+    if (*set == NULL)
+        *set = state_set_init(-1, S_DATA);
+    if (*set == NULL)
+        return -1;
+    int i = state_set_push(*set, fst);
+    if (i == -1)
+        return -1;
+    (*set)->data[i] = snd;
+
+    return 0;
+}
+
+/* Return the index of the pair (FST, SND) in SET, or -1 if SET contains no
+   such pair.
+ */
+static int state_pair_find(struct state_set *set, struct state *fst,
+                           struct state *snd) {
+    for (int i=0; i < set->used; i++)
+        if (set->states[i] == fst && set->data[i] == snd)
+            return i;
+    return -1;
+}
+
+/* Jenkins' hash for void* */
+static hash_val_t ptr_hash(const void *p) {
+    hash_val_t hash = 0;
+    char *c = (char *) &p;
+    for (int i=0; i < sizeof(p); i++) {
+        hash += c[i];
+        hash += (hash << 10);
+        hash ^= (hash >> 6);
+    }
+    hash += (hash << 3);
+    hash ^= (hash >> 11);
+    hash += (hash << 15);
+    return hash;
+}
+
+typedef hash_t state_triple_hash;
+
+static hash_val_t pair_hash(const void *key) {
+    register struct state *const *pair = key;
+    return pair[0]->hash + pair[1]->hash;
+}
+
+static int pair_cmp(const void *key1, const void *key2) {
+    return memcmp(key1, key2, 2*sizeof(struct state *));
+}
+
+static void state_triple_node_free(hnode_t *node, ATTRIBUTE_UNUSED void *ctx) {
+    free((void *) hnode_getkey(node));
+    free(node);
+}
+
+static state_triple_hash *state_triple_init(void) {
+    state_triple_hash *hash;
+
+    hash = hash_create(HASHCOUNT_T_MAX, pair_cmp, pair_hash);
+    if (hash == NULL)
+        return NULL;
+    hash_set_allocator(hash, NULL, state_triple_node_free, NULL);
+    return hash;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int state_triple_push(state_triple_hash *hash,
+                             struct state *s1,
+                             struct state *s2,
+                             struct state *s3) {
+    struct state **pair;
+    if (ALLOC_N(pair, 2) < 0)
+        return -1;
+    pair[0] = s1;
+    pair[1] = s2;
+    return hash_alloc_insert(hash, pair, s3);
+}
+
+static struct state * state_triple_thd(state_triple_hash *hash,
+                                       struct state *s1,
+                                       struct state *s2) {
+    struct state *pair[2];
+    hnode_t *node;
+    pair[0] = s1;
+    pair[1] = s2;
+    node = hash_lookup(hash, pair);
+    return (node == NULL) ? NULL : (struct state *) hnode_get(node);
+}
+
+static void state_triple_free(state_triple_hash *hash) {
+    if (hash != NULL) {
+        hash_free_nodes(hash);
+        hash_destroy(hash);
+    }
+}
+
+/*
+ * State operations
+ */
+ATTRIBUTE_RETURN_CHECK
+static int mark_reachable(struct fa *fa) {
+    struct state_set *worklist = state_set_init(-1, S_NONE);
+    int result = -1;
+
+    E(worklist == NULL);
+
+    list_for_each(s, fa->initial) {
+        s->reachable = 0;
+    }
+    fa->initial->reachable = 1;
+
+    for (struct state *s = fa->initial;
+         s != NULL;
+         s = state_set_pop(worklist)) {
+        for_each_trans(t, s) {
+            if (! t->to->reachable) {
+                t->to->reachable = 1;
+                F(state_set_push(worklist, t->to));
+            }
+        }
+    }
+    result = 0;
+
+ error:
+    state_set_free(worklist);
+    return result;
+}
+
+/* Return all reachable states. As a sideeffect, all states have their
+   REACHABLE flag set appropriately.
+ */
+static struct state_set *fa_states(struct fa *fa) {
+    struct state_set *visited = state_set_init(-1, S_NONE);
+    int r;
+
+    r = mark_reachable(fa);
+    E(visited == NULL || r < 0);
+
+    list_for_each(s, fa->initial) {
+        if (s->reachable)
+            F(state_set_push(visited, s));
+    }
+    return visited;
+ error:
+    state_set_free(visited);
+    return NULL;
+}
+
+/* Return all reachable accepting states. As a sideeffect, all states have
+   their REACHABLE flag set appropriately.
+ */
+static struct state_set *fa_accept_states(struct fa *fa) {
+    struct state_set *accept = state_set_init(-1, S_NONE);
+    int r;
+
+    r = mark_reachable(fa);
+    E(r < 0);
+
+    list_for_each(s, fa->initial) {
+        if (s->reachable && s->accept)
+            F(state_set_push(accept, s));
+    }
+    return accept;
+ error:
+    return NULL;
+}
+
+/* Mark all live states, i.e. states from which an accepting state can be
+   reached. All states have their REACHABLE and LIVE flags set
+   appropriately.
+ */
+ATTRIBUTE_RETURN_CHECK
+static int mark_live(struct fa *fa) {
+    int changed;
+
+    F(mark_reachable(fa));
+
+    list_for_each(s, fa->initial) {
+        s->live = s->reachable && s->accept;
+    }
+
+    do {
+        changed = 0;
+        list_for_each(s, fa->initial) {
+            if (! s->live && s->reachable) {
+                for_each_trans(t, s) {
+                    if (t->to->live) {
+                        s->live = 1;
+                        changed = 1;
+                        break;
+                    }
+                }
+            }
+        }
+    } while (changed);
+    return 0;
+ error:
+    return -1;
+}
+
+/*
+ * Reverse an automaton in place. Change FA so that it accepts the
+ * language that is the reverse of the input automaton.
+ *
+ * Returns a list of the new initial states of the automaton. The list must
+ * be freed by the caller.
+ */
+static struct state_set *fa_reverse(struct fa *fa) {
+    struct state_set *all = NULL;
+    struct state_set *accept = NULL;
+    int r;
+
+    all = fa_states(fa);
+    accept = fa_accept_states(fa);
+
+    F(state_set_init_data(all));
+
+    /* Reverse all transitions */
+    int *tused;
+    F(ALLOC_N(tused, all->used));
+    for (int i=0; i < all->used; i++) {
+        all->data[i] = all->states[i]->trans;
+        tused[i] = all->states[i]->tused;
+        all->states[i]->trans = NULL;
+        all->states[i]->tsize = 0;
+        all->states[i]->tused = 0;
+    }
+    for (int i=0; i < all->used; i++) {
+        struct state *s = all->states[i];
+        struct trans *t = all->data[i];
+        s->accept = 0;
+        for (int j=0; j < tused[i]; j++) {
+            r = add_new_trans(t[j].to, s, t[j].min, t[j].max);
+            if (r < 0)
+                goto error;
+        }
+        free(t);
+    }
+    free(tused);
+
+    /* Make new initial and final states */
+    struct state *s = add_state(fa, 0);
+    fa->initial->accept = 1;
+    set_initial(fa, s);
+    for (int i=0; i < accept->used; i++) {
+        r = add_epsilon_trans(s, accept->states[i]);
+        if (r < 0)
+            goto error;
+    }
+
+    fa->deterministic = 0;
+    fa->minimal = 0;
+    state_set_free(all);
+    return accept;
+ error:
+    state_set_free(all);
+    state_set_free(accept);
+    return NULL;
+}
+
+/*
+ * Return a sorted array of all interval start points in FA. The returned
+ * array is a string (null terminated)
+ */
+static uchar* start_points(struct fa *fa, int *npoints) {
+    char pointset[UCHAR_NUM];
+    uchar *points = NULL;
+
+    F(mark_reachable(fa));
+    MEMZERO(pointset, UCHAR_NUM);
+    list_for_each(s, fa->initial) {
+        if (! s->reachable)
+            continue;
+        pointset[0] = 1;
+        for_each_trans(t, s) {
+            pointset[t->min] = 1;
+            if (t->max < UCHAR_MAX)
+                pointset[t->max+1] = 1;
+        }
+    }
+
+    *npoints = 0;
+    for(int i=0; i < UCHAR_NUM; *npoints += pointset[i], i++);
+
+    F(ALLOC_N(points, *npoints+1));
+    for (int i=0, n=0; i < UCHAR_NUM; i++) {
+        if (pointset[i])
+            points[n++] = (uchar) i;
+    }
+
+    return points;
+ error:
+    free(points);
+    return NULL;
+}
+
+/*
+ * Operations on STATE_SET_HASH
+ */
+static int state_set_hash_contains(state_set_hash *smap,
+                               struct state_set *set) {
+    return hash_lookup(smap, set) != NULL;
+}
+
+/*
+ * Find the set in SMAP that has the same states as SET. If the two are
+ * different, i.e. they point to different memory locations, free SET and
+ * return the set found in SMAP
+ */
+static struct state_set *state_set_hash_uniq(state_set_hash *smap,
+                                             struct state_set *set) {
+    hnode_t *node = hash_lookup(smap, set);
+    const struct state_set *orig_set = hnode_getkey(node);
+    if (orig_set != set) {
+        state_set_free(set);
+    }
+    return (struct state_set *) orig_set;
+}
+
+static struct state *state_set_hash_get_state(state_set_hash *smap,
+                                             struct state_set *set) {
+    hnode_t *node = hash_lookup(smap, set);
+    return (struct state *) hnode_get(node);
+}
+
+static hash_val_t set_hash(const void *key) {
+    hash_val_t hash = 0;
+    const struct state_set *set = key;
+
+    for (int i = 0; i < set->used; i++) {
+        hash += set->states[i]->hash;
+    }
+    return hash;
+}
+
+static int set_cmp(const void *key1, const void *key2) {
+    const struct state_set *set1 = key1;
+    const struct state_set *set2 = key2;
+
+    return state_set_equal(set1, set2) ? 0 : 1;
+}
+
+static void set_destroy(hnode_t *node, ATTRIBUTE_UNUSED void *ctx) {
+    struct state_set *set = (struct state_set *) hnode_getkey(node);
+    state_set_free(set);
+    free(node);
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int state_set_hash_add(state_set_hash **smap,
+                              struct state_set *set, struct fa *fa) {
+    if (*smap == NULL) {
+        *smap = hash_create(HASHCOUNT_T_MAX, set_cmp, set_hash);
+        E(*smap == NULL);
+        hash_set_allocator(*smap, NULL, set_destroy, NULL);
+    }
+    struct state *s = add_state(fa, 0);
+    E(s == NULL);
+    F(hash_alloc_insert(*smap, set, s));
+    return 0;
+ error:
+    return -1;
+}
+
+static void state_set_hash_free(state_set_hash *smap,
+                                struct state_set *protect) {
+    if (protect != NULL) {
+        hnode_t *node = hash_lookup(smap, protect);
+        hash_delete(smap, node);
+        hnode_getkey(node) = NULL;
+        set_destroy(node, NULL);
+    }
+    hash_free_nodes(smap);
+    hash_destroy(smap);
+}
+
+static int state_set_list_add(struct state_set_list **list,
+                              struct state_set *set) {
+    struct state_set_list *elt;
+    if (ALLOC(elt) < 0)
+        return -1;
+    elt->set = set;
+    list_cons(*list, elt);
+    return 0;
+}
+
+static struct state_set *state_set_list_pop(struct state_set_list **list) {
+    struct state_set_list *elt = *list;
+    struct state_set      *set = elt->set;
+
+    *list = elt->next;
+    free(elt);
+    return set;
+}
+
+/* Compare transitions lexicographically by (to, min, reverse max) */
+static int trans_to_cmp(const void *v1, const void *v2) {
+    const struct trans *t1 = v1;
+    const struct trans *t2 = v2;
+
+    if (t1->to != t2->to) {
+        return (t1->to < t2->to) ? -1 : 1;
+    }
+    if (t1->min < t2->min)
+        return -1;
+    if (t1->min > t2->min)
+        return 1;
+    if (t1->max > t2->max)
+        return -1;
+    return (t1->max < t2->max) ? 1 : 0;
+}
+
+/* Compare transitions lexicographically by (min, reverse max, to) */
+static int trans_intv_cmp(const void *v1, const void *v2) {
+    const struct trans *t1 = v1;
+    const struct trans *t2 = v2;
+
+    if (t1->min < t2->min)
+        return -1;
+    if (t1->min > t2->min)
+        return 1;
+    if (t1->max > t2->max)
+        return -1;
+    if (t1->max < t2->max)
+        return 1;
+    if (t1->to != t2->to) {
+        return (t1->to < t2->to) ? -1 : 1;
+    }
+    return 0;
+}
+
+/*
+ * Reduce an automaton by combining overlapping and adjacent edge intervals
+ * with the same destination.
+ */
+static void reduce(struct fa *fa) {
+    list_for_each(s, fa->initial) {
+        if (s->tused == 0)
+            continue;
+
+        qsort(s->trans, s->tused, sizeof(*s->trans), trans_to_cmp);
+        int i=0, j=1;
+        struct trans *t = s->trans;
+        while (j < s->tused) {
+            if (t[i].to == t[j].to && t[j].min <= t[i].max + 1) {
+                if (t[j].max > t[i].max)
+                    t[i].max = t[j].max;
+                j += 1;
+            } else {
+                i += 1;
+                if (i < j)
+                    memmove(s->trans + i, s->trans + j,
+                            sizeof(*s->trans) * (s->tused - j));
+                s->tused -= j - i;
+                j = i + 1;
+            }
+        }
+        s->tused = i+1;
+        /* Shrink if we use less than half the allocated size */
+        if (s->tsize > array_initial_size && 2*s->tused < s->tsize) {
+            int r;
+            r = REALLOC_N(s->trans, s->tsize);
+            if (r == 0)
+                s->tsize = s->tused;
+        }
+    }
+}
+
+/*
+ * Remove dead transitions from an FA; a transition is dead is it does not
+ * lead to a live state. This also removes any states that are not
+ * reachable any longer from FA->INITIAL.
+ *
+ * Returns the same FA as a convenience
+ */
+
+static void collect_trans(struct fa *fa) {
+    list_for_each(s, fa->initial) {
+        if (! s->live) {
+            free_trans(s);
+        } else {
+            int i=0;
+            while (i < s->tused) {
+                if (! s->trans[i].to->live) {
+                    s->tused -= 1;
+                    memmove(s->trans + i, s->trans + s->tused,
+                            sizeof(*s->trans));
+                } else {
+                    i += 1;
+                }
+            }
+        }
+    }
+}
+
+static void collect_dead_states(struct fa *fa) {
+    /* Remove all dead states and free their storage */
+    for (struct state *s = fa->initial; s->next != NULL; ) {
+        if (! s->next->live) {
+            struct state *del = s->next;
+            s->next = del->next;
+            free_trans(del);
+            free(del);
+        } else {
+            s = s->next;
+        }
+    }
+}
+
+static int collect(struct fa *fa) {
+    F(mark_live(fa));
+
+    if (! fa->initial->live) {
+        /* This automaton accepts nothing, make it the canonical
+         * epsilon automaton
+         */
+        list_for_each(s, fa->initial) {
+            free_trans(s);
+        }
+        list_free(fa->initial->next);
+        fa->deterministic = 1;
+    } else {
+        collect_trans(fa);
+        collect_dead_states(fa);
+    }
+    reduce(fa);
+    return 0;
+ error:
+    return -1;
+}
+
+static void swap_initial(struct fa *fa) {
+    struct state *s = fa->initial;
+    if (s->next != NULL) {
+        fa->initial = s->next;
+        s->next = fa->initial->next;
+        fa->initial->next = s;
+    }
+}
+
+/*
+ * Make a finite automaton deterministic using the given set of initial
+ * states with the subset construction. This also eliminates dead states
+ * and transitions and reduces and orders the transitions for each state
+ */
+static int determinize(struct fa *fa, struct state_set *ini) {
+    int npoints;
+    int make_ini = (ini == NULL);
+    const uchar *points = NULL;
+    state_set_hash *newstate = NULL;
+    struct state_set_list *worklist = NULL;
+    int ret = 0;
+
+    if (fa->deterministic)
+        return 0;
+
+    points = start_points(fa, &npoints);
+    E(points == NULL);
+    if (make_ini) {
+        ini = state_set_init(-1, S_NONE);
+        if (ini == NULL || state_set_push(ini, fa->initial) < 0)
+            goto error;
+    }
+
+    F(state_set_list_add(&worklist, ini));
+    F(state_set_hash_add(&newstate, ini, fa));
+    // Make the new state the initial state
+    swap_initial(fa);
+    while (worklist != NULL) {
+        struct state_set *sset = state_set_list_pop(&worklist);
+        struct state *r = state_set_hash_get_state(newstate, sset);
+        for (int q=0; q < sset->used; q++) {
+            r->accept |= sset->states[q]->accept;
+        }
+        for (int n=0; n < npoints; n++) {
+            struct state_set *pset = state_set_init(-1, S_SORTED);
+            E(pset == NULL);
+            for(int q=0 ; q < sset->used; q++) {
+                for_each_trans(t, sset->states[q]) {
+                    if (t->min <= points[n] && points[n] <= t->max) {
+                        F(state_set_add(pset, t->to));
+                    }
+                }
+            }
+            if (!state_set_hash_contains(newstate, pset)) {
+                F(state_set_list_add(&worklist, pset));
+                F(state_set_hash_add(&newstate, pset, fa));
+            }
+            pset = state_set_hash_uniq(newstate, pset);
+
+            struct state *q = state_set_hash_get_state(newstate, pset);
+            uchar min = points[n];
+            uchar max = UCHAR_MAX;
+            if (n+1 < npoints)
+                max = points[n+1] - 1;
+            if (add_new_trans(r, q, min, max) < 0)
+                goto error;
+        }
+    }
+    fa->deterministic = 1;
+
+ done:
+    if (newstate)
+        state_set_hash_free(newstate, make_ini ? NULL : ini);
+    free((void *) points);
+    if (collect(fa) < 0)
+        ret = -1;
+    return ret;
+ error:
+    ret = -1;
+    goto done;
+}
+
+/*
+ * Minimization. As a sideeffect of minimization, the transitions are
+ * reduced and ordered.
+ */
+
+static struct state *step(struct state *s, uchar c) {
+    for_each_trans(t, s) {
+        if (t->min <= c && c <= t->max)
+            return t->to;
+    }
+    return NULL;
+}
+
+struct state_list {
+    struct state_list_node *first;
+    struct state_list_node *last;
+    unsigned int            size;
+};
+
+struct state_list_node {
+    struct state_list      *sl;
+    struct state_list_node *next;
+    struct state_list_node *prev;
+    struct state           *state;
+};
+
+static struct state_list_node *state_list_add(struct state_list *sl,
+                                              struct state *s) {
+    struct state_list_node *n;
+
+    if (ALLOC(n) < 0)
+        return NULL;
+
+    n->state = s;
+    n->sl = sl;
+
+    if (sl->size++ == 0) {
+        sl->first = n;
+        sl->last = n;
+    } else {
+        sl->last->next = n;
+        n->prev = sl->last;
+        sl->last = n;
+    }
+    return n;
+}
+
+static void state_list_remove(struct state_list_node *n) {
+    struct state_list *sl = n->sl;
+    sl->size -= 1;
+    if (sl->first == n)
+        sl->first = n->next;
+    else
+        n->prev->next = n->next;
+    if (sl->last == n)
+        sl->last = n->prev;
+    else
+        n->next->prev = n->prev;
+
+    free(n);
+}
+
+static void state_list_free(struct state_list *sl) {
+    if (sl)
+        list_free(sl->first);
+    free(sl);
+}
+
+/* The linear index of element (q,c) in an NSTATES * NSIGMA matrix */
+#define INDEX(q, c) (q * nsigma + c)
+
+static int minimize_hopcroft(struct fa *fa) {
+    struct state_set *states = NULL;
+    uchar *sigma = NULL;
+    struct state_set **reverse = NULL;
+    bitset *reverse_nonempty = NULL;
+    struct state_set **partition = NULL;
+    unsigned int *block = NULL;
+    struct state_list **active = NULL;
+    struct state_list_node **active2 = NULL;
+    int *pending = NULL;
+    bitset *pending2 = NULL;
+    struct state_set *split = NULL;
+    bitset *split2 = NULL;
+    int *refine = NULL;
+    bitset *refine2 = NULL;
+    struct state_set **splitblock = NULL;
+    struct state_set *newstates = NULL;
+    int *nsnum = NULL;
+    int *nsind = NULL;
+    int result = -1;
+
+    F(determinize(fa, NULL));
+
+    /* Total automaton, nothing to do */
+    if (fa->initial->tused == 1
+        && fa->initial->trans[0].to == fa->initial
+        && fa->initial->trans[0].min == UCHAR_MIN
+        && fa->initial->trans[0].max == UCHAR_MAX)
+        return 0;
+
+    F(totalize(fa));
+
+    /* make arrays for numbered states and effective alphabet */
+    states = state_set_init(-1, S_NONE);
+    E(states == NULL);
+
+    list_for_each(s, fa->initial) {
+        F(state_set_push(states, s));
+    }
+    unsigned int nstates = states->used;
+
+    int nsigma;
+    sigma = start_points(fa, &nsigma);
+    E(sigma == NULL);
+
+    /* initialize data structures */
+
+    /* An ss->used x nsigma matrix of lists of states */
+    F(ALLOC_N(reverse, nstates * nsigma));
+    reverse_nonempty = bitset_init(nstates * nsigma);
+    E(reverse_nonempty == NULL);
+    F(ALLOC_N(partition, nstates));
+    F(ALLOC_N(block, nstates));
+
+    F(ALLOC_N(active, nstates * nsigma));
+    F(ALLOC_N(active2, nstates * nsigma));
+
+    /* PENDING is an array of pairs of ints. The i'th pair is stored in
+     * PENDING[2*i] and PENDING[2*i + 1]. There are NPENDING pairs in
+     * PENDING at any time. SPENDING is the maximum number of pairs
+     * allocated for PENDING.
+     */
+    size_t npending = 0, spending = 0;
+    pending2 = bitset_init(nstates * nsigma);
+    E(pending2 == NULL);
+
+    split = state_set_init(-1, S_NONE);
+    split2 = bitset_init(nstates);
+    E(split == NULL || split2 == NULL);
+
+    F(ALLOC_N(refine, nstates));
+    refine2 = bitset_init(nstates);
+    E(refine2 == NULL);
+
+    F(ALLOC_N(splitblock, nstates));
+
+    for (int q = 0; q < nstates; q++) {
+        splitblock[q] = state_set_init(-1, S_NONE);
+        partition[q] = state_set_init(-1, S_NONE);
+        E(splitblock[q] == NULL || partition[q] == NULL);
+        for (int x = 0; x < nsigma; x++) {
+            reverse[INDEX(q, x)] = state_set_init(-1, S_NONE);
+            E(reverse[INDEX(q, x)] == NULL);
+            F(ALLOC_N(active[INDEX(q, x)], 1));
+        }
+    }
+
+    /* find initial partition and reverse edges */
+    for (int q = 0; q < nstates; q++) {
+        struct state *qq = states->states[q];
+        int j;
+        if (qq->accept)
+            j = 0;
+        else
+            j = 1;
+        F(state_set_push(partition[j], qq));
+        block[q] = j;
+        for (int x = 0; x < nsigma; x++) {
+            uchar y = sigma[x];
+            struct state *p = step(qq, y);
+            assert(p != NULL);
+            int pn = state_set_index(states, p);
+            assert(pn >= 0);
+            F(state_set_push(reverse[INDEX(pn, x)], qq));
+            bitset_set(reverse_nonempty, INDEX(pn, x));
+        }
+    }
+
+    /* initialize active sets */
+    for (int j = 0; j <= 1; j++)
+        for (int x = 0; x < nsigma; x++)
+            for (int q = 0; q < partition[j]->used; q++) {
+                struct state *qq = partition[j]->states[q];
+                int qn = state_set_index(states, qq);
+                if (bitset_get(reverse_nonempty, INDEX(qn, x))) {
+                    active2[INDEX(qn, x)] =
+                        state_list_add(active[INDEX(j, x)], qq);
+                    E(active2[INDEX(qn, x)] == NULL);
+                }
+            }
+
+    /* initialize pending */
+    F(ALLOC_N(pending, 2*nsigma));
+    npending = nsigma;
+    spending = nsigma;
+    for (int x = 0; x < nsigma; x++) {
+        int a0 = active[INDEX(0,x)]->size;
+        int a1 = active[INDEX(1,x)]->size;
+        int j;
+        if (a0 <= a1)
+            j = 0;
+        else
+            j = 1;
+        pending[2*x] = j;
+        pending[2*x+1] = x;
+        bitset_set(pending2, INDEX(j, x));
+    }
+
+    /* process pending until fixed point */
+    int k = 2;
+    while (npending-- > 0) {
+        int p = pending[2*npending];
+        int x = pending[2*npending+1];
+        bitset_clr(pending2, INDEX(p, x));
+        int ref = 0;
+        /* find states that need to be split off their blocks */
+        struct state_list *sh = active[INDEX(p,x)];
+        for (struct state_list_node *m = sh->first; m != NULL; m = m->next) {
+            int q = state_set_index(states, m->state);
+            struct state_set *rev = reverse[INDEX(q, x)];
+            for (int r =0; r < rev->used; r++) {
+                struct state *rs = rev->states[r];
+                int s = state_set_index(states, rs);
+                if (! bitset_get(split2, s)) {
+                    bitset_set(split2, s);
+                    F(state_set_push(split, rs));
+                    int j = block[s];
+                    F(state_set_push(splitblock[j], rs));
+                    if (!bitset_get(refine2, j)) {
+                        bitset_set(refine2, j);
+                        refine[ref++] = j;
+                    }
+                }
+            }
+        }
+        // refine blocks
+        for(int rr=0; rr < ref; rr++) {
+            int j = refine[rr];
+            struct state_set *sp = splitblock[j];
+            if (sp->used < partition[j]->used) {
+                struct state_set *b1 = partition[j];
+                struct state_set *b2 = partition[k];
+                for (int s = 0; s < sp->used; s++) {
+                    state_set_remove(b1, sp->states[s]);
+                    F(state_set_push(b2, sp->states[s]));
+                    int snum = state_set_index(states, sp->states[s]);
+                    block[snum] = k;
+                    for (int c = 0; c < nsigma; c++) {
+                        struct state_list_node *sn = active2[INDEX(snum, c)];
+                        if (sn != NULL && sn->sl == active[INDEX(j,c)]) {
+                            state_list_remove(sn);
+                            active2[INDEX(snum, c)] =
+                                state_list_add(active[INDEX(k, c)],
+                                               sp->states[s]);
+                            E(active2[INDEX(snum, c)] == NULL);
+                        }
+                    }
+                }
+                // update pending
+                for (int c = 0; c < nsigma; c++) {
+                    int aj = active[INDEX(j, c)]->size;
+                    int ak = active[INDEX(k, c)]->size;
+                    if (npending + 1 > spending) {
+                        spending *= 2;
+                        F(REALLOC_N(pending, 2 * spending));
+                    }
+                    pending[2*npending + 1] = c;
+                    if (!bitset_get(pending2, INDEX(j, c))
+                        && 0 < aj && aj <= ak) {
+                        bitset_set(pending2, INDEX(j, c));
+                        pending[2*npending] = j;
+                    } else {
+                        bitset_set(pending2, INDEX(k, c));
+                        pending[2*npending] = k;
+                    }
+                    npending += 1;
+                }
+                k++;
+            }
+            for (int s = 0; s < sp->used; s++) {
+                int snum = state_set_index(states, sp->states[s]);
+                bitset_clr(split2, snum);
+            }
+            bitset_clr(refine2, j);
+            sp->used = 0;
+        }
+        split->used = 0;
+    }
+
+    /* make a new state for each equivalence class, set initial state */
+    newstates = state_set_init(k, S_NONE);
+    E(newstates == NULL);
+    F(ALLOC_N(nsnum, k));
+    F(ALLOC_N(nsind, nstates));
+
+    for (int n = 0; n < k; n++) {
+        struct state *s = make_state();
+        E(s == NULL);
+        newstates->states[n] = s;
+        struct state_set *partn = partition[n];
+        for (int q=0; q < partn->used; q++) {
+            struct state *qs = partn->states[q];
+            int qnum = state_set_index(states, qs);
+            if (qs == fa->initial)
+                s->live = 1;     /* Abuse live to flag the new intial state */
+            nsnum[n] = qnum;     /* select representative */
+            nsind[qnum] = n;     /* and point from partition to new state */
+        }
+    }
+
+    /* build transitions and set acceptance */
+    for (int n = 0; n < k; n++) {
+        struct state *s = newstates->states[n];
+        s->accept = states->states[nsnum[n]]->accept;
+        for_each_trans(t, states->states[nsnum[n]]) {
+            int toind = state_set_index(states, t->to);
+            struct state *nto = newstates->states[nsind[toind]];
+            F(add_new_trans(s, nto, t->min, t->max));
+        }
+    }
+
+    /* Get rid of old states and transitions and turn NEWTSTATES into
+       a linked list */
+    gut(fa);
+    for (int n=0; n < k; n++)
+        if (newstates->states[n]->live) {
+            struct state *ini = newstates->states[n];
+            newstates->states[n] = newstates->states[0];
+            newstates->states[0] = ini;
+        }
+    for (int n=0; n < k-1; n++)
+        newstates->states[n]->next = newstates->states[n+1];
+    fa->initial = newstates->states[0];
+
+    result = 0;
+
+    /* clean up */
+ done:
+    free(nsind);
+    free(nsnum);
+    state_set_free(states);
+    free(sigma);
+    bitset_free(reverse_nonempty);
+    free(block);
+    for (int i=0; i < nstates*nsigma; i++) {
+        if (reverse)
+            state_set_free(reverse[i]);
+        if (active)
+            state_list_free(active[i]);
+    }
+    free(reverse);
+    free(active);
+    free(active2);
+    free(pending);
+    bitset_free(pending2);
+    state_set_free(split);
+    bitset_free(split2);
+    free(refine);
+    bitset_free(refine2);
+    for (int q=0; q < nstates; q++) {
+        if (splitblock)
+            state_set_free(splitblock[q]);
+        if (partition)
+            state_set_free(partition[q]);
+    }
+    free(splitblock);
+    free(partition);
+    state_set_free(newstates);
+
+    if (collect(fa) < 0)
+        result = -1;
+    return result;
+ error:
+    result = -1;
+    goto done;
+}
+
+static int minimize_brzozowski(struct fa *fa) {
+    struct state_set *set;
+
+    /* Minimize using Brzozowski's algorithm */
+    set = fa_reverse(fa);
+    E(set == NULL);
+    F(determinize(fa, set));
+    state_set_free(set);
+
+    set = fa_reverse(fa);
+    E(set == NULL);
+    F(determinize(fa, set));
+    state_set_free(set);
+    return 0;
+ error:
+    return -1;
+}
+
+int fa_minimize(struct fa *fa) {
+    int r;
+
+    if (fa == NULL)
+        return -1;
+    if (fa->minimal)
+        return 0;
+
+    if (fa_minimization_algorithm == FA_MIN_BRZOZOWSKI) {
+        r = minimize_brzozowski(fa);
+    } else {
+        r = minimize_hopcroft(fa);
+    }
+
+    if (r == 0)
+        fa->minimal = 1;
+    return r;
+}
+
+/*
+ * Construction of fa
+ */
+
+static struct fa *fa_make_empty(void) {
+    struct fa *fa;
+
+    if (ALLOC(fa) < 0)
+        return NULL;
+    if (add_state(fa, 0) == NULL) {
+        fa_free(fa);
+        return NULL;
+    }
+    fa->deterministic = 1;
+    fa->minimal = 1;
+    return fa;
+}
+
+static struct fa *fa_make_epsilon(void) {
+    struct fa *fa = fa_make_empty();
+    if (fa) {
+        fa->initial->accept = 1;
+        fa->deterministic= 1;
+        fa->minimal = 1;
+    }
+    return fa;
+}
+
+static struct fa *fa_make_char(uchar c) {
+    struct fa *fa = fa_make_empty();
+    if (! fa)
+        return NULL;
+
+    struct state *s = fa->initial;
+    struct state *t = add_state(fa, 1);
+    int r;
+
+    if (t == NULL)
+        goto error;
+
+    r = add_new_trans(s, t, c, c);
+    if (r < 0)
+        goto error;
+    fa->deterministic = 1;
+    fa->minimal = 1;
+    return fa;
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+struct fa *fa_make_basic(unsigned int basic) {
+    int r;
+
+    if (basic == FA_EMPTY) {
+        return fa_make_empty();
+    } else if (basic == FA_EPSILON) {
+        return fa_make_epsilon();
+    } else if (basic == FA_TOTAL) {
+        struct fa *fa = fa_make_epsilon();
+        r = add_new_trans(fa->initial, fa->initial, UCHAR_MIN, UCHAR_MAX);
+        if (r < 0) {
+            fa_free(fa);
+            fa = NULL;
+        }
+        return fa;
+    }
+    return NULL;
+}
+
+int fa_is_basic(struct fa *fa, unsigned int basic) {
+    if (basic == FA_EMPTY) {
+        return ! fa->initial->accept && fa->initial->tused == 0;
+    } else if (basic == FA_EPSILON) {
+        return fa->initial->accept && fa->initial->tused == 0;
+    } else if (basic == FA_TOTAL) {
+        if (! fa->initial->accept)
+            return 0;
+        if (fa->nocase) {
+            if (fa->initial->tused != 2)
+                return 0;
+            struct trans *t1 = fa->initial->trans;
+            struct trans *t2 = fa->initial->trans + 1;
+            if (t1->to != fa->initial || t2->to != fa->initial)
+                return 0;
+            if (t2->max != UCHAR_MAX) {
+                t1 = t2;
+                t2 = fa->initial->trans;
+            }
+            return (t1->min == UCHAR_MIN && t1->max == 'A' - 1 &&
+                    t2->min == 'Z' + 1 && t2->max == UCHAR_MAX);
+        } else {
+            struct trans *t = fa->initial->trans;
+            return fa->initial->tused == 1 &&
+                t->to == fa->initial &&
+                t->min == UCHAR_MIN && t->max == UCHAR_MAX;
+        }
+    }
+    return 0;
+}
+
+static struct fa *fa_clone(struct fa *fa) {
+    struct fa *result = NULL;
+    struct state_set *set = state_set_init(-1, S_DATA|S_SORTED);
+    int r;
+
+    if (fa == NULL || set == NULL || ALLOC(result) < 0)
+        goto error;
+
+    result->deterministic = fa->deterministic;
+    result->minimal = fa->minimal;
+    result->nocase = fa->nocase;
+    list_for_each(s, fa->initial) {
+        int i = state_set_push(set, s);
+        E(i < 0);
+
+        struct state *q = add_state(result, s->accept);
+        if (q == NULL)
+            goto error;
+        set->data[i] = q;
+        q->live = s->live;
+        q->reachable = s->reachable;
+    }
+    for (int i=0; i < set->used; i++) {
+        struct state *s = set->states[i];
+        struct state *sc = set->data[i];
+        for_each_trans(t, s) {
+            int to = state_set_index(set, t->to);
+            assert(to >= 0);
+            struct state *toc = set->data[to];
+            r = add_new_trans(sc, toc, t->min, t->max);
+            if (r < 0)
+                goto error;
+        }
+    }
+    state_set_free(set);
+    return result;
+ error:
+    state_set_free(set);
+    fa_free(result);
+    return NULL;
+}
+
+static int case_expand(struct fa *fa);
+
+/* Compute FA1|FA2 and set FA1 to that automaton. FA2 is freed */
+ATTRIBUTE_RETURN_CHECK
+static int union_in_place(struct fa *fa1, struct fa **fa2) {
+    struct state *s;
+    int r;
+
+    if (fa1->nocase != (*fa2)->nocase) {
+        if (case_expand(fa1) < 0)
+            return -1;
+        if (case_expand(*fa2) < 0)
+            return -1;
+    }
+
+    s = add_state(fa1, 0);
+    if (s == NULL)
+        return -1;
+    r = add_epsilon_trans(s, fa1->initial);
+    if (r < 0)
+        return -1;
+    r = add_epsilon_trans(s, (*fa2)->initial);
+    if (r < 0)
+        return -1;
+
+    fa1->deterministic = 0;
+    fa1->minimal = 0;
+    fa_merge(fa1, fa2);
+
+    set_initial(fa1, s);
+
+    return 0;
+}
+
+struct fa *fa_union(struct fa *fa1, struct fa *fa2) {
+    fa1 = fa_clone(fa1);
+    fa2 = fa_clone(fa2);
+    if (fa1 == NULL || fa2 == NULL)
+        goto error;
+
+    F(union_in_place(fa1, &fa2));
+
+    return fa1;
+ error:
+    fa_free(fa1);
+    fa_free(fa2);
+    return NULL;
+}
+
+/* Concat FA2 onto FA1; frees FA2 and changes FA1 to FA1.FA2 */
+ATTRIBUTE_RETURN_CHECK
+static int concat_in_place(struct fa *fa1, struct fa **fa2) {
+    int r;
+
+    if (fa1->nocase != (*fa2)->nocase) {
+        if (case_expand(fa1) < 0)
+            return -1;
+        if (case_expand(*fa2) < 0)
+            return -1;
+    }
+
+    list_for_each(s, fa1->initial) {
+        if (s->accept) {
+            s->accept = 0;
+            r = add_epsilon_trans(s, (*fa2)->initial);
+            if (r < 0)
+                return -1;
+        }
+    }
+
+    fa1->deterministic = 0;
+    fa1->minimal = 0;
+    fa_merge(fa1, fa2);
+
+    return 0;
+}
+
+struct fa *fa_concat(struct fa *fa1, struct fa *fa2) {
+    fa1 = fa_clone(fa1);
+    fa2 = fa_clone(fa2);
+
+    if (fa1 == NULL || fa2 == NULL)
+        goto error;
+
+    F(concat_in_place(fa1, &fa2));
+
+    F(collect(fa1));
+
+    return fa1;
+
+ error:
+    fa_free(fa1);
+    fa_free(fa2);
+    return NULL;
+}
+
+static struct fa *fa_make_char_set(bitset *cset, int negate) {
+    struct fa *fa = fa_make_empty();
+    if (!fa)
+        return NULL;
+
+    struct state *s = fa->initial;
+    struct state *t = add_state(fa, 1);
+    int from = 0;
+    int r;
+
+    if (t == NULL)
+        goto error;
+
+    while (from <= UCHAR_MAX) {
+        while (from <= UCHAR_MAX && bitset_get(cset, from) == negate)
+            from += 1;
+        if (from > UCHAR_MAX)
+            break;
+        int to = from;
+        while (to < UCHAR_MAX && (bitset_get(cset, to + 1) == !negate))
+            to += 1;
+        r = add_new_trans(s, t, from, to);
+        if (r < 0)
+            goto error;
+        from = to + 1;
+    }
+
+    fa->deterministic = 1;
+    fa->minimal = 1;
+    return fa;
+
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+static struct fa *fa_star(struct fa *fa) {
+    struct state *s;
+    int r;
+
+    fa = fa_clone(fa);
+    if (fa == NULL)
+        return NULL;
+
+    s = add_state(fa, 1);
+    if (s == NULL)
+        goto error;
+
+    r = add_epsilon_trans(s, fa->initial);
+    if (r < 0)
+        goto error;
+
+    set_initial(fa, s);
+    list_for_each(p, fa->initial->next) {
+        if (p->accept) {
+            r = add_epsilon_trans(p, s);
+            if (r < 0)
+                goto error;
+        }
+    }
+    fa->deterministic = 0;
+    fa->minimal = 0;
+
+    return fa;
+
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+/* Form the automaton (FA){N}; FA is not modified */
+static struct fa *repeat(struct fa *fa, int n) {
+    if (n == 0) {
+        return fa_make_epsilon();
+    } else if (n == 1) {
+        return fa_clone(fa);
+    } else {
+        struct fa *cfa = fa_clone(fa);
+        if (cfa == NULL)
+            return NULL;
+        while (n > 1) {
+            struct fa *tfa = fa_clone(fa);
+            if (tfa == NULL) {
+                fa_free(cfa);
+                return NULL;
+            }
+            if (concat_in_place(cfa, &tfa) < 0) {
+                fa_free(cfa);
+                fa_free(tfa);
+                return NULL;
+            }
+            n -= 1;
+        }
+        return cfa;
+    }
+}
+
+struct fa *fa_iter(struct fa *fa, int min, int max) {
+    int r;
+
+    if (min < 0)
+        min = 0;
+
+    if (min > max && max != -1) {
+        return fa_make_empty();
+    }
+    if (max == -1) {
+        struct fa *sfa = fa_star(fa);
+        if (min == 0)
+            return sfa;
+        if (! sfa)
+            return NULL;
+        struct fa *cfa = repeat(fa, min);
+        if (! cfa) {
+            fa_free(sfa);
+            return NULL;
+        }
+        if (concat_in_place(cfa, &sfa) < 0) {
+            fa_free(sfa);
+            fa_free(cfa);
+            return NULL;
+        }
+        return cfa;
+    } else {
+        struct fa *cfa = NULL;
+
+        max -= min;
+        cfa = repeat(fa, min);
+        if (cfa == NULL)
+            return NULL;
+        if (max > 0) {
+            struct fa *cfa2 = fa_clone(fa);
+            if (cfa2 == NULL) {
+                fa_free(cfa);
+                return NULL;
+            }
+            while (max > 1) {
+                struct fa *cfa3 = fa_clone(fa);
+                if (cfa3 == NULL) {
+                    fa_free(cfa);
+                    fa_free(cfa2);
+                    return NULL;
+                }
+                list_for_each(s, cfa3->initial) {
+                    if (s->accept) {
+                        r = add_epsilon_trans(s, cfa2->initial);
+                        if (r < 0) {
+                            fa_free(cfa);
+                            fa_free(cfa2);
+                            fa_free(cfa3);
+                            return NULL;
+                        }
+                    }
+                }
+                fa_merge(cfa3, &cfa2);
+                cfa2 = cfa3;
+                max -= 1;
+            }
+            list_for_each(s, cfa->initial) {
+                if (s->accept) {
+                    r = add_epsilon_trans(s, cfa2->initial);
+                    if (r < 0) {
+                        fa_free(cfa);
+                        fa_free(cfa2);
+                        return NULL;
+                    }
+                }
+            }
+            fa_merge(cfa, &cfa2);
+            cfa->deterministic = 0;
+            cfa->minimal = 0;
+        }
+        if (collect(cfa) < 0) {
+            fa_free(cfa);
+            cfa = NULL;
+        }
+        return cfa;
+    }
+}
+
+static void sort_transition_intervals(struct fa *fa) {
+    list_for_each(s, fa->initial) {
+        qsort(s->trans, s->tused, sizeof(*s->trans), trans_intv_cmp);
+    }
+}
+
+struct fa *fa_intersect(struct fa *fa1, struct fa *fa2) {
+    int ret;
+    struct fa *fa = NULL;
+    struct state_set *worklist = NULL;
+    state_triple_hash *newstates = NULL;
+
+    if (fa1 == fa2)
+        return fa_clone(fa1);
+
+    if (fa_is_basic(fa1, FA_EMPTY) || fa_is_basic(fa2, FA_EMPTY))
+        return fa_make_empty();
+
+    if (fa1->nocase != fa2->nocase) {
+        F(case_expand(fa1));
+        F(case_expand(fa2));
+    }
+
+    fa = fa_make_empty();
+    worklist = state_set_init(-1, S_NONE);
+    newstates = state_triple_init();
+    if (fa == NULL || worklist == NULL || newstates == NULL)
+        goto error;
+
+    sort_transition_intervals(fa1);
+    sort_transition_intervals(fa2);
+
+    F(state_set_push(worklist, fa1->initial));
+    F(state_set_push(worklist, fa2->initial));
+    F(state_set_push(worklist, fa->initial));
+    F(state_triple_push(newstates,
+                         fa1->initial, fa2->initial, fa->initial));
+    while (worklist->used) {
+        struct state *s  = state_set_pop(worklist);
+        struct state *p2 = state_set_pop(worklist);
+        struct state *p1 = state_set_pop(worklist);
+        s->accept = p1->accept && p2->accept;
+
+        struct trans *t1 = p1->trans;
+        struct trans *t2 = p2->trans;
+        for (int n1 = 0, b2 = 0; n1 < p1->tused; n1++) {
+            while (b2 < p2->tused && t2[b2].max < t1[n1].min)
+                b2++;
+            for (int n2 = b2;
+                 n2 < p2->tused && t1[n1].max >= t2[n2].min;
+                 n2++) {
+                if (t2[n2].max >= t1[n1].min) {
+                    struct state *r = state_triple_thd(newstates,
+                                                       t1[n1].to, t2[n2].to);
+                    if (r == NULL) {
+                        r = add_state(fa, 0);
+                        E(r == NULL);
+                        F(state_set_push(worklist, t1[n1].to));
+                        F(state_set_push(worklist, t2[n2].to));
+                        F(state_set_push(worklist, r));
+                        F(state_triple_push(newstates,
+                                             t1[n1].to, t2[n2].to, r));
+                    }
+                    char min = t1[n1].min > t2[n2].min
+                        ? t1[n1].min : t2[n2].min;
+                    char max = t1[n1].max < t2[n2].max
+                        ? t1[n1].max : t2[n2].max;
+                    ret = add_new_trans(s, r, min, max);
+                    if (ret < 0)
+                        goto error;
+                }
+            }
+        }
+    }
+    fa->deterministic = fa1->deterministic && fa2->deterministic;
+    fa->nocase = fa1->nocase && fa2->nocase;
+ done:
+    state_set_free(worklist);
+    state_triple_free(newstates);
+    if (fa != NULL) {
+        if (collect(fa) < 0) {
+            fa_free(fa);
+            fa = NULL;
+        }
+    }
+
+    return fa;
+ error:
+    fa_free(fa);
+    fa = NULL;
+    goto done;
+}
+
+int fa_contains(struct fa *fa1, struct fa *fa2) {
+    int result = 0;
+    struct state_set *worklist = NULL;  /* List of pairs of states */
+    struct state_set *visited = NULL;   /* List of pairs of states */
+
+    if (fa1 == NULL || fa2 == NULL)
+        return -1;
+
+    if (fa1 == fa2)
+        return 1;
+
+    determinize(fa2, NULL);
+    sort_transition_intervals(fa1);
+    sort_transition_intervals(fa2);
+
+    F(state_pair_push(&worklist, fa1->initial, fa2->initial));
+    F(state_pair_push(&visited, fa1->initial, fa2->initial));
+    while (worklist->used) {
+        struct state *p1, *p2;
+        void *v2;
+        p1 = state_set_pop_data(worklist, &v2);
+        p2 = v2;
+
+        if (p1->accept && !p2->accept)
+            goto done;
+
+        struct trans *t1 = p1->trans;
+        struct trans *t2 = p2->trans;
+        for(int n1 = 0, b2 = 0; n1 < p1->tused; n1++) {
+            while (b2 < p2->tused && t2[b2].max < t1[n1].min)
+                b2++;
+            int min1 = t1[n1].min, max1 = t1[n1].max;
+            for (int n2 = b2;
+                 n2 < p2->tused && t1[n1].max >= t2[n2].min;
+                 n2++) {
+                if (t2[n2].min > min1)
+                    goto done;
+                if (t2[n2].max < CHAR_MAX)
+                    min1 = t2[n2].max + 1;
+                else {
+                    min1 = UCHAR_MAX;
+                    max1 = UCHAR_MIN;
+                }
+                if (state_pair_find(visited, t1[n1].to, t2[n2].to) == -1) {
+                    F(state_pair_push(&worklist, t1[n1].to, t2[n2].to));
+                    F(state_pair_push(&visited, t1[n1].to, t2[n2].to));
+                }
+            }
+            if (min1 <= max1)
+                goto done;
+        }
+    }
+
+    result = 1;
+ done:
+    state_set_free(worklist);
+    state_set_free(visited);
+    return result;
+ error:
+    result = -1;
+    goto done;
+}
+
+static int totalize(struct fa *fa) {
+    int r;
+    struct state *crash = add_state(fa, 0);
+
+    E(crash == NULL);
+    F(mark_reachable(fa));
+    sort_transition_intervals(fa);
+
+    if (fa->nocase) {
+        r = add_new_trans(crash, crash, UCHAR_MIN, 'A' - 1);
+        if (r < 0)
+            return -1;
+        r = add_new_trans(crash, crash, 'Z' + 1, UCHAR_MAX);
+        if (r < 0)
+            return -1;
+    } else {
+        r = add_new_trans(crash, crash, UCHAR_MIN, UCHAR_MAX);
+        if (r < 0)
+            return -1;
+    }
+
+    list_for_each(s, fa->initial) {
+        int next = UCHAR_MIN;
+        int tused = s->tused;
+        for (int i=0; i < tused; i++) {
+            uchar min = s->trans[i].min, max = s->trans[i].max;
+            if (fa->nocase) {
+                /* Don't add transitions on [A-Z] into crash */
+                if (isupper(min)) min = 'A';
+                if (isupper(max)) max = 'Z';
+            }
+            if (min > next) {
+                r = add_new_trans(s, crash, next, min - 1);
+                if (r < 0)
+                    return -1;
+            }
+            if (max + 1 > next) {
+                next = max + 1;
+                if (fa->nocase && isupper(next))
+                    next = 'Z' + 1;
+            }
+        }
+        if (next <= UCHAR_MAX) {
+            r = add_new_trans(s, crash, next, UCHAR_MAX);
+            if (r < 0)
+                return -1;
+        }
+    }
+    return 0;
+ error:
+    return -1;
+}
+
+struct fa *fa_complement(struct fa *fa) {
+    fa = fa_clone(fa);
+    E(fa == NULL);
+    F(determinize(fa, NULL));
+    F(totalize(fa));
+    list_for_each(s, fa->initial)
+        s->accept = ! s->accept;
+
+    F(collect(fa));
+    return fa;
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+struct fa *fa_minus(struct fa *fa1, struct fa *fa2) {
+    if (fa1 == NULL || fa2 == NULL)
+        return NULL;
+
+    if (fa_is_basic(fa1, FA_EMPTY) || fa1 == fa2)
+        return fa_make_empty();
+    if (fa_is_basic(fa2, FA_EMPTY))
+        return fa_clone(fa1);
+
+    struct fa *cfa2 = fa_complement(fa2);
+    if (cfa2 == NULL)
+        return NULL;
+
+    struct fa *result = fa_intersect(fa1, cfa2);
+    fa_free(cfa2);
+    return result;
+}
+
+static int accept_to_accept(struct fa *fa) {
+    int r;
+    struct state *s = add_state(fa, 0);
+    if (s == NULL)
+        return -1;
+
+    F(mark_reachable(fa));
+    list_for_each(a, fa->initial) {
+        if (a->accept && a->reachable) {
+            r = add_epsilon_trans(s, a);
+            if (r < 0)
+                return -1;
+        }
+    }
+
+    set_initial(fa, s);
+    fa->deterministic = fa->minimal = 0;
+    return 0;
+ error:
+    return -1;
+}
+
+struct fa *fa_overlap(struct fa *fa1, struct fa *fa2) {
+    struct fa *fa = NULL, *eps = NULL, *result = NULL;
+    struct state_set *map = NULL;
+
+    if (fa1 == NULL || fa2 == NULL)
+        return NULL;
+
+    fa1 = fa_clone(fa1);
+    fa2 = fa_clone(fa2);
+    if (fa1 == NULL || fa2 == NULL)
+        goto error;
+
+    if (determinize(fa1, NULL) < 0)
+        goto error;
+    if (accept_to_accept(fa1) < 0)
+        goto error;
+
+    map = fa_reverse(fa2);
+    state_set_free(map);
+    if (determinize(fa2, NULL) < 0)
+        goto error;
+    if (accept_to_accept(fa2) < 0)
+        goto error;
+    map = fa_reverse(fa2);
+    state_set_free(map);
+    if (determinize(fa2, NULL) < 0)
+        goto error;
+
+    fa = fa_intersect(fa1, fa2);
+    if (fa == NULL)
+        goto error;
+
+    eps = fa_make_epsilon();
+    if (eps == NULL)
+        goto error;
+
+    result = fa_minus(fa, eps);
+    if (result == NULL)
+        goto error;
+
+ error:
+    fa_free(fa1);
+    fa_free(fa2);
+    fa_free(fa);
+    fa_free(eps);
+    return result;
+}
+
+int fa_equals(struct fa *fa1, struct fa *fa2) {
+    if (fa1 == NULL || fa2 == NULL)
+        return -1;
+
+    /* fa_contains(fa1, fa2) && fa_contains(fa2, fa1) with error checking */
+    int c1 = fa_contains(fa1, fa2);
+    if (c1 < 0)
+        return -1;
+    if (c1 == 0)
+        return 0;
+    return fa_contains(fa2, fa1);
+}
+
+static unsigned int chr_score(char c) {
+    if (isalpha(c)) {
+        return 2;
+    } else if (isalnum(c)) {
+        return 3;
+    } else if (isprint(c)) {
+        return 7;
+    } else if (c == '\0') {
+        return 10000;
+    } else {
+        return 100;
+    }
+}
+
+static unsigned int str_score(const struct re_str *str) {
+    unsigned int score = 0;
+    for (int i=0; i < str->len; i++) {
+        score += chr_score(str->rx[i]);
+    }
+    return score;
+}
+
+/* See if we get a better string for DST by appending C to SRC. If DST is
+ * NULL or empty, always use SRC + C
+ */
+static struct re_str *string_extend(struct re_str *dst,
+                                    const struct re_str *src,
+                                    char c) {
+    if (dst == NULL
+        || dst->len == 0
+        || str_score(src) + chr_score(c) < str_score(dst)) {
+        int slen = src->len;
+        if (dst == NULL)
+            dst = make_re_str(NULL);
+        if (dst == NULL)
+            return NULL;
+        if (REALLOC_N(dst->rx, slen+2) < 0)
+            return NULL;
+        memcpy(dst->rx, src->rx, slen);
+        dst->rx[slen] = c;
+        dst->rx[slen + 1] = '\0';
+        dst->len = slen + 1;
+    }
+    return dst;
+}
+
+static char pick_char(struct trans *t) {
+    for (int c = t->min; c <= t->max; c++)
+        if (isalpha(c)) return c;
+    for (int c = t->min; c <= t->max; c++)
+        if (isalnum(c)) return c;
+    for (int c = t->min; c <= t->max; c++)
+        if (isprint(c)) return c;
+    return t->max;
+}
+
+/* Generate an example string for FA. Traverse all transitions and record
+ * at each turn the "best" word found for that state.
+ */
+int fa_example(struct fa *fa, char **example, size_t *example_len) {
+    struct re_str *word = NULL;
+    struct state_set *path = NULL, *worklist = NULL;
+    struct re_str *str = NULL;
+
+    *example = NULL;
+    *example_len = 0;
+
+    /* Sort to avoid any ambiguity because of reordering of transitions */
+    sort_transition_intervals(fa);
+
+    /* Map from state to string */
+    path = state_set_init(-1, S_DATA|S_SORTED);
+    str = make_re_str("");
+    if (path == NULL || str == NULL)
+        goto error;
+    F(state_set_push_data(path, fa->initial, str));
+
+    /* List of states still to visit */
+    worklist = state_set_init(-1, S_NONE);
+    if (worklist == NULL)
+        goto error;
+    F(state_set_push(worklist, fa->initial));
+
+    while (worklist->used) {
+        struct state *s = state_set_pop(worklist);
+        struct re_str *ps = state_set_find_data(path, s);
+        for_each_trans(t, s) {
+            char c = pick_char(t);
+            int toind = state_set_index(path, t->to);
+            if (toind == -1) {
+                struct re_str *w = string_extend(NULL, ps, c);
+                E(w == NULL);
+                F(state_set_push(worklist, t->to));
+                F(state_set_push_data(path, t->to, w));
+            } else {
+                path->data[toind] = string_extend(path->data[toind], ps, c);
+            }
+        }
+    }
+
+    for (int i=0; i < path->used; i++) {
+        struct state *p = path->states[i];
+        struct re_str *ps = path->data[i];
+        if (p->accept &&
+            (word == NULL || word->len == 0
+             || (ps->len > 0 && str_score(word) > str_score(ps)))) {
+            free_re_str(word);
+            word = ps;
+        } else {
+            free_re_str(ps);
+        }
+    }
+    state_set_free(path);
+    state_set_free(worklist);
+    if (word != NULL) {
+        *example_len = word->len;
+        *example = word->rx;
+        free(word);
+    }
+    return 0;
+ error:
+    state_set_free(path);
+    state_set_free(worklist);
+    free_re_str(word);
+    return -1;
+}
+
+/* Expand the automaton FA by replacing every transition s(c) -> p from
+ * state s to p on character c by two transitions s(X) -> r, r(c) -> p via
+ * a new state r.
+ * If ADD_MARKER is true, also add for each original state s a new a loop
+ * s(Y) -> q and q(X) -> s through a new state q.
+ *
+ * The end result is that an automaton accepting "a|ab" is turned into one
+ * accepting "Xa|XaXb" if add_marker is false and "(YX)*Xa|(YX)*Xa(YX)*Xb"
+ * when add_marker is true.
+ *
+ * The returned automaton is a copy of FA, FA is not modified.
+ */
+static struct fa *expand_alphabet(struct fa *fa, int add_marker,
+                                  char X, char Y) {
+    int ret;
+
+    fa = fa_clone(fa);
+    if (fa == NULL)
+        return NULL;
+
+    F(mark_reachable(fa));
+    list_for_each(p, fa->initial) {
+        if (! p->reachable)
+            continue;
+
+        struct state *r = add_state(fa, 0);
+        r->trans = p->trans;
+        r->tused = p->tused;
+        r->tsize = p->tsize;
+        p->trans = NULL;
+        p->tused = p->tsize = 0;
+        ret = add_new_trans(p, r, X, X);
+        if (ret < 0)
+            goto error;
+        if (add_marker) {
+            struct state *q = add_state(fa, 0);
+            ret = add_new_trans(p, q, Y, Y);
+            if (ret < 0)
+                goto error;
+            ret = add_new_trans(q, p, X, X);
+            if (ret < 0)
+                goto error;
+        }
+    }
+    return fa;
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+static bitset *alphabet(struct fa *fa) {
+    bitset *bs = bitset_init(UCHAR_NUM);
+
+    list_for_each(s, fa->initial) {
+        for (int i=0; i < s->tused; i++) {
+            for (uint c = s->trans[i].min; c <= s->trans[i].max; c++)
+                bitset_set(bs, c);
+        }
+    }
+    return bs;
+}
+
+static bitset *last_chars(struct fa *fa) {
+    bitset *bs = bitset_init(UCHAR_NUM);
+
+    list_for_each(s, fa->initial) {
+        for (int i=0; i < s->tused; i++) {
+            if (s->trans[i].to->accept) {
+                for (uint c = s->trans[i].min; c <= s->trans[i].max; c++)
+                    bitset_set(bs, c);
+            }
+        }
+    }
+    return bs;
+}
+
+static bitset *first_chars(struct fa *fa) {
+    bitset *bs = bitset_init(UCHAR_NUM);
+    struct state *s = fa->initial;
+
+    for (int i=0; i < s->tused; i++) {
+        for (uint c = s->trans[i].min; c <= s->trans[i].max; c++)
+            bitset_set(bs, c);
+    }
+    return bs;
+}
+
+/* Return true if F1 and F2 are known to be unambiguously concatenable
+ * according to simple heuristics. Return false if they need to be checked
+ * further to decide ambiguity */
+static bool is_splittable(struct fa *fa1, struct fa *fa2) {
+    bitset *alpha1 = NULL;
+    bitset *alpha2 = NULL;
+    bitset *last1 = NULL;
+    bitset *first2 = NULL;
+    bool result = false;
+
+    alpha2 = alphabet(fa2);
+    last1 = last_chars(fa1);
+    if (bitset_disjoint(last1, alpha2, UCHAR_NUM)) {
+        result = true;
+        goto done;
+    }
+
+    alpha1 = alphabet(fa1);
+    first2 = first_chars(fa2);
+    if (bitset_disjoint(first2, alpha1, UCHAR_NUM)) {
+        result = true;
+        goto done;
+    }
+ done:
+    bitset_free(alpha1);
+    bitset_free(alpha2);
+    bitset_free(last1);
+    bitset_free(first2);
+    return result;
+}
+
+/* This algorithm is due to Anders Moeller, and can be found in class
+ * AutomatonOperations in dk.brics.grammar
+ */
+int fa_ambig_example(struct fa *fa1, struct fa *fa2,
+                     char **upv, size_t *upv_len,
+                     char **pv, char **v) {
+    static const char X = '\001';
+    static const char Y = '\002';
+    char *result = NULL, *s = NULL;
+    int ret = -1, r;
+    struct fa *mp = NULL, *ms = NULL, *sp = NULL, *ss = NULL, *amb = NULL;
+    struct fa *a1f = NULL, *a1t = NULL, *a2f = NULL, *a2t = NULL;
+    struct fa *b1 = NULL, *b2 = NULL;
+
+    *upv = NULL;
+    *upv_len = 0;
+    if (pv != NULL)
+        *pv = NULL;
+    if (v != NULL)
+        *v = NULL;
+
+    if (is_splittable(fa1, fa2))
+        return 0;
+
+#define Xs "\001"
+#define Ys "\002"
+#define MPs Ys Xs "(" Xs "(.|\n))+"
+#define MSs Ys Xs "(" Xs "(.|\n))*"
+#define SPs "(" Xs "(.|\n))+" Ys Xs
+#define SSs "(" Xs "(.|\n))*" Ys Xs
+    /* These could become static constants */
+    r = fa_compile( MPs, strlen(MPs), &mp);
+    if (r != REG_NOERROR)
+        goto error;
+    r = fa_compile( MSs, strlen(MSs), &ms);
+    if (r != REG_NOERROR)
+        goto error;
+    r = fa_compile( SPs, strlen(SPs), &sp);
+    if (r != REG_NOERROR)
+        goto error;
+    r = fa_compile( SSs, strlen(SSs), &ss);
+    if (r != REG_NOERROR)
+        goto error;
+#undef SSs
+#undef SPs
+#undef MSs
+#undef MPs
+#undef Xs
+#undef Ys
+
+    a1f = expand_alphabet(fa1, 0, X, Y);
+    a1t = expand_alphabet(fa1, 1, X, Y);
+    a2f = expand_alphabet(fa2, 0, X, Y);
+    a2t = expand_alphabet(fa2, 1, X, Y);
+    if (a1f == NULL || a1t == NULL || a2f == NULL || a2t == NULL)
+        goto error;
+
+    /* Compute b1 = ((a1f . mp) & a1t) . ms */
+    if (concat_in_place(a1f, &mp) < 0)
+        goto error;
+    b1 = fa_intersect(a1f, a1t);
+    if (b1 == NULL)
+        goto error;
+    if (concat_in_place(b1, &ms) < 0)
+        goto error;
+
+    /* Compute b2 = ss . ((sp . a2f) & a2t) */
+    if (concat_in_place(sp, &a2f) < 0)
+        goto error;
+    b2 = fa_intersect(sp, a2t);
+    if (b2 == NULL)
+        goto error;
+    if (concat_in_place(ss, &b2) < 0)
+        goto error;
+    b2 = ss;
+    ss = NULL;
+
+    /* The automaton we are really interested in */
+    amb = fa_intersect(b1, b2);
+    if (amb == NULL)
+        goto error;
+
+    size_t s_len = 0;
+    r = fa_example(amb, &s, &s_len);
+    if (r < 0)
+        goto error;
+
+    if (s != NULL) {
+        char *t;
+        F(ALLOC_N(result, (strlen(s)-1)/2 + 1));
+        t = result;
+        int i = 0;
+        for (i=0; s[2*i] == X; i++)
+            *t++ = s[2*i + 1];
+        if (pv != NULL)
+            *pv = t;
+        i += 1;
+
+        for ( ;s[2*i] == X; i++)
+            *t++ = s[2*i + 1];
+        if (v != NULL)
+            *v = t;
+        i += 1;
+
+        for (; 2*i+1 < strlen(s); i++)
+            *t++ = s[2*i + 1];
+    }
+    ret = 0;
+
+ done:
+    /* Clean up intermediate automata */
+    fa_free(mp);
+    fa_free(ms);
+    fa_free(ss);
+    fa_free(sp);
+    fa_free(a1f);
+    fa_free(a1t);
+    fa_free(a2f);
+    fa_free(a2t);
+    fa_free(b1);
+    fa_free(b2);
+    fa_free(amb);
+
+    FREE(s);
+    *upv = result;
+    if (result != NULL)
+        *upv_len = strlen(result);
+    return ret;
+ error:
+    FREE(result);
+    ret = -1;
+    goto done;
+}
+
+/*
+ * Construct an fa from a regular expression
+ */
+static struct fa *fa_from_re(struct re *re) {
+    struct fa *result = NULL;
+
+    switch(re->type) {
+    case UNION:
+        {
+            result = fa_from_re(re->exp1);
+            if (result == NULL)
+                goto error;
+            struct fa *fa2 = fa_from_re(re->exp2);
+            if (fa2 == NULL)
+                goto error;
+            if (union_in_place(result, &fa2) < 0)
+                goto error;
+        }
+        break;
+    case CONCAT:
+        {
+            result = fa_from_re(re->exp1);
+            if (result == NULL)
+                goto error;
+            struct fa *fa2 = fa_from_re(re->exp2);
+            if (fa2 == NULL)
+                goto error;
+            if (concat_in_place(result, &fa2) < 0)
+                goto error;
+        }
+        break;
+    case CSET:
+        result = fa_make_char_set(re->cset, re->negate);
+        break;
+    case ITER:
+        {
+            struct fa *fa = fa_from_re(re->exp);
+            if (fa == NULL)
+                goto error;
+            result = fa_iter(fa, re->min, re->max);
+            fa_free(fa);
+        }
+        break;
+    case EPSILON:
+        result = fa_make_epsilon();
+        break;
+    case CHAR:
+        result = fa_make_char(re->c);
+        break;
+    default:
+        assert(0);
+        break;
+    }
+    return result;
+ error:
+    fa_free(result);
+    return NULL;
+}
+
+static void free_re(struct re *re) {
+    if (re == NULL)
+        return;
+    assert(re->ref == 0);
+
+    if (re->type == UNION || re->type == CONCAT) {
+        re_unref(re->exp1);
+        re_unref(re->exp2);
+    } else if (re->type == ITER) {
+        re_unref(re->exp);
+    } else if (re->type == CSET) {
+        bitset_free(re->cset);
+    }
+    free(re);
+}
+
+int fa_compile(const char *regexp, size_t size, struct fa **fa) {
+    struct re *re = NULL;
+    struct re_parse parse;
+
+    *fa = NULL;
+
+    parse.rx = regexp;
+    parse.rend = regexp + size;
+    parse.error = REG_NOERROR;
+
+    re = parse_regexp(&parse);
+    if (re == NULL)
+        return parse.error;
+
+    *fa = fa_from_re(re);
+    re_unref(re);
+
+    if (*fa == NULL || collect(*fa) < 0)
+        parse.error = REG_ESPACE;
+    return parse.error;
+}
+
+/* We represent a case-insensitive FA by using only transitions on
+ * lower-case letters.
+ */
+int fa_nocase(struct fa *fa) {
+    if (fa == NULL || fa->nocase)
+        return 0;
+
+    fa->nocase = 1;
+    list_for_each(s, fa->initial) {
+        int tused = s->tused;
+        /* For every transition on characters in [A-Z] add a corresponding
+         * transition on [a-z]; remove any portion covering [A-Z] */
+        for (int i=0; i < tused; i++) {
+            struct trans *t = s->trans + i;
+            int lc_min = t->min < 'A' ? 'a' : tolower(t->min);
+            int lc_max = t->max > 'Z' ? 'z' : tolower(t->max);
+
+            if (t->min > 'Z' || t->max < 'A')
+                continue;
+            if (t->min >= 'A' && t->max <= 'Z') {
+                t->min = tolower(t->min);
+                t->max = tolower(t->max);
+            } else if (t->max <= 'Z') {
+                /* t->min < 'A' */
+                t->max = 'A' - 1;
+                F(add_new_trans(s, t->to, lc_min, lc_max));
+            } else {
+                /* t->min < 'A' && t->max > 'Z' */
+                F(add_new_trans(s, t->to, 'Z' + 1, t->max));
+                s->trans[i].max = 'A' - 1;
+                F(add_new_trans(s, s->trans[i].to, lc_min, lc_max));
+            }
+        }
+    }
+    F(collect(fa));
+    return 0;
+ error:
+    return -1;
+}
+
+int fa_is_nocase(struct fa *fa) {
+    return fa->nocase;
+}
+
+/* If FA is case-insensitive, turn it into a case-sensitive automaton by
+ * adding transitions on upper-case letters for each existing transition on
+ * lower-case letters */
+static int case_expand(struct fa *fa) {
+    if (! fa->nocase)
+        return 0;
+
+    fa->nocase = 0;
+    list_for_each(s, fa->initial) {
+        int tused = s->tused;
+        /* For every transition on characters in [a-z] add a corresponding
+         * transition on [A-Z] */
+        for (int i=0; i < tused; i++) {
+            struct trans *t = s->trans + i;
+            int lc_min = t->min < 'a' ? 'A' : toupper(t->min);
+            int lc_max = t->max > 'z' ? 'Z' : toupper(t->max);
+
+            if (t->min > 'z' || t->max < 'a')
+                continue;
+            F(add_new_trans(s, t->to, lc_min, lc_max));
+        }
+    }
+    F(collect(fa));
+    return 0;
+ error:
+    return -1;
+}
+
+/*
+ * Regular expression parser
+ */
+
+static struct re *make_re(enum re_type type) {
+    struct re *re;
+    if (make_ref(re) == 0)
+        re->type = type;
+    return re;
+}
+
+static struct re *make_re_rep(struct re *exp, int min, int max) {
+    struct re *re = make_re(ITER);
+    if (re) {
+        re->exp = exp;
+        re->min = min;
+        re->max = max;
+    } else {
+        re_unref(exp);
+    }
+    return re;
+}
+
+static struct re *make_re_binop(enum re_type type, struct re *exp1,
+                                struct re *exp2) {
+    struct re *re = make_re(type);
+    if (re) {
+        re->exp1 = exp1;
+        re->exp2 = exp2;
+    } else {
+        re_unref(exp1);
+        re_unref(exp2);
+    }
+    return re;
+}
+
+static struct re *make_re_char(uchar c) {
+    struct re *re = make_re(CHAR);
+    if (re)
+        re->c = c;
+    return re;
+}
+
+static struct re *make_re_char_set(bool negate, bool no_ranges) {
+    struct re *re = make_re(CSET);
+    if (re) {
+        re->negate = negate;
+        re->no_ranges = no_ranges;
+        re->cset = bitset_init(UCHAR_NUM);
+        if (re->cset == NULL)
+            re_unref(re);
+    }
+    return re;
+}
+
+static bool more(struct re_parse *parse) {
+    return parse->rx < parse->rend;
+}
+
+static bool match(struct re_parse *parse, char m) {
+    if (!more(parse))
+        return false;
+    if (*parse->rx == m) {
+        parse->rx += 1;
+        return true;
+    }
+    return false;
+}
+
+static bool peek(struct re_parse *parse, const char *chars) {
+    return *parse->rx != '\0' && strchr(chars, *parse->rx) != NULL;
+}
+
+static bool next(struct re_parse *parse, char *c) {
+    if (!more(parse))
+        return false;
+    *c = *parse->rx;
+    parse->rx += 1;
+    return true;
+}
+
+static bool parse_char(struct re_parse *parse, int quoted, char *c) {
+    if (!more(parse))
+        return false;
+    if (quoted && *parse->rx == '\\') {
+        parse->rx += 1;
+        return next(parse, c);
+    } else {
+        return next(parse, c);
+    }
+}
+
+static void add_re_char(struct re *re, uchar from, uchar to) {
+    assert(re->type == CSET);
+    for (unsigned int c = from; c <= to; c++)
+        bitset_set(re->cset, c);
+}
+
+static void parse_char_class(struct re_parse *parse, struct re *re) {
+    if (! more(parse)) {
+        parse->error = REG_EBRACK;
+        goto error;
+    }
+    char from, to;
+    parse_char(parse, 0, &from);
+    to = from;
+    if (match(parse, '-')) {
+        if (! more(parse)) {
+            parse->error = REG_EBRACK;
+            goto error;
+        }
+        if (peek(parse, "]")) {
+            if (from > to) {
+                parse->error = REG_ERANGE;
+                goto error;
+            }
+            add_re_char(re, from, to);
+            add_re_char(re, '-', '-');
+            return;
+        } else if (!parse_char(parse, 0, &to)) {
+            parse->error = REG_ERANGE;
+            goto error;
+        }
+    }
+    if (from > to) {
+        parse->error = REG_ERANGE;
+        goto error;
+    }
+    add_re_char(re, from, to);
+ error:
+    return;
+}
+
+static struct re *parse_simple_exp(struct re_parse *parse) {
+    struct re *re = NULL;
+
+    if (match(parse, '[')) {
+        bool negate = match(parse, '^');
+        re = make_re_char_set(negate, parse->no_ranges);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+        parse_char_class(parse, re);
+        if (parse->error != REG_NOERROR)
+            goto error;
+        while (more(parse) && ! peek(parse, "]")) {
+            parse_char_class(parse, re);
+            if (parse->error != REG_NOERROR)
+                goto error;
+        }
+        if (! match(parse, ']')) {
+            parse->error = REG_EBRACK;
+            goto error;
+        }
+    } else if (match(parse, '(')) {
+        if (match(parse, ')')) {
+            re = make_re(EPSILON);
+            if (re == NULL) {
+                parse->error = REG_ESPACE;
+                goto error;
+            }
+        } else {
+            re = parse_regexp(parse);
+            if (re == NULL)
+                goto error;
+            if (! match(parse, ')')) {
+                parse->error = REG_EPAREN;
+                goto error;
+            }
+        }
+    } else if (match(parse, '.')) {
+        re = make_re_char_set(1, parse->no_ranges);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+        add_re_char(re, '\n', '\n');
+    } else if (more(parse)) {
+        char c;
+        if (!parse_char(parse, 1, &c)) {
+            parse->error = REG_EESCAPE;
+            goto error;
+        }
+        re = make_re_char(c);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+    } else {
+        re = make_re(EPSILON);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+    }
+    return re;
+ error:
+    re_unref(re);
+    return NULL;
+}
+
+static int parse_int(struct re_parse *parse) {
+    const char *lim;
+    char *end;
+    size_t used;
+    long l;
+
+    /* We need to be careful that strtoul will never access
+     * memory beyond parse->rend
+     */
+    for (lim = parse->rx; lim < parse->rend && *lim >= '0' && *lim <= '9';
+         lim++);
+    if (lim < parse->rend) {
+        l = strtoul(parse->rx, &end, 10);
+        used = end - parse->rx;
+    } else {
+        char *s = strndup(parse->rx, parse->rend - parse->rx);
+        if (s == NULL) {
+            parse->error = REG_ESPACE;
+            return -1;
+        }
+        l = strtoul(s, &end, 10);
+        used = end - s;
+        free(s);
+    }
+
+    if (used == 0)
+        return -1;
+    parse->rx += used;
+    if ((l<0) || (l > INT_MAX)) {
+        parse->error = REG_BADBR;
+        return -1;
+    }
+    return (int) l;
+}
+
+static struct re *parse_repeated_exp(struct re_parse *parse) {
+    struct re *re = parse_simple_exp(parse);
+    if (re == NULL)
+        goto error;
+    if (match(parse, '?')) {
+        re = make_re_rep(re, 0, 1);
+    } else if (match(parse, '*')) {
+        re = make_re_rep(re, 0, -1);
+    } else if (match(parse, '+')) {
+        re = make_re_rep(re, 1, -1);
+    } else if (match(parse, '{')) {
+        int min, max;
+        min = parse_int(parse);
+        if (min == -1)
+            goto error;
+        if (match(parse, ',')) {
+            max = parse_int(parse);
+            if (max == -1)
+                max = -1;      /* If it's not an int, it means 'unbounded' */
+            if (! match(parse, '}')) {
+                parse->error = REG_EBRACE;
+                goto error;
+            }
+        } else if (match(parse, '}')) {
+            max = min;
+        } else {
+            parse->error = REG_EBRACE;
+            goto error;
+        }
+        if (min > max && max != -1) {
+            parse->error = REG_BADBR;
+            goto error;
+        }
+        re = make_re_rep(re, min, max);
+    }
+    if (re == NULL)
+        parse->error = REG_ESPACE;
+    return re;
+ error:
+    re_unref(re);
+    return NULL;
+}
+
+static struct re *parse_concat_exp(struct re_parse *parse) {
+    struct re *re = parse_repeated_exp(parse);
+    if (re == NULL)
+        goto error;
+
+    if (more(parse) && ! peek(parse, ")|")) {
+        struct re *re2 = parse_concat_exp(parse);
+        if (re2 == NULL)
+            goto error;
+        re = make_re_binop(CONCAT, re, re2);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+    }
+    return re;
+
+ error:
+    re_unref(re);
+    return NULL;
+}
+
+static struct re *parse_regexp(struct re_parse *parse) {
+    struct re *re = NULL;
+
+    /* Something like (|r) */
+    if (peek(parse, "|"))
+        re = make_re(EPSILON);
+    else
+        re = parse_concat_exp(parse);
+    if (re == NULL)
+        goto error;
+
+    if (match(parse, '|')) {
+        struct re *re2 = NULL;
+        /* Something like (r|) */
+        if (peek(parse, ")"))
+            re2 = make_re(EPSILON);
+        else
+            re2 = parse_regexp(parse);
+        if (re2 == NULL)
+            goto error;
+
+        re = make_re_binop(UNION, re, re2);
+        if (re == NULL) {
+            parse->error = REG_ESPACE;
+            goto error;
+        }
+    }
+    return re;
+
+ error:
+    re_unref(re);
+    return NULL;
+}
+
+/*
+ * Convert a STRUCT RE to a string. Code is complicated by the fact that
+ * we try to be clever and avoid unneeded parens and concatenation with
+ * epsilon etc.
+ */
+static int re_as_string(const struct re *re, struct re_str *str);
+
+static int re_binop_count(enum re_type type, const struct re *re) {
+    assert(type == CONCAT || type == UNION);
+    if (re->type == type) {
+        return re_binop_count(type, re->exp1) + re_binop_count(type, re->exp2);
+    } else {
+        return 1;
+    }
+}
+
+static int re_binop_store(enum re_type type, const struct re *re,
+                          const struct re **list) {
+    int pos = 0;
+    if (type == re->type) {
+        pos = re_binop_store(type, re->exp1, list);
+        pos += re_binop_store(type, re->exp2, list + pos);
+    } else {
+        list[0] = re;
+        pos = 1;
+    }
+    return pos;
+}
+
+static int re_union_as_string(const struct re *re, struct re_str *str) {
+    assert(re->type == UNION);
+
+    int result = -1;
+    const struct re **res = NULL;
+    struct re_str *strings = NULL;
+    int nre = 0, r;
+
+    nre = re_binop_count(re->type, re);
+    r = ALLOC_N(res, nre);
+    if (r < 0)
+        goto done;
+
+    re_binop_store(re->type, re, res);
+
+    r = ALLOC_N(strings, nre);
+    if (r < 0)
+        goto error;
+
+    str->len = 0;
+    for (int i=0; i < nre; i++) {
+        if (re_as_string(res[i], strings + i) < 0)
+            goto error;
+        str->len += strings[i].len;
+    }
+    str->len += nre-1;
+
+    r = re_str_alloc(str);
+    if (r < 0)
+        goto error;
+
+    char *p = str->rx;
+    for (int i=0; i < nre; i++) {
+        if (i>0)
+            *p++ = '|';
+        memcpy(p, strings[i].rx, strings[i].len);
+        p += strings[i].len;
+    }
+
+    result = 0;
+ done:
+    free(res);
+    if (strings != NULL) {
+        for (int i=0; i < nre; i++)
+            release_re_str(strings + i);
+    }
+    free(strings);
+    return result;
+ error:
+    release_re_str(str);
+    result = -1;
+    goto done;
+}
+
+ATTRIBUTE_PURE
+static int re_needs_parens_in_concat(const struct re *re) {
+    return (re->type != CHAR && re->type != CSET && re->type != ITER);
+}
+
+static int re_concat_as_string(const struct re *re, struct re_str *str) {
+    assert(re->type == CONCAT);
+
+    const struct re **res = NULL;
+    struct re_str *strings = NULL;
+    int nre = 0, r;
+    int result = -1;
+
+    nre = re_binop_count(re->type, re);
+    r = ALLOC_N(res, nre);
+    if (r < 0)
+        goto error;
+    re_binop_store(re->type, re, res);
+
+    r = ALLOC_N(strings, nre);
+    if (r < 0)
+        goto error;
+
+    str->len = 0;
+    for (int i=0; i < nre; i++) {
+        if (res[i]->type == EPSILON)
+            continue;
+        if (re_as_string(res[i], strings + i) < 0)
+            goto error;
+        str->len += strings[i].len;
+        if (re_needs_parens_in_concat(res[i]))
+            str->len += 2;
+    }
+
+    r = re_str_alloc(str);
+    if (r < 0)
+        goto error;
+
+    char *p = str->rx;
+    for (int i=0; i < nre; i++) {
+        if (res[i]->type == EPSILON)
+            continue;
+        if (re_needs_parens_in_concat(res[i]))
+            *p++ = '(';
+        p = memcpy(p, strings[i].rx, strings[i].len);
+        p += strings[i].len;
+        if (re_needs_parens_in_concat(res[i]))
+            *p++ = ')';
+    }
+
+    result = 0;
+ done:
+    free(res);
+    if (strings != NULL) {
+        for (int i=0; i < nre; i++)
+            release_re_str(strings + i);
+    }
+    free(strings);
+    return result;
+ error:
+    release_re_str(str);
+    result = -1;
+    goto done;
+}
+
+static bool cset_contains(const struct re *cset, int c) {
+    return bitset_get(cset->cset, c) != cset->negate;
+}
+
+static int re_cset_as_string(const struct re *re, struct re_str *str) {
+    const uchar rbrack = ']';
+    const uchar dash = '-';
+    const uchar nul = '\0';
+
+    static const char *const empty_set = "[]";
+    static const char *const total_set = "(.|\n)";
+    static const char *const not_newline = ".";
+
+    char *s;
+    int from, to, negate;
+    size_t len;
+    int incl_rbrack, incl_dash;
+    int r;
+
+    str->len = strlen(empty_set);
+
+    /* We can not include NUL explicitly in a CSET since we use ordinary
+       NUL delimited strings to represent them. That means that we need to
+       use negated representation if NUL is to be included (and vice versa)
+    */
+    negate = cset_contains(re, nul);
+    if (negate) {
+        for (from = UCHAR_MIN;
+             from <= UCHAR_MAX && cset_contains(re, from);
+             from += 1);
+        if (from > UCHAR_MAX) {
+            /* Special case: the set matches every character */
+            str->rx = strdup(total_set);
+            goto done;
+        }
+        if (from == '\n') {
+            for (from += 1;
+                 from <= UCHAR_MAX && cset_contains(re, from);
+                 from += 1);
+            if (from > UCHAR_MAX) {
+                /* Special case: the set matches everything but '\n' */
+                str->rx = strdup(not_newline);
+                goto done;
+            }
+        }
+    }
+
+    /* See if ']' and '-' will be explicitly included in the character set
+       (INCL_RBRACK, INCL_DASH) As we loop over the character set, we reset
+       these flags if they are in the set, but not mentioned explicitly
+    */
+    incl_rbrack = cset_contains(re, rbrack) != negate;
+    incl_dash = cset_contains(re, dash) != negate;
+
+    if (re->no_ranges) {
+        for (from = UCHAR_MIN; from <= UCHAR_MAX; from++)
+            if (cset_contains(re, from) != negate)
+                str->len += 1;
+    } else {
+        for (from = UCHAR_MIN; from <= UCHAR_MAX; from = to+1) {
+            while (from <= UCHAR_MAX && cset_contains(re, from) == negate)
+                from += 1;
+            if (from > UCHAR_MAX)
+                break;
+            for (to = from;
+                 to < UCHAR_MAX && (cset_contains(re, to+1) != negate);
+                 to++);
+
+            if (to == from && (from == rbrack || from == dash))
+                continue;
+            if (from == rbrack || from == dash)
+                from += 1;
+            if (to == rbrack || to == dash)
+                to -= 1;
+
+            len = (to == from) ? 1 : ((to == from + 1) ? 2 : 3);
+
+            if (from < rbrack && rbrack < to)
+                incl_rbrack = 0;
+            if (from < dash && dash < to)
+                incl_dash = 0;
+            str->len += len;
+        }
+        str->len += incl_rbrack + incl_dash;
+    }
+    if (negate)
+        str->len += 1;        /* For the ^ */
+
+    r = re_str_alloc(str);
+    if (r < 0)
+        goto error;
+
+    s = str->rx;
+    *s++ = '[';
+    if (negate)
+        *s++ = '^';
+    if (incl_rbrack)
+        *s++ = rbrack;
+
+    if (re->no_ranges) {
+        for (from = UCHAR_MIN; from <= UCHAR_MAX; from++) {
+            if (from == rbrack || from == dash)
+                continue;
+            if (cset_contains(re, from) != negate)
+                *s++ = from;
+        }
+    } else {
+        for (from = UCHAR_MIN; from <= UCHAR_MAX; from = to+1) {
+            while (from <= UCHAR_MAX && cset_contains(re, from) == negate)
+                from += 1;
+            if (from > UCHAR_MAX)
+                break;
+            for (to = from;
+                 to < UCHAR_MAX && (cset_contains(re, to+1) != negate);
+                 to++);
+
+            if (to == from && (from == rbrack || from == dash))
+                continue;
+            if (from == rbrack || from == dash)
+                from += 1;
+            if (to == rbrack || to == dash)
+                to -= 1;
+
+            if (to == from) {
+                *s++ = from;
+            } else if (to == from + 1) {
+                *s++ = from;
+                *s++ = to;
+            } else {
+                *s++ = from;
+                *s++ = '-';
+                *s++ = to;
+            }
+        }
+    }
+    if (incl_dash)
+        *s++ = dash;
+
+    *s = ']';
+ done:
+    if (str->rx == NULL)
+        goto error;
+    str->len = strlen(str->rx);
+    return 0;
+ error:
+    release_re_str(str);
+    return -1;
+}
+
+static int re_iter_as_string(const struct re *re, struct re_str *str) {
+    const char *quant = NULL;
+    char *iter = NULL;
+    int r, result = -1;
+
+    if (re_as_string(re->exp, str) < 0)
+        return -1;
+
+    if (re->min == 0 && re->max == -1) {
+        quant = "*";
+    } else if (re->min == 1 && re->max == -1) {
+        quant = "+";
+    } else if (re->min == 0 && re->max == 1) {
+        quant = "?";
+    } else if (re->max == -1) {
+        r = asprintf(&iter, "{%d,}", re->min);
+        if (r < 0)
+            return -1;
+        quant = iter;
+    } else {
+        r = asprintf(&iter, "{%d,%d}", re->min, re->max);
+        if (r < 0)
+            return -1;
+        quant = iter;
+    }
+
+    if (re->exp->type == CHAR || re->exp->type == CSET) {
+        if (REALLOC_N(str->rx, str->len + strlen(quant) + 1) < 0)
+            goto error;
+        strcpy(str->rx + str->len, quant);
+        str->len += strlen(quant);
+    } else {
+        /* Format '(' + str->rx ')' + quant */
+        if (REALLOC_N(str->rx, str->len + strlen(quant) + 1 + 2) < 0)
+            goto error;
+        memmove(str->rx + 1, str->rx, str->len);
+        str->rx[0] = '(';
+        str->rx[str->len + 1] = ')';
+        str->len += 2;
+        strcpy(str->rx + str->len, quant);
+        str->len += strlen(quant);
+    }
+
+    result = 0;
+ done:
+    FREE(iter);
+    return result;
+ error:
+    release_re_str(str);
+    goto done;
+}
+
+static int re_as_string(const struct re *re, struct re_str *str) {
+    /* Characters that must be escaped */
+    static const char * const special_chars = ".()[]{}*|+?\\^$";
+    int result = 0;
+
+    switch(re->type) {
+    case UNION:
+        result = re_union_as_string(re, str);
+        break;
+    case CONCAT:
+        result = re_concat_as_string(re, str);
+        break;
+    case CSET:
+        result = re_cset_as_string(re, str);
+        break;
+    case CHAR:
+        if (re->c == '\0' || strchr(special_chars, re->c) == NULL) {
+            if (ALLOC_N(str->rx, 2) < 0)
+                goto error;
+            str->rx[0] = re->c;
+            str->len = 1;
+        } else {
+            if (ALLOC_N(str->rx, 3) < 0)
+                goto error;
+            str->rx[0] = '\\';
+            str->rx[1] = re->c;
+            str->len = strlen(str->rx);
+        }
+        break;
+    case ITER:
+        result = re_iter_as_string(re, str);
+        break;
+    case EPSILON:
+        if (ALLOC_N(str->rx, 3) < 0)
+            goto error;
+        strcpy(str->rx, "()");
+        str->len = strlen(str->rx);
+        break;
+    default:
+        assert(0);
+        abort();
+        break;
+    }
+    return result;
+ error:
+    release_re_str(str);
+    return -1;
+}
+
+static int convert_trans_to_re(struct state *s) {
+    struct re *re = NULL;
+    size_t nto = 1;
+    struct trans *trans = NULL;
+    int r;
+
+    if (s->tused == 0)
+        return 0;
+
+    qsort(s->trans, s->tused, sizeof(*s->trans), trans_to_cmp);
+    for (int i = 0; i < s->tused - 1; i++) {
+        if (s->trans[i].to != s->trans[i+1].to)
+            nto += 1;
+    }
+    r = ALLOC_N(trans, nto);
+    if (r < 0)
+        goto error;
+
+    struct state *to = s->trans[0].to;
+    int tind = 0;
+    for_each_trans(t, s) {
+        if (t->to != to) {
+            trans[tind].to = to;
+            trans[tind].re = re;
+            tind += 1;
+            re = NULL;
+            to = t->to;
+        }
+        if (re == NULL) {
+            re = make_re_char_set(0, 0);
+            if (re == NULL)
+                goto error;
+        }
+        add_re_char(re, t->min, t->max);
+    }
+    assert(nto == tind + 1);
+    trans[tind].to = to;
+    trans[tind].re = re;
+
+    /* Simplify CSETs with a single char to a CHAR */
+    for (int t=0; t < nto; t++) {
+        int cnt = 0;
+        uchar chr = UCHAR_MIN;
+        for (int c = 0; c < UCHAR_NUM; c++) {
+            if (bitset_get(trans[t].re->cset, c)) {
+                cnt += 1;
+                chr = c;
+            }
+        }
+        if (cnt == 1) {
+            re_unref(trans[t].re);
+            trans[t].re = make_re_char(chr);
+            if (trans[t].re == NULL)
+                goto error;
+        }
+    }
+    free_trans(s);
+    s->trans = trans;
+    s->tused = s->tsize = nto;
+    return 0;
+
+ error:
+    if (trans)
+        for (int i=0; i < nto; i++)
+            unref(trans[i].re, re);
+    free(trans);
+    return -1;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int add_new_re_trans(struct state *s1, struct state *s2,
+                            struct re *re) {
+    int r;
+    r = add_new_trans(s1, s2, 0, 0);
+    if (r < 0)
+        return -1;
+    last_trans(s1)->re = re;
+    return 0;
+}
+
+/* Add the regular expression R1 . LOOP* . R2 to the transition
+   from S1 to S2. */
+static int re_collapse_trans(struct state *s1, struct state *s2,
+                             struct re *r1, struct re *loop, struct re *r2) {
+    struct re *re = NULL;
+
+    if (loop->type != EPSILON) {
+        loop = make_re_rep(ref(loop), 0, -1);
+        if (loop == NULL)
+            goto error;
+    }
+
+    if (r1->type == EPSILON) {
+        if (loop->type == EPSILON) {
+            re = ref(r2);
+        } else {
+            re = make_re_binop(CONCAT, loop, ref(r2));
+        }
+    } else {
+        if (loop->type == EPSILON) {
+            if (r2->type == EPSILON) {
+                re = ref(r1);
+            } else {
+                re = make_re_binop(CONCAT, ref(r1), ref(r2));
+            }
+        } else {
+            re = make_re_binop(CONCAT, ref(r1), loop);
+            if (re != NULL && r2->type != EPSILON) {
+                re = make_re_binop(CONCAT, re, ref(r2));
+            }
+        }
+    }
+    if (re == NULL)
+        goto error;
+
+    struct trans *t = NULL;
+    for (t = s1->trans; t <= last_trans(s1) && t->to != s2; t += 1);
+    if (t > last_trans(s1)) {
+        if (add_new_re_trans(s1, s2, re) < 0)
+            goto error;
+    } else {
+        if (t->re == NULL) {
+            t->re = re;
+        } else {
+            t->re = make_re_binop(UNION, re, t->re);
+            if (t->re == NULL)
+                goto error;
+        }
+    }
+    return 0;
+ error:
+    // FIXME: make sure we don't leak loop
+    return -1;
+}
+
+static int convert_strings(struct fa *fa) {
+    struct state_set *worklist = state_set_init(-1, S_NONE);
+    int result = -1;
+
+    E(worklist == NULL);
+
+    /* Abuse hash to count indegree, reachable to mark visited states */
+    list_for_each(s, fa->initial) {
+        s->hash = 0;
+        s->reachable = 0;
+    }
+
+    list_for_each(s, fa->initial) {
+        for_each_trans(t, s) {
+            t->to->hash += 1;
+        }
+    }
+
+    for (struct state *s = fa->initial;
+         s != NULL;
+         s = state_set_pop(worklist)) {
+        for (int i=0; i < s->tused; i++) {
+            struct trans *t = s->trans + i;
+            struct state *to = t->to;
+            while (to->hash == 1 && to->tused == 1 && ! to->accept) {
+                if (t->re == NULL) {
+                    t->re = to->trans->re;
+                    to->trans->re = NULL;
+                } else {
+                    t->re = make_re_binop(CONCAT, t->re, to->trans->re);
+                    if (t->re == NULL)
+                        goto error;
+                }
+                t->to = to->trans->to;
+                to->tused = 0;
+                to->hash -= 1;
+                to = t->to;
+                for (int j=0; j < s->tused; j++) {
+                    if (j != i && s->trans[j].to == to) {
+                        /* Combine transitions i and j; remove trans j */
+                        t->re = make_re_binop(UNION, t->re, s->trans[j].re);
+                        if (t->re == NULL)
+                            goto error;
+                        memmove(s->trans + j, s->trans + j + 1,
+                                sizeof(s->trans[j]) * (s->tused - j - 1));
+                        to->hash -= 1;
+                        s->tused -= 1;
+                        if (j < i) {
+                            i = i - 1;
+                            t = s->trans + i;
+                        }
+                    }
+                }
+            }
+
+            if (! to->reachable) {
+                to->reachable = 1;
+                F(state_set_push(worklist, to));
+            }
+        }
+    }
+
+    for (struct state *s = fa->initial; s->next != NULL; ) {
+        if (s->next->hash == 0 && s->next->tused == 0) {
+            struct state *del = s->next;
+            s->next = del->next;
+            free(del->trans);
+            free(del);
+        } else {
+            s = s->next;
+        }
+    }
+    result = 0;
+
+ error:
+    state_set_free(worklist);
+    return result;
+}
+
+/* Convert an FA to a regular expression.
+ * The strategy is the following:
+ * (1) For all states S1 and S2, convert the transitions between them
+ *     into one transition whose regexp is a CSET
+ * (2) Add a new initial state INI and a new final state FIN to the automaton,
+ *     a transition from INI to the old initial state of FA, and a transition
+ *     from all accepting states of FA to FIN; the regexp on those transitions
+ *     matches only the empty word
+ * (3) Eliminate states S (except for INI and FIN) one by one:
+ *     Let LOOP the regexp for the transition S -> S if it exists, epsilon
+ *     otherwise.
+ *     For all S1, S2 different from S with S1 -> S -> S2
+ *       Let R1 the regexp of S1 -> S
+ *           R2 the regexp of S -> S2
+ *           R3 the regexp S1 -> S2 (or epsilon if no such transition)
+ *        set the regexp on the transition S1 -> S2 to
+ *          R1 . (LOOP)* . R2 | R3
+ * (4) The regexp for the whole FA can now be found as the regexp of
+ *     the transition INI -> FIN
+ * (5) Convert that STRUCT RE to a string with RE_AS_STRING
+ */
+int fa_as_regexp(struct fa *fa, char **regexp, size_t *regexp_len) {
+    int r;
+    struct state *fin = NULL, *ini = NULL;
+    struct re *eps = NULL;
+
+    *regexp = NULL;
+    *regexp_len = 0;
+    fa = fa_clone(fa);
+    if (fa == NULL)
+        goto error;
+
+    eps = make_re(EPSILON);
+    if (eps == NULL)
+        goto error;
+
+    fin = add_state(fa,1);
+    if (fin == NULL)
+        goto error;
+
+    fa->trans_re = 1;
+
+    list_for_each(s, fa->initial) {
+        r = convert_trans_to_re(s);
+        if (r < 0)
+            goto error;
+        if (s->accept && s != fin) {
+            r = add_new_re_trans(s, fin, ref(eps));
+            if (r < 0)
+                goto error;
+            s->accept = 0;
+        }
+    }
+
+    ini = add_state(fa, 0);
+    if (ini == NULL)
+        goto error;
+
+    r = add_new_re_trans(ini, fa->initial, ref(eps));
+    if (r < 0)
+        goto error;
+    set_initial(fa, ini);
+
+    convert_strings(fa);
+
+    list_for_each(s, fa->initial->next) {
+        if (s == fin)
+            continue;
+        /* Eliminate S */
+        struct re *loop = eps;
+        for_each_trans(t, s) {
+            if (t->to == s)
+                loop = t->re;
+        }
+        list_for_each(s1, fa->initial) {
+            if (s == s1)
+                continue;
+            for (int t1 = 0; t1 < s1->tused; t1++) {
+                if (s1->trans[t1].to == s) {
+                    for (int t = 0; t < s->tused; t++) {
+                        if (s->trans[t].to == s)
+                            continue;
+                        r = re_collapse_trans(s1, s->trans[t].to,
+                                              s1->trans[t1].re,
+                                              loop,
+                                              s->trans[t].re);
+                        if (r < 0)
+                            goto error;
+                    }
+                }
+            }
+        }
+    }
+
+    re_unref(eps);
+
+    for_each_trans(t, fa->initial) {
+        if (t->to == fin) {
+            struct re_str str;
+            MEMZERO(&str, 1);
+            if (re_as_string(t->re, &str) < 0)
+                goto error;
+            *regexp = str.rx;
+            *regexp_len = str.len;
+        }
+    }
+
+    list_for_each(s, fa->initial) {
+        for_each_trans(t, s) {
+            unref(t->re, re);
+        }
+    }
+    fa_free(fa);
+
+    return 0;
+ error:
+    fa_free(fa);
+    re_unref(eps);
+    return -1;
+}
+
+static int re_restrict_alphabet(struct re *re, uchar from, uchar to) {
+    int r1, r2;
+    int result = 0;
+
+    switch(re->type) {
+    case UNION:
+    case CONCAT:
+        r1 = re_restrict_alphabet(re->exp1, from, to);
+        r2 = re_restrict_alphabet(re->exp2, from, to);
+        result = (r1 != 0) ? r1 : r2;
+        break;
+    case CSET:
+        if (re->negate) {
+            re->negate = 0;
+            bitset_negate(re->cset, UCHAR_NUM);
+        }
+        for (int i=from; i <= to; i++)
+            bitset_clr(re->cset, i);
+        break;
+    case CHAR:
+        if (from <= re->c && re->c <= to)
+            result = -1;
+        break;
+    case ITER:
+        result = re_restrict_alphabet(re->exp, from, to);
+        break;
+    case EPSILON:
+        break;
+    default:
+        assert(0);
+        abort();
+        break;
+    }
+    return result;
+}
+
+int fa_restrict_alphabet(const char *regexp, size_t regexp_len,
+                         char **newregexp, size_t *newregexp_len,
+                         char from, char to) {
+    int result;
+    struct re *re = NULL;
+    struct re_parse parse;
+    struct re_str str;
+
+    *newregexp = NULL;
+    MEMZERO(&parse, 1);
+    parse.rx = regexp;
+    parse.rend = regexp + regexp_len;
+    parse.error = REG_NOERROR;
+    re = parse_regexp(&parse);
+    if (parse.error != REG_NOERROR)
+        return parse.error;
+
+    result = re_restrict_alphabet(re, from, to);
+    if (result != 0) {
+        result = -2;
+        goto done;
+    }
+
+    MEMZERO(&str, 1);
+    result = re_as_string(re, &str);
+    *newregexp = str.rx;
+    *newregexp_len = str.len;
+ done:
+    re_unref(re);
+    return result;
+}
+
+int fa_expand_char_ranges(const char *regexp, size_t regexp_len,
+                          char **newregexp, size_t *newregexp_len) {
+    int result;
+    struct re *re = NULL;
+    struct re_parse parse;
+    struct re_str str;
+
+    *newregexp = NULL;
+    MEMZERO(&parse, 1);
+    parse.rx = regexp;
+    parse.rend = regexp + regexp_len;
+    parse.error = REG_NOERROR;
+    parse.no_ranges = 1;
+    re = parse_regexp(&parse);
+    if (parse.error != REG_NOERROR)
+        return parse.error;
+
+    MEMZERO(&str, 1);
+    result = re_as_string(re, &str);
+    *newregexp = str.rx;
+    *newregexp_len = str.len;
+    re_unref(re);
+    return result;
+}
+
+/* Expand regexp so that it is case-insensitive in a case-sensitive match.
+ *
+ * Return 1 when a change was made, -1 when an allocation failed, and 0
+ * when no change was made.
+ */
+static int re_case_expand(struct re *re) {
+    int result = 0, r1, r2;
+
+    switch(re->type) {
+    case UNION:
+    case CONCAT:
+        r1 = re_case_expand(re->exp1);
+        r2 = re_case_expand(re->exp2);
+        result = (r1 != 0) ? r1 : r2;
+        break;
+    case CSET:
+        for (int c = 'A'; c <= 'Z'; c++)
+            if (bitset_get(re->cset, c)) {
+                result = 1;
+                bitset_set(re->cset, tolower(c));
+            }
+        for (int c = 'a'; c <= 'z'; c++)
+            if (bitset_get(re->cset, c)) {
+                result = 1;
+                bitset_set(re->cset, toupper(c));
+            }
+        break;
+    case CHAR:
+        if (isalpha(re->c)) {
+            int c = re->c;
+            re->type = CSET;
+            re->negate = false;
+            re->no_ranges = 0;
+            re->cset = bitset_init(UCHAR_NUM);
+            if (re->cset == NULL)
+                return -1;
+            bitset_set(re->cset, tolower(c));
+            bitset_set(re->cset, toupper(c));
+            result = 1;
+        }
+        break;
+    case ITER:
+        result = re_case_expand(re->exp);
+        break;
+    case EPSILON:
+        break;
+    default:
+        assert(0);
+        abort();
+        break;
+    }
+    return result;
+}
+
+int fa_expand_nocase(const char *regexp, size_t regexp_len,
+                     char **newregexp, size_t *newregexp_len) {
+    int result, r;
+    struct re *re = NULL;
+    struct re_parse parse;
+    struct re_str str;
+
+    *newregexp = NULL;
+    MEMZERO(&parse, 1);
+    parse.rx = regexp;
+    parse.rend = regexp + regexp_len;
+    parse.error = REG_NOERROR;
+    re = parse_regexp(&parse);
+    if (parse.error != REG_NOERROR)
+        return parse.error;
+
+    r = re_case_expand(re);
+    if (r < 0) {
+        re_unref(re);
+        return REG_ESPACE;
+    }
+
+    if (r == 1) {
+        MEMZERO(&str, 1);
+        result = re_as_string(re, &str);
+        *newregexp = str.rx;
+        *newregexp_len = str.len;
+    } else {
+        *newregexp = strndup(regexp, regexp_len);
+        *newregexp_len = regexp_len;
+        result = (*newregexp == NULL) ? REG_ESPACE : REG_NOERROR;
+    }
+    re_unref(re);
+    return result;
+}
+
+static void print_char(FILE *out, uchar c) {
+    /* We escape '/' as '\\/' since dot chokes on bare slashes in labels;
+       Also, a space ' ' is shown as '\s' */
+    static const char *const escape_from = " \n\t\v\b\r\f\a/\0";
+    static const char *const escape_to = "sntvbrfa/0";
+    char *p = strchr(escape_from, c);
+    if (p != NULL) {
+        int i = p - escape_from;
+        fprintf(out, "\\\\%c", escape_to[i]);
+    } else if (! isprint(c)) {
+        fprintf(out, "\\\\0%03o", (unsigned char) c);
+    } else if (c == '"') {
+        fprintf(out, "\\\"");
+    } else {
+        fputc(c, out);
+    }
+}
+
+void fa_dot(FILE *out, struct fa *fa) {
+    fprintf(out, "digraph {\n  rankdir=LR;");
+    list_for_each(s, fa->initial) {
+        if (s->accept) {
+            fprintf(out, "\"%p\" [shape=doublecircle];\n", s);
+        } else {
+            fprintf(out, "\"%p\" [shape=circle];\n", s);
+        }
+    }
+    fprintf(out, "%s -> \"%p\";\n", fa->deterministic ? "dfa" : "nfa",
+            fa->initial);
+
+    struct re_str str;
+    MEMZERO(&str, 1);
+    list_for_each(s, fa->initial) {
+        for_each_trans(t, s) {
+            fprintf(out, "\"%p\" -> \"%p\" [ label = \"", s, t->to);
+            if (fa->trans_re) {
+                re_as_string(t->re, &str);
+                for (int i=0; i < str.len; i++) {
+                    print_char(out, str.rx[i]);
+                }
+                release_re_str(&str);
+            } else {
+                print_char(out, t->min);
+                if (t->min != t->max) {
+                    fputc('-', out);
+                    print_char(out, t->max);
+                }
+            }
+            fprintf(out, "\" ];\n");
+        }
+    }
+    fprintf(out, "}\n");
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/fa.h b/src/fa.h
new file mode 100644 (file)
index 0000000..ce97eb6
--- /dev/null
+++ b/src/fa.h
@@ -0,0 +1,267 @@
+/*
+ * fa.h: finite automata
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef FA_H_
+#define FA_H_
+
+#include <stdio.h>
+#include <regex.h>
+
+/* The type for a finite automaton. */
+struct fa;
+
+/* Denote some basic automata, used by fa_is_basic and fa_make_basic */
+enum fa_basic {
+    FA_EMPTY,        /* Accepts the empty language, i.e. no strings */
+    FA_EPSILON,      /* Accepts only the empty word */
+    FA_TOTAL         /* Accepts all words */
+};
+
+/* Choice of minimization algorithm to use; either Hopcroft's O(n log(n))
+ * algorithm or Brzozowski's reverse-determinize-reverse-determinize
+ * algorithm. While the latter has exponential complexity in theory, it
+ * works quite well for some cases.
+ */
+enum fa_minimization_algorithms {
+    FA_MIN_HOPCROFT,
+    FA_MIN_BRZOZOWSKI
+};
+
+/* Which minimization algorithm to use in FA_MINIMIZE. The library
+ * minimizes internally at certain points, too.
+ *
+ * Defaults to FA_MIN_HOPCROFT
+ */
+extern int fa_minimization_algorithm;
+
+/* Unless otherwise mentioned, automata passed into routines are never
+ * modified. It is the responsibility of the caller to free automata
+ * returned by any of these routines when they are no longer needed.
+ */
+
+/*
+ * Compile the regular expression RE of length SIZE into an automaton. The
+ * return value is the same as the return value for the POSIX function
+ * regcomp. The syntax for regular expressions is extended POSIX syntax,
+ * with the difference that '.' does not match newlines.
+ *
+ * On success, FA points to the newly allocated automaton constructed for
+ * RE, and the function returns REG_NOERROR. Otherwise, FA is NULL, and the
+ * return value indicates the error.
+ *
+ * The FA is case sensitive. Call FA_NOCASE to switch it to
+ * case-insensitive.
+ */
+int fa_compile(const char *re, size_t size, struct fa **fa);
+
+/* Make a new automaton that accepts one of the basic languages defined in
+ * the enum FA_BASIC.
+ */
+struct fa *fa_make_basic(unsigned int basic);
+
+/* Return 1 if FA accepts the basic language BASIC, which must be one of
+ * the constantsfrom enum FA_BASIC.
+ */
+int fa_is_basic(struct fa *fa, unsigned int basic);
+
+/* Minimize FA using Brzozowski's algorithm. As a side-effect, the
+ * automaton will also be deterministic after being minimized. Modifies the
+ * automaton in place.
+ */
+int fa_minimize(struct fa *fa);
+
+/* Return a finite automaton that accepts the concatenation of the
+ * languages for FA1 and FA2, i.e. L(FA1).L(FA2)
+ */
+struct fa *fa_concat(struct fa *fa1, struct fa *fa2);
+
+/* Return a finite automaton that accepts the union of the languages that
+ * FA1 and FA2 accept (the '|' operator in regular expressions).
+ */
+struct fa *fa_union(struct fa *fa1, struct fa *fa2);
+
+/* Return a finite automaton that accepts the intersection of the languages
+ * of FA1 and FA2.
+ */
+struct fa *fa_intersect(struct fa *fa1, struct fa *fa2);
+
+/* Return a finite automaton that accepts the complement of the language of
+ * FA, i.e. the set of all words not accepted by FA
+ */
+struct fa *fa_complement(struct fa *fa);
+
+/* Return a finite automaton that accepts the set difference of the
+ * languages of FA1 and FA2, i.e. L(FA1)\L(FA2)
+ */
+struct fa *fa_minus(struct fa *fa1, struct fa *fa2);
+
+/* Return a finite automaton that accepts a repetition of the language that
+ * FA accepts. If MAX == -1, the returned automaton accepts arbitrarily
+ * long repetitions. MIN must be 0 or bigger, and unless MAX == -1, MIN
+ * must be less or equal to MAX. If MIN is greater than 0, the returned
+ * automaton accepts only words that have at least MIN repetitions of words
+ * from L(FA).
+ *
+ * The following common regexp repetitios are achieved by the following
+ * calls (using a lose notation equating automata and their languages):
+ *
+ * - FA* = FA_ITER(FA, 0, -1)
+ * - FA+ = FA_ITER(FA, 1, -1)
+ * - FA? = FA_ITER(FA, 0, 1)
+ * - FA{n,m} = FA_ITER(FA, n, m) with 0 <= n and m = -1 or n <= m
+ */
+struct fa *fa_iter(struct fa *fa, int min, int max);
+
+/* Return 1 if the language of FA1 is contained in the language of FA2, 0
+ * otherwise.
+ */
+int fa_contains(struct fa *fa1, struct fa *fa2);
+
+/* Return 1 if the language of FA1 equals the language of FA2 */
+int fa_equals(struct fa *fa1, struct fa *fa2);
+
+/* Free all memory used by FA */
+void fa_free(struct fa *fa);
+
+/* Print FA to OUT as a graphviz dot file */
+void fa_dot(FILE *out, struct fa *fa);
+
+/* Return a finite automaton that accepts the overlap of the languages of
+ * FA1 and FA2. The overlap of two languages is the set of strings that can
+ * be split in more than one way into a left part accepted by FA1 and a
+ * right part accepted by FA2.
+ */
+struct fa *fa_overlap(struct fa *fa1, struct fa *fa2);
+
+/* Produce an example for the language of FA. The example is not
+ * necessarily the shortest possible. The implementation works very hard to
+ * have printable characters (preferrably alphanumeric) in the example, and
+ * to avoid just an empty word.
+ *
+ * *EXAMPLE will be the example, which may be NULL. If it is non-NULL,
+ *  EXAMPLE_LEN will hold the length of the example.
+ *
+ * Return 0 on success, and a negative numer on error. On error, *EXAMPLE
+ * will be NULL
+ */
+int fa_example(struct fa *fa, char **example, size_t *example_len);
+
+/* Produce an example of an ambiguous word for the concatenation of the
+ * languages of FA1 and FA2. The return value is such a word (which must be
+ * freed by the caller) if it exists. If none exists, NULL is returned.
+ *
+ * The returned word is of the form UPV and PV and V are set to the first
+ * character of P and V in the returned word. The word UPV has the property
+ * that U and UP are accepted by FA1 and that PV and V are accepted by FA2.
+ *
+ * Neither the language of FA1 or of FA2 may contain words with the
+ * characters '\001' and '\002', as they are used during construction of
+ * the ambiguous word.
+ *
+ * UPV_LEN will be set to the length of the entire string UPV
+ *
+ * Returns 0 on success, and a negative number on failure. On failure, UPV,
+ * PV, and V will be NULL
+ */
+int fa_ambig_example(struct fa *fa1, struct fa *fa2,
+                     char **upv, size_t *upv_len,
+                     char **pv, char **v);
+
+/* Convert the finite automaton FA into a regular expression and set REGEXP
+ * to point to that. When REGEXP is compiled into another automaton, it is
+ * guaranteed that that automaton and FA accept the same language.
+ *
+ * The code tries to be semi-clever about keeping the generated regular
+ * expression short; to guarantee reasonably short regexps, the automaton
+ * should be minimized before passing it to this routine.
+ *
+ * On success, REGEXP_LEN is set to the length of REGEXP
+ *
+ * Return 0 on success, and a negative number on failure. The only reason
+ * to fail for FA_AS_REGEXP is running out of memory.
+ */
+int fa_as_regexp(struct fa *fa, char **regexp, size_t *regexp_len);
+
+/* Given the regular expression REGEXP construct a new regular expression
+ * NEWREGEXP that does not match strings containing any of the characters
+ * in the range FROM to TO, with the endpoints included.
+ *
+ * The new regular expression is constructed by removing the range FROM to
+ * TO from all character sets in REGEXP; if any of the characters [FROM,
+ * TO] appear outside a character set in REGEXP, return -2.
+ *
+ * Return 0 if NEWREGEXP was constructed successfully, -1 if an internal
+ * error happened (e.g., an allocation failed) and -2 if NEWREGEXP can not
+ * be constructed because any character in the range [FROM, TO] appears
+ * outside of a character set.
+ *
+ * Return a positive value if REGEXP is not syntactically valid; the value
+ * returned is one of the REG_ERRCODE_T POSIX error codes. Return 0 on
+ * success and -1 if an allocation fails.
+ */
+int fa_restrict_alphabet(const char *regexp, size_t regexp_len,
+                         char **newregexp, size_t *newregexp_len,
+                         char from, char to);
+
+/* Convert REGEXP into one that does not use ranges inside character
+ * classes.
+ *
+ * Return a positive value if REGEXP is not syntactically valid; the value
+ * returned is one of the REG_ERRCODE_T POSIX error codes. Return 0 on
+ * success and -1 if an allocation fails.
+ */
+int fa_expand_char_ranges(const char *regexp, size_t regexp_len,
+                          char **newregexp, size_t *newregexp_len);
+
+/* Modify FA so that it matches ignoring case.
+ *
+ * Returns 0 on success, and -1 if an allocation fails. On failure, the
+ * automaton is not guaranteed to represent anything sensible.
+ */
+int fa_nocase(struct fa *fa);
+
+/* Return 1 if FA matches ignoring case, 0 if matches are case sensitive */
+int fa_is_nocase(struct fa *fa);
+
+/* Assume REGEXP is a case-insensitive regular expression, and convert it
+ * to one that matches the same strings when used case sensitively. All
+ * occurrences of individual letters c in the regular expression will be
+ * replaced by character sets [cC], and lower/upper case characters are
+ * added to character sets as needed.
+ *
+ * Return a positive value if REGEXP is not syntactically valid; the value
+ * returned is one of the REG_ERRCODE_T POSIX error codes. Return 0 on
+ * success and -1 if an allocation fails.
+ */
+int fa_expand_nocase(const char *regexp, size_t regexp_len,
+                     char **newregexp, size_t *newregexp_len);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/fa_sym.version b/src/fa_sym.version
new file mode 100644 (file)
index 0000000..5d513e9
--- /dev/null
@@ -0,0 +1,31 @@
+FA_1.0.0 {
+    global:
+      fa_minimization_algorithm;
+      fa_compile;
+      fa_make_basic;
+      fa_is_basic;
+      fa_minimize;
+      fa_concat;
+      fa_union;
+      fa_intersect;
+      fa_complement;
+      fa_minus;
+      fa_iter;
+      fa_contains;
+      fa_equals;
+      fa_free;
+      fa_dot;
+      fa_overlap;
+      fa_example;
+      fa_ambig_example;
+      fa_as_regexp;
+      fa_restrict_alphabet;
+      fa_expand_char_ranges;
+    local: *;
+};
+
+FA_1.2.0 {
+      fa_nocase;
+      fa_is_nocase;
+      fa_expand_nocase;
+} FA_1.0.0;
diff --git a/src/get.c b/src/get.c
new file mode 100644 (file)
index 0000000..18947ef
--- /dev/null
+++ b/src/get.c
@@ -0,0 +1,1454 @@
+/*
+ * parser.c: parse a configuration file according to a grammar
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <regex.h>
+#include <stdarg.h>
+
+#include "regexp.h"
+#include "list.h"
+#include "internal.h"
+#include "memory.h"
+#include "info.h"
+#include "lens.h"
+#include "errcode.h"
+
+/* Our favorite error message */
+static const char *const short_iteration =
+    "Iterated lens matched less than it should";
+
+struct seq {
+    struct seq *next;
+    const char *name;
+    int value;
+};
+
+struct state {
+    struct info      *info;
+    struct span      *span;
+    const char       *text;
+    struct seq       *seqs;
+    char             *key;
+    char             *value;     /* GET_STORE leaves a value here */
+    char             *square;    /* last L_DEL from L_SQUARE */
+    struct lns_error *error;
+    /* We use the registers from a regular expression match to keep track
+     * of the substring we are currently looking at. REGS are the registers
+     * from the last regexp match; NREG is the number of the register
+     * in REGS that describes the substring we are currently looking at.
+     *
+     * We adjust NREG as we traverse lenses either because we know the
+     * grouping structure of lenses (for L_STAR, the child lens is always
+     * in NREG + 1) or by looking at the number of groups in a sublens (as
+     * we move from one child of L_CONCAT to the next, we need to add 1 +
+     * number of groups of that child to NREG) How NREG is adjusted is
+     * closely related to how the REGEXP_* routines build up bigger regexps
+     * from smaller ones.
+     */
+    struct re_registers *regs;
+    uint                 nreg;
+};
+
+/* Used by recursive lenses to stack intermediate results */
+struct frame {
+    struct lens     *lens;
+    char            *key;
+    char            *square;
+    struct span     *span;
+    union {
+        struct { /* MGET */
+            char        *value;
+            struct tree *tree;
+        };
+        struct { /* M_PARSE */
+            struct skel *skel;
+            struct dict *dict;
+        };
+    };
+};
+
+/* Used by recursive lenses in get_rec and parse_rec */
+enum mode_t { M_GET, M_PARSE };
+
+struct rec_state {
+    enum mode_t          mode;
+    struct state        *state;
+    uint                 fsize;
+    uint                 fused;
+    struct frame        *frames;
+    size_t               start;
+    uint                 lvl;  /* Debug only */
+};
+
+#define REG_START(state) ((state)->regs->start[(state)->nreg])
+#define REG_END(state)   ((state)->regs->end[(state)->nreg])
+#define REG_SIZE(state) (REG_END(state) - REG_START(state))
+#define REG_POS(state) ((state)->text + REG_START(state))
+#define REG_VALID(state) ((state)->regs != NULL &&                      \
+                          (state)->nreg < (state)->regs->num_regs)
+#define REG_MATCHED(state) (REG_VALID(state)                            \
+                            && (state)->regs->start[(state)->nreg] >= 0)
+
+static void get_error(struct state *state, struct lens *lens,
+                      const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 3, 4);
+
+void free_lns_error(struct lns_error *err) {
+    if (err == NULL)
+        return;
+    free(err->message);
+    free(err->path);
+    unref(err->lens, lens);
+    free(err);
+}
+
+static void vget_error(struct state *state, struct lens *lens,
+                       const char *format, va_list ap) {
+    int r;
+
+    if (state->error != NULL)
+        return;
+    CALLOC(state->error, 1);
+    state->error->lens = ref(lens);
+    if (REG_MATCHED(state))
+        state->error->pos  = REG_END(state);
+    else
+        state->error->pos = 0;
+    r = vasprintf(&state->error->message, format, ap);
+    if (r == -1)
+        state->error->message = NULL;
+}
+
+static void get_error(struct state *state, struct lens *lens,
+                      const char *format, ...)
+{
+    va_list ap;
+
+    va_start(ap, format);
+    vget_error(state, lens, format, ap);
+    va_end(ap);
+}
+
+static struct skel *make_skel(struct lens *lens) {
+    struct skel *skel;
+    enum lens_tag tag = lens->tag;
+    CALLOC(skel, 1);
+    skel->tag = tag;
+    return skel;
+}
+
+void free_skel(struct skel *skel) {
+    if (skel == NULL)
+        return;
+    if (skel->tag == L_CONCAT || skel->tag == L_STAR || skel->tag == L_MAYBE ||
+        skel->tag == L_SQUARE) {
+        while (skel->skels != NULL) {
+            struct skel *del = skel->skels;
+            skel->skels = del->next;
+            free_skel(del);
+        }
+    } else if (skel->tag == L_DEL) {
+        free(skel->text);
+    }
+    free(skel);
+}
+
+static void print_skel(struct skel *skel);
+static void print_skel_list(struct skel *skels, const char *beg,
+                            const char *sep, const char *end) {
+    printf("%s", beg);
+    list_for_each(s, skels) {
+        print_skel(s);
+        if (s->next != NULL)
+            printf("%s", sep);
+    }
+    printf("%s", end);
+}
+
+static void print_skel(struct skel *skel) {
+    switch(skel->tag) {
+    case L_DEL:
+        if (skel->text == NULL) {
+            printf("<>");
+        } else {
+            fputc('\'', stdout);
+            print_chars(stdout, skel->text, -1);
+            fputc('\'', stdout);
+        }
+        break;
+    case L_CONCAT:
+        print_skel_list(skel->skels, "", " . ", "");
+        break;
+    case L_STAR:
+        print_skel_list(skel->skels, "(", " ", ")*");
+        break;
+    case L_MAYBE:
+        print_skel_list(skel->skels, "(", " ", ")?");
+        break;
+    case L_SUBTREE:
+        print_skel_list(skel->skels, "[", " ", "]");
+        break;
+    default:
+        printf("??");
+        break;
+    }
+}
+
+// DICT_DUMP is only used for debugging
+#ifdef DICT_DUMP
+static void print_dict(struct dict *dict, int indent) {
+    list_for_each(d, dict) {
+        printf("%*s%s:\n", indent, "", d->key);
+        list_for_each(e, d->entry) {
+            printf("%*s", indent+2, "");
+            print_skel(e->skel);
+            printf("\n");
+            print_dict(e->dict, indent+2);
+        }
+    }
+}
+#endif
+
+static void get_expected_error(struct state *state, struct lens *l) {
+    /* Size of the excerpt of the input text we'll show */
+    static const int wordlen = 10;
+    char word[wordlen+1];
+    char *p, *pat;
+
+    if (REG_MATCHED(state))
+        strncpy(word, REG_POS(state), wordlen);
+    else
+        strncpy(word, state->text, wordlen);
+    word[wordlen] = '\0';
+    for (p = word; *p != '\0' && *p != '\n'; p++);
+    *p = '\0';
+
+    pat = escape(l->ctype->pattern->str, -1);
+    get_error(state, l, "expected %s at '%s'", pat, word);
+    free(pat);
+}
+
+/*
+ * Splitting of the input text
+ */
+
+static char *token(struct state *state) {
+    ensure0(REG_MATCHED(state), state->info);
+    return strndup(REG_POS(state), REG_SIZE(state));
+}
+
+static void regexp_match_error(struct state *state, struct lens *lens,
+                               int count, struct regexp *r) {
+    char *text = strndup(REG_POS(state), REG_SIZE(state));
+    char *pat = regexp_escape(r);
+
+    if (count == -1) {
+        get_error(state, lens, "Failed to match /%s/ with %s", pat, text);
+    } else if (count == -2) {
+        get_error(state, lens, "Internal error matching /%s/ with %s",
+                  pat, text);
+    } else if (count == -3) {
+        /* Should have been caught by the typechecker */
+        get_error(state, lens, "Syntax error in regexp /%s/", pat);
+    }
+    free(pat);
+    free(text);
+}
+
+static void no_match_error(struct state *state, struct lens *lens) {
+    ensure(lens->tag == L_KEY || lens->tag == L_DEL
+           || lens->tag == L_STORE, state->info);
+    char *pat = regexp_escape(lens->ctype);
+    const char *lname = "(lname)";
+    if (lens->tag == L_KEY)
+        lname = "key";
+    else if (lens->tag == L_DEL)
+        lname = "del";
+    else if (lens->tag == L_STORE)
+        lname = "store";
+    get_error(state, lens, "no match for %s /%s/", lname, pat);
+    free(pat);
+ error:
+    return;
+}
+
+/* Modifies STATE->REGS and STATE->NREG. The caller must save these
+ * if they are still needed
+ *
+ * Return the number of characters matched
+ */
+static int match(struct state *state, struct lens *lens,
+                 struct regexp *re, uint size, uint start) {
+    struct re_registers *regs;
+    int count;
+
+    if (ALLOC(regs) < 0)
+        return -1;
+
+    count = regexp_match(re, state->text, size, start, regs);
+    if (count < -1) {
+        regexp_match_error(state, lens, count, re);
+        FREE(regs);
+        return -1;
+    }
+    state->regs = regs;
+    state->nreg = 0;
+    return count;
+}
+
+static void free_regs(struct state *state) {
+    if (state->regs != NULL) {
+        free(state->regs->start);
+        free(state->regs->end);
+        FREE(state->regs);
+    }
+}
+
+static struct tree *get_lens(struct lens *lens, struct state *state);
+static struct skel *parse_lens(struct lens *lens, struct state *state,
+                               struct dict **dict);
+
+static void free_seqs(struct seq *seqs) {
+    /* Do not free seq->name; it's not owned by the seq, but by some lens */
+    list_free(seqs);
+}
+
+static struct seq *find_seq(const char *name, struct state *state) {
+    ensure0(name != NULL, state->info);
+    struct seq *seq;
+
+    for (seq=state->seqs;
+         seq != NULL && STRNEQ(seq->name, name);
+         seq = seq->next);
+
+    if (seq == NULL) {
+        CALLOC(seq, 1);
+        seq->name = name;
+        seq->value = 1;
+        list_append(state->seqs, seq);
+    }
+
+    return seq;
+}
+
+static struct tree *get_seq(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_SEQ, state->info);
+    struct seq *seq = find_seq(lens->string->str, state);
+    int r;
+
+    r = asprintf((char **) &(state->key), "%d", seq->value);
+    ERR_NOMEM(r < 0, state->info);
+
+    seq->value += 1;
+ error:
+    return NULL;
+}
+
+static struct skel *parse_seq(struct lens *lens, struct state *state) {
+    get_seq(lens, state);
+    return make_skel(lens);
+}
+
+static struct tree *get_counter(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_COUNTER, state->info);
+    struct seq *seq = find_seq(lens->string->str, state);
+    seq->value = 1;
+    return NULL;
+}
+
+static struct skel *parse_counter(struct lens *lens, struct state *state) {
+    get_counter(lens, state);
+    return make_skel(lens);
+}
+
+static struct tree *get_del(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_DEL, state->info);
+    if (! REG_MATCHED(state)) {
+        char *pat = regexp_escape(lens->ctype);
+        get_error(state, lens, "no match for del /%s/", pat);
+        free(pat);
+    }
+    if (lens->string == NULL) {
+        state->square = token(state);
+    }
+    update_span(state->span, REG_START(state), REG_END(state));
+    return NULL;
+}
+
+static struct skel *parse_del(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_DEL, state->info);
+    struct skel *skel = NULL;
+
+    skel = make_skel(lens);
+    if (! REG_MATCHED(state))
+        no_match_error(state, lens);
+    else
+        skel->text = token(state);
+    return skel;
+}
+
+static struct tree *get_store(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_STORE, state->info);
+    ensure0(state->value == NULL, state->info);
+
+    struct tree *tree = NULL;
+
+    if (state->value != NULL)
+        get_error(state, lens, "More than one store in a subtree");
+    else if (! REG_MATCHED(state))
+        no_match_error(state, lens);
+    else {
+        state->value = token(state);
+        if (state->span) {
+            state->span->value_start = REG_START(state);
+            state->span->value_end = REG_END(state);
+            update_span(state->span, REG_START(state), REG_END(state));
+        }
+    }
+    return tree;
+}
+
+static struct skel *parse_store(struct lens *lens,
+                                ATTRIBUTE_UNUSED struct state *state) {
+    ensure0(lens->tag == L_STORE, state->info);
+    return make_skel(lens);
+}
+
+static struct tree *get_value(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_VALUE, state->info);
+    state->value = strdup(lens->string->str);
+    return NULL;
+}
+
+static struct skel *parse_value(struct lens *lens,
+                                ATTRIBUTE_UNUSED struct state *state) {
+    ensure0(lens->tag == L_VALUE, state->info);
+    return make_skel(lens);
+}
+
+static struct tree *get_key(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_KEY, state->info);
+    if (! REG_MATCHED(state))
+        no_match_error(state, lens);
+    else {
+        state->key = token(state);
+        if (state->span) {
+            state->span->label_start = REG_START(state);
+            state->span->label_end = REG_END(state);
+            update_span(state->span, REG_START(state), REG_END(state));
+        }
+    }
+    return NULL;
+}
+
+static struct skel *parse_key(struct lens *lens, struct state *state) {
+    get_key(lens, state);
+    return make_skel(lens);
+}
+
+static struct tree *get_label(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_LABEL, state->info);
+    state->key = strdup(lens->string->str);
+    return NULL;
+}
+
+static struct skel *parse_label(struct lens *lens, struct state *state) {
+    get_label(lens, state);
+    return make_skel(lens);
+}
+
+static struct tree *get_union(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_UNION, state->info);
+
+    struct tree *tree = NULL;
+    int applied = 0;
+    uint old_nreg = state->nreg;
+
+    state->nreg += 1;
+    for (int i=0; i < lens->nchildren; i++) {
+        if (REG_MATCHED(state)) {
+            tree = get_lens(lens->children[i], state);
+            applied = 1;
+            break;
+        }
+        state->nreg += 1 + regexp_nsub(lens->children[i]->ctype);
+    }
+    state->nreg = old_nreg;
+    if (!applied)
+        get_expected_error(state, lens);
+    return tree;
+}
+
+static struct skel *parse_union(struct lens *lens, struct state *state,
+                                struct dict **dict) {
+    ensure0(lens->tag == L_UNION, state->info);
+
+    struct skel *skel = NULL;
+    int applied = 0;
+    uint old_nreg = state->nreg;
+
+    state->nreg += 1;
+    for (int i=0; i < lens->nchildren; i++) {
+        struct lens *l = lens->children[i];
+        if (REG_MATCHED(state)) {
+            skel = parse_lens(l, state, dict);
+            applied = 1;
+            break;
+        }
+        state->nreg += 1 + regexp_nsub(lens->children[i]->ctype);
+    }
+    state->nreg = old_nreg;
+    if (! applied)
+        get_expected_error(state, lens);
+
+    return skel;
+}
+
+static struct tree *get_concat(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_CONCAT, state->info);
+
+    struct tree *tree = NULL;
+    uint old_nreg = state->nreg;
+
+    state->nreg += 1;
+    for (int i=0; i < lens->nchildren; i++) {
+        struct tree *t = NULL;
+        if (! REG_VALID(state)) {
+            get_error(state, lens->children[i],
+                      "Not enough components in concat");
+            free_tree(tree);
+            state->nreg = old_nreg;
+            return NULL;
+        }
+
+        t = get_lens(lens->children[i], state);
+        list_append(tree, t);
+        state->nreg += 1 + regexp_nsub(lens->children[i]->ctype);
+    }
+    state->nreg = old_nreg;
+
+    return tree;
+}
+
+static struct skel *parse_concat(struct lens *lens, struct state *state,
+                                 struct dict **dict) {
+    ensure0(lens->tag == L_CONCAT, state->info);
+    struct skel *skel = make_skel(lens);
+    uint old_nreg = state->nreg;
+
+    state->nreg += 1;
+    for (int i=0; i < lens->nchildren; i++) {
+        struct skel *sk = NULL;
+        struct dict *di = NULL;
+        if (! REG_VALID(state)) {
+            get_error(state, lens->children[i],
+                      "Not enough components in concat");
+            free_skel(skel);
+            return NULL;
+        }
+
+        sk = parse_lens(lens->children[i], state, &di);
+        list_append(skel->skels, sk);
+        dict_append(dict, di);
+        state->nreg += 1 + regexp_nsub(lens->children[i]->ctype);
+    }
+    state->nreg = old_nreg;
+
+    return skel;
+}
+
+static struct tree *get_quant_star(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_STAR, state->info);
+    struct lens *child = lens->child;
+    struct tree *tree = NULL, *tail = NULL;
+    struct re_registers *old_regs = state->regs;
+    uint old_nreg = state->nreg;
+    uint end = REG_END(state);
+    uint start = REG_START(state);
+    uint size = end - start;
+
+    state->regs = NULL;
+    while (size > 0 && match(state, child, child->ctype, end, start) > 0) {
+        struct tree *t = NULL;
+
+        t = get_lens(lens->child, state);
+        list_tail_cons(tree, tail, t);
+
+        start += REG_SIZE(state);
+        size -= REG_SIZE(state);
+        free_regs(state);
+    }
+    free_regs(state);
+    state->regs = old_regs;
+    state->nreg = old_nreg;
+    if (size != 0) {
+        get_error(state, lens, "%s", short_iteration);
+        state->error->pos = start;
+    }
+    return tree;
+}
+
+static struct skel *parse_quant_star(struct lens *lens, struct state *state,
+                                     struct dict **dict) {
+    ensure0(lens->tag == L_STAR, state->info);
+    struct lens *child = lens->child;
+    struct skel *skel = make_skel(lens), *tail = NULL;
+    struct re_registers *old_regs = state->regs;
+    uint old_nreg = state->nreg;
+    uint end = REG_END(state);
+    uint start = REG_START(state);
+    uint size = end - start;
+
+    *dict = NULL;
+    state->regs = NULL;
+    while (size > 0 && match(state, child, child->ctype, end, start) > 0) {
+        struct skel *sk;
+        struct dict *di = NULL;
+
+        sk = parse_lens(lens->child, state, &di);
+        list_tail_cons(skel->skels, tail, sk);
+        dict_append(dict, di);
+
+        start += REG_SIZE(state);
+        size -= REG_SIZE(state);
+        free_regs(state);
+    }
+    free_regs(state);
+    state->regs = old_regs;
+    state->nreg = old_nreg;
+    if (size != 0) {
+        get_error(state, lens, "%s", short_iteration);
+    }
+    return skel;
+}
+
+static struct tree *get_quant_maybe(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_MAYBE, state->info);
+    struct tree *tree = NULL;
+
+    /* Check that our child matched. For a construct like (r)?, the
+     * matcher will report a zero length match for group 0, even if r
+     * does not match at all
+     */
+    state->nreg += 1;
+    if (REG_MATCHED(state)) {
+        tree = get_lens(lens->child, state);
+    }
+    state->nreg -= 1;
+    return tree;
+}
+
+static struct skel *parse_quant_maybe(struct lens *lens, struct state *state,
+                                      struct dict **dict) {
+    ensure0(lens->tag == L_MAYBE, state->info);
+
+    struct skel *skel = NULL;
+
+    state->nreg += 1;
+    if (REG_MATCHED(state)) {
+        skel = parse_lens(lens->child, state, dict);
+    }
+    state->nreg -= 1;
+    if (skel == NULL)
+        skel = make_skel(lens);
+    return skel;
+}
+
+static struct tree *get_subtree(struct lens *lens, struct state *state) {
+    char *key = state->key;
+    char *value = state->value;
+    struct span *span = state->span;
+
+    struct tree *tree = NULL, *children;
+
+    state->key = NULL;
+    state->value = NULL;
+    if (state->info->flags & AUG_ENABLE_SPAN) {
+        state->span = make_span(state->info);
+        ERR_NOMEM(state->span == NULL, state->info);
+    }
+
+    children = get_lens(lens->child, state);
+
+    tree = make_tree(state->key, state->value, NULL, children);
+    tree->span = state->span;
+
+    if (state->span != NULL) {
+        update_span(span, state->span->span_start, state->span->span_end);
+    }
+
+    state->key = key;
+    state->value = value;
+    state->span = span;
+    return tree;
+ error:
+    return NULL;
+}
+
+static struct skel *parse_subtree(struct lens *lens, struct state *state,
+                                  struct dict **dict) {
+    char *key = state->key;
+    struct skel *skel;
+    struct dict *di = NULL;
+
+    state->key = NULL;
+    skel = parse_lens(lens->child, state, &di);
+    *dict = make_dict(state->key, skel, di);
+    state->key = key;
+    return make_skel(lens);
+}
+
+static struct tree *get_square(struct lens *lens, struct state *state) {
+    ensure0(lens->tag == L_SQUARE, state->info);
+
+    struct tree *tree = NULL;
+    char *key = NULL, *square = NULL;
+
+    // get the child lens
+    tree = get_concat(lens->child, state);
+
+    key = state->key;
+    square = state->square;
+    ensure0(key != NULL, state->info);
+    ensure0(square != NULL, state->info);
+
+    if (strcmp(key, square) != 0) {
+        get_error(state, lens, "%s \"%s\" %s \"%s\"",
+                "Parse error: mismatched key in square lens, expecting", key,
+                "but got", square);
+    }
+
+    FREE(state->square);
+    return tree;
+}
+
+static struct skel *parse_square(struct lens *lens, struct state *state,
+                                 struct dict **dict) {
+    ensure0(lens->tag == L_SQUARE, state->info);
+    struct skel *skel, *sk;
+
+    skel = parse_concat(lens->child, state, dict);
+    sk = make_skel(lens);
+    sk->skels = skel;
+
+    return sk;
+}
+
+/*
+ * Helpers for recursive lenses
+ */
+
+ATTRIBUTE_UNUSED
+static void print_frames(struct rec_state *state) {
+    for (int j = state->fused - 1; j >=0; j--) {
+        struct frame *f = state->frames + j;
+        for (int i=0; i < state->lvl; i++) fputc(' ', stderr);
+        fprintf(stderr, "%2d %s %s %s", j, f->key, f->value, f->square);
+        if (f->tree == NULL) {
+            fprintf(stderr, " - ");
+        } else {
+            fprintf(stderr, " { %s = %s } ", f->tree->label, f->tree->value);
+        }
+        fprintf(stderr, "%s\n", format_lens(f->lens));
+    }
+}
+
+ATTRIBUTE_PURE
+static struct frame *top_frame(struct rec_state *state) {
+    ensure0(state->fsize > 0, state->state->info);
+    return state->frames + state->fused - 1;
+}
+
+/* The nth frame from the top of the stack, where 0th frame is the top */
+ATTRIBUTE_PURE
+static struct frame *nth_frame(struct rec_state *state, uint n) {
+    assert(state->fsize > n);
+    return state->frames + state->fused - (n+1);
+}
+
+static struct frame *push_frame(struct rec_state *state, struct lens *lens) {
+    int r;
+
+    if (state->fused >= state->fsize) {
+        uint expand = state->fsize;
+        if (expand < 8)
+            expand = 8;
+        r = REALLOC_N(state->frames, state->fsize + expand);
+        ERR_NOMEM(r < 0, state->state->info);
+        state->fsize += expand;
+    }
+
+    state->fused += 1;
+
+    struct frame *top = top_frame(state);
+    MEMZERO(top, 1);
+    top->lens = lens;
+    return top;
+ error:
+    return NULL;
+}
+
+static struct frame *pop_frame(struct rec_state *state) {
+    ensure0(state->fused > 0, state->state->info);
+
+    state->fused -= 1;
+    if (state->fused > 0)
+        return top_frame(state);
+    else
+        return NULL;
+}
+
+static void dbg_visit(struct lens *lens, char action, size_t start, size_t end,
+                      int fused, int lvl) {
+
+    for (int i=0; i < lvl; i++)
+        fputc(' ', stderr);
+    fprintf(stderr, "%c %zd..%zd %d %s\n", action, start, end,
+            fused, format_lens(lens));
+}
+
+static void get_terminal(struct frame *top, struct lens *lens,
+                         struct state *state) {
+    top->tree = get_lens(lens, state);
+    top->key = state->key;
+    top->value = state->value;
+    top->square = state->square;
+    state->key = NULL;
+    state->value = NULL;
+    state->square = NULL;
+}
+
+static void parse_terminal(struct frame *top, struct lens *lens,
+                           struct state *state) {
+    top->dict = NULL;
+    top->skel = parse_lens(lens, state, &top->dict);
+    top->key = state->key;
+    state->key = NULL;
+}
+
+static void visit_terminal(struct lens *lens, size_t start, size_t end,
+                           void *data) {
+    struct rec_state *rec_state = data;
+    struct state *state = rec_state->state;
+    struct re_registers *old_regs = state->regs;
+    uint old_nreg = state->nreg;
+
+    if (state->error != NULL)
+        return;
+
+    if (debugging("cf.get"))
+        dbg_visit(lens, 'T', start, end, rec_state->fused, rec_state->lvl);
+    match(state, lens, lens->ctype, end, start);
+    struct frame *top = push_frame(rec_state, lens);
+    if (rec_state->mode == M_GET)
+        get_terminal(top, lens, state);
+    else
+        parse_terminal(top, lens, state);
+    free_regs(state);
+    state->regs = old_regs;
+    state->nreg = old_nreg;
+}
+
+static void visit_enter(struct lens *lens,
+                        ATTRIBUTE_UNUSED size_t start,
+                        ATTRIBUTE_UNUSED size_t end,
+                        void *data) {
+    struct rec_state *rec_state = data;
+    struct state *state = rec_state->state;
+
+    if (state->error != NULL)
+        return;
+
+    if (debugging("cf.get"))
+        dbg_visit(lens, '{', start, end, rec_state->fused, rec_state->lvl);
+    rec_state->lvl += 1;
+    if (lens->tag == L_SUBTREE) {
+        /* Same for parse and get */
+        struct frame *f = push_frame(rec_state, lens);
+        f->key = state->key;
+        f->value = state->value;
+        f->span = state->span;
+        state->key = NULL;
+        state->value = NULL;
+    } else if (lens->tag == L_MAYBE) {
+        push_frame(rec_state, lens);
+        if (state->info->flags & AUG_ENABLE_SPAN) {
+            state->span = make_span(state->info);
+            ERR_NOMEM(state->span == NULL, state->info);
+        }
+    }
+ error:
+    return;
+}
+
+static void get_combine(struct rec_state *rec_state,
+                        struct lens *lens, uint n) {
+    struct tree *tree = NULL, *tail = NULL;
+    char *key = NULL, *value = NULL, *square = NULL;
+    struct frame *top = NULL;
+
+    if (n > 0)
+        top = top_frame(rec_state);
+
+    for (int i=0; i < n; i++, top = pop_frame(rec_state)) {
+        list_tail_cons(tree, tail, top->tree);
+        /* top->tree might have more than one node, update tail */
+        if (tail != NULL)
+            while (tail->next != NULL) tail = tail->next;
+
+        if (top->key != NULL) {
+            ensure(key == NULL, rec_state->state->info);
+            key = top->key;
+        }
+        if (top->value != NULL) {
+            ensure(value == NULL, rec_state->state->info);
+            value = top->value;
+        }
+        if (top->square != NULL) {
+            ensure(square == NULL, rec_state->state->info);
+            square = top->square;
+        }
+    }
+    top = push_frame(rec_state, lens);
+    top->tree = tree;
+    top->key = key;
+    top->value = value;
+    top->square = square;
+ error:
+    return;
+}
+
+static void parse_combine(struct rec_state *rec_state,
+                          struct lens *lens, uint n) {
+    struct skel *skel = make_skel(lens), *tail = NULL;
+    struct dict *dict = NULL;
+    char *key = NULL;
+    struct frame *top = NULL;
+
+    if (n > 0)
+        top = top_frame(rec_state);
+
+    for (int i=0; i < n; i++, top = pop_frame(rec_state)) {
+        list_tail_cons(skel->skels, tail, top->skel);
+        /* top->skel might have more than one node, update skel */
+        if (tail != NULL)
+            while (tail->next != NULL) tail = tail->next;
+        dict_append(&dict, top->dict);
+        if (top->key != NULL) {
+            ensure(key == NULL, rec_state->state->info);
+            key = top->key;
+        }
+    }
+    top = push_frame(rec_state, lens);
+    top->skel = skel;
+    top->dict = dict;
+    top->key = key;
+ error:
+    return;
+}
+
+static void visit_exit(struct lens *lens,
+                       ATTRIBUTE_UNUSED size_t start,
+                       ATTRIBUTE_UNUSED size_t end,
+                       void *data) {
+    struct rec_state *rec_state = data;
+    struct state *state = rec_state->state;
+
+    if (state->error != NULL)
+        return;
+
+    rec_state->lvl -= 1;
+    if (debugging("cf.get"))
+        dbg_visit(lens, '}', start, end, rec_state->fused, rec_state->lvl);
+
+    ERR_BAIL(lens->info);
+
+    if (lens->tag == L_SUBTREE) {
+        struct frame *top = top_frame(rec_state);
+        if (rec_state->mode == M_GET) {
+            struct tree *tree;
+            // FIXME: tree may leak if pop_frame ensure0 fail
+            tree = make_tree(top->key, top->value, NULL, top->tree);
+            tree->span = state->span;
+            ERR_NOMEM(tree == NULL, lens->info);
+            top = pop_frame(rec_state);
+            ensure(lens == top->lens, state->info);
+            state->key = top->key;
+            state->value = top->value;
+            state->span = top->span;
+            pop_frame(rec_state);
+            top = push_frame(rec_state, lens);
+            top->tree = tree;
+        } else {
+            struct skel *skel;
+            struct dict *dict;
+            skel = make_skel(lens);
+            ERR_NOMEM(skel == NULL, lens->info);
+            dict = make_dict(top->key, top->skel, top->dict);
+            ERR_NOMEM(dict == NULL, lens->info);
+            top = pop_frame(rec_state);
+            ensure(lens == top->lens, state->info);
+            state->key = top->key;
+            pop_frame(rec_state);
+            top = push_frame(rec_state, lens);
+            top->skel = skel;
+            top->dict = dict;
+        }
+    } else if (lens->tag == L_CONCAT) {
+        ensure(rec_state->fused >= lens->nchildren, state->info);
+        for (int i = 0; i < lens->nchildren; i++) {
+            struct frame *fr = nth_frame(rec_state, i);
+            BUG_ON(lens->children[i] != fr->lens,
+                    lens->info,
+             "Unexpected lens in concat %zd..%zd\n  Expected: %s\n  Actual: %s",
+                    start, end,
+                    format_lens(lens->children[i]),
+                    format_lens(fr->lens));
+        }
+        if (rec_state->mode == M_GET)
+            get_combine(rec_state, lens, lens->nchildren);
+        else
+            parse_combine(rec_state, lens, lens->nchildren);
+    } else if (lens->tag == L_STAR) {
+        uint n = 0;
+        while (n < rec_state->fused &&
+               nth_frame(rec_state, n)->lens == lens->child)
+            n++;
+        if (rec_state->mode == M_GET)
+            get_combine(rec_state, lens, n);
+        else
+            parse_combine(rec_state, lens, n);
+    } else if (lens->tag == L_MAYBE) {
+        uint n = 1;
+        if (rec_state->fused > 0
+            && top_frame(rec_state)->lens == lens->child) {
+            n = 2;
+        }
+        if (rec_state->mode == M_GET)
+            get_combine(rec_state, lens, n);
+        else
+            parse_combine(rec_state, lens, n);
+    } else if (lens->tag == L_SQUARE) {
+        if (rec_state->mode == M_GET) {
+            char *key, *square;
+
+            key = top_frame(rec_state)->key;
+            square = top_frame(rec_state)->square;
+
+            ensure(key != NULL, state->info);
+            ensure(square != NULL, state->info);
+
+            // raise syntax error if they are not equals
+            if (strcmp(key, square) != 0){
+                get_error(state, lens, "%s \"%s\" %s \"%s\"",
+                        "Parse error: mismatched key in square lens, expecting",
+                        key, "but got", square);
+                state->error->pos = end - strlen(square);
+                goto error;
+            }
+
+            FREE(square);
+            get_combine(rec_state, lens, 1);
+        } else {
+            parse_combine(rec_state, lens, 1);
+        }
+    } else {
+        top_frame(rec_state)->lens = lens;
+    }
+ error:
+    return;
+}
+
+static void visit_error(struct lens *lens, void *data, size_t pos,
+                        const char *format, ...) {
+    struct rec_state *rec_state = data;
+    va_list ap;
+
+    va_start(ap, format);
+    vget_error(rec_state->state, lens, format, ap);
+    va_end(ap);
+    rec_state->state->error->pos = rec_state->start + pos;
+}
+
+static struct frame *rec_process(enum mode_t mode, struct lens *lens,
+                                 struct state *state) {
+    uint end = REG_END(state);
+    uint start = REG_START(state);
+    size_t len = 0;
+    struct re_registers *old_regs = state->regs;
+    uint old_nreg = state->nreg;
+    int r;
+    struct jmt_visitor visitor;
+    struct rec_state rec_state;
+    int i;
+    struct frame *f = NULL;
+
+    MEMZERO(&rec_state, 1);
+    MEMZERO(&visitor, 1);
+
+    if (lens->jmt == NULL) {
+        lens->jmt = jmt_build(lens);
+        ERR_BAIL(lens->info);
+    }
+
+    state->regs = NULL;
+    state->nreg = 0;
+
+    rec_state.mode  = mode;
+    rec_state.state = state;
+    rec_state.fused = 0;
+    rec_state.lvl   = 0;
+    rec_state.start = start;
+
+    visitor.parse = jmt_parse(lens->jmt, state->text + start, end - start);
+    ERR_BAIL(lens->info);
+    visitor.terminal = visit_terminal;
+    visitor.enter = visit_enter;
+    visitor.exit = visit_exit;
+    visitor.error = visit_error;
+    visitor.data = &rec_state;
+    r = jmt_visit(&visitor, &len);
+    ERR_BAIL(lens->info);
+    if (r != 1) {
+        get_error(state, lens, "Syntax error");
+        state->error->pos = start + len;
+    }
+    if (rec_state.fused == 0) {
+        get_error(state, lens,
+                  "Parse did not leave a result on the stack");
+        goto error;
+    } else if (rec_state.fused > 1) {
+        get_error(state, lens,
+                  "Parse left additional garbage on the stack");
+        goto error;
+    }
+
+ done:
+    state->regs = old_regs;
+    state->nreg = old_nreg;
+    jmt_free_parse(visitor.parse);
+    return rec_state.frames;
+ error:
+
+    for(i = 0; i < rec_state.fused; i++) {
+        f = nth_frame(&rec_state, i);
+        FREE(f->key);
+        FREE(f->square);
+        if (mode == M_GET) {
+            FREE(f->value);
+            free_tree(f->tree);
+        } else if (mode == M_PARSE) {
+            free_skel(f->skel);
+            free_dict(f->dict);
+        }
+    }
+    FREE(rec_state.frames);
+    goto done;
+}
+
+static struct tree *get_rec(struct lens *lens, struct state *state) {
+    struct frame *fr;
+    struct tree *tree = NULL;
+
+    fr = rec_process(M_GET, lens, state);
+    if (fr != NULL) {
+        tree = fr->tree;
+        state->key = fr->key;
+        state->value = fr->value;
+        FREE(fr);
+    }
+    return tree;
+}
+
+static struct skel *parse_rec(struct lens *lens, struct state *state,
+                              struct dict **dict) {
+    struct skel *skel = NULL;
+    struct frame *fr;
+
+    fr = rec_process(M_PARSE, lens, state);
+    if (fr != NULL) {
+        skel = fr->skel;
+        *dict = fr->dict;
+        state->key = fr->key;
+        FREE(fr);
+    }
+    return skel;
+}
+
+static struct tree *get_lens(struct lens *lens, struct state *state) {
+    struct tree *tree = NULL;
+
+    switch(lens->tag) {
+    case L_DEL:
+        tree = get_del(lens, state);
+        break;
+    case L_STORE:
+        tree = get_store(lens, state);
+        break;
+    case L_VALUE:
+        tree = get_value(lens, state);
+        break;
+    case L_KEY:
+        tree = get_key(lens, state);
+        break;
+    case L_LABEL:
+        tree = get_label(lens, state);
+        break;
+    case L_SEQ:
+        tree = get_seq(lens, state);
+        break;
+    case L_COUNTER:
+        tree = get_counter(lens, state);
+        break;
+    case L_CONCAT:
+        tree = get_concat(lens, state);
+        break;
+    case L_UNION:
+        tree = get_union(lens, state);
+        break;
+    case L_SUBTREE:
+        tree = get_subtree(lens, state);
+        break;
+    case L_STAR:
+        tree = get_quant_star(lens, state);
+        break;
+    case L_MAYBE:
+        tree = get_quant_maybe(lens, state);
+        break;
+    case L_SQUARE:
+        tree = get_square(lens, state);
+        break;
+    default:
+        BUG_ON(true, state->info, "illegal lens tag %d", lens->tag);
+        break;
+    }
+ error:
+    return tree;
+}
+
+/* Initialize registers. Return 0 if the lens matches the entire text, 1 if
+ * it does not and -1 on error.
+ */
+static int init_regs(struct state *state, struct lens *lens, uint size) {
+    int r;
+
+    if (lens->tag != L_STAR && ! lens->recursive) {
+        r = match(state, lens, lens->ctype, size, 0);
+        if (r == -1)
+            get_error(state, lens, "Input string does not match at all");
+        if (r <= -1)
+            return -1;
+        return r != size;
+    }
+    /* Special case the very common situation that the lens is (l)*
+     * We can avoid matching the entire text in that case - that
+     * match can be very expensive
+     */
+    if (ALLOC(state->regs) < 0)
+        return -1;
+    state->regs->num_regs = 1;
+    if (ALLOC(state->regs->start) < 0 || ALLOC(state->regs->end) < 0)
+        return -1;
+    state->regs->start[0] = 0;
+    state->regs->end[0] = size;
+    return 0;
+}
+
+struct tree *lns_get(struct info *info, struct lens *lens, const char *text,
+                     struct lns_error **err) {
+    struct state state;
+    struct tree *tree = NULL;
+    uint size = strlen(text);
+    int partial, r;
+
+    MEMZERO(&state, 1);
+    r = ALLOC(state.info);
+    ERR_NOMEM(r < 0, info);
+
+    *state.info = *info;
+    state.info->ref = UINT_MAX;
+
+    state.text = text;
+
+    /* We are probably being overly cautious here: if the lens can't process
+     * all of TEXT, we should really fail somewhere in one of the sublenses.
+     * But to be safe, we check that we can process everything anyway, then
+     * try to process, hoping we'll get a more specific error, and if that
+     * fails, we throw our arms in the air and say 'something went wrong'
+     */
+    partial = init_regs(&state, lens, size);
+    if (partial >= 0) {
+        if (lens->recursive)
+            tree = get_rec(lens, &state);
+        else
+            tree = get_lens(lens, &state);
+    }
+
+    free_seqs(state.seqs);
+    if (state.key != NULL) {
+        get_error(&state, lens, "get left unused key %s", state.key);
+        free(state.key);
+    }
+    if (state.value != NULL) {
+        get_error(&state, lens, "get left unused value %s", state.value);
+        free(state.value);
+    }
+    if (state.square != NULL) {
+        get_error(&state, lens, "get left unused square %s", state.square);
+        free(state.square);
+    }
+    if (partial && state.error == NULL) {
+        get_error(&state, lens, "Get did not match entire input");
+    }
+
+ error:
+    free_regs(&state);
+    FREE(state.info);
+
+    if (err != NULL) {
+        *err = state.error;
+    } else {
+        if (state.error != NULL) {
+            free_tree(tree);
+            tree = NULL;
+        }
+        free_lns_error(state.error);
+    }
+    return tree;
+}
+
+static struct skel *parse_lens(struct lens *lens, struct state *state,
+                               struct dict **dict) {
+    struct skel *skel = NULL;
+
+    switch(lens->tag) {
+    case L_DEL:
+        skel = parse_del(lens, state);
+        break;
+    case L_STORE:
+        skel = parse_store(lens, state);
+        break;
+    case L_VALUE:
+        skel = parse_value(lens, state);
+        break;
+    case L_KEY:
+        skel = parse_key(lens, state);
+        break;
+    case L_LABEL:
+        skel = parse_label(lens, state);
+        break;
+    case L_SEQ:
+        skel = parse_seq(lens, state);
+        break;
+    case L_COUNTER:
+        skel = parse_counter(lens, state);
+        break;
+    case L_CONCAT:
+        skel = parse_concat(lens, state, dict);
+        break;
+    case L_UNION:
+        skel = parse_union(lens, state, dict);
+        break;
+    case L_SUBTREE:
+        skel = parse_subtree(lens, state, dict);
+        break;
+    case L_STAR:
+        skel = parse_quant_star(lens, state, dict);
+        break;
+    case L_MAYBE:
+        skel = parse_quant_maybe(lens, state, dict);
+        break;
+    case L_SQUARE:
+        skel = parse_square(lens, state, dict);
+        break;
+    default:
+        BUG_ON(true, state->info, "illegal lens tag %d", lens->tag);
+        break;
+    }
+ error:
+    return skel;
+}
+
+struct skel *lns_parse(struct lens *lens, const char *text, struct dict **dict,
+                       struct lns_error **err) {
+    struct state state;
+    struct skel *skel = NULL;
+    uint size = strlen(text);
+    int partial, r;
+
+    MEMZERO(&state, 1);
+    r = ALLOC(state.info);
+    ERR_NOMEM(r< 0, lens->info);
+    state.info->ref = UINT_MAX;
+    state.info->error = lens->info->error;
+    state.text = text;
+
+    state.text = text;
+
+    partial = init_regs(&state, lens, size);
+    if (! partial) {
+        *dict = NULL;
+        if (lens->recursive)
+            skel = parse_rec(lens, &state, dict);
+        else
+            skel = parse_lens(lens, &state, dict);
+
+        free_seqs(state.seqs);
+        if (state.error != NULL) {
+            free_skel(skel);
+            skel = NULL;
+            free_dict(*dict);
+            *dict = NULL;
+        }
+        if (state.key != NULL) {
+            get_error(&state, lens, "parse left unused key %s", state.key);
+            free(state.key);
+        }
+        if (state.value != NULL) {
+            get_error(&state, lens, "parse left unused value %s", state.value);
+            free(state.value);
+        }
+    } else {
+        // This should never happen during lns_parse
+        get_error(&state, lens, "parse can not process entire input");
+    }
+
+ error:
+    free_regs(&state);
+    FREE(state.info);
+    if (err != NULL) {
+        *err = state.error;
+    } else {
+        free_lns_error(state.error);
+    }
+    return skel;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/hash.c b/src/hash.c
new file mode 100644 (file)
index 0000000..42c320e
--- /dev/null
@@ -0,0 +1,1052 @@
+/*
+ * Hash Table Data Type
+ * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
+ *
+ * Free Software License:
+ *
+ * All rights are reserved by the author, with the following exceptions:
+ * Permission is granted to freely reproduce and distribute this software,
+ * possibly in exchange for a fee, provided that this copyright notice appears
+ * intact. Permission is also granted to adapt this software to produce
+ * derivative works, as long as the modified versions carry this copyright
+ * notice and additional notices stating that the work has been modified.
+ * This source code may be translated into executable form and incorporated
+ * into proprietary software; there is no requirement for such software to
+ * contain a copyright notice related to this source.
+ *
+ * $Id: hash.c,v 1.36.2.11 2000/11/13 01:36:45 kaz Exp $
+ * $Name: kazlib_1_20 $
+ *
+ * 2008-04-17 Small modifications to build with stricter warnings
+ *            David Lutterkort <dlutter@redhat.com>
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <assert.h>
+#include <string.h>
+#define HASH_IMPLEMENTATION
+#include "internal.h"
+#include "hash.h"
+
+#ifdef HASH_DEBUG_VERIFY
+# define expensive_assert(expr) assert (expr)
+#else
+# define expensive_assert(expr) /* empty */
+#endif
+
+#ifdef KAZLIB_RCSID
+static const char rcsid[] = "$Id: hash.c,v 1.36.2.11 2000/11/13 01:36:45 kaz Exp $";
+#endif
+
+#define INIT_BITS      4
+#define INIT_SIZE      (1UL << (INIT_BITS))    /* must be power of two         */
+#define INIT_MASK      ((INIT_SIZE) - 1)
+
+#define next hash_next
+#define key hash_key
+#define data hash_data
+#define hkey hash_hkey
+
+#define table hash_table
+#define nchains hash_nchains
+#define nodecount hash_nodecount
+#define maxcount hash_maxcount
+#define highmark hash_highmark
+#define lowmark hash_lowmark
+#define compare hash_compare
+#define function hash_function
+#define allocnode hash_allocnode
+#define freenode hash_freenode
+#define context hash_context
+#define mask hash_mask
+#define dynamic hash_dynamic
+
+#define table hash_table
+#define chain hash_chain
+
+static hnode_t *hnode_alloc(void *context);
+static void hnode_free(hnode_t *node, void *context);
+static hash_val_t hash_fun_default(const void *key);
+static int hash_comp_default(const void *key1, const void *key2);
+
+int hash_val_t_bit;
+
+/*
+ * Compute the number of bits in the hash_val_t type.  We know that hash_val_t
+ * is an unsigned integral type. Thus the highest value it can hold is a
+ * Mersenne number (power of two, less one). We initialize a hash_val_t
+ * object with this value and then shift bits out one by one while counting.
+ * Notes:
+ * 1. HASH_VAL_T_MAX is a Mersenne number---one that is one less than a power
+ *    of two. This means that its binary representation consists of all one
+ *    bits, and hence ``val'' is initialized to all one bits.
+ * 2. While bits remain in val, we increment the bit count and shift it to the
+ *    right, replacing the topmost bit by zero.
+ */
+
+static void compute_bits(void)
+{
+    hash_val_t val = HASH_VAL_T_MAX;   /* 1 */
+    int bits = 0;
+
+    while (val) {      /* 2 */
+       bits++;
+       val >>= 1;
+    }
+
+    hash_val_t_bit = bits;
+}
+
+/*
+ * Verify whether the given argument is a power of two.
+ */
+
+static int is_power_of_two(hash_val_t arg)
+{
+    if (arg == 0)
+       return 0;
+    while ((arg & 1) == 0)
+       arg >>= 1;
+    return (arg == 1);
+}
+
+/*
+ * Compute a shift amount from a given table size
+ */
+
+static hash_val_t compute_mask(hashcount_t size)
+{
+    assert (is_power_of_two(size));
+    assert (size >= 2);
+
+    return size - 1;
+}
+
+/*
+ * Initialize the table of pointers to null.
+ */
+
+static void clear_table(hash_t *hash)
+{
+    hash_val_t i;
+
+    for (i = 0; i < hash->nchains; i++)
+       hash->table[i] = NULL;
+}
+
+/*
+ * Double the size of a dynamic table. This works as follows. Each chain splits
+ * into two adjacent chains.  The shift amount increases by one, exposing an
+ * additional bit of each hashed key. For each node in the original chain, the
+ * value of this newly exposed bit will decide which of the two new chains will
+ * receive the node: if the bit is 1, the chain with the higher index will have
+ * the node, otherwise the lower chain will receive the node. In this manner,
+ * the hash table will continue to function exactly as before without having to
+ * rehash any of the keys.
+ * Notes:
+ * 1.  Overflow check.
+ * 2.  The new number of chains is twice the old number of chains.
+ * 3.  The new mask is one bit wider than the previous, revealing a
+ *     new bit in all hashed keys.
+ * 4.  Allocate a new table of chain pointers that is twice as large as the
+ *     previous one.
+ * 5.  If the reallocation was successful, we perform the rest of the growth
+ *     algorithm, otherwise we do nothing.
+ * 6.  The exposed_bit variable holds a mask with which each hashed key can be
+ *     AND-ed to test the value of its newly exposed bit.
+ * 7.  Now loop over each chain in the table and sort its nodes into two
+ *     chains based on the value of each node's newly exposed hash bit.
+ * 8.  The low chain replaces the current chain.  The high chain goes
+ *     into the corresponding sister chain in the upper half of the table.
+ * 9.  We have finished dealing with the chains and nodes. We now update
+ *     the various bookeeping fields of the hash structure.
+ */
+
+static void grow_table(hash_t *hash)
+{
+    hnode_t **newtable;
+
+    assert (2 * hash->nchains > hash->nchains);        /* 1 */
+
+    newtable = realloc(hash->table,
+           sizeof *newtable * hash->nchains * 2);      /* 4 */
+
+    if (newtable) {    /* 5 */
+       hash_val_t mask = (hash->mask << 1) | 1;        /* 3 */
+       hash_val_t exposed_bit = mask ^ hash->mask;     /* 6 */
+       hash_val_t chain;
+
+       assert (mask != hash->mask);
+
+       for (chain = 0; chain < hash->nchains; chain++) { /* 7 */
+           hnode_t *low_chain = 0, *high_chain = 0, *hptr, *next;
+
+           for (hptr = newtable[chain]; hptr != 0; hptr = next) {
+               next = hptr->next;
+
+               if (hptr->hkey & exposed_bit) {
+                   hptr->next = high_chain;
+                   high_chain = hptr;
+               } else {
+                   hptr->next = low_chain;
+                   low_chain = hptr;
+               }
+           }
+
+           newtable[chain] = low_chain;        /* 8 */
+           newtable[chain + hash->nchains] = high_chain;
+       }
+
+       hash->table = newtable;                 /* 9 */
+       hash->mask = mask;
+       hash->nchains *= 2;
+       hash->lowmark *= 2;
+       hash->highmark *= 2;
+    }
+    expensive_assert (hash_verify(hash));
+}
+
+/*
+ * Cut a table size in half. This is done by folding together adjacent chains
+ * and populating the lower half of the table with these chains. The chains are
+ * simply spliced together. Once this is done, the whole table is reallocated
+ * to a smaller object.
+ * Notes:
+ * 1.  It is illegal to have a hash table with one slot. This would mean that
+ *     hash->shift is equal to hash_val_t_bit, an illegal shift value.
+ *     Also, other things could go wrong, such as hash->lowmark becoming zero.
+ * 2.  Looping over each pair of sister chains, the low_chain is set to
+ *     point to the head node of the chain in the lower half of the table,
+ *     and high_chain points to the head node of the sister in the upper half.
+ * 3.  The intent here is to compute a pointer to the last node of the
+ *     lower chain into the low_tail variable. If this chain is empty,
+ *     low_tail ends up with a null value.
+ * 4.  If the lower chain is not empty, we simply tack the upper chain onto it.
+ *     If the upper chain is a null pointer, nothing happens.
+ * 5.  Otherwise if the lower chain is empty but the upper one is not,
+ *     If the low chain is empty, but the high chain is not, then the
+ *     high chain is simply transferred to the lower half of the table.
+ * 6.  Otherwise if both chains are empty, there is nothing to do.
+ * 7.  All the chain pointers are in the lower half of the table now, so
+ *     we reallocate it to a smaller object. This, of course, invalidates
+ *     all pointer-to-pointers which reference into the table from the
+ *     first node of each chain.
+ * 8.  Though it's unlikely, the reallocation may fail. In this case we
+ *     pretend that the table _was_ reallocated to a smaller object.
+ * 9.  Finally, update the various table parameters to reflect the new size.
+ */
+
+static void shrink_table(hash_t *hash)
+{
+    hash_val_t chain, nchains;
+    hnode_t **newtable, *low_tail, *low_chain, *high_chain;
+
+    assert (hash->nchains >= 2);                       /* 1 */
+    nchains = hash->nchains / 2;
+
+    for (chain = 0; chain < nchains; chain++) {
+       low_chain = hash->table[chain];         /* 2 */
+       high_chain = hash->table[chain + nchains];
+       for (low_tail = low_chain; low_tail && low_tail->next; low_tail = low_tail->next)
+           ;   /* 3 */
+       if (low_chain != 0)                             /* 4 */
+           low_tail->next = high_chain;
+       else if (high_chain != 0)                       /* 5 */
+           hash->table[chain] = high_chain;
+       else
+           assert (hash->table[chain] == NULL);        /* 6 */
+    }
+    newtable = realloc(hash->table,
+           sizeof *newtable * nchains);                /* 7 */
+    if (newtable)                                      /* 8 */
+       hash->table = newtable;
+    hash->mask >>= 1;                  /* 9 */
+    hash->nchains = nchains;
+    hash->lowmark /= 2;
+    hash->highmark /= 2;
+    expensive_assert (hash_verify(hash));
+}
+
+
+/*
+ * Create a dynamic hash table. Both the hash table structure and the table
+ * itself are dynamically allocated. Furthermore, the table is extendible in
+ * that it will automatically grow as its load factor increases beyond a
+ * certain threshold.
+ * Notes:
+ * 1. If the number of bits in the hash_val_t type has not been computed yet,
+ *    we do so here, because this is likely to be the first function that the
+ *    user calls.
+ * 2. Allocate a hash table control structure.
+ * 3. If a hash table control structure is successfully allocated, we
+ *    proceed to initialize it. Otherwise we return a null pointer.
+ * 4. We try to allocate the table of hash chains.
+ * 5. If we were able to allocate the hash chain table, we can finish
+ *    initializing the hash structure and the table. Otherwise, we must
+ *    backtrack by freeing the hash structure.
+ * 6. INIT_SIZE should be a power of two. The high and low marks are always set
+ *    to be twice the table size and half the table size respectively. When the
+ *    number of nodes in the table grows beyond the high size (beyond load
+ *    factor 2), it will double in size to cut the load factor down to about
+ *    about 1. If the table shrinks down to or beneath load factor 0.5,
+ *    it will shrink, bringing the load up to about 1. However, the table
+ *    will never shrink beneath INIT_SIZE even if it's emptied.
+ * 7. This indicates that the table is dynamically allocated and dynamically
+ *    resized on the fly. A table that has this value set to zero is
+ *    assumed to be statically allocated and will not be resized.
+ * 8. The table of chains must be properly reset to all null pointers.
+ */
+
+hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
+       hash_fun_t hashfun)
+{
+    hash_t *hash;
+
+    if (hash_val_t_bit == 0)   /* 1 */
+       compute_bits();
+
+    hash = malloc(sizeof *hash);       /* 2 */
+
+    if (hash) {                /* 3 */
+       hash->table = malloc(sizeof *hash->table * INIT_SIZE);  /* 4 */
+       if (hash->table) {      /* 5 */
+           hash->nchains = INIT_SIZE;          /* 6 */
+           hash->highmark = INIT_SIZE * 2;
+           hash->lowmark = INIT_SIZE / 2;
+           hash->nodecount = 0;
+           hash->maxcount = maxcount;
+           hash->compare = compfun ? compfun : hash_comp_default;
+           hash->function = hashfun ? hashfun : hash_fun_default;
+           hash->allocnode = hnode_alloc;
+           hash->freenode = hnode_free;
+           hash->context = NULL;
+           hash->mask = INIT_MASK;
+           hash->dynamic = 1;                  /* 7 */
+           clear_table(hash);                  /* 8 */
+           expensive_assert (hash_verify(hash));
+           return hash;
+       }
+       free(hash);
+    }
+
+    return NULL;
+}
+
+/*
+ * Select a different set of node allocator routines.
+ */
+
+void hash_set_allocator(hash_t *hash, hnode_alloc_t al,
+       hnode_free_t fr, void *context)
+{
+    assert (hash_count(hash) == 0);
+
+    hash->allocnode = al ? al : hnode_alloc;
+    hash->freenode = fr ? fr : hnode_free;
+    hash->context = context;
+}
+
+/*
+ * Free every node in the hash using the hash->freenode() function pointer, and
+ * cause the hash to become empty.
+ */
+
+void hash_free_nodes(hash_t *hash)
+{
+    hnode_t *node, *next;
+    hash_val_t chain;
+
+    for (chain = 0; chain < hash->nchains; chain ++) {
+      node = hash->table[chain];
+      while (node != NULL) {
+        next = node->next;
+        hash->freenode(node, hash->context);
+        node = next;
+      }
+      hash->table[chain] = NULL;
+    }
+    hash->nodecount = 0;
+    clear_table(hash);
+}
+
+/*
+ * Obsolescent function for removing all nodes from a table,
+ * freeing them and then freeing the table all in one step.
+ */
+
+void hash_free(hash_t *hash)
+{
+#ifdef KAZLIB_OBSOLESCENT_DEBUG
+    assert ("call to obsolescent function hash_free()" && 0);
+#endif
+    hash_free_nodes(hash);
+    hash_destroy(hash);
+}
+
+/*
+ * Free a dynamic hash table structure.
+ */
+
+void hash_destroy(hash_t *hash)
+{
+    assert (hash_val_t_bit != 0);
+    assert (hash_isempty(hash));
+    free(hash->table);
+    free(hash);
+}
+
+/*
+ * Initialize a user supplied hash structure. The user also supplies a table of
+ * chains which is assigned to the hash structure. The table is static---it
+ * will not grow or shrink.
+ * 1. See note 1. in hash_create().
+ * 2. The user supplied array of pointers hopefully contains nchains nodes.
+ * 3. See note 7. in hash_create().
+ * 4. We must dynamically compute the mask from the given power of two table
+ *    size.
+ * 5. The user supplied table can't be assumed to contain null pointers,
+ *    so we reset it here.
+ */
+
+hash_t *hash_init(hash_t *hash, hashcount_t maxcount,
+       hash_comp_t compfun, hash_fun_t hashfun, hnode_t **table,
+       hashcount_t nchains)
+{
+    if (hash_val_t_bit == 0)   /* 1 */
+       compute_bits();
+
+    assert (is_power_of_two(nchains));
+
+    hash->table = table;       /* 2 */
+    hash->nchains = nchains;
+    hash->nodecount = 0;
+    hash->maxcount = maxcount;
+    hash->compare = compfun ? compfun : hash_comp_default;
+    hash->function = hashfun ? hashfun : hash_fun_default;
+    hash->dynamic = 0;         /* 3 */
+    hash->mask = compute_mask(nchains);        /* 4 */
+    clear_table(hash);         /* 5 */
+
+    expensive_assert (hash_verify(hash));
+    return hash;
+}
+
+/*
+ * Reset the hash scanner so that the next element retrieved by
+ * hash_scan_next() shall be the first element on the first non-empty chain.
+ * Notes:
+ * 1. Locate the first non empty chain.
+ * 2. If an empty chain is found, remember which one it is and set the next
+ *    pointer to refer to its first element.
+ * 3. Otherwise if a chain is not found, set the next pointer to NULL
+ *    so that hash_scan_next() shall indicate failure.
+ */
+
+void hash_scan_begin(hscan_t *scan, hash_t *hash)
+{
+    hash_val_t nchains = hash->nchains;
+    hash_val_t chain;
+
+    scan->table = hash;
+
+    /* 1 */
+
+    for (chain = 0; chain < nchains && hash->table[chain] == 0; chain++)
+       ;
+
+    if (chain < nchains) {     /* 2 */
+       scan->chain = chain;
+       scan->next = hash->table[chain];
+    } else {                   /* 3 */
+       scan->next = NULL;
+    }
+}
+
+/*
+ * Retrieve the next node from the hash table, and update the pointer
+ * for the next invocation of hash_scan_next().
+ * Notes:
+ * 1. Remember the next pointer in a temporary value so that it can be
+ *    returned.
+ * 2. This assertion essentially checks whether the module has been properly
+ *    initialized. The first point of interaction with the module should be
+ *    either hash_create() or hash_init(), both of which set hash_val_t_bit to
+ *    a non zero value.
+ * 3. If the next pointer we are returning is not NULL, then the user is
+ *    allowed to call hash_scan_next() again. We prepare the new next pointer
+ *    for that call right now. That way the user is allowed to delete the node
+ *    we are about to return, since we will no longer be needing it to locate
+ *    the next node.
+ * 4. If there is a next node in the chain (next->next), then that becomes the
+ *    new next node, otherwise ...
+ * 5. We have exhausted the current chain, and must locate the next subsequent
+ *    non-empty chain in the table.
+ * 6. If a non-empty chain is found, the first element of that chain becomes
+ *    the new next node. Otherwise there is no new next node and we set the
+ *    pointer to NULL so that the next time hash_scan_next() is called, a null
+ *    pointer shall be immediately returned.
+ */
+
+
+hnode_t *hash_scan_next(hscan_t *scan)
+{
+    hnode_t *next = scan->next;                /* 1 */
+    hash_t *hash = scan->table;
+    hash_val_t chain = scan->chain + 1;
+    hash_val_t nchains = hash->nchains;
+
+    assert (hash_val_t_bit != 0);      /* 2 */
+
+    if (next) {                        /* 3 */
+       if (next->next) {       /* 4 */
+           scan->next = next->next;
+       } else {
+           while (chain < nchains && hash->table[chain] == 0)  /* 5 */
+               chain++;
+           if (chain < nchains) {      /* 6 */
+               scan->chain = chain;
+               scan->next = hash->table[chain];
+           } else {
+               scan->next = NULL;
+           }
+       }
+    }
+    return next;
+}
+
+/*
+ * Insert a node into the hash table.
+ * Notes:
+ * 1. It's illegal to insert more than the maximum number of nodes. The client
+ *    should verify that the hash table is not full before attempting an
+ *    insertion.
+ * 2. The same key may not be inserted into a table twice.
+ * 3. If the table is dynamic and the load factor is already at >= 2,
+ *    grow the table.
+ * 4. We take the bottom N bits of the hash value to derive the chain index,
+ *    where N is the base 2 logarithm of the size of the hash table.
+ */
+
+void hash_insert(hash_t *hash, hnode_t *node, const void *key)
+{
+    hash_val_t hkey, chain;
+
+    assert (hash_val_t_bit != 0);
+    assert (node->next == NULL);
+    assert (hash->nodecount < hash->maxcount); /* 1 */
+    expensive_assert (hash_lookup(hash, key) == NULL); /* 2 */
+
+    if (hash->dynamic && hash->nodecount >= hash->highmark)    /* 3 */
+       grow_table(hash);
+
+    hkey = hash->function(key);
+    chain = hkey & hash->mask; /* 4 */
+
+    node->key = key;
+    node->hkey = hkey;
+    node->next = hash->table[chain];
+    hash->table[chain] = node;
+    hash->nodecount++;
+
+    expensive_assert (hash_verify(hash));
+}
+
+/*
+ * Find a node in the hash table and return a pointer to it.
+ * Notes:
+ * 1. We hash the key and keep the entire hash value. As an optimization, when
+ *    we descend down the chain, we can compare hash values first and only if
+ *    hash values match do we perform a full key comparison.
+ * 2. To locate the chain from among 2^N chains, we look at the lower N bits of
+ *    the hash value by anding them with the current mask.
+ * 3. Looping through the chain, we compare the stored hash value inside each
+ *    node against our computed hash. If they match, then we do a full
+ *    comparison between the unhashed keys. If these match, we have located the
+ *    entry.
+ */
+
+hnode_t *hash_lookup(hash_t *hash, const void *key)
+{
+    hash_val_t hkey, chain;
+    hnode_t *nptr;
+
+    hkey = hash->function(key);                /* 1 */
+    chain = hkey & hash->mask;         /* 2 */
+
+    for (nptr = hash->table[chain]; nptr; nptr = nptr->next) { /* 3 */
+       if (nptr->hkey == hkey && hash->compare(nptr->key, key) == 0)
+           return nptr;
+    }
+
+    return NULL;
+}
+
+/*
+ * Delete the given node from the hash table.  Since the chains
+ * are singly linked, we must locate the start of the node's chain
+ * and traverse.
+ * Notes:
+ * 1. The node must belong to this hash table, and its key must not have
+ *    been tampered with.
+ * 2. If this deletion will take the node count below the low mark, we
+ *    shrink the table now.
+ * 3. Determine which chain the node belongs to, and fetch the pointer
+ *    to the first node in this chain.
+ * 4. If the node being deleted is the first node in the chain, then
+ *    simply update the chain head pointer.
+ * 5. Otherwise advance to the node's predecessor, and splice out
+ *    by updating the predecessor's next pointer.
+ * 6. Indicate that the node is no longer in a hash table.
+ */
+
+hnode_t *hash_delete(hash_t *hash, hnode_t *node)
+{
+    hash_val_t chain;
+    hnode_t *hptr;
+
+    expensive_assert (hash_lookup(hash, node->key) == node);   /* 1 */
+    assert (hash_val_t_bit != 0);
+
+    if (hash->dynamic && hash->nodecount <= hash->lowmark
+           && hash->nodecount > INIT_SIZE)
+       shrink_table(hash);                             /* 2 */
+
+    chain = node->hkey & hash->mask;                   /* 3 */
+    hptr = hash->table[chain];
+
+    if (hptr == node) {                                        /* 4 */
+       hash->table[chain] = node->next;
+    } else {
+       while (hptr->next != node) {                    /* 5 */
+           assert (hptr != 0);
+           hptr = hptr->next;
+       }
+       assert (hptr->next == node);
+       hptr->next = node->next;
+    }
+
+    hash->nodecount--;
+    expensive_assert (hash_verify(hash));
+
+    node->next = NULL;                                 /* 6 */
+    return node;
+}
+
+int hash_alloc_insert(hash_t *hash, const void *key, void *data)
+{
+    hnode_t *node = hash->allocnode(hash->context);
+
+    if (node) {
+      hnode_init(node, data);
+      hash_insert(hash, node, key);
+      return 0;
+    }
+    return -1;
+}
+
+void hash_delete_free(hash_t *hash, hnode_t *node)
+{
+    hash_delete(hash, node);
+    hash->freenode(node, hash->context);
+}
+
+/*
+ *  Exactly like hash_delete, except does not trigger table shrinkage. This is to be
+ *  used from within a hash table scan operation. See notes for hash_delete.
+ */
+
+hnode_t *hash_scan_delete(hash_t *hash, hnode_t *node)
+{
+    hash_val_t chain;
+    hnode_t *hptr;
+
+    expensive_assert (hash_lookup(hash, node->key) == node);
+    assert (hash_val_t_bit != 0);
+
+    chain = node->hkey & hash->mask;
+    hptr = hash->table[chain];
+
+    if (hptr == node) {
+       hash->table[chain] = node->next;
+    } else {
+       while (hptr->next != node)
+           hptr = hptr->next;
+       hptr->next = node->next;
+    }
+
+    hash->nodecount--;
+    expensive_assert (hash_verify(hash));
+    node->next = NULL;
+
+    return node;
+}
+
+/*
+ * Like hash_delete_free but based on hash_scan_delete.
+ */
+
+void hash_scan_delfree(hash_t *hash, hnode_t *node)
+{
+    hash_scan_delete(hash, node);
+    hash->freenode(node, hash->context);
+}
+
+/*
+ * Verify whether the given object is a valid hash table. This means
+ * Notes:
+ * 1. If the hash table is dynamic, verify whether the high and
+ *    low expansion/shrinkage thresholds are powers of two.
+ * 2. Count all nodes in the table, and test each hash value
+ *    to see whether it is correct for the node's chain.
+ */
+
+int hash_verify(hash_t *hash)
+{
+    hashcount_t count = 0;
+    hash_val_t chain;
+    hnode_t *hptr;
+
+    if (hash->dynamic) {       /* 1 */
+       if (hash->lowmark >= hash->highmark)
+           return 0;
+       if (!is_power_of_two(hash->highmark))
+           return 0;
+       if (!is_power_of_two(hash->lowmark))
+           return 0;
+    }
+
+    for (chain = 0; chain < hash->nchains; chain++) {  /* 2 */
+       for (hptr = hash->table[chain]; hptr != 0; hptr = hptr->next) {
+           if ((hptr->hkey & hash->mask) != chain)
+               return 0;
+           count++;
+       }
+    }
+
+    if (count != hash->nodecount)
+       return 0;
+
+    return 1;
+}
+
+/*
+ * Test whether the hash table is full and return 1 if this is true,
+ * 0 if it is false.
+ */
+
+#undef hash_isfull
+int hash_isfull(hash_t *hash)
+{
+    return hash->nodecount == hash->maxcount;
+}
+
+/*
+ * Test whether the hash table is empty and return 1 if this is true,
+ * 0 if it is false.
+ */
+
+#undef hash_isempty
+int hash_isempty(hash_t *hash)
+{
+    return hash->nodecount == 0;
+}
+
+static hnode_t *hnode_alloc(ATTRIBUTE_UNUSED void *context)
+{
+    return malloc(sizeof *hnode_alloc(NULL));
+}
+
+static void hnode_free(hnode_t *node, ATTRIBUTE_UNUSED void *context)
+{
+    free(node);
+}
+
+
+/*
+ * Create a hash table node dynamically and assign it the given data.
+ */
+
+hnode_t *hnode_create(void *data)
+{
+    hnode_t *node = malloc(sizeof *node);
+    if (node) {
+       node->data = data;
+       node->next = NULL;
+    }
+    return node;
+}
+
+/*
+ * Initialize a client-supplied node
+ */
+
+hnode_t *hnode_init(hnode_t *hnode, void *data)
+{
+    hnode->data = data;
+    hnode->next = NULL;
+    return hnode;
+}
+
+/*
+ * Destroy a dynamically allocated node.
+ */
+
+void hnode_destroy(hnode_t *hnode)
+{
+    free(hnode);
+}
+
+#undef hnode_put
+void hnode_put(hnode_t *node, void *data)
+{
+    node->data = data;
+}
+
+#undef hnode_get
+void *hnode_get(hnode_t *node)
+{
+    return node->data;
+}
+
+#undef hnode_getkey
+const void *hnode_getkey(hnode_t *node)
+{
+    return node->key;
+}
+
+#undef hash_count
+hashcount_t hash_count(hash_t *hash)
+{
+    return hash->nodecount;
+}
+
+#undef hash_size
+hashcount_t hash_size(hash_t *hash)
+{
+    return hash->nchains;
+}
+
+static hash_val_t hash_fun_default(const void *key)
+{
+    static unsigned long randbox[] = {
+       0x49848f1bU, 0xe6255dbaU, 0x36da5bdcU, 0x47bf94e9U,
+       0x8cbcce22U, 0x559fc06aU, 0xd268f536U, 0xe10af79aU,
+       0xc1af4d69U, 0x1d2917b5U, 0xec4c304dU, 0x9ee5016cU,
+       0x69232f74U, 0xfead7bb3U, 0xe9089ab6U, 0xf012f6aeU,
+    };
+
+    const unsigned char *str = key;
+    hash_val_t acc = 0;
+
+    while (*str) {
+       acc ^= randbox[(*str + acc) & 0xf];
+       acc = (acc << 1) | (acc >> 31);
+       acc &= 0xffffffffU;
+       acc ^= randbox[((*str++ >> 4) + acc) & 0xf];
+       acc = (acc << 2) | (acc >> 30);
+       acc &= 0xffffffffU;
+    }
+    return acc;
+}
+
+static int hash_comp_default(const void *key1, const void *key2)
+{
+    return strcmp(key1, key2);
+}
+
+#ifdef KAZLIB_TEST_MAIN
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+typedef char input_t[256];
+
+static int tokenize(char *string, ...)
+{
+    char **tokptr;
+    va_list arglist;
+    int tokcount = 0;
+
+    va_start(arglist, string);
+    tokptr = va_arg(arglist, char **);
+    while (tokptr) {
+       while (*string && isspace((unsigned char) *string))
+           string++;
+       if (!*string)
+           break;
+       *tokptr = string;
+       while (*string && !isspace((unsigned char) *string))
+           string++;
+       tokptr = va_arg(arglist, char **);
+       tokcount++;
+       if (!*string)
+           break;
+       *string++ = 0;
+    }
+    va_end(arglist);
+
+    return tokcount;
+}
+
+static char *dupstring(char *str)
+{
+    int sz = strlen(str) + 1;
+    char *new = malloc(sz);
+    if (new)
+       memcpy(new, str, sz);
+    return new;
+}
+
+static hnode_t *new_node(void *c)
+{
+    static hnode_t few[5];
+    static int count;
+
+    if (count < 5)
+       return few + count++;
+
+    return NULL;
+}
+
+static void del_node(hnode_t *n, void *c)
+{
+}
+
+int main(void)
+{
+    input_t in;
+    hash_t *h = hash_create(HASHCOUNT_T_MAX, 0, 0);
+    hnode_t *hn;
+    hscan_t hs;
+    char *tok1, *tok2, *val;
+    const char *key;
+    int prompt = 0;
+
+    char *help =
+       "a <key> <val>          add value to hash table\n"
+       "d <key>                delete value from hash table\n"
+       "l <key>                lookup value in hash table\n"
+       "n                      show size of hash table\n"
+       "c                      show number of entries\n"
+       "t                      dump whole hash table\n"
+       "+                      increase hash table (private func)\n"
+       "-                      decrease hash table (private func)\n"
+       "b                      print hash_t_bit value\n"
+       "p                      turn prompt on\n"
+       "s                      switch to non-functioning allocator\n"
+       "q                      quit";
+
+    if (!h)
+       puts("hash_create failed");
+
+    for (;;) {
+       if (prompt)
+           putchar('>');
+       fflush(stdout);
+
+       if (!fgets(in, sizeof(input_t), stdin))
+           break;
+
+       switch(in[0]) {
+           case '?':
+               puts(help);
+               break;
+           case 'b':
+               printf("%d\n", hash_val_t_bit);
+               break;
+           case 'a':
+               if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) {
+                   puts("what?");
+                   break;
+               }
+               key = dupstring(tok1);
+               val = dupstring(tok2);
+
+               if (!key || !val) {
+                   puts("out of memory");
+                   free((void *) key);
+                   free(val);
+                    break;
+               }
+
+               if (hash_alloc_insert(h, key, val) < 0) {
+                   puts("hash_alloc_insert failed");
+                   free((void *) key);
+                   free(val);
+                   break;
+               }
+               break;
+           case 'd':
+               if (tokenize(in+1, &tok1, (char **) 0) != 1) {
+                   puts("what?");
+                   break;
+               }
+               hn = hash_lookup(h, tok1);
+               if (!hn) {
+                   puts("hash_lookup failed");
+                   break;
+               }
+               val = hnode_get(hn);
+               key = hnode_getkey(hn);
+               hash_scan_delfree(h, hn);
+               free((void *) key);
+               free(val);
+               break;
+           case 'l':
+               if (tokenize(in+1, &tok1, (char **) 0) != 1) {
+                   puts("what?");
+                   break;
+               }
+               hn = hash_lookup(h, tok1);
+               if (!hn) {
+                   puts("hash_lookup failed");
+                   break;
+               }
+               val = hnode_get(hn);
+               puts(val);
+               break;
+           case 'n':
+               printf("%lu\n", (unsigned long) hash_size(h));
+               break;
+           case 'c':
+               printf("%lu\n", (unsigned long) hash_count(h));
+               break;
+           case 't':
+               hash_scan_begin(&hs, h);
+               while ((hn = hash_scan_next(&hs)))
+                   printf("%s\t%s\n", (char*) hnode_getkey(hn),
+                           (char*) hnode_get(hn));
+               break;
+           case '+':
+               grow_table(h);          /* private function     */
+               break;
+           case '-':
+               shrink_table(h);        /* private function     */
+               break;
+           case 'q':
+               exit(0);
+               break;
+           case '\0':
+               break;
+           case 'p':
+               prompt = 1;
+               break;
+           case 's':
+               hash_set_allocator(h, new_node, del_node, NULL);
+               break;
+           default:
+               putchar('?');
+               putchar('\n');
+               break;
+       }
+    }
+
+    return 0;
+}
+
+#endif
diff --git a/src/hash.h b/src/hash.h
new file mode 100644 (file)
index 0000000..90bcf93
--- /dev/null
@@ -0,0 +1,240 @@
+/*
+ * Hash Table Data Type
+ * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
+ *
+ * Free Software License:
+ *
+ * All rights are reserved by the author, with the following exceptions:
+ * Permission is granted to freely reproduce and distribute this software,
+ * possibly in exchange for a fee, provided that this copyright notice appears
+ * intact. Permission is also granted to adapt this software to produce
+ * derivative works, as long as the modified versions carry this copyright
+ * notice and additional notices stating that the work has been modified.
+ * This source code may be translated into executable form and incorporated
+ * into proprietary software; there is no requirement for such software to
+ * contain a copyright notice related to this source.
+ *
+ * $Id: hash.h,v 1.22.2.7 2000/11/13 01:36:45 kaz Exp $
+ * $Name: kazlib_1_20 $
+ */
+
+#ifndef HASH_H
+#define HASH_H
+
+#include <limits.h>
+#ifdef KAZLIB_SIDEEFFECT_DEBUG
+#include "sfx.h"
+#endif
+
+/*
+ * Blurb for inclusion into C++ translation units
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned long hashcount_t;
+#define HASHCOUNT_T_MAX ULONG_MAX
+
+typedef unsigned long hash_val_t;
+#define HASH_VAL_T_MAX ULONG_MAX
+
+extern int hash_val_t_bit;
+
+#ifndef HASH_VAL_T_BIT
+#define HASH_VAL_T_BIT ((int) hash_val_t_bit)
+#endif
+
+/*
+ * Hash chain node structure.
+ * Notes:
+ * 1. This preprocessing directive is for debugging purposes.  The effect is
+ *    that if the preprocessor symbol KAZLIB_OPAQUE_DEBUG is defined prior to the
+ *    inclusion of this header,  then the structure shall be declared as having
+ *    the single member   int __OPAQUE__.   This way, any attempts by the
+ *    client code to violate the principles of information hiding (by accessing
+ *    the structure directly) can be diagnosed at translation time. However,
+ *    note the resulting compiled unit is not suitable for linking.
+ * 2. This is a pointer to the next node in the chain. In the last node of a
+ *    chain, this pointer is null.
+ * 3. The key is a pointer to some user supplied data that contains a unique
+ *    identifier for each hash node in a given table. The interpretation of
+ *    the data is up to the user. When creating or initializing a hash table,
+ *    the user must supply a pointer to a function for comparing two keys,
+ *    and a pointer to a function for hashing a key into a numeric value.
+ * 4. The value is a user-supplied pointer to void which may refer to
+ *    any data object. It is not interpreted in any way by the hashing
+ *    module.
+ * 5. The hashed key is stored in each node so that we don't have to rehash
+ *    each key when the table must grow or shrink.
+ */
+
+typedef struct hnode_t {
+    #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)  /* 1 */
+    struct hnode_t *hash_next;         /* 2 */
+    const void *hash_key;              /* 3 */
+    void *hash_data;                   /* 4 */
+    hash_val_t hash_hkey;              /* 5 */
+    #else
+    int hash_dummy;
+    #endif
+} hnode_t;
+
+/*
+ * The comparison function pointer type. A comparison function takes two keys
+ * and produces a value of -1 if the left key is less than the right key, a
+ * value of 0 if the keys are equal, and a value of 1 if the left key is
+ * greater than the right key.
+ */
+
+typedef int (*hash_comp_t)(const void *, const void *);
+
+/*
+ * The hashing function performs some computation on a key and produces an
+ * integral value of type hash_val_t based on that key. For best results, the
+ * function should have a good randomness properties in *all* significant bits
+ * over the set of keys that are being inserted into a given hash table. In
+ * particular, the most significant bits of hash_val_t are most significant to
+ * the hash module. Only as the hash table expands are less significant bits
+ * examined. Thus a function that has good distribution in its upper bits but
+ * not lower is preferrable to one that has poor distribution in the upper bits
+ * but not the lower ones.
+ */
+
+typedef hash_val_t (*hash_fun_t)(const void *);
+
+/*
+ * allocator functions
+ */
+
+typedef hnode_t *(*hnode_alloc_t)(void *);
+typedef void (*hnode_free_t)(hnode_t *, void *);
+
+/*
+ * This is the hash table control structure. It keeps track of information
+ * about a hash table, as well as the hash table itself.
+ * Notes:
+ * 1.  Pointer to the hash table proper. The table is an array of pointers to
+ *     hash nodes (of type hnode_t). If the table is empty, every element of
+ *     this table is a null pointer. A non-null entry points to the first
+ *     element of a chain of nodes.
+ * 2.  This member keeps track of the size of the hash table---that is, the
+ *     number of chain pointers.
+ * 3.  The count member maintains the number of elements that are presently
+ *     in the hash table.
+ * 4.  The maximum count is the greatest number of nodes that can populate this
+ *     table. If the table contains this many nodes, no more can be inserted,
+ *     and the hash_isfull() function returns true.
+ * 5.  The high mark is a population threshold, measured as a number of nodes,
+ *     which, if exceeded, will trigger a table expansion. Only dynamic hash
+ *     tables are subject to this expansion.
+ * 6.  The low mark is a minimum population threshold, measured as a number of
+ *     nodes. If the table population drops below this value, a table shrinkage
+ *     will occur. Only dynamic tables are subject to this reduction.  No table
+ *     will shrink beneath a certain absolute minimum number of nodes.
+ * 7.  This is the a pointer to the hash table's comparison function. The
+ *     function is set once at initialization or creation time.
+ * 8.  Pointer to the table's hashing function, set once at creation or
+ *     initialization time.
+ * 9.  The current hash table mask. If the size of the hash table is 2^N,
+ *     this value has its low N bits set to 1, and the others clear. It is used
+ *     to select bits from the result of the hashing function to compute an
+ *     index into the table.
+ * 10. A flag which indicates whether the table is to be dynamically resized. It
+ *     is set to 1 in dynamically allocated tables, 0 in tables that are
+ *     statically allocated.
+ */
+
+typedef struct hash_t {
+    #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+    struct hnode_t **hash_table;               /* 1 */
+    hashcount_t hash_nchains;                  /* 2 */
+    hashcount_t hash_nodecount;                        /* 3 */
+    hashcount_t hash_maxcount;                 /* 4 */
+    hashcount_t hash_highmark;                 /* 5 */
+    hashcount_t hash_lowmark;                  /* 6 */
+    hash_comp_t hash_compare;                  /* 7 */
+    hash_fun_t hash_function;                  /* 8 */
+    hnode_alloc_t hash_allocnode;
+    hnode_free_t hash_freenode;
+    void *hash_context;
+    hash_val_t hash_mask;                      /* 9 */
+    int hash_dynamic;                          /* 10 */
+    #else
+    int hash_dummy;
+    #endif
+} hash_t;
+
+/*
+ * Hash scanner structure, used for traversals of the data structure.
+ * Notes:
+ * 1. Pointer to the hash table that is being traversed.
+ * 2. Reference to the current chain in the table being traversed (the chain
+ *    that contains the next node that shall be retrieved).
+ * 3. Pointer to the node that will be retrieved by the subsequent call to
+ *    hash_scan_next().
+ */
+
+typedef struct hscan_t {
+    #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+    hash_t *hash_table;                /* 1 */
+    hash_val_t hash_chain;     /* 2 */
+    hnode_t *hash_next;                /* 3 */
+    #else
+    int hash_dummy;
+    #endif
+} hscan_t;
+
+extern hash_t *hash_create(hashcount_t, hash_comp_t, hash_fun_t);
+extern void hash_set_allocator(hash_t *, hnode_alloc_t, hnode_free_t, void *);
+extern void hash_destroy(hash_t *);
+extern void hash_free_nodes(hash_t *);
+extern void hash_free(hash_t *);
+extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t,
+       hash_fun_t, hnode_t **, hashcount_t);
+extern void hash_insert(hash_t *, hnode_t *, const void *);
+extern hnode_t *hash_lookup(hash_t *, const void *);
+extern hnode_t *hash_delete(hash_t *, hnode_t *);
+extern int hash_alloc_insert(hash_t *, const void *, void *);
+extern void hash_delete_free(hash_t *, hnode_t *);
+
+extern void hnode_put(hnode_t *, void *);
+extern void *hnode_get(hnode_t *);
+extern const void *hnode_getkey(hnode_t *);
+extern hashcount_t hash_count(hash_t *);
+extern hashcount_t hash_size(hash_t *);
+
+extern int hash_isfull(hash_t *);
+extern int hash_isempty(hash_t *);
+
+extern void hash_scan_begin(hscan_t *, hash_t *);
+extern hnode_t *hash_scan_next(hscan_t *);
+extern hnode_t *hash_scan_delete(hash_t *, hnode_t *);
+extern void hash_scan_delfree(hash_t *, hnode_t *);
+
+extern int hash_verify(hash_t *);
+
+extern hnode_t *hnode_create(void *);
+extern hnode_t *hnode_init(hnode_t *, void *);
+extern void hnode_destroy(hnode_t *);
+
+#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+#ifdef KAZLIB_SIDEEFFECT_DEBUG
+#define hash_isfull(H) (SFX_CHECK(H)->hash_nodecount == (H)->hash_maxcount)
+#else
+#define hash_isfull(H) ((H)->hash_nodecount == (H)->hash_maxcount)
+#endif
+#define hash_isempty(H) ((H)->hash_nodecount == 0)
+#define hash_count(H) ((H)->hash_nodecount)
+#define hash_size(H) ((H)->hash_nchains)
+#define hnode_get(N) ((N)->hash_data)
+#define hnode_getkey(N) ((N)->hash_key)
+#define hnode_put(N, V) ((N)->hash_data = (V))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/info.c b/src/info.c
new file mode 100644 (file)
index 0000000..288290d
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * info.c: filename/linenumber information for parser/interpreter
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+#include "info.h"
+#include "internal.h"
+#include "memory.h"
+#include "ref.h"
+
+/*
+ * struct string
+ */
+struct string *make_string(char *str) {
+    struct string *string;
+    make_ref(string);
+    string->str = str;
+    return string;
+}
+
+struct string *dup_string(const char *str) {
+    struct string *string;
+    make_ref(string);
+    if (str == NULL)
+        string->str = strdup("");
+    else
+        string->str = strdup(str);
+    if (string->str == NULL)
+        unref(string, string);
+    return string;
+}
+
+void free_string(struct string *string) {
+    if (string == NULL)
+        return;
+    assert(string->ref == 0);
+    free(string->str);
+    free(string);
+}
+
+/*
+ * struct info
+ */
+char *format_info(struct info *info) {
+    const char *fname;
+    char *result = NULL;
+    int r = 0;
+    int fl = info->first_line, ll = info->last_line;
+    int fc = info->first_column, lc = info->last_column;
+    fname = (info->filename != NULL) ? info->filename->str : "(unknown file)";
+
+    if (fl > 0) {
+        if (fl == ll) {
+            if (fc == lc) {
+                r = xasprintf(&result, "%s:%d.%d:", fname, fl, fc);
+            } else {
+                r = xasprintf(&result, "%s:%d.%d-.%d:", fname, fl, fc, lc);
+            }
+        } else {
+            r = xasprintf(&result, "%s:%d.%d-%d.%d:", fname, fl, fc, ll, lc);
+        }
+    } else {
+        r = xasprintf(&result, "%s:", fname);
+    }
+    return (r == -1) ? NULL : result;
+}
+
+void print_info(FILE *out, struct info *info) {
+    if (info == NULL) {
+        fprintf(out, "(no file info):");
+        return;
+    }
+    fprintf(out, "%s:",
+            info->filename != NULL ? info->filename->str : "(unknown file)");
+    if (info->first_line > 0) {
+        if (info->first_line == info->last_line) {
+            if (info->first_column == info->last_column) {
+                fprintf(out, "%d.%d:", info->first_line, info->first_column);
+            } else {
+                fprintf(out, "%d.%d-.%d:", info->first_line,
+                        info->first_column, info->last_column);
+            }
+        } else {
+            fprintf(out, "%d.%d-%d.%d:",
+                    info->first_line, info->first_column,
+                    info->last_line, info->last_column);
+        }
+    }
+}
+
+void free_info(struct info *info) {
+    if (info == NULL)
+        return;
+    assert(info->ref == 0);
+    unref(info->filename, string);
+    free(info);
+}
+
+struct span *make_span(struct info *info) {
+    struct span *span = NULL;
+    if (ALLOC(span) < 0) {
+        return NULL;
+    }
+    /* UINT_MAX means span is not initialized yet */
+    span->span_start = UINT_MAX;
+    span->filename = ref(info->filename);
+    return span;
+}
+
+void free_span(struct span *span) {
+    if (span == NULL)
+        return;
+    unref(span->filename, string);
+    free(span);
+}
+
+void print_span(struct span *span) {
+    if (span == NULL)
+        return;
+    printf("%s label=(%i:%i) value=(%i:%i) span=(%i,%i)\n",
+            span->filename->str,
+            span->label_start, span->label_end,
+            span->value_start, span->value_end,
+            span->span_start, span->span_end);
+}
+
+void update_span(struct span *node_info, int x, int y) {
+    if (node_info == NULL)
+        return;
+    if (node_info->span_start == UINT_MAX) {
+        node_info->span_start = x;
+        node_info->span_end = y;
+    } else {
+        if (node_info->span_start > x)
+            node_info->span_start = x;
+        if (node_info->span_end < y)
+            node_info->span_end = y;
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/info.h b/src/info.h
new file mode 100644 (file)
index 0000000..2e3aa0f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * info.h: filename/linenumber information for parser/interpreter
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#ifndef INFO_H_
+#define INFO_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "ref.h"
+
+/* Reference-counted strings */
+struct string {
+    ref_t   ref;
+    char   *str;
+};
+
+struct string *make_string(char *str);
+
+/* Duplicate a string; if STR is NULL, use the empty string "" */
+struct string *dup_string(const char *str);
+
+/* Do not call directly, use UNREF instead */
+void free_string(struct string *string);
+
+/* File information */
+struct info {
+    /* There is only one struct error for each Augeas instance */
+    struct error  *error;
+    struct string *filename;
+    uint16_t first_line;
+    uint16_t first_column;
+    uint16_t last_line;
+    uint16_t last_column;
+    ref_t    ref;
+    int flags;
+};
+
+struct span {
+    struct string *filename;
+    uint label_start;
+    uint label_end;
+    uint value_start;
+    uint value_end;
+    uint span_start;
+    uint span_end;
+};
+
+char *format_info(struct info *info);
+
+void print_info(FILE *out, struct info *info);
+
+/* Do not call directly, use UNREF instead */
+void free_info(struct info *info);
+
+struct span *make_span(struct info *info);
+void free_span(struct span *node_info);
+void update_span(struct span *node_info, int x, int y);
+void print_span(struct span *node_info);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/internal.c b/src/internal.c
new file mode 100644 (file)
index 0000000..8419ca2
--- /dev/null
@@ -0,0 +1,508 @@
+/*
+ * internal.c: internal data structures and helpers
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <locale.h>
+
+#include "internal.h"
+#include "memory.h"
+#include "fa.h"
+
+#ifndef MIN
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* Cap file reads somwhat arbitrarily at 32 MB */
+#define MAX_READ_LEN (32*1024*1024)
+
+int pathjoin(char **path, int nseg, ...) {
+    va_list ap;
+
+    va_start(ap, nseg);
+    for (int i=0; i < nseg; i++) {
+        const char *seg = va_arg(ap, const char *);
+        if (seg == NULL)
+            seg = "()";
+        int len = strlen(seg) + 1;
+
+        if (*path != NULL) {
+            len += strlen(*path) + 1;
+            if (REALLOC_N(*path, len) == -1) {
+                FREE(*path);
+                return -1;
+            }
+            if (strlen(*path) == 0 || (*path)[strlen(*path)-1] != SEP)
+                strcat(*path, "/");
+            if (seg[0] == SEP)
+                seg += 1;
+            strcat(*path, seg);
+        } else {
+            if ((*path = malloc(len)) == NULL)
+                return -1;
+            strcpy(*path, seg);
+        }
+    }
+    va_end(ap);
+    return 0;
+}
+
+/* Like gnulib's fread_file, but read no more than the specified maximum
+   number of bytes.  If the length of the input is <= max_len, and
+   upon error while reading that data, it works just like fread_file.
+
+   Taken verbatim from libvirt's util.c
+*/
+
+static char *
+fread_file_lim (FILE *stream, size_t max_len, size_t *length)
+{
+    char *buf = NULL;
+    size_t alloc = 0;
+    size_t size = 0;
+    int save_errno;
+
+    for (;;) {
+        size_t count;
+        size_t requested;
+
+        if (size + BUFSIZ + 1 > alloc) {
+            char *new_buf;
+
+            alloc += alloc / 2;
+            if (alloc < size + BUFSIZ + 1)
+                alloc = size + BUFSIZ + 1;
+
+            new_buf = realloc (buf, alloc);
+            if (!new_buf) {
+                save_errno = errno;
+                break;
+            }
+
+            buf = new_buf;
+        }
+
+        /* Ensure that (size + requested <= max_len); */
+        requested = MIN (size < max_len ? max_len - size : 0,
+                         alloc - size - 1);
+        count = fread (buf + size, 1, requested, stream);
+        size += count;
+
+        if (count != requested || requested == 0) {
+            save_errno = errno;
+            if (ferror (stream))
+                break;
+            buf[size] = '\0';
+            *length = size;
+            return buf;
+        }
+    }
+
+    free (buf);
+    errno = save_errno;
+    return NULL;
+}
+
+char* xread_file(const char *path) {
+    FILE *fp = fopen(path, "r");
+    char *result;
+    size_t len;
+
+    if (!fp)
+        return NULL;
+
+    result = fread_file_lim(fp, MAX_READ_LEN, &len);
+    fclose (fp);
+
+    if (result != NULL
+        && len <= MAX_READ_LEN
+        && (int) len == len)
+        return result;
+
+    free(result);
+    return NULL;
+}
+
+/*
+ * Escape/unescape of string literals
+ */
+static const char *const escape_chars    = "\"\a\b\t\n\v\f\r\\";
+static const char *const escape_names = "\"abtnvfr\\";
+
+char *unescape(const char *s, int len) {
+    size_t size;
+    const char *n;
+    char *result, *t;
+    int i;
+
+    if (len < 0 || len > strlen(s))
+        len = strlen(s);
+
+    size = 0;
+    for (i=0; i < len; i++, size++)
+        if (s[i] == '\\' && strchr(escape_names, s[i+1]) != NULL) {
+            i += 1;
+        }
+
+    if (ALLOC_N(result, size + 1) < 0)
+        return NULL;
+
+    for (i = 0, t = result; i < len; i++, size++) {
+        if (s[i] == '\\' && (n = strchr(escape_names, s[i+1])) != NULL) {
+            *t++ = escape_chars[n - escape_names];
+            i += 1;
+        } else {
+            *t++ = s[i];
+        }
+    }
+    return result;
+}
+
+char *escape(const char *text, int cnt) {
+
+    int len = 0;
+    char *esc = NULL, *e;
+
+    if (cnt < 0 || cnt > strlen(text))
+        cnt = strlen(text);
+
+    for (int i=0; i < cnt; i++) {
+        if (text[i] && (strchr(escape_chars, text[i]) != NULL))
+            len += 2;  /* Escaped as '\x' */
+        else if (! isprint(text[i]))
+            len += 4;  /* Escaped as '\ooo' */
+        else
+            len += 1;
+    }
+    if (ALLOC_N(esc, len+1) < 0)
+        return NULL;
+    e = esc;
+    for (int i=0; i < cnt; i++) {
+        char *p;
+        if (text[i] && ((p = strchr(escape_chars, text[i])) != NULL)) {
+            *e++ = '\\';
+            *e++ = escape_names[p - escape_chars];
+        } else if (! isprint(text[i])) {
+            sprintf(e, "\\%03o", (unsigned char) text[i]);
+            e += 4;
+        } else {
+            *e++ = text[i];
+        }
+    }
+    return esc;
+}
+
+int print_chars(FILE *out, const char *text, int cnt) {
+    int total = 0;
+    char *esc;
+
+    if (text == NULL) {
+        fprintf(out, "nil");
+        return 3;
+    }
+    if (cnt < 0)
+        cnt = strlen(text);
+
+    esc = escape(text, cnt);
+    total = strlen(esc);
+    if (out != NULL)
+        fprintf(out, "%s", esc);
+    free(esc);
+
+    return total;
+}
+
+char *format_pos(const char *text, int pos) {
+    static const int window = 28;
+    char *buf = NULL, *left = NULL, *right = NULL;
+    int before = pos;
+    int llen, rlen;
+    int r;
+
+    if (before > window)
+        before = window;
+    left = escape(text + pos - before, before);
+    if (left == NULL)
+        goto done;
+    right = escape(text + pos, window);
+    if (right == NULL)
+        goto done;
+
+    llen = strlen(left);
+    rlen = strlen(right);
+    if (llen < window && rlen < window) {
+        r = asprintf(&buf, "%*s%s|=|%s%-*s\n", window - llen, "<", left,
+                     right, window - rlen, ">");
+    } else if (strlen(left) < window) {
+        r = asprintf(&buf, "%*s%s|=|%s>\n", window - llen, "<", left, right);
+    } else if (strlen(right) < window) {
+        r = asprintf(&buf, "<%s|=|%s%-*s\n", left, right, window - rlen, ">");
+    } else {
+        r = asprintf(&buf, "<%s|=|%s>\n", left, right);
+    }
+    if (r < 0) {
+        buf = NULL;
+    }
+
+ done:
+    free(left);
+    free(right);
+    return buf;
+}
+
+void print_pos(FILE *out, const char *text, int pos) {
+    char *format = format_pos(text, pos);
+
+    if (format != NULL) {
+        fputs(format, out);
+        FREE(format);
+    }
+}
+
+int init_memstream(struct memstream *ms) {
+    MEMZERO(ms, 1);
+#if HAVE_OPEN_MEMSTREAM
+    ms->stream = open_memstream(&(ms->buf), &(ms->size));
+    return ms->stream == NULL ? -1 : 0;
+#else
+    ms->stream = tmpfile();
+    if (ms->stream == NULL) {
+        return -1;
+    }
+    return 0;
+#endif
+}
+
+int close_memstream(struct memstream *ms) {
+#if !HAVE_OPEN_MEMSTREAM
+    rewind(ms->stream);
+    ms->buf = fread_file_lim(ms->stream, MAX_READ_LEN, &(ms->size));
+#endif
+    if (fclose(ms->stream) == EOF) {
+        FREE(ms->buf);
+        ms->size = 0;
+        return -1;
+    }
+    return 0;
+}
+
+char *path_expand(struct tree *tree, const char *ppath) {
+    struct tree *siblings = tree->parent->children;
+
+    char *path;
+    const char *label;
+    int cnt = 0, ind = 0, r;
+
+    list_for_each(t, siblings) {
+        if (streqv(t->label, tree->label)) {
+            cnt += 1;
+            if (t == tree)
+                ind = cnt;
+        }
+    }
+
+    if (ppath == NULL)
+        ppath = "";
+
+    if (tree == NULL)
+        label = "(no_tree)";
+    else if (tree->label == NULL)
+        label = "(none)";
+    else
+        label = tree->label;
+
+    if (cnt > 1) {
+        r = asprintf(&path, "%s/%s[%d]", ppath, label, ind);
+    } else {
+        r = asprintf(&path, "%s/%s", ppath, label);
+    }
+    if (r == -1)
+        return NULL;
+    return path;
+}
+
+char *path_of_tree(struct tree *tree) {
+    int depth, i;
+    struct tree *t, **anc;
+    char *path = NULL;
+
+    for (t = tree, depth = 1; ! ROOT_P(t); depth++, t = t->parent);
+    if (ALLOC_N(anc, depth) < 0)
+        return NULL;
+
+    for (t = tree, i = depth - 1; i >= 0; i--, t = t->parent)
+        anc[i] = t;
+
+    for (i = 0; i < depth; i++) {
+        char *p = path_expand(anc[i], path);
+        free(path);
+        path = p;
+    }
+    FREE(anc);
+    return path;
+}
+
+const char *xstrerror(int errnum, char *buf, size_t len) {
+#ifdef HAVE_STRERROR_R
+# ifdef __USE_GNU
+    /* Annoying linux specific API contract */
+    return strerror_r(errnum, buf, len);
+# else
+    strerror_r(errnum, buf, len);
+    return buf;
+# endif
+#else
+    int n = snprintf(buf, len, "errno=%d", errnum);
+    return (0 < n && n < len
+            ? buf : "internal error: buffer too small in xstrerror");
+#endif
+}
+
+int xasprintf(char **strp, const char *format, ...) {
+  va_list args;
+  int result;
+
+  va_start (args, format);
+  result = vasprintf (strp, format, args);
+  va_end (args);
+  if (result < 0)
+      *strp = NULL;
+  return result;
+}
+
+/* From libvirt's src/xen/block_stats.c */
+int xstrtoint64(char const *s, int base, int64_t *result) {
+    long long int lli;
+    char *p;
+
+    errno = 0;
+    lli = strtoll(s, &p, base);
+    if (errno || !(*p == 0 || *p == '\n') || p == s || (int64_t) lli != lli)
+        return -1;
+    *result = lli;
+    return 0;
+}
+
+void calc_line_ofs(const char *text, size_t pos, size_t *line, size_t *ofs) {
+    *line = 1;
+    *ofs = 0;
+    for (const char *t = text; t < text + pos; t++) {
+        *ofs += 1;
+        if (*t == '\n') {
+            *ofs = 0;
+            *line += 1;
+        }
+    }
+}
+
+#if HAVE_USELOCALE
+int regexp_c_locale(ATTRIBUTE_UNUSED char **u, ATTRIBUTE_UNUSED size_t *len) {
+    /* On systems with uselocale, we are ok, since we make sure that we
+     * switch to the "C" locale any time we enter through the public API
+     */
+    return 0;
+}
+#else
+int regexp_c_locale(char **u, size_t *len) {
+    /* Without uselocale, we need to expand character ranges */
+    int r;
+    char *s = *u;
+    size_t s_len, u_len;
+    if (len == NULL) {
+        len = &u_len;
+        s_len = strlen(s);
+    } else {
+        s_len = *len;
+    }
+    r = fa_expand_char_ranges(s, s_len, u, len);
+    if (r != 0) {
+        *u = s;
+        *len = s_len;
+    }
+    if (r < 0)
+        return -1;
+    /* Syntax errors will be caught when the result is compiled */
+    if (r > 0)
+        return 0;
+    free(s);
+    return 1;
+}
+#endif
+
+#if ENABLE_DEBUG
+bool debugging(const char *category) {
+    const char *debug = getenv("AUGEAS_DEBUG");
+    const char *s;
+
+    if (debug == NULL)
+        return false;
+
+    for (s = debug; s != NULL; ) {
+        if (STREQLEN(s, category, strlen(category)))
+            return true;
+        s = strchr(s, ':');
+        if (s != NULL)
+            s+=1;
+    }
+    return false;
+}
+
+FILE *debug_fopen(const char *format, ...) {
+    va_list ap;
+    FILE *result = NULL;
+    const char *dir;
+    char *name = NULL, *path = NULL;
+    int r;
+
+    dir = getenv("AUGEAS_DEBUG_DIR");
+    if (dir == NULL)
+        goto error;
+
+    va_start(ap, format);
+    r = vasprintf(&name, format, ap);
+    va_end(ap);
+    if (r < 0)
+        goto error;
+
+    r = xasprintf(&path, "%s/%s", dir, name);
+    if (r < 0)
+        goto error;
+
+    result = fopen(path, "w");
+
+ error:
+    free(name);
+    free(path);
+    return result;
+}
+#endif
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/internal.h b/src/internal.h
new file mode 100644 (file)
index 0000000..b649e23
--- /dev/null
@@ -0,0 +1,558 @@
+/*
+ * internal.h: Useful definitions
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef INTERNAL_H_
+#define INTERNAL_H_
+
+#include "list.h"
+#include "datadir.h"
+#include "augeas.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <errno.h>
+#include <assert.h>
+#include <locale.h>
+
+/*
+ * Various parameters about env vars, special tree nodes etc.
+ */
+
+/* Define: AUGEAS_LENS_DIR
+ * The default location for lens definitions */
+#define AUGEAS_LENS_DIR DATADIR "/augeas/lenses"
+
+/* The directory where we install lenses distribute with Augeas */
+#define AUGEAS_LENS_DIST_DIR DATADIR "/augeas/lenses/dist"
+
+/* Define: AUGEAS_ROOT_ENV
+ * The env var that points to the chroot holding files we may modify.
+ * Mostly useful for testing */
+#define AUGEAS_ROOT_ENV "AUGEAS_ROOT"
+
+/* Define: AUGEAS_FILES_TREE
+ * The root for actual file contents */
+#define AUGEAS_FILES_TREE "/files"
+
+/* Define: AUGEAS_META_TREE
+ * Augeas reports some information in this subtree */
+#define AUGEAS_META_TREE "/augeas"
+
+/* Define: AUGEAS_META_FILES
+ * Information about files */
+#define AUGEAS_META_FILES AUGEAS_META_TREE AUGEAS_FILES_TREE
+
+/* Define: AUGEAS_META_ROOT
+ * The root directory */
+#define AUGEAS_META_ROOT AUGEAS_META_TREE "/root"
+
+/* Define: AUGEAS_META_SAVE_MODE
+ * How we save files. One of 'backup', 'overwrite' or 'newfile' */
+#define AUGEAS_META_SAVE_MODE AUGEAS_META_TREE "/save"
+
+/* Define: AUGEAS_CLONE_IF_RENAME_FAILS
+ * Control what save does when renaming the temporary file to its final
+ * destination fails with EXDEV or EBUSY: when this tree node exists, copy
+ * the file contents. If it is not present, simply give up and report an
+ * error.  */
+#define AUGEAS_COPY_IF_RENAME_FAILS \
+    AUGEAS_META_SAVE_MODE "/copy_if_rename_fails"
+
+/* A hierarchy where we record certain 'events', e.g. which tree
+ * nodes actually gotsaved into files */
+#define AUGEAS_EVENTS AUGEAS_META_TREE "/events"
+
+#define AUGEAS_EVENTS_SAVED AUGEAS_EVENTS "/saved"
+
+/* Where to put information about parsing of path expressions */
+#define AUGEAS_META_PATHX AUGEAS_META_TREE "/pathx"
+
+/* Define: AUGEAS_SPAN_OPTION
+ * Enable or disable node indexes */
+#define AUGEAS_SPAN_OPTION AUGEAS_META_TREE "/span"
+
+/* Define: AUGEAS_LENS_ENV
+ * Name of env var that contains list of paths to search for additional
+   spec files */
+#define AUGEAS_LENS_ENV "AUGEAS_LENS_LIB"
+
+/* Define: MAX_ENV_SIZE
+ * Fairly arbitrary bound on the length of the path we
+ *  accept from AUGEAS_SPEC_ENV */
+#define MAX_ENV_SIZE 4096
+
+/* Define: PATH_SEP_CHAR
+ * Character separating paths in a list of paths */
+#define PATH_SEP_CHAR ':'
+
+/* Constants for setting the save mode via the augeas path at
+ * AUGEAS_META_SAVE_MODE */
+#define AUG_SAVE_BACKUP_TEXT "backup"
+#define AUG_SAVE_NEWFILE_TEXT "newfile"
+#define AUG_SAVE_NOOP_TEXT "noop"
+#define AUG_SAVE_OVERWRITE_TEXT "overwrite"
+
+/* constants for options in the tree */
+#define AUG_ENABLE "enable"
+#define AUG_DISABLE "disable"
+
+#ifdef __GNUC__
+
+#ifndef __GNUC_PREREQ
+#define __GNUC_PREREQ(maj,min) 0
+#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro to flag conciously unused parameters to functions
+ */
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__((__unused__))
+#endif
+
+/**
+ * ATTRIBUTE_FORMAT
+ *
+ * Macro used to check printf/scanf-like functions, if compiling
+ * with gcc.
+ */
+#ifndef ATTRIBUTE_FORMAT
+#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
+#endif
+
+#ifndef ATTRIBUTE_PURE
+#define ATTRIBUTE_PURE __attribute__((pure))
+#endif
+
+#ifndef ATTRIBUTE_RETURN_CHECK
+#if __GNUC_PREREQ (3, 4)
+#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+#else
+#define ATTRIBUTE_RETURN_CHECK
+#endif
+#endif
+
+#else
+#define ATTRIBUTE_UNUSED
+#define ATTRIBUTE_FORMAT(...)
+#define ATTRIBUTE_PURE
+#define ATTRIBUTE_RETURN_CHECK
+#endif                                   /* __GNUC__ */
+
+#define ARRAY_CARDINALITY(array) (sizeof (array) / sizeof *(array))
+
+/* String equality tests, suggested by Jim Meyering. */
+#define STREQ(a,b) (strcmp((a),(b)) == 0)
+#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
+#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
+#define STRNEQ(a,b) (strcmp((a),(b)) != 0)
+#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
+#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
+#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
+
+ATTRIBUTE_PURE
+static inline int streqv(const char *a, const char *b) {
+    if (a == NULL || b == NULL)
+        return a == b;
+    return STREQ(a,b);
+}
+
+/* Path length and comparison */
+
+#define SEP '/'
+
+/* Length of PATH without any trailing '/' */
+ATTRIBUTE_PURE
+static inline int pathlen(const char *path) {
+    int len = strlen(path);
+
+    if (len > 0 && path[len-1] == SEP)
+        len--;
+
+    return len;
+}
+
+/* Return 1 if P1 is a prefix of P2. P1 as a string must have length <= P2 */
+ATTRIBUTE_PURE
+static inline int pathprefix(const char *p1, const char *p2) {
+    if (p1 == NULL || p2 == NULL)
+        return 0;
+    int l1 = pathlen(p1);
+
+    return STREQLEN(p1, p2, l1) && (p2[l1] == '\0' || p2[l1] == SEP);
+}
+
+static inline int pathendswith(const char *path, const char *basenam) {
+    const char *p = strrchr(path, SEP);
+    if (p == NULL)
+        return 0;
+    return streqv(p+1, basenam);
+}
+
+/* Join NSEG path components (passed as const char *) into one PATH.
+   Allocate as needed. Return 0 on success, -1 on failure */
+int pathjoin(char **path, int nseg, ...);
+
+/* Call calloc to allocate an array of N instances of *VAR */
+#define CALLOC(Var,N) do { (Var) = calloc ((N), sizeof (*(Var))); } while (0)
+
+#define MEMZERO(ptr, n) memset((ptr), 0, (n) * sizeof(*(ptr)));
+
+#define MEMCPY(dest, src, n) memcpy((dest), (src), (n) * sizeof(*(src)))
+
+#define MEMMOVE(dest, src, n) memmove((dest), (src), (n) * sizeof(*(src)))
+
+/**
+ * TODO:
+ *
+ * macro to flag unimplemented blocks
+ */
+#define TODO                                                           \
+    fprintf(stderr, "%s:%d Unimplemented block\n",                     \
+            __FILE__, __LINE__);
+
+#define FIXME(msg, args ...)                            \
+    do {                                                \
+        fprintf(stderr, "%s:%d Fixme: ",                \
+                __FILE__, __LINE__);                    \
+      fprintf(stderr, msg, ## args);                    \
+      fputc('\n', stderr);                              \
+    } while(0)
+
+/*
+ * Internal data structures
+ */
+
+// internal.c
+
+/* Function: escape
+ * Escape nonprintable characters within TEXT, similar to how it's done in
+ * C string literals. Caller must free the returned string.
+ */
+char *escape(const char *text, int cnt);
+
+/* Function: unescape */
+char *unescape(const char *s, int len);
+
+/* Function: print_chars */
+int print_chars(FILE *out, const char *text, int cnt);
+
+/* Function: print_pos
+ * Print a pretty representation of being at position POS within TEXT */
+void print_pos(FILE *out, const char *text, int pos);
+char *format_pos(const char *text, int pos);
+
+/* Function: xread_file
+ * Read the contents of file PATH and return them as one long string. The
+ * caller must free the result. Return NULL if any error occurs.
+ */
+char* xread_file(const char *path);
+
+/* Get the error message for ERRNUM in a threadsafe way. Based on libvirt's
+ * virStrError
+ */
+const char *xstrerror(int errnum, char *buf, size_t len);
+
+/* Like asprintf, but set *STRP to NULL on error */
+int xasprintf(char **strp, const char *format, ...);
+
+/* Convert S to RESULT with error checking */
+int xstrtoint64(char const *s, int base, int64_t *result);
+
+/* Calculate line and column number of character POS in TEXT */
+void calc_line_ofs(const char *text, size_t pos, size_t *line, size_t *ofs);
+
+/* Take the first LEN characters from the regexp *U and expand any
+ * character ranges in it. The expanded regexp, if expansion is necessary,
+ * is in U, and the old string is freed. If expansion is not needed or an
+ * error happens, U will be unchanged.
+ *
+ * Return 0 if expansion is not necessary, -1 if an error occurs, and 1 if
+ * expansion was needed.
+ */
+int regexp_c_locale(char **u, size_t *len);
+
+/* Struct: augeas
+ * The data structure representing a connection to Augeas. */
+struct augeas {
+    struct tree      *origin;     /* Actual tree root is origin->children */
+    const char       *root;       /* Filesystem root for all files */
+                                  /* always ends with '/' */
+    unsigned int      flags;      /* Flags passed to AUG_INIT */
+    struct module    *modules;    /* Loaded modules */
+    size_t            nmodpath;
+    char             *modpathz;   /* The search path for modules as a
+                                     glibc argz vector */
+    struct pathx_symtab *symtab;
+    struct error        *error;
+    uint                api_entries;  /* Number of entries through a public
+                                       * API, 0 when called from outside */
+#if HAVE_USELOCALE
+    /* On systems that have a uselocale call, we switch to the C locale
+     * on entry into API functions, and back to the old user locale
+     * on exit.
+     * FIXME: We need some solution for systems without uselocale, like
+     * setlocale + critical section, though that is very heavy-handed
+     */
+    locale_t            c_locale;
+    locale_t            user_locale;
+#endif
+};
+
+static inline struct error *err_of_aug(const struct augeas *aug) {
+    return ((struct augeas *) aug)->error;
+}
+
+/* Used by augparse for loading tests */
+int __aug_load_module_file(struct augeas *aug, const char *filename);
+
+/* Struct: tree
+ * An entry in the global config tree. The data structure allows associating
+ * values with interior nodes, but the API currently marks that as an error.
+ *
+ * To make dealing with parents uniform, even for the root, we create
+ * standalone trees with a fake root, called origin. That root is generally
+ * not referenced from anywhere. Standalone trees should be created with
+ * MAKE_TREE_ORIGIN.
+ *
+ * The DIRTY flag is used to track which parts of the tree might need to be
+ * saved. For any node that is marked dirty, all of its ancestors must be
+ * marked dirty, too. Instead of setting this flag directly, the function
+ * TREE_MARK_DIRTY in augeas.c should be used (and only functions in that
+ * file should have a need to mark nodes as dirty)
+ */
+struct tree {
+    struct tree *next;
+    struct tree *parent;     /* Points to self for root */
+    char        *label;      /* Last component of PATH */
+    struct tree *children;   /* List of children through NEXT */
+    char        *value;
+    int          dirty;
+    struct span *span;
+};
+
+/* The opaque structure used to represent path expressions. API's
+ * using STRUCT PATHX are declared farther below
+ */
+struct pathx;
+
+#define ROOT_P(t) ((t) != NULL && (t)->parent == (t)->parent->parent)
+
+/* Function: make_tree
+ * Allocate a new tree node with the given LABEL, VALUE, and CHILDREN,
+ * which are not copied. The new tree is marked as dirty
+ */
+struct tree *make_tree(char *label, char *value,
+                       struct tree *parent, struct tree *children);
+
+/* Mark a tree as a standalone tree; this creates a fake parent for ROOT,
+ * so that even ROOT has a parent. A new node with only child ROOT is
+ * returned on success, and NULL on failure.
+ */
+struct tree  *make_tree_origin(struct tree *root);
+
+int tree_replace(struct augeas *aug, const char *path, struct tree *sub);
+/* Make a new tree node and append it to parent's children */
+struct tree *tree_append(struct tree *parent, char *label, char *value);
+
+int tree_rm(struct pathx *p);
+int tree_unlink(struct tree *tree);
+struct tree *tree_set(struct pathx *p, const char *value);
+int tree_insert(struct pathx *p, const char *label, int before);
+int free_tree(struct tree *tree);
+int dump_tree(FILE *out, struct tree *tree);
+int tree_equal(const struct tree *t1, const struct tree *t2);
+char *path_expand(struct tree *tree, const char *ppath);
+char *path_of_tree(struct tree *tree);
+/* Clear the dirty flag in the whole TREE */
+void tree_clean(struct tree *tree);
+/* Return first child with label LABEL or NULL */
+struct tree *tree_child(struct tree *tree, const char *label);
+/* Return first existing child with label LABEL or create one. Return NULL
+ * when allocation fails */
+struct tree *tree_child_cr(struct tree *tree, const char *label);
+/* Create a path in the tree; nodes along the path are looked up with
+ * tree_child_cr */
+struct tree *tree_path_cr(struct tree *tree, int n, ...);
+/* Store VALUE directly as the value of TREE and set VALUE to NULL.
+ * Update dirty flags */
+void tree_store_value(struct tree *tree, char **value);
+/* Set the value of TREE to a copy of VALUE and update dirty flags */
+int tree_set_value(struct tree *tree, const char *value);
+/* Cleanly remove all children of TREE, but leave TREE itself unchanged */
+void tree_unlink_children(struct augeas *aug, struct tree *tree);
+/* Find the node matching PATH.
+ * Returns the node or NULL on error
+ * Errors: EMMATCH - more than one node matches PATH
+ *         ENOMEM  - allocation error
+ */
+struct tree *tree_find(struct augeas *aug, const char *path);
+/* Find the node matching PATH. Expand the tree to contain such a node if
+ * none exists.
+ * Returns the node or NULL on error
+ */
+struct tree *tree_find_cr(struct augeas *aug, const char *path);
+
+/* Struct: memstream
+ * Wrappers to simulate OPEN_MEMSTREAM where that's not available. The
+ * STREAM member is opened by INIT_MEMSTREAM and closed by
+ * CLOSE_MEMSTREAM. The BUF is allocated automatically, but can not be used
+ * until after CLOSE_MEMSTREAM has been called. It is the callers
+ * responsibility to free up BUF.
+ */
+struct memstream {
+    FILE   *stream;
+    char   *buf;
+    size_t size;
+};
+
+/* Function: init_memstream
+ * Initialize a memstream. On systems that have OPEN_MEMSTREAM, it is used
+ * to open MS->STREAM. On systems without OPEN_MEMSTREAM, MS->STREAM is
+ * backed by a temporary file.
+ *
+ * MS must be allocated in advance; INIT_MEMSTREAM initializes it.
+ */
+int init_memstream(struct memstream *ms);
+
+/* Function: close_memstream
+ * Close a memstream. After calling this, MS->STREAM can not be used
+ * anymore and a string representing whatever was written to it is
+ * available in MS->BUF. The caller must free MS->BUF.
+ *
+ * The caller must free the MEMSTREAM structure.
+ */
+int close_memstream(struct memstream *ms);
+
+/*
+ * Path expressions
+ */
+
+typedef enum {
+    PATHX_NOERROR = 0,
+    PATHX_ENAME,
+    PATHX_ESTRING,
+    PATHX_ENUMBER,
+    PATHX_EDELIM,
+    PATHX_ENOEQUAL,
+    PATHX_ENOMEM,
+    PATHX_EPRED,
+    PATHX_EPAREN,
+    PATHX_ESLASH,
+    PATHX_EINTERNAL,
+    PATHX_ETYPE,
+    PATHX_ENOVAR,
+    PATHX_EEND,
+    PATHX_ENONODES,
+    PATHX_EARITY,
+    PATHX_EREGEXP
+} pathx_errcode_t;
+
+struct pathx;
+struct pathx_symtab;
+
+const char *pathx_error(struct pathx *pathx, const char **txt, int *pos);
+
+/* Parse a path expression PATH rooted at TREE, which is a node somewhere
+ * in AUG->ORIGIN. If TREE is NULL, AUG->ORIGIN is used.
+ *
+ * Use this function rather than PATHX_PARSE for path expressions inside
+ * the tree in AUG->ORIGIN.
+ *
+ * If NEED_NODESET is true, the resulting path expression must evaluate toa
+ * nodeset, otherwise it can evaluate to a value of any type.
+ *
+ * Return the resulting path expression, or NULL on error. If an error
+ * occurs, the error struct in AUG contains details.
+ */
+struct pathx *pathx_aug_parse(const struct augeas *aug,
+                              struct tree *tree,
+                              const char *path, bool need_nodeset);
+
+/* Parse the string PATH into a path expression PX that will be evaluated
+ * against the tree ORIGIN.
+ *
+ * If NEED_NODESET is true, the resulting path expression must evaluate toa
+ * nodeset, otherwise it can evaluate to a value of any type.
+ *
+ * Returns 0 on success, and -1 on error
+ */
+int pathx_parse(const struct tree *origin,
+                struct error *err,
+                const char *path,
+                bool need_nodeset,
+                struct pathx_symtab *symtab,
+                struct pathx **px);
+/* Return the error struct that was passed into pathx_parse */
+struct error *err_of_pathx(struct pathx *px);
+struct tree *pathx_first(struct pathx *path);
+struct tree *pathx_next(struct pathx *path);
+/* Return -1 if evalutating PATH runs into trouble, otherwise return the
+ * number of nodes matching PATH and set MATCH to the first matching
+ * node */
+int pathx_find_one(struct pathx *path, struct tree **match);
+int pathx_expand_tree(struct pathx *path, struct tree **tree);
+void free_pathx(struct pathx *path);
+
+struct pathx_symtab *pathx_get_symtab(struct pathx *pathx);
+int pathx_symtab_define(struct pathx_symtab **symtab,
+                        const char *name, struct pathx *px);
+/* Returns 1 on success, and -1 when out of memory */
+int pathx_symtab_assign_tree(struct pathx_symtab **symtab, const char *name,
+                             struct tree *tree);
+int pathx_symtab_undefine(struct pathx_symtab **symtab, const char *name);
+void pathx_symtab_remove_descendants(struct pathx_symtab *symtab,
+                                     const struct tree *tree);
+void free_symtab(struct pathx_symtab *symtab);
+
+/* Debug helpers, all defined in internal.c. When ENABLE_DEBUG is not
+ * set, they compile to nothing.
+ */
+#  if ENABLE_DEBUG
+  /* Return true if debugging for CATEGORY is turned on */
+  bool debugging(const char *category);
+  /* Format the arguments into a file name, prepend it with the directory
+   * from the environment variable AUGEAS_DEBUG_DIR, and open the file for
+   * writing.
+  */
+  FILE *debug_fopen(const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 1, 2);
+#  else
+#    define debugging(facility) (0)
+#    define debug_fopen(format ...) (NULL)
+#  endif
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/jmt.c b/src/jmt.c
new file mode 100644 (file)
index 0000000..9af0be7
--- /dev/null
+++ b/src/jmt.c
@@ -0,0 +1,1952 @@
+/*
+ * jmt.c: Earley parser for lenses based on Jim/Mandelbaum transducers
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "jmt.h"
+#include "internal.h"
+#include "memory.h"
+#include "errcode.h"
+
+/* This is an implementation of the Earley parser described in the paper
+ * "Efficient Earley Parsing with Regular Right-hand Sides" by Trever Jim
+ * and Yitzhak Mandelbaum.
+ *
+ * Since we only deal in lenses, they are both terminals and nonterminals:
+ * recursive lenses (those with lens->recursive set) are nonterminals, and
+ * non-recursive lenses are terminals, with the exception of non-recursive
+ * lenses that match the empty word. Lenses are also the semantic actions
+ * attached to a SCAN or COMPLETE during recosntruction of the parse
+ * tree. Our SCAN makes sure that we only ever scan nonempty words - that
+ * means that for nonrecursive lenses which match the empty word (e.g., del
+ * [ \t]* "") we need to make sure we get a COMPLETE when the lens matched
+ * the empty word.
+ *
+ * That is achieved by treating such a lens t as the construct (t|T) with
+ * T := eps.
+ */
+
+/*
+ * Data structures for the Jim/Mandelbaum parser
+ */
+
+#define IND_MAX UINT32_MAX
+
+struct array {
+    size_t elem_size;
+    ind_t used;
+    ind_t size;
+    void *data;
+};
+
+#define array_elem(arr, ind, typ)                               \
+    (((typ *) (arr).data) + ind)
+
+#define array_for_each(i, arr)                                  \
+    for(ind_t i = 0; i < (arr).used; i++)
+
+#define array_each_elem(elt, arr, typ)                          \
+    for(typ *elt = (typ *) (arr).data + 0;                      \
+        elt - (typ *) (arr).data < (arr).used;                  \
+        elt++)
+
+static void array_init(struct array *arr, size_t elem_size) {
+    MEMZERO(arr, 1);
+    arr->elem_size = elem_size;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int array_add(struct array *arr, ind_t *ind) {
+    if (arr->used >= arr->size) {
+        int r;
+        ind_t expand = arr->size;
+        if (expand < 8)
+            expand = 8;
+        r = mem_realloc_n(&(arr->data), arr->elem_size, arr->size + expand);
+        if (r < 0)
+            return -1;
+        memset((char *) arr->data + arr->elem_size*arr->size, 0,
+               arr->elem_size * expand);
+        arr->size += expand;
+    }
+    *ind = arr->used;
+    arr->used += 1;
+    return 0;
+}
+
+/* Insert a new entry into the array at index IND. Shift all entries from
+ * IND on back by one. */
+ATTRIBUTE_RETURN_CHECK
+static int array_insert(struct array *arr, ind_t ind) {
+    ind_t last;
+
+    if (array_add(arr, &last) < 0)
+        return -1;
+
+    if (ind >= last)
+        return 0;
+
+    memmove((char *) arr->data + arr->elem_size*(ind+1),
+            (char *) arr->data + arr->elem_size*ind,
+            arr->elem_size * (arr->used - ind - 1));
+    memset((char *) arr->data + arr->elem_size*ind, 0, arr->elem_size);
+    return 0;
+}
+
+static void array_release(struct array *arr) {
+    if (arr != NULL)
+        free(arr->data);
+    arr->used = arr->size = 0;
+}
+
+static void array_remove(struct array *arr, ind_t ind) {
+    char *data = arr->data;
+    memmove(data + ind * arr->elem_size,
+            data + (ind + 1) * arr->elem_size,
+            (arr->used - ind - 1) * arr->elem_size);
+    arr->used -= 1;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int array_join(struct array *dst, struct array *src) {
+    int r;
+
+    if (dst->elem_size != src->elem_size)
+        return -1;
+
+    r = mem_realloc_n(&(dst->data), dst->elem_size,
+                      dst->used + src->used);
+    if (r < 0)
+        return -1;
+
+    memcpy(((char *) dst->data) + dst->used * dst->elem_size,
+           src->data,
+           src->used * src->elem_size);
+    dst->used += src->used;
+    dst->size = dst->used;
+    return 0;
+}
+
+/* Special lens indices - these don't reference lenses, but
+ * some pseudo actions. We stash them at the top of the range
+ * of IND_T, with LENS_MAX giving us the maximal lens index for
+ * a real lens
+ */
+enum trans_op {
+    EPS = IND_MAX,
+    CALL = EPS - 1,
+    LENS_MAX = CALL - 1
+};
+
+struct trans {
+    struct state *to;
+    ind_t lens;
+};
+
+struct state {
+    struct state *next;      /* Linked list for memory management */
+    struct array trans;      /* Array of struct trans */
+    ind_t  nret;             /* Number of returned lenses */
+    ind_t  *ret;             /* The returned lenses */
+    ind_t  num;              /* Counter for num of new states */
+    unsigned int reachable : 1;
+    unsigned int live : 1;
+};
+
+/* Sets of states used in determinizing the NFA to a DFA */
+struct nfa_state {
+    struct state *state;  /* The new state in the DFA */
+    struct array     set; /* Set of (struct state *) in the NFA, sorted */
+};
+
+/* For recursive lenses (nonterminals), the mapping of nonterminal to
+ * state. We also store nonrecursive lenses here; in that case, the state
+ * will be NULL */
+struct jmt_lens {
+    struct lens  *lens;
+    struct state *state;
+};
+
+/* A Jim/Mandelbaum transducer */
+struct jmt {
+    struct error *error;
+    struct array lenses;       /* Array of struct jmt_lens */
+    struct state *start;
+    ind_t  lens;               /* The start symbol of the grammar */
+    ind_t  state_count;
+};
+
+enum item_reason {
+    R_ROOT = 1,
+    R_COMPLETE = R_ROOT << 1,
+    R_PREDICT = R_COMPLETE << 1,
+    R_SCAN = R_PREDICT << 1
+};
+
+/* The reason an item was added for parse reconstruction; can be R_SCAN,
+ * R_COMPLETE, R_PREDICT or R_COMPLETE|R_PREDICT */
+struct link {
+    enum item_reason reason;
+    ind_t            lens;       /* R_COMPLETE, R_SCAN */
+    ind_t            from_set;   /* R_COMPLETE, R_PREDICT, R_SCAN */
+    ind_t            from_item;  /* R_COMPLETE, R_PREDICT, R_SCAN */
+    ind_t            to_item;    /* R_COMPLETE */
+    ind_t            caller;     /* number of a state */
+};
+
+struct item {
+    /* The 'classical' Earley item (state, parent) */
+    struct state    *state;
+    ind_t            parent;
+    /* Backlinks to why item was added */
+    ind_t            nlinks;
+    struct link     *links;
+};
+
+struct item_set {
+    struct array items;
+};
+
+struct jmt_parse {
+    struct jmt       *jmt;
+    struct error     *error;
+    const char       *text;
+    ind_t             nsets;
+    struct item_set **sets;
+};
+
+#define for_each_item(it, set)                                  \
+    array_each_elem(it, (set)->items, struct item)
+
+#define for_each_trans(t, s)                                    \
+    array_each_elem(t, (s)->trans, struct trans)
+
+#define parse_state(parse, ind)                                 \
+    array_elem(parse->states, ind, struct state)
+
+static struct item *set_item(struct jmt_parse *parse, ind_t set,
+                                 ind_t item) {
+    ensure(parse->sets[set] != NULL, parse);
+    ensure(item < parse->sets[set]->items.used, parse);
+    return array_elem(parse->sets[set]->items, item, struct item);
+ error:
+    return NULL;
+}
+
+static struct state *item_state(struct jmt_parse *parse, ind_t set,
+                                    ind_t item) {
+    return set_item(parse, set, item)->state;
+}
+
+static struct trans *state_trans(struct state *state, ind_t t) {
+    return array_elem(state->trans, t, struct trans);
+}
+
+static ind_t item_parent(struct jmt_parse *parse, ind_t set, ind_t item) {
+    return set_item(parse, set, item)->parent;
+}
+
+static bool is_return(const struct state *s) {
+    return s->nret > 0;
+}
+
+static struct lens *lens_of_parse(struct jmt_parse *parse, ind_t lens) {
+    return array_elem(parse->jmt->lenses, lens, struct jmt_lens)->lens;
+}
+
+/*
+ * The parser
+ */
+
+/*
+ * Manipulate the Earley graph. We denote edges in the graph as
+ *   [j, (s,i)] -> [k, item_k] => [l, item_l]
+ * to indicate that we are adding item (s,i) to E_j and record that its
+ * child is the item with index item_k in E_k and its sibling is item
+ * item_l in E_l.
+ */
+
+/* Add item (s, k) to E_j. Note that the item was caused by action reason
+ * using lens starting at from_item in E_{from_set}
+ *
+ * [j, (s,k)] -> [from_set, from_item] => [j, to_item]
+ */
+static ind_t parse_add_item(struct jmt_parse *parse, ind_t j,
+                            struct state *s, ind_t k,
+                            enum item_reason reason, ind_t lens,
+                            ind_t from_set,
+                            ind_t from_item, ind_t to_item,
+                            ind_t caller) {
+
+    ensure(from_item == EPS || from_item < parse->sets[from_set]->items.used,
+           parse);
+    ensure(to_item == EPS || to_item < parse->sets[j]->items.used,
+           parse);
+
+    int r;
+    struct item_set *set = parse->sets[j];
+    struct item *item = NULL;
+    ind_t result = IND_MAX;
+
+    if (set == NULL) {
+        r = ALLOC(parse->sets[j]);
+        ERR_NOMEM(r < 0, parse);
+        array_init(&parse->sets[j]->items, sizeof(struct item));
+        set = parse->sets[j];
+    }
+
+    for (ind_t i=0; i < set->items.used; i++) {
+        if (item_state(parse, j, i) == s
+            && item_parent(parse, j, i) == k) {
+            result = i;
+            item = set_item(parse, j, i);
+            break;
+        }
+    }
+
+    if (result == IND_MAX) {
+        r = array_add(&set->items, &result);
+        ERR_NOMEM(r < 0, parse);
+
+        item = set_item(parse, j, result);
+        item->state = s;
+        item->parent = k;
+    }
+
+    for (ind_t i = 0; i < item->nlinks; i++) {
+        struct link *lnk = item->links + i;
+        if (lnk->reason == reason && lnk->lens == lens
+            && lnk->from_set == from_set && lnk->from_item == from_item
+            && lnk->to_item == to_item && lnk->caller == caller)
+            return result;
+    }
+
+    r = REALLOC_N(item->links, item->nlinks + 1);
+    ERR_NOMEM(r < 0, parse);
+
+    struct link *lnk = item->links+ item->nlinks;
+    item->nlinks += 1;
+
+    lnk->reason = reason;
+    lnk->lens = lens;
+    lnk->from_set = from_set;
+    lnk->from_item = from_item;
+    lnk->to_item = to_item;
+    lnk->caller = caller;
+ error:
+    return result;
+}
+
+/* Add item (s, i) to set E_j and record that it was added because
+ * a parse of nonterminal lens, starting at itemk in E_k, was completed
+ * by item item in E_j
+ *
+ * [j, (s,i)] -> [j, item] => [k, itemk]
+ */
+static void parse_add_complete(struct jmt_parse *parse, ind_t j,
+                               struct state *s, ind_t i,
+                               ind_t k, ind_t itemk,
+                               ind_t lens,
+                               ind_t item) {
+    parse_add_item(parse, j, s, i, R_COMPLETE, lens, k, itemk, item, IND_MAX);
+}
+
+/* Same as parse_add_complete, but mark the item also as a predict
+ *
+ * [j, (s,i)] -> [j, item] => [k, itemk]
+ */
+static void parse_add_predict_complete(struct jmt_parse *parse, ind_t j,
+                                       struct state *s, ind_t i,
+                                       ind_t k, ind_t itemk,
+                                       ind_t lens,
+                                       ind_t item, ind_t caller) {
+    parse_add_item(parse, j, s, i, R_COMPLETE|R_PREDICT,
+                   lens, k, itemk, item, caller);
+}
+
+/* Add item (s, j) to E_j and record that it was added because of a
+ * prediction from item from in E_j
+ */
+static ind_t parse_add_predict(struct jmt_parse *parse, ind_t j,
+                               struct state *s, ind_t from) {
+
+    ensure(from < parse->sets[j]->items.used, parse);
+    struct state *t = item_state(parse, j, from);
+
+    return parse_add_item(parse, j, s, j, R_PREDICT, EPS, j, from, EPS,
+                          t->num);
+ error:
+    return IND_MAX;
+}
+
+/* Add item (s,i) to E_j and record that it was added because of scanning
+ * with lens starting from item item in E_k.
+ *
+ * [j, (s,i)] -> [k, item]
+ */
+static void parse_add_scan(struct jmt_parse *parse, ind_t j,
+                           struct state *s, ind_t i,
+                           ind_t lens, ind_t k, ind_t item) {
+    ensure(item < parse->sets[k]->items.used, parse);
+
+    parse_add_item(parse, j, s, i, R_SCAN, lens, k, item, EPS, IND_MAX);
+ error:
+    return;
+}
+
+ATTRIBUTE_PURE
+static bool is_complete(const struct link *lnk) {
+    return lnk->reason & R_COMPLETE;
+}
+
+ATTRIBUTE_PURE
+static bool is_predict(const struct link *lnk) {
+    return lnk->reason & R_PREDICT;
+}
+
+ATTRIBUTE_PURE
+static bool is_scan(const struct link *lnk) {
+    return lnk->reason & R_SCAN;
+}
+
+ATTRIBUTE_PURE
+static bool is_last_sibling(const struct link *lnk) {
+    if (is_complete(lnk))
+        return false;
+    return lnk->reason & (R_PREDICT|R_ROOT);
+}
+
+ATTRIBUTE_PURE
+static bool returns(const struct state *s, ind_t l) {
+    for (ind_t i = 0; i < s->nret; i++)
+        if (s->ret[i] == l)
+            return true;
+    return false;
+}
+
+static void state_add_return(struct jmt *jmt, struct state *s, ind_t l) {
+    int r;
+
+    if (s == NULL || returns(s, l))
+        return;
+
+    r = REALLOC_N(s->ret, s->nret + 1);
+    ERR_NOMEM(r < 0, jmt);
+    s->ret[s->nret] = l;
+    s->nret += 1;
+ error:
+    return;
+}
+
+static void state_merge_returns(struct jmt *jmt, struct state *dst,
+                                const struct state *src) {
+    for (ind_t l = 0; l < src->nret; l++)
+        state_add_return(jmt, dst, src->ret[l]);
+}
+
+static void nncomplete(struct jmt_parse *parse, ind_t j,
+                       struct state *t, ind_t k, ind_t item) {
+
+    for (ind_t itemk = 0; itemk < parse->sets[k]->items.used; itemk++) {
+        struct state *u = item_state(parse, k, itemk);
+        for_each_trans(y, u) {
+            if (returns(t, y->lens)) {
+                ind_t parent = item_parent(parse, k, itemk);
+                parse_add_complete(parse, j,
+                                   y->to, parent,
+                                   k, itemk, y->lens, item);
+            }
+        }
+    }
+}
+
+/* NCALLER for (t, i) in E_j, which has index item in E_j, and t -> s a
+ * call in the transducer and s a return. The item (s,j) has index pred in
+ * E_j
+ */
+static void ncaller(struct jmt_parse *parse, ind_t j, ind_t item,
+                    struct state *t, ind_t i, struct state *s, ind_t pred) {
+    for_each_trans(u, t) {
+        if (returns(s, u->lens)) {
+            /* [j, (u->to, i)] -> [j, pred] => [j, item] */
+            parse_add_predict_complete(parse, j,
+                                       u->to, i,
+                                       j, item, u->lens,
+                                       pred, t->num);
+        }
+    }
+}
+
+/* NCALLEE for (t, parent) in E_j, which has index item in E_j, and t -> s
+ * a call in the transducer and s a return. The item (s,j) has index pred
+ * in E_j
+ */
+static void ncallee(struct jmt_parse *parse, ind_t j, ATTRIBUTE_UNUSED ind_t item,
+                    ATTRIBUTE_UNUSED struct state *t, ATTRIBUTE_UNUSED ind_t parent, struct state *s, ind_t pred) {
+    for_each_trans(u, s) {
+        if (returns(s, u->lens)) {
+            /* [j, (u->to, j)] -> [j, item] => [j, item] */
+            parse_add_predict_complete(parse, j,
+                                       u->to, j,
+                                       j, pred, u->lens,
+                                       pred, t->num);
+        }
+    }
+}
+
+static struct jmt_parse *parse_init(struct jmt *jmt,
+                                    const char *text, size_t text_len) {
+    int r;
+    struct jmt_parse *parse;
+
+    r = ALLOC(parse);
+    ERR_NOMEM(r < 0, jmt);
+
+    parse->jmt = jmt;
+    parse->error = jmt->error;
+    parse->text = text;
+    parse->nsets = text_len + 1;
+    r = ALLOC_N(parse->sets, parse->nsets);
+    ERR_NOMEM(r < 0, jmt);
+    return parse;
+ error:
+    if (parse != NULL)
+        free(parse->sets);
+    free(parse);
+    return NULL;
+}
+
+void jmt_free_parse(struct jmt_parse *parse) {
+    if (parse == NULL)
+        return;
+    for (int i=0; i < parse->nsets; i++) {
+        struct item_set *set = parse->sets[i];
+        if (set != NULL) {
+            array_each_elem(x, set->items, struct item)
+                free(x->links);
+            array_release(&set->items);
+            free(set);
+        }
+    }
+    free(parse->sets);
+    free(parse);
+}
+
+static struct state *lens_state(struct jmt *jmt, ind_t l);
+
+static void flens(FILE *fp, ind_t l) {
+    if (l == 0)
+        fprintf(fp, "%c", 'S');
+    else if (l < 'S' - 'A')
+        fprintf(fp, "%c", 'A' + l - 1);
+    else if (l <= 'Z' - 'A')
+        fprintf(fp, "%c", 'A' + l);
+    else
+        fprintf(fp, "%u", l);
+}
+
+static void parse_dot_link(FILE *fp, struct jmt_parse *parse,
+                           ind_t k, struct item *x, struct link *lnk) {
+    char *lens_label = NULL;
+    if (is_complete(lnk) || is_scan(lnk)) {
+        struct state *sA = lens_state(parse->jmt, lnk->lens);
+        int r;
+
+        if (sA == NULL)
+            r = xasprintf(&lens_label, "<%d>", lnk->lens);
+        else
+            r = xasprintf(&lens_label, "%d", lnk->lens);
+        if (r < 0) {
+            fprintf(fp, "// Internal error generating lens_label\n");
+            return;
+        }
+    }
+    fprintf(fp, "    n%d_%d_%d [ label = \"(%d, %d)\"];\n",
+            k, x->state->num, x->parent, x->state->num, x->parent);
+    if (is_complete(lnk)) {
+        struct item *y = set_item(parse, k, lnk->to_item);
+        const char *pred = is_predict(lnk) ? "p" : "";
+        fprintf(fp, "    n%d_%d_%d -> n%s%d_%d_%d [ style = dashed ];\n",
+                k, x->state->num, x->parent,
+                pred, k, y->state->num, y->parent);
+        if (is_predict(lnk)) {
+            fprintf(fp, "    n%s%d_%d_%d [ label = \"\" ];\n",
+                    pred, k, y->state->num, y->parent);
+            fprintf(fp, "    n%s%d_%d_%d -> n%d_%d_%d [ style = bold ];\n",
+                    pred, k, y->state->num, y->parent,
+                    k, y->state->num, y->parent);
+        }
+        y = set_item(parse, lnk->from_set, lnk->from_item);
+        fprintf(fp,
+                "    n%d_%d_%d -> n%d_%d_%d [ style = dashed, label = \"",
+                k, x->state->num, x->parent,
+                lnk->from_set, y->state->num, y->parent);
+        flens(fp, lnk->lens);
+        fprintf(fp, "\" ];\n");
+    } else if (is_scan(lnk)) {
+        struct item *y =
+            set_item(parse, lnk->from_set, lnk->from_item);
+        fprintf(fp,
+                "    n%d_%d_%d -> n%d_%d_%d [ label = \"",
+                k, x->state->num, x->parent,
+                lnk->from_set, y->state->num, y->parent);
+        for (ind_t i=lnk->from_set; i < k; i++)
+            fprintf(fp, "%c", parse->text[i]);
+        fprintf(fp, "\" ];\n");
+
+    } else if (is_predict(lnk)) {
+        struct item *y =
+            set_item(parse, lnk->from_set, lnk->from_item);
+        fprintf(fp,
+                "    n%d_%d_%d -> n%d_%d_%d [ style = bold ];\n",
+                k, x->state->num, x->parent,
+                lnk->from_set, y->state->num, y->parent);
+
+    }
+    free(lens_label);
+}
+
+static void parse_dot(struct jmt_parse *parse, const char *fname) {
+    FILE *fp = debug_fopen("%s", fname);
+    if (fp == NULL)
+        return;
+
+    fprintf(fp, "digraph \"jmt_parse\" {\n");
+    fprintf(fp, "  rankdir = RL;\n");
+    for (int k=0; k < parse->nsets; k++) {
+        struct item_set *set = parse->sets[k];
+
+        if (set == NULL)
+            continue;
+
+        fprintf(fp, "  subgraph \"cluster_E_%d\" {\n", k);
+        fprintf(fp, "    rankdir=RL;\n    rank=same;\n");
+        fprintf(fp, "    title%d [ label=\"E%d\", shape=plaintext ]\n", k, k);
+        for_each_item(x, set) {
+            for (int i=0; i < x->nlinks; i++) {
+                struct link *lnk = x->links + i;
+                parse_dot_link(fp, parse, k, x, lnk);
+            }
+        }
+        fprintf(fp, "}\n");
+    }
+    fprintf(fp, "}\n");
+    fclose(fp);
+}
+
+struct jmt_parse *
+jmt_parse(struct jmt *jmt, const char *text, size_t text_len)
+{
+    struct jmt_parse *parse = NULL;
+
+    parse = parse_init(jmt, text, text_len);
+    ERR_BAIL(jmt);
+
+    /* INIT */
+    parse_add_item(parse, 0, jmt->start, 0, R_ROOT, EPS, EPS, EPS, EPS,
+                   jmt->lens);
+    /* NINIT */
+    if (is_return(jmt->start)) {
+        for_each_trans(x, jmt->start) {
+            if (returns(jmt->start, x->lens))
+                parse_add_predict_complete(parse, 0, x->to, 0,
+                                           0, 0, x->lens, 0, 0);
+        }
+    }
+
+    for (int j=0; j <= text_len; j++) {
+        struct item_set *set = parse->sets[j];
+        if (set == NULL)
+            continue;
+
+        for (int item=0; item < set->items.used; item++) {
+            struct state *t = item_state(parse, j, item);
+            ind_t i = item_parent(parse, j, item);
+
+            if (is_return(t) && i != j) {
+                /* NNCOMPLETE */
+                nncomplete(parse, j, t, i, item);
+            }
+
+            for_each_trans(x, t) {
+                if (x->lens == CALL) {
+                    /* PREDICT */
+                    ind_t pred = parse_add_predict(parse, j, x->to, item);
+                    ERR_BAIL(parse);
+                    if (is_return(x->to)) {
+                        /* NCALLER */
+                        ncaller(parse, j, item, t, i, x->to, pred);
+                        /* NCALLEE */
+                        ncallee(parse, j, item, t, i, x->to, pred);
+                    }
+                } else {
+                    int count;
+                    struct lens *lens = lens_of_parse(parse, x->lens);
+                    struct state *sA = lens_state(parse->jmt, x->lens);
+                    if (! lens->recursive && sA == NULL) {
+                        /* SCAN, terminal */
+                        // FIXME: We really need to find every k so that
+                        // text[j..k] matches lens->ctype, not just one
+                        count = regexp_match(lens->ctype, text, text_len, j, NULL);
+                        if (count > 0) {
+                            parse_add_scan(parse, j+count,
+                                           x->to, i,
+                                           x->lens, j, item);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    if (debugging("cf.jmt.parse"))
+        parse_dot(parse, "jmt_parse.dot");
+    return parse;
+ error:
+    jmt_free_parse(parse);
+    return NULL;
+}
+
+/*
+ * Reconstruction of the parse tree
+ */
+
+static void
+build_nullable(struct jmt_parse *parse, ind_t pos,
+               struct jmt_visitor *visitor, struct lens *lens, int lvl) {
+    if (! lens->recursive) {
+        if (visitor->terminal != NULL) {
+            (*visitor->terminal)(lens, pos, pos, visitor->data);
+            ERR_BAIL(parse);
+        }
+    } else {
+        if (visitor->enter != NULL) {
+            (*visitor->enter)(lens, pos, pos, visitor->data);
+            ERR_BAIL(parse);
+        }
+
+        switch(lens->tag) {
+        case L_REC:
+            build_nullable(parse, pos, visitor, lens->body, lvl+1);
+            break;
+        case L_CONCAT:
+            for (int i=0; i < lens->nchildren; i++)
+                build_nullable(parse, pos, visitor, lens->children[i], lvl+1);
+            break;
+        case L_UNION:
+            for (int i=0; i < lens->nchildren; i++)
+                if (lens->children[i]->ctype_nullable)
+                    build_nullable(parse, pos, visitor,
+                                   lens->children[i], lvl+1);
+            break;
+        case L_SUBTREE:
+        case L_SQUARE:
+            build_nullable(parse, pos, visitor, lens->child, lvl+1);
+            break;
+        case L_STAR:
+        case L_MAYBE:
+            break;
+        default:
+            BUG_ON(true, parse, "Unexpected lens tag %d", lens->tag);
+        }
+
+        if (visitor->exit != NULL) {
+            (*visitor->exit)(lens, pos, pos, visitor->data);
+            ERR_BAIL(parse);
+        }
+    }
+ error:
+    return;
+}
+
+static void build_trace(const char *msg, ind_t start, ind_t end,
+                        struct item *x, int lvl) {
+    for (int i=0; i < lvl; i++) putc(' ', stderr);
+    if (x != NULL) {
+        printf("%s %d..%d: (%d, %d) %d %s%s%s\n", msg,
+               start, end, x->state->num,
+               x->parent, x->links->lens,
+               is_complete(x->links) ? "c" : "",
+               is_predict(x->links) ? "p" : "",
+               is_scan(x->links) ? "s" : "");
+    } else {
+        printf("%s %d..%d\n", msg, start, end);
+    }
+}
+
+static int add_sibling(struct array *siblings, ind_t lnk) {
+    int r;
+    ind_t ind;
+
+    r = array_add(siblings, &ind);
+    if (r < 0)
+        return -1;
+    *array_elem(*siblings, ind, ind_t) = lnk;
+    return 0;
+}
+
+/* Return true if CALLER is a possible caller for the link LNK which starts
+ * at item X.
+ *
+ * FIXME: We can get rid of the caller field on a link if we distinguish
+ * between NCALLER and NCALLEE in the Earley graph, rather than collapse
+ * them both into links with reason PREDICT|COMPLETE
+ */
+static bool is_caller(struct item *x, struct link *lnk, ind_t caller) {
+    if (lnk->reason & R_ROOT)
+        return caller == lnk->caller;
+
+    if (! is_predict(lnk))
+        return false;
+
+    if (is_complete(lnk)) {
+        /* NCALLER: caller == t
+         * NCALLEE: caller == s */
+        return caller == lnk->caller;
+    }
+    /* PREDICT: caller == t || caller == s */
+    return caller == lnk->caller || caller == x->state->num;
+}
+
+/* Traverse the siblings of x and check that the callee's set of callers
+ * contains CALLER. When a path ending with a call from CALLER exists,
+ * record the number of the corresponding link for each item in
+ * SIBLINGS. The links are recorded in left-to-right order, i.e. the number
+ * of the first link to follow is in the last entry in SIBLINGS.
+ *
+ * Returns 0 if there is a path ending in a callee of CALLER. Return -1 if
+ * there is none. Return -2 if there are multiple such paths. Return -3 for
+ * any other error.
+ */
+static int filter_siblings(struct jmt_visitor *visitor, struct lens *lens,
+                          ind_t k, ind_t item, ind_t caller,
+                          struct array *siblings) {
+    struct jmt_parse *parse = visitor->parse;
+    struct item *x = set_item(parse, k, item);
+    ind_t nlast = 0;
+    int r;
+
+    for (ind_t lnk = 0; lnk < x->nlinks; lnk++)
+        if (is_last_sibling(x->links + lnk))
+            nlast += 1;
+
+    if (nlast > 0 && nlast < x->nlinks)
+        goto ambig;
+
+    if (nlast == x->nlinks) {
+        for (ind_t lnk = 0; lnk < x->nlinks; lnk++) {
+            if (is_caller(x, x->links + lnk, caller)) {
+                siblings->used = 0;
+                r = add_sibling(siblings, lnk);
+                if (r < 0) {
+                    ERR_REPORT(parse, AUG_ENOMEM, NULL);
+                    return -3;
+                }
+                return 0;
+            }
+        }
+        return -1;
+    } else {
+        /* nlast == 0 */
+        ind_t found = IND_MAX;
+        for (ind_t lnk = 0; lnk < x->nlinks; lnk++) {
+            struct link *l = x->links + lnk;
+            r = filter_siblings(visitor, lens,
+                                l->from_set, l->from_item, caller,
+                                siblings);
+            if (r == -1)
+                continue;
+            if (r == 0) {
+                if (found != IND_MAX)
+                    goto ambig;
+                else
+                    found = lnk;
+            } else {
+                return r;
+            }
+        }
+        if (found == IND_MAX) {
+            return -1;
+        } else {
+            r = add_sibling(siblings, found);
+            if (r < 0) {
+                ERR_REPORT(parse, AUG_ENOMEM, NULL);
+                return -3;
+            }
+            return 0;
+        }
+    }
+ ambig:
+    (*visitor->error)(lens, visitor->data, k,
+                      "Ambiguous parse: %d links in state (%d, %d) in E_%d",
+                      x->nlinks, x->state->num, x->parent, k);
+    return -2;
+}
+
+static void visit_enter(struct jmt_visitor *visitor, struct lens *lens,
+                        size_t start, size_t end,
+                        struct item *x, int lvl) {
+    if (debugging("cf.jmt.visit"))
+        build_trace("{", start, end, x, lvl);
+    if (visitor->enter != NULL)
+        (*visitor->enter)(lens, start, end, visitor->data);
+}
+
+static void visit_exit(struct jmt_visitor *visitor, struct lens *lens,
+                       size_t start, size_t end,
+                       struct item *x, int lvl) {
+    if (debugging("cf.jmt.visit"))
+        build_trace("}", start, end, x, lvl);
+    if (visitor->exit != NULL)
+        (*visitor->exit)(lens, start, end, visitor->data);
+}
+
+static int
+build_children(struct jmt_parse *parse, ind_t k, ind_t item,
+               struct jmt_visitor *visitor, int lvl, ind_t caller);
+
+static int
+build_tree(struct jmt_parse *parse, ind_t k, ind_t item, struct lens *lens,
+           struct jmt_visitor *visitor, int lvl) {
+    struct item *x = set_item(parse, k, item);
+    ind_t start = x->links->from_set;
+    ind_t end = k;
+    struct item *old_x = x;
+
+    if (start == end) {
+        /* This completion corresponds to a nullable nonterminal
+         * that match epsilon. Reconstruct the full parse tree
+         * for matching epsilon */
+        if (debugging("cf.jmt.visit"))
+            build_trace("N", x->links->from_set, k, x, lvl);
+        build_nullable(parse, start, visitor, lens, lvl);
+        return end;
+    }
+
+    ensure(is_complete(x->links), parse);
+
+    visit_enter(visitor, lens, start, end, x, lvl);
+    ERR_BAIL(parse);
+
+    /* x is a completion item. (k, x->to_item) is its first child in the
+     * parse tree. */
+    if (! is_predict(x->links)) {
+        struct link *lnk = x->links;
+        struct item *sib = set_item(parse, lnk->from_set, lnk->from_item);
+        ind_t caller = sib->state->num;
+
+        item = lnk->to_item;
+        x = set_item(parse, k, item);
+        build_children(parse, k, item, visitor, lvl, caller);
+        ERR_BAIL(parse);
+    }
+
+    visit_exit(visitor, lens, start, end, old_x, lvl);
+    ERR_BAIL(parse);
+ error:
+    return end;
+}
+
+static int
+build_children(struct jmt_parse *parse, ind_t k, ind_t item,
+               struct jmt_visitor *visitor, int lvl, ind_t caller) {
+    struct item *x = set_item(parse, k, item);
+    struct lens *lens = lens_of_parse(parse, x->links->lens);
+    struct array siblings;
+    ind_t end = k;
+    int r;
+
+    array_init(&siblings, sizeof(ind_t));
+    r = filter_siblings(visitor, lens, k, item, caller, &siblings);
+    if (r < 0)
+        goto error;
+
+    /* x the first item in a list of siblings; visit items (x->from_set,
+     * x->from_item) in order, which will visit x and its siblings in the
+     * parse tree from right to left */
+    for (ind_t i = siblings.used - 1; i > 0; i--) {
+        ind_t lnk = *array_elem(siblings, i, ind_t);
+        struct lens *sub = lens_of_parse(parse, x->links[lnk].lens);
+        if (sub->recursive) {
+            build_tree(parse, k, item, sub, visitor, lvl+1);
+            ERR_BAIL(parse);
+        } else {
+            if (debugging("cf.jmt.visit"))
+                build_trace("T", x->links->from_set, k, x, lvl+1);
+            if (visitor->terminal != NULL) {
+                (*visitor->terminal)(sub,
+                                     x->links->from_set, k, visitor->data);
+                ERR_BAIL(parse);
+            }
+        }
+        k = x->links[lnk].from_set;
+        item = x->links[lnk].from_item;
+        x = set_item(parse, k, item);
+    }
+ error:
+    array_release(&siblings);
+    return end;
+}
+
+int jmt_visit(struct jmt_visitor *visitor, size_t *len) {
+    struct jmt_parse *parse = visitor->parse;
+    ind_t k = parse->nsets - 1;     /* Current Earley set */
+    ind_t item;
+    struct item_set *set = parse->sets[k];
+
+    if (set == NULL)
+        goto noparse;
+
+    for (item = 0; item < set->items.used; item++) {
+        struct item *x = set_item(parse, k, item);
+        if (x->parent == 0 && returns(x->state, parse->jmt->lens)) {
+            for (ind_t i = 0; i < x->nlinks; i++) {
+                if (is_complete(x->links + i) || is_scan(x->links + i)) {
+                    if (debugging("cf.jmt.visit"))
+                        printf("visit: found (%d, %d) in E_%d\n",
+                               x->state->num, x->parent, k);
+                    goto found;
+                }
+            }
+        }
+    }
+ found:
+    if (item >= parse->sets[k]->items.used)
+        goto noparse;
+    struct lens *lens = lens_of_parse(parse, parse->jmt->lens);
+
+    visit_enter(visitor, lens, 0, k, NULL, 0);
+    ERR_BAIL(parse);
+
+    *len = build_children(parse, k, item, visitor, 0,
+                          parse->jmt->start->num);
+    ERR_BAIL(parse);
+
+    visit_exit(visitor, lens, 0, k, NULL, 0);
+    ERR_BAIL(parse);
+    return 1;
+ error:
+    return -1;
+ noparse:
+    for (; k > 0; k--)
+        if (parse->sets[k] != NULL) break;
+    *len = k;
+    return 0;
+}
+
+/*
+ * Build the automaton
+ */
+
+
+static struct state *make_state(struct jmt *jmt) {
+    struct state *s;
+    int r;
+
+    r = ALLOC(s);
+    ERR_NOMEM(r < 0, jmt);
+    s->num = jmt->state_count++;
+    array_init(&s->trans, sizeof(struct trans));
+    if (jmt->start != NULL)
+        list_cons(jmt->start->next, s);
+    else
+        jmt->start = s;
+    return s;
+ error:
+    return NULL;
+}
+
+static ind_t add_lens(struct jmt *jmt, struct lens *lens) {
+    int r;
+    ind_t l;
+    struct state *sA = NULL;
+    int nullable = 0;
+
+    r = array_add(&jmt->lenses, &l);
+    ERR_NOMEM(r < 0, jmt);
+    ERR_NOMEM(l == IND_MAX, jmt);
+
+    if (! lens->recursive)
+        nullable = regexp_matches_empty(lens->ctype);
+
+    array_elem(jmt->lenses, l, struct jmt_lens)->lens = lens;
+    /* A nonrecursive lens that matches epsilon is both a terminal
+     * and a nonterminal */
+    if (lens->recursive || nullable) {
+        sA = make_state(jmt);
+        ERR_NOMEM(sA == NULL, jmt);
+        array_elem(jmt->lenses, l, struct jmt_lens)->state = sA;
+        if (! lens->recursive) {
+            /* Add lens again, so that l refers to the nonterminal T
+             * for the lens, and l+1 refers to the terminal t for it */
+            ind_t m;
+            r = array_add(&jmt->lenses, &m);
+            ERR_NOMEM(r < 0, jmt);
+            ERR_NOMEM(m == IND_MAX, jmt);
+
+            array_elem(jmt->lenses, m, struct jmt_lens)->lens = lens;
+        }
+    }
+
+    if (debugging("cf.jmt")) {
+        if (sA == NULL) {
+            printf("add_lens: ");
+            print_regexp(stdout, lens->ctype);
+            printf(" %s\n", format_lens(lens));
+        } else {
+            printf("add_lens: ");
+            flens(stdout, l);
+            printf(" %u %s\n", sA->num, format_lens(lens));
+            if (nullable) {
+                printf("add_lens: // %s\n", format_lens(lens));
+            }
+        }
+    }
+
+    return l;
+ error:
+    return IND_MAX;
+}
+
+static struct trans *
+add_new_trans(struct jmt *jmt,
+              struct state *from, struct state *to, ind_t lens) {
+    struct trans *t;
+    ind_t i;
+    int r;
+
+    if (from == NULL || to == NULL)
+        return NULL;
+
+    r = array_add(&from->trans, &i);
+    ERR_NOMEM(r < 0, jmt);
+    t = array_elem(from->trans, i, struct trans);
+    t->to = to;
+    t->lens = lens;
+    return t;
+ error:
+    return NULL;
+}
+
+static struct trans *
+add_eps_trans(struct jmt *jmt, struct state *from, struct state *to) {
+    return add_new_trans(jmt, from, to, EPS);
+}
+
+static struct lens *lens_of_jmt(struct jmt *jmt, ind_t l) {
+    return array_elem(jmt->lenses, l, struct jmt_lens)->lens;
+}
+
+static ind_t lens_index(struct jmt *jmt, struct lens *lens) {
+    array_for_each(i, jmt->lenses)
+        if (lens_of_jmt(jmt, i) == lens)
+            return i;
+    return IND_MAX;
+}
+
+static struct state *lens_state(struct jmt *jmt, ind_t l) {
+    return array_elem(jmt->lenses, l, struct jmt_lens)->state;
+}
+
+static void print_lens_symbol(FILE *fp, struct jmt *jmt, struct lens *lens) {
+    ind_t l = lens_index(jmt, lens);
+    struct state *sA = lens_state(jmt, l);
+
+    if (sA == NULL)
+        print_regexp(fp, lens->ctype);
+    else
+        flens(fp, l);
+}
+
+static void print_grammar(struct jmt *jmt, struct lens *lens) {
+    ind_t l = lens_index(jmt, lens);
+    struct state *sA = lens_state(jmt, l);
+
+    if (sA == NULL || (lens->tag == L_REC && lens->rec_internal))
+        return;
+
+    printf("  ");
+    print_lens_symbol(stdout, jmt, lens);
+    printf(" := ");
+
+    if (! lens->recursive) {
+        /* Nullable regexps */
+        print_regexp(stdout, lens->ctype);
+        printf("\n");
+        return;
+    }
+
+    switch (lens->tag) {
+    case L_CONCAT:
+        print_lens_symbol(stdout, jmt, lens->children[0]);
+        for (int i=1; i < lens->nchildren; i++) {
+            printf(" . ");
+            print_lens_symbol(stdout, jmt, lens->children[i]);
+        }
+        printf("\n");
+        for (int i=0; i < lens->nchildren; i++)
+            print_grammar(jmt, lens->children[i]);
+        break;
+    case L_UNION:
+        print_lens_symbol(stdout, jmt, lens->children[0]);
+        for (int i=1; i < lens->nchildren; i++) {
+            printf(" | ");
+            print_lens_symbol(stdout, jmt, lens->children[i]);
+        }
+        printf("\n");
+        for (int i=0; i < lens->nchildren; i++)
+            print_grammar(jmt, lens->children[i]);
+        break;
+    case L_SUBTREE:
+        print_lens_symbol(stdout, jmt, lens->child);
+        printf("\n");
+        print_grammar(jmt, lens->child);
+        break;
+    case L_STAR:
+        print_lens_symbol(stdout, jmt, lens->child);
+        printf("*\n");
+        print_grammar(jmt, lens->child);
+        break;
+    case L_MAYBE:
+        print_lens_symbol(stdout, jmt, lens->child);
+        printf("?\n");
+        print_grammar(jmt, lens->child);
+        break;
+    case L_REC:
+        print_lens_symbol(stdout, jmt, lens->body);
+        printf("\n");
+        print_grammar(jmt, lens->body);
+        break;
+    case L_SQUARE:
+       print_lens_symbol(stdout, jmt, lens->child);
+       printf("\n");
+       print_grammar(jmt, lens->child);
+       break;
+    default:
+        BUG_ON(true, jmt, "Unexpected lens tag %d", lens->tag);
+        break;
+    }
+ error:
+    return;
+}
+
+static void print_grammar_top(struct jmt *jmt, struct lens *lens) {
+    printf("Grammar:\n");
+    print_grammar(jmt, lens);
+    if (lens->tag == L_REC) {
+        printf("  ");
+        print_lens_symbol(stdout, jmt, lens->alias);
+        printf(" := ");
+        print_lens_symbol(stdout, jmt, lens->alias->body);
+        printf("\n");
+    }
+}
+
+static void index_lenses(struct jmt *jmt, struct lens *lens) {
+    ind_t l;
+
+    l = lens_index(jmt, lens);
+    if (l == IND_MAX) {
+        l = add_lens(jmt, lens);
+        ERR_BAIL(jmt);
+    }
+
+    if (! lens->recursive)
+        return;
+
+    switch (lens->tag) {
+    case L_CONCAT:
+    case L_UNION:
+        for (int i=0; i < lens->nchildren; i++)
+            index_lenses(jmt, lens->children[i]);
+        break;
+    case L_SUBTREE:
+    case L_STAR:
+    case L_MAYBE:
+    case L_SQUARE:
+        index_lenses(jmt, lens->child);
+        break;
+    case L_REC:
+        if (! lens->rec_internal)
+            index_lenses(jmt, lens->body);
+        break;
+    default:
+        BUG_ON(true, jmt, "Unexpected lens tag %d", lens->tag);
+        break;
+    }
+ error:
+    return;
+}
+
+static void thompson(struct jmt *jmt, struct lens *lens,
+                     struct state **s, struct state **f) {
+    ind_t l = lens_index(jmt, lens);
+    struct state *sA = lens_state(jmt, l);
+    ensure(l < jmt->lenses.used, jmt);
+
+    *s = make_state(jmt);
+    *f = make_state(jmt);
+    ERR_BAIL(jmt);
+
+    if (lens->recursive) {
+        /* A nonterminal */
+        add_new_trans(jmt, *s, *f, l);
+        add_new_trans(jmt, *s, sA, CALL);
+    } else if (sA == NULL) {
+        /* A terminal that never matches epsilon */
+        add_new_trans(jmt, *s, *f, l);
+    } else {
+        /* A terminal that matches epsilon */
+        add_new_trans(jmt, *s, *f, l);
+        add_new_trans(jmt, *s, sA, CALL);
+        add_new_trans(jmt, *s, *f, l+1);
+    }
+ error:
+    return;
+}
+
+static void conv(struct jmt *jmt, struct lens *lens,
+                 struct state **s, struct state **e,
+                 struct state **f) {
+    ind_t l = lens_index(jmt, lens);
+    ensure(l < jmt->lenses.used, jmt);
+    struct state *sA = lens_state(jmt, l);
+
+    *s = NULL;
+    *e = NULL;
+    *f = NULL;
+
+    if (lens->recursive) {
+        /* A nonterminal */
+        *s = make_state(jmt);
+        *f = make_state(jmt);
+        ERR_BAIL(jmt);
+        add_new_trans(jmt, *s, *f, l);
+        ERR_BAIL(jmt);
+        ensure(sA != NULL, jmt);
+        add_new_trans(jmt, *s, sA, EPS);
+        ERR_BAIL(jmt);
+    } else if (sA == NULL) {
+        /* A terminal that never matches epsilon */
+        *s = make_state(jmt);
+        *f = make_state(jmt);
+        ERR_BAIL(jmt);
+        add_new_trans(jmt, *s, *f, l);
+        ERR_BAIL(jmt);
+    } else {
+        /* A terminal that matches epsilon */
+        *s = make_state(jmt);
+        *f = make_state(jmt);
+        ERR_BAIL(jmt);
+        add_new_trans(jmt, *s, *f, l);
+        add_new_trans(jmt, *s, *f, l+1);
+        add_new_trans(jmt, *s, sA, EPS);
+        ERR_BAIL(jmt);
+    }
+ error:
+    return;
+}
+
+static void conv_concat(struct jmt *jmt, struct lens *lens,
+                        struct state **s, struct state **e,
+                        struct state **f) {
+    struct state *s2, *f2, *e2;
+
+    conv(jmt, lens->children[0], &s2, &e2, &f2);
+    *s = make_state(jmt);
+    add_new_trans(jmt, *s, s2, EPS);
+
+    for (int i=1; i < lens->nchildren; i++) {
+        struct state *s3, *e3, *f3, *scall, *fcall;
+        conv(jmt, lens->children[i], &s3, &e3, &f3);
+        thompson(jmt, lens->children[i], &scall, &fcall);
+        ERR_BAIL(jmt);
+        add_eps_trans(jmt, f2, scall);
+        add_eps_trans(jmt, e2, s3);
+        *f = make_state(jmt);
+        add_eps_trans(jmt, f3, *f);
+        add_eps_trans(jmt, fcall, *f);
+        *e = make_state(jmt);
+        add_eps_trans(jmt, e3, *e);
+        f2 = *f;
+        e2 = *e;
+    }
+ error:
+    return;
+}
+
+static void conv_union(struct jmt *jmt, struct lens *lens,
+                        struct state **s, struct state **e,
+                        struct state **f) {
+
+    *s = make_state(jmt);
+    *e = make_state(jmt);
+    *f = make_state(jmt);
+    ERR_BAIL(jmt);
+
+    for (int i = 0; i < lens->nchildren; i++) {
+        struct state *s2, *e2, *f2;
+
+        conv(jmt, lens->children[i], &s2, &e2, &f2);
+        ERR_BAIL(jmt);
+
+        add_eps_trans(jmt, *s, s2);
+        add_eps_trans(jmt, e2, *e);
+        add_eps_trans(jmt, f2, *f);
+    }
+
+ error:
+    return;
+}
+
+static void conv_star(struct jmt *jmt, struct lens *lens,
+                      struct state **s, struct state **e,
+                      struct state **f) {
+
+    *s = make_state(jmt);
+    *e = make_state(jmt);
+    *f = make_state(jmt);
+    ERR_BAIL(jmt);
+
+    struct state *si, *ei, *fi, *scall, *fcall;
+    conv(jmt, lens->child, &si, &ei, &fi);
+    thompson(jmt, lens->child, &scall, &fcall);
+    ERR_BAIL(jmt);
+
+    add_eps_trans(jmt, *s, si);
+    add_eps_trans(jmt, ei, si);
+    add_eps_trans(jmt, *s, *e);
+    add_eps_trans(jmt, ei, *e);
+    add_eps_trans(jmt, fi, scall);
+    add_eps_trans(jmt, fcall, scall);
+    add_eps_trans(jmt, fi, *f);
+    add_eps_trans(jmt, fcall, *f);
+    ERR_BAIL(jmt);
+
+ error:
+    return;
+}
+
+static void conv_rhs(struct jmt *jmt, ind_t l) {
+    struct lens *lens = lens_of_jmt(jmt, l);
+    struct state *s = NULL, *e = NULL, *f = NULL;
+    struct state *sA = lens_state(jmt, l);
+
+    if (! lens->recursive) {
+        /* Nothing to do for terminals that do not match epsilon */
+        if (sA != NULL)
+            state_add_return(jmt, sA, l);
+        return;
+    }
+
+    /* All other nonterminals/recursive lenses */
+
+    /* Maintain P1 */
+    if (lens->ctype_nullable)
+        state_add_return(jmt, sA, l);
+
+    switch (lens->tag) {
+    case L_REC:
+        conv(jmt, lens->body, &s, &e, &f);
+        break;
+    case L_CONCAT:
+        conv_concat(jmt, lens, &s, &e, &f);
+        break;
+    case L_UNION:
+        conv_union(jmt, lens, &s, &e, &f);
+        break;
+    case L_SUBTREE:
+        conv(jmt, lens->child, &s, &e, &f);
+        break;
+    case L_STAR:
+        conv_star(jmt, lens, &s, &e, &f);
+        break;
+    case L_MAYBE:
+        conv(jmt, lens->child, &s, &e, &f);
+        add_new_trans(jmt, s, e, EPS);
+        break;
+    case L_SQUARE:
+       conv(jmt, lens->child, &s, &e, &f);
+       break;
+    default:
+        BUG_ON(true, jmt, "Unexpected lens tag %d", lens->tag);
+    }
+
+    ensure(sA != NULL, jmt);
+
+    add_eps_trans(jmt, sA, s);
+    state_add_return(jmt, e, l);
+    state_add_return(jmt, f, l);
+
+ error:
+    return;
+}
+
+ATTRIBUTE_RETURN_CHECK
+static int push_state(struct array *worklist, struct state *s) {
+    int r;
+    ind_t ind;
+
+    r = array_add(worklist, &ind);
+    if (r < 0)
+        return -1;
+    *array_elem(*worklist, ind, struct state *) = s;
+    return 0;
+}
+
+static struct state *pop_state(struct array *worklist) {
+    if (worklist->used > 0) {
+        worklist->used -= 1;
+        return *array_elem(*worklist, worklist->used, struct state *);
+    } else {
+        return NULL;
+    }
+}
+
+static void free_state(struct state *s) {
+    if (s == NULL)
+        return;
+    free(s->ret);
+    array_release(&s->trans);
+    free(s);
+}
+
+static void collect(struct jmt *jmt) {
+    struct array worklist;
+    size_t count, removed;
+    int r;
+
+    count = 0;
+    list_for_each(s, jmt->start) {
+        s->live = 0;
+        s->reachable = 0;
+        count += 1;
+    }
+
+    array_init(&worklist, sizeof(struct state *));
+    jmt->start->reachable = 1;
+    for (struct state *s = jmt->start;
+         s != NULL;
+         s = pop_state(&worklist)) {
+        for_each_trans(t, s) {
+            if (! t->to->reachable) {
+                t->to->reachable = 1;
+                r = push_state(&worklist, t->to);
+                ERR_NOMEM(r < 0, jmt);
+            }
+        }
+    }
+
+    list_for_each(s, jmt->start)
+        if (s->reachable && is_return(s))
+            s->live = 1;
+
+    bool changed;
+    do {
+        changed = false;
+        list_for_each(s, jmt->start) {
+            if (! s->live && s->reachable) {
+                for_each_trans(t, s) {
+                    if (t->lens != CALL && t->to->live) {
+                        s->live = 1;
+                        changed = true;
+                        break;
+                    }
+                }
+            }
+        }
+    } while (changed);
+
+    list_for_each(s, jmt->start) {
+        if (s->live && s->reachable) {
+            for (ind_t i = 0; i < s->trans.used; ) {
+                struct trans *t = state_trans(s, i);
+                if (! (t->to->live && t->to->reachable))
+                    array_remove(&s->trans, i);
+                else
+                    i += 1;
+            }
+        }
+    }
+
+    removed = 0;
+    for (struct state *s = jmt->start;
+         s->next != NULL; ) {
+        struct state *p = s->next;
+        if (p->live && p->reachable) {
+            s = p;
+        } else {
+            s->next = p->next;
+            free_state(p);
+            removed += 1;
+        }
+    }
+
+ error:
+    array_release(&worklist);
+    return;
+}
+
+static void dedup(struct state *s) {
+    array_for_each(i, s->trans) {
+        struct trans *t = state_trans(s, i);
+        for (ind_t j = i+1; j < s->trans.used;) {
+            struct trans *u = state_trans(s, j);
+            if (t->to == u->to && t->lens == u->lens)
+                array_remove(&s->trans, j);
+            else
+                j += 1;
+        }
+    }
+}
+
+static void unepsilon(struct jmt *jmt) {
+    int r;
+
+    if (debugging("cf.jmt.build"))
+        jmt_dot(jmt, "jmt_10_raw.dot");
+    collect(jmt);
+
+    /* Get rid of epsilon transitions */
+    bool changed;
+    do {
+        changed = false;
+        list_for_each(s, jmt->start) {
+            array_for_each(i , s->trans) {
+                struct trans *t = state_trans(s, i);
+                if (t->lens == EPS) {
+                    struct state *to = t->to;
+                    array_remove(&s->trans, i);
+                    r = array_join(&s->trans, &to->trans);
+                    ERR_NOMEM(r < 0, jmt);
+                    state_merge_returns(jmt, s, to);
+                    dedup(s);
+                    changed = true;
+                }
+            }
+        }
+    } while (changed);
+
+    collect(jmt);
+    if (debugging("cf.jmt.build"))
+        jmt_dot(jmt, "jmt_20_uneps.dot");
+ error:
+    return;
+}
+
+static bool is_deterministic(struct jmt *jmt) {
+    list_for_each(s, jmt->start) {
+        array_for_each(i, s->trans) {
+            struct trans *t = state_trans(s, i);
+            for (ind_t j = i+1; j < s->trans.used; j++) {
+                struct trans *u = state_trans(s, j);
+                if (t->lens == u->lens)
+                    return false;
+            }
+        }
+    }
+    return true;
+}
+
+static void free_nfa_state(struct nfa_state *s) {
+    if (s == NULL)
+        return;
+    array_release(&s->set);
+    free(s);
+}
+
+static struct nfa_state *make_nfa_state(struct jmt *jmt) {
+    struct nfa_state *result = NULL;
+    int r;
+
+    r = ALLOC(result);
+    ERR_NOMEM(r < 0, jmt);
+
+    array_init(&result->set, sizeof(struct state *));
+
+    return result;
+ error:
+    FREE(result);
+    return NULL;
+}
+
+static ind_t nfa_state_add(struct jmt *jmt, struct nfa_state *nfa,
+                           struct state *s) {
+    ind_t i;
+    int r;
+
+    array_for_each(j, nfa->set) {
+        struct state *q = *array_elem(nfa->set, j, struct state *);
+        if (q == s)
+            return j;
+    }
+
+    /* Keep the list of states sorted */
+    i = nfa->set.used;
+    for (int j=0; j + 1 < nfa->set.used; j++) {
+        if (s < *array_elem(nfa->set, j, struct state *)) {
+            i = j;
+            break;
+        }
+    }
+    r = array_insert(&nfa->set, i);
+    ERR_NOMEM(r < 0, jmt);
+
+    *array_elem(nfa->set, i, struct state *) = s;
+    return i;
+ error:
+    return IND_MAX;
+}
+
+static bool nfa_same_set(struct nfa_state *s1, struct nfa_state *s2) {
+    if (s1->set.used != s2->set.used)
+        return false;
+
+    array_for_each(i, s1->set) {
+        struct state *q1 = *array_elem(s1->set, i, struct state *);
+        struct state *q2 = *array_elem(s2->set, i, struct state *);
+        if (q1 != q2)
+            return false;
+    }
+
+    return true;
+}
+
+static struct nfa_state *nfa_uniq(struct jmt *jmt, struct array *newstates,
+                                  struct nfa_state *s) {
+    ind_t ind;
+    int r;
+
+    array_each_elem(q, *newstates, struct nfa_state *) {
+        if (nfa_same_set(s, *q)) {
+            if (s == *q)
+                return s;
+            free_nfa_state(s);
+            return *q;
+        }
+    }
+
+    r = array_add(newstates, &ind);
+    ERR_NOMEM(r < 0, jmt);
+    *array_elem(*newstates, ind, struct nfa_state *) = s;
+
+    if (s->state == NULL) {
+        s->state = make_state(jmt);
+        ERR_BAIL(jmt);
+    }
+
+    /* This makes looking at pictures easier */
+    if (s->set.used == 1)
+        s->state->num = (*array_elem(s->set, 0, struct state *))->num;
+
+    return s;
+
+ error:
+    return NULL;
+}
+
+static void det_target(struct jmt *jmt, struct array *newstates,
+                       struct nfa_state *nfas, ind_t l) {
+    struct nfa_state *to = NULL;
+
+    array_each_elem(s, nfas->set, struct state *) {
+        for_each_trans(t, *s) {
+            if (t->lens == l) {
+                if (to == NULL) {
+                    to = make_nfa_state(jmt);
+                    ERR_RET(jmt);
+                }
+                nfa_state_add(jmt, to, t->to);
+                ERR_RET(jmt);
+            }
+        }
+    }
+
+    if (to != NULL) {
+        to = nfa_uniq(jmt, newstates, to);
+        ERR_RET(jmt);
+        add_new_trans(jmt, nfas->state, to->state, l);
+    }
+}
+
+static void determinize(struct jmt *jmt) {
+    struct nfa_state *ini = NULL;
+    struct array *newstates = NULL;
+    int r;
+    ind_t ind, nlenses;
+
+    if (is_deterministic(jmt))
+        return;
+
+    r = ALLOC(newstates);
+    ERR_NOMEM(r < 0, jmt);
+    array_init(newstates, sizeof(struct nfa_state *));
+
+    nlenses = jmt->lenses.used;
+
+    /* The initial state consists of just the start state */
+    ini = make_nfa_state(jmt);
+    ERR_BAIL(jmt);
+    nfa_state_add(jmt, ini, jmt->start);
+    ERR_BAIL(jmt);
+
+    /* Make a new initial state */
+    ini->state = make_state(jmt);
+    ini->state->num = jmt->start->num;  /* Makes lokking at pictures easier */
+    ERR_BAIL(jmt);
+    jmt->start->next = ini->state->next;
+    ini->state->next = jmt->start;
+    jmt->start = ini->state;
+
+    r = array_add(newstates, &ind);
+    ERR_NOMEM(r < 0, jmt);
+
+    *array_elem(*newstates, ind, struct nfa_state *) = ini;
+    ini = NULL;
+
+    for (ind_t i = 0; i < newstates->used; i++) {
+        struct nfa_state *nfas = *array_elem(*newstates, i, struct nfa_state *);
+
+        for (int j = 0; j < nfas->set.used; j++) {
+            struct state *s = *array_elem(nfas->set, j, struct state *);
+            state_merge_returns(jmt, nfas->state, s);
+        }
+
+        for (ind_t l = 0; l < nlenses; l++) {
+            det_target(jmt, newstates, nfas, l);
+            ERR_BAIL(jmt);
+        }
+        det_target(jmt, newstates, nfas, CALL);
+        ERR_BAIL(jmt);
+    }
+
+    collect(jmt);
+
+ done:
+    if (newstates) {
+        array_each_elem(s, *newstates, struct nfa_state *) {
+            free_nfa_state(*s);
+        }
+        array_release(newstates);
+        FREE(newstates);
+    }
+    free_nfa_state(ini);
+    return;
+ error:
+    goto done;
+}
+
+struct jmt *jmt_build(struct lens *lens) {
+    struct jmt *jmt = NULL;
+    int r;
+
+    r = ALLOC(jmt);
+    ERR_NOMEM(r < 0, lens->info);
+
+    jmt->error = lens->info->error;
+    array_init(&jmt->lenses, sizeof(struct jmt_lens));
+
+    index_lenses(jmt, lens);
+
+    if (debugging("cf.jmt"))
+        print_grammar_top(jmt, lens);
+
+    for (ind_t i=0; i < jmt->lenses.used; i++) {
+        conv_rhs(jmt, i);
+        ERR_BAIL(jmt);
+    }
+
+    unepsilon(jmt);
+    ERR_BAIL(jmt);
+
+    determinize(jmt);
+    ERR_BAIL(jmt);
+
+    if (debugging("cf.jmt.build"))
+        jmt_dot(jmt, "jmt_30_dfa.dot");
+
+    return jmt;
+ error:
+    jmt_free(jmt);
+    return NULL;
+}
+
+void jmt_free(struct jmt *jmt) {
+    if (jmt == NULL)
+        return;
+    array_release(&jmt->lenses);
+    struct state *s = jmt->start;
+    while (s != NULL) {
+        struct state *del = s;
+        s = del->next;
+        free_state(del);
+    }
+    free(jmt);
+}
+
+void jmt_dot(struct jmt *jmt, const char *fname) {
+    FILE *fp = debug_fopen("%s", fname);
+    if (fp == NULL)
+        return;
+
+    fprintf(fp, "digraph \"jmt\" {\n");
+    fprintf(fp, "  rankdir = LR;\n");
+    list_for_each(s, jmt->start) {
+        if (is_return(s)) {
+            fprintf(fp, "  %u [ shape = doublecircle, label = \"%u (",
+                    s->num, s->num);
+            flens(fp, s->ret[0]);
+            for (ind_t i = 1; i < s->nret; i++) {
+                fprintf(fp, ", ");
+                flens(fp, s->ret[i]);
+            }
+            fprintf(fp, ")\" ];\n");
+        }
+        for_each_trans(t, s) {
+            fprintf(fp, "  %u -> %u ", s->num, t->to->num);
+            if (t->lens == EPS)
+                fprintf(fp, ";\n");
+            else if (t->lens == CALL)
+                fprintf(fp, "[ label = \"call\" ];\n");
+            else if (lens_state(jmt, t->lens) == NULL) {
+                struct lens *lens = lens_of_jmt(jmt, t->lens);
+                fprintf(fp, "[ label = \"");
+                print_regexp(fp, lens->ctype);
+                fprintf(fp, "\" ];\n");
+            } else {
+                fprintf(fp, "[ label = \"");
+                flens(fp, t->lens);
+                fprintf(fp, "\" ];\n");
+            }
+        }
+    }
+    fprintf(fp, "}\n");
+    fclose(fp);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/jmt.h b/src/jmt.h
new file mode 100644 (file)
index 0000000..5653d73
--- /dev/null
+++ b/src/jmt.h
@@ -0,0 +1,75 @@
+/*
+ * jmt.h: Earley parser for lenses based on Jim/Mandelbaum transducers
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#ifndef EARLEY_H_
+#define EARLEY_H_
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "lens.h"
+
+struct jmt;
+struct jmt_parse;
+
+typedef uint32_t ind_t;
+
+struct lens;
+
+typedef void (*jmt_traverser)(struct lens *l, size_t start, size_t end,
+                              void *data);
+
+typedef void (*jmt_error)(struct lens *lens, void *data, size_t pos,
+                          const char *format, ...);
+
+struct jmt_visitor {
+    struct jmt_parse *parse;
+    jmt_traverser    terminal;
+    jmt_traverser    enter;
+    jmt_traverser    exit;
+    jmt_error        error;
+    void             *data;
+};
+
+struct jmt *jmt_build(struct lens *l);
+
+struct jmt_parse *jmt_parse(struct jmt *jmt, const char *text, size_t text_len);
+
+void jmt_free_parse(struct jmt_parse *);
+
+/* Returns -1 on internal error, 0 on syntax error, 1 on a successful
+ * parse.
+ */
+int jmt_visit(struct jmt_visitor *visitor, size_t *len);
+
+void jmt_free(struct jmt *jmt);
+
+void jmt_dot(struct jmt *jmt, const char *fname);
+#endif
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/lens.c b/src/lens.c
new file mode 100644 (file)
index 0000000..63f6758
--- /dev/null
@@ -0,0 +1,2271 @@
+/*
+ * lens.c:
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <stddef.h>
+
+#include "lens.h"
+#include "memory.h"
+#include "errcode.h"
+#include "internal.h"
+
+/* This enum must be kept in sync with type_offs and ntypes */
+enum lens_type {
+    CTYPE, ATYPE, KTYPE, VTYPE
+};
+
+static const int const type_offs[] = {
+    offsetof(struct lens, ctype),
+    offsetof(struct lens, atype),
+    offsetof(struct lens, ktype),
+    offsetof(struct lens, vtype)
+};
+static const int ntypes = sizeof(type_offs)/sizeof(type_offs[0]);
+
+static const char *lens_type_names[] =
+    { "ctype", "atype", "ktype", "vtype" };
+
+#define ltype(lns, t) *((struct regexp **) ((char *) lns + type_offs[t]))
+
+static struct value * typecheck_union(struct info *,
+                                      struct lens *l1, struct lens *l2);
+static struct value *typecheck_concat(struct info *,
+                                      struct lens *l1, struct lens *l2);
+static struct value *typecheck_iter(struct info *info, struct lens *l);
+static struct value *typecheck_maybe(struct info *info, struct lens *l);
+
+/* Lens names for pretty printing */
+/* keep order in sync with enum type */
+static const char *const tags[] = {
+    "del", "store", "value", "key", "label", "seq", "counter",
+    "concat", "union",
+    "subtree", "star", "maybe", "rec", "square"
+};
+
+#define ltag(lens) (tags[lens->tag - L_DEL])
+
+static const struct string digits_string = {
+    .ref = REF_MAX, .str = (char *) "[0123456789]+"
+};
+static const struct string *const digits_pat = &digits_string;
+
+char *format_lens(struct lens *l) {
+    char *inf = format_info(l->info);
+    char *result;
+
+    xasprintf(&result, "%s[%s]%s", tags[l->tag - L_DEL], inf,
+              l->recursive ? "R" : "r");
+    free(inf);
+    return result;
+}
+
+#define BUG_LENS_TAG(lns)  bug_lens_tag(lns, __FILE__, __LINE__)
+
+static void bug_lens_tag(struct lens *lens, const char *file, int lineno) {
+    char *s = format_lens(lens);
+
+    if (lens != NULL && lens->info != NULL && lens->info->error != NULL) {
+        bug_on(lens->info->error, file, lineno, "Unexpected lens tag %s", s);
+    } else {
+        /* We are really screwed */
+        assert(0);
+    }
+    free(s);
+    return;
+}
+
+/* Construct a finite automaton from REGEXP and return it in *FA.
+ *
+ * Return NULL if REGEXP is valid, if the regexp REGEXP has syntax errors,
+ * return an exception.
+ */
+static struct value *str_to_fa(struct info *info, const char *pattern,
+                               struct fa **fa, int nocase) {
+    int error;
+    struct value *exn = NULL;
+    size_t re_err_len;
+    char *re_str = NULL, *re_err = NULL;
+
+    *fa = NULL;
+    error = fa_compile(pattern, strlen(pattern), fa);
+    if (error == REG_NOERROR) {
+        if (nocase) {
+            error = fa_nocase(*fa);
+            ERR_NOMEM(error < 0, info);
+        }
+        return NULL;
+    }
+
+    re_str = escape(pattern, -1);
+    ERR_NOMEM(re_str == NULL, info);
+
+    exn = make_exn_value(info, "Invalid regular expression /%s/", re_str);
+
+    re_err_len = regerror(error, NULL, NULL, 0);
+    error = ALLOC_N(re_err, re_err_len);
+    ERR_NOMEM(error < 0, info);
+
+    regerror(error, NULL, re_err, re_err_len);
+    exn_printf_line(exn, "%s", re_err);
+
+ done:
+    free(re_str);
+    free(re_err);
+    return exn;
+ error:
+    fa_free(*fa);
+    *fa = NULL;
+    exn = exn_error();
+    goto done;
+}
+
+static struct value *regexp_to_fa(struct regexp *regexp, struct fa **fa) {
+    return str_to_fa(regexp->info, regexp->pattern->str, fa, regexp->nocase);
+}
+
+static struct lens *make_lens(enum lens_tag tag, struct info *info) {
+    struct lens *lens;
+    make_ref(lens);
+    lens->tag = tag;
+    lens->info = info;
+
+    return lens;
+}
+
+static struct lens *make_lens_unop(enum lens_tag tag, struct info *info,
+                                  struct lens *child) {
+    struct lens *lens = make_lens(tag, info);
+    lens->child = child;
+    lens->value = child->value;
+    lens->key = child->key;
+    return lens;
+}
+
+typedef struct regexp *regexp_combinator(struct info *, int, struct regexp **);
+
+static struct lens *make_lens_binop(enum lens_tag tag, struct info *info,
+                                    struct lens *l1, struct lens *l2,
+                                    regexp_combinator *combinator) {
+    struct lens *lens = make_lens(tag, info);
+    int n1 = (l1->tag == tag) ? l1->nchildren : 1;
+    struct regexp **types = NULL;
+
+    if (lens == NULL)
+        goto error;
+
+    lens->nchildren = n1;
+    lens->nchildren += (l2->tag == tag) ? l2->nchildren : 1;
+
+    lens->recursive = l1->recursive || l2->recursive;
+    lens->rec_internal = l1->rec_internal || l2->rec_internal;
+
+    if (ALLOC_N(lens->children, lens->nchildren) < 0) {
+        lens->nchildren = 0;
+        goto error;
+    }
+
+    if (l1->tag == tag) {
+        for (int i=0; i < l1->nchildren; i++)
+            lens->children[i] = ref(l1->children[i]);
+        unref(l1, lens);
+    } else {
+        lens->children[0] = l1;
+    }
+
+    if (l2->tag == tag) {
+        for (int i=0; i < l2->nchildren; i++)
+            lens->children[n1 + i] = ref(l2->children[i]);
+        unref(l2, lens);
+    } else {
+        lens->children[n1] = l2;
+    }
+
+    for (int i=0; i < lens->nchildren; i++) {
+        lens->value = lens->value || lens->children[i]->value;
+        lens->key = lens->key || lens->children[i]->key;
+    }
+
+    if (ALLOC_N(types, lens->nchildren) < 0)
+        goto error;
+
+    if (! lens->rec_internal) {
+        /* Inside a recursive lens, we assign types with lns_check_rec
+         * once we know the entire lens */
+        for (int t=0; t < ntypes; t++) {
+            if (lens->recursive && t == CTYPE)
+                continue;
+            for (int i=0; i < lens->nchildren; i++)
+                types[i] = ltype(lens->children[i], t);
+            ltype(lens, t) = (*combinator)(info, lens->nchildren, types);
+        }
+    }
+    FREE(types);
+
+    for (int i=0; i < lens->nchildren; i++)
+        ensure(tag != lens->children[i]->tag, lens->info);
+
+    return lens;
+ error:
+    unref(lens, lens);
+    FREE(types);
+    return NULL;
+}
+
+static struct value *make_lens_value(struct lens *lens) {
+    struct value *v;
+    v = make_value(V_LENS, ref(lens->info));
+    v->lens = lens;
+    return v;
+}
+
+struct value *lns_make_union(struct info *info,
+                             struct lens *l1, struct lens *l2, int check) {
+    struct lens *lens = NULL;
+    int consumes_value = l1->consumes_value && l2->consumes_value;
+    int recursive = l1->recursive || l2->recursive;
+    int ctype_nullable = l1->ctype_nullable || l2->ctype_nullable;
+
+    if (check) {
+        struct value *exn = typecheck_union(info, l1, l2);
+        if (exn != NULL)
+            return exn;
+    }
+
+    lens = make_lens_binop(L_UNION, info, l1, l2, regexp_union_n);
+    lens->consumes_value = consumes_value;
+    if (! recursive)
+        lens->ctype_nullable = ctype_nullable;
+    return make_lens_value(lens);
+}
+
+struct value *lns_make_concat(struct info *info,
+                              struct lens *l1, struct lens *l2, int check) {
+    struct lens *lens = NULL;
+    int consumes_value = l1->consumes_value || l2->consumes_value;
+    int recursive = l1->recursive || l2->recursive;
+    int ctype_nullable = l1->ctype_nullable && l2->ctype_nullable;
+
+    if (check) {
+        struct value *exn = typecheck_concat(info, l1, l2);
+        if (exn != NULL)
+            return exn;
+    }
+    if (l1->value && l2->value) {
+        return make_exn_value(info, "Multiple stores in concat");
+    }
+    if (l1->key && l2->key) {
+        return make_exn_value(info, "Multiple keys/labels in concat");
+    }
+
+    lens = make_lens_binop(L_CONCAT, info, l1, l2, regexp_concat_n);
+    lens->consumes_value = consumes_value;
+    if (! recursive)
+        lens->ctype_nullable = ctype_nullable;
+    return make_lens_value(lens);
+}
+
+static struct regexp *subtree_atype(struct info *info,
+                                    struct regexp *ktype,
+                                    struct regexp *vtype) {
+    const char *kpat = (ktype == NULL) ? ENC_NULL : ktype->pattern->str;
+    const char *vpat = (vtype == NULL) ? ENC_NULL : vtype->pattern->str;
+    char *pat;
+    struct regexp *result = NULL;
+    char *ks = NULL, *vs = NULL;
+    int nocase;
+
+    if (ktype != NULL && vtype != NULL && ktype->nocase != vtype->nocase) {
+        ks = regexp_expand_nocase(ktype);
+        vs = regexp_expand_nocase(vtype);
+        ERR_NOMEM(ks == NULL || vs == NULL, info);
+        if (asprintf(&pat, "(%s)%s(%s)%s", ks, ENC_EQ, vs, ENC_SLASH) < 0)
+            ERR_NOMEM(true, info);
+        nocase = 0;
+    } else {
+        if (asprintf(&pat, "(%s)%s(%s)%s", kpat, ENC_EQ, vpat, ENC_SLASH) < 0)
+            ERR_NOMEM(pat == NULL, info);
+
+        nocase = 0;
+        if (ktype != NULL)
+            nocase = ktype->nocase;
+        else if (vtype != NULL)
+            nocase = vtype->nocase;
+    }
+    result = make_regexp(info, pat, nocase);
+ error:
+    free(ks);
+    free(vs);
+    return result;
+}
+
+/*
+ * A subtree lens l1 = [ l ]
+ *
+ * Types are assigned as follows:
+ *
+ * l1->ctype = l->ctype
+ * l1->atype = encode(l->ktype, l->vtype)
+ * l1->ktype = NULL
+ * l1->vtype = NULL
+ */
+struct value *lns_make_subtree(struct info *info, struct lens *l) {
+    struct lens *lens;
+
+    lens = make_lens_unop(L_SUBTREE, info, l);
+    lens->ctype = ref(l->ctype);
+    if (! l->recursive)
+        lens->atype = subtree_atype(info, l->ktype, l->vtype);
+    lens->value = lens->key = 0;
+    lens->recursive = l->recursive;
+    lens->rec_internal = l->rec_internal;
+    if (! l->recursive)
+        lens->ctype_nullable = l->ctype_nullable;
+    return make_lens_value(lens);
+}
+
+struct value *lns_make_star(struct info *info, struct lens *l, int check) {
+    struct lens *lens;
+
+    if (check) {
+        struct value *exn = typecheck_iter(info, l);
+        if (exn != NULL)
+            return exn;
+    }
+    if (l->value) {
+        return make_exn_value(info, "Multiple stores in iteration");
+    }
+    if (l->key) {
+        return make_exn_value(info, "Multiple keys/labels in iteration");
+    }
+
+    lens = make_lens_unop(L_STAR, info, l);
+    for (int t = 0; t < ntypes; t++) {
+        ltype(lens, t) = regexp_iter(info, ltype(l, t), 0, -1);
+    }
+    lens->recursive = l->recursive;
+    lens->rec_internal = l->rec_internal;
+    lens->ctype_nullable = 1;
+    return make_lens_value(lens);
+}
+
+struct value *lns_make_plus(struct info *info, struct lens *l, int check) {
+    struct value *star, *conc;
+
+    star = lns_make_star(info, l, check);
+    if (EXN(star))
+        return star;
+
+    conc = lns_make_concat(ref(info), ref(l), ref(star->lens), check);
+    unref(star, value);
+    return conc;
+}
+
+struct value *lns_make_maybe(struct info *info, struct lens *l, int check) {
+    struct lens *lens;
+
+    if (check) {
+        struct value *exn = typecheck_maybe(info, l);
+        if (exn != NULL)
+            return exn;
+    }
+    lens = make_lens_unop(L_MAYBE, info, l);
+    for (int t=0; t < ntypes; t++)
+        ltype(lens, t) = regexp_maybe(info, ltype(l, t));
+    lens->value = l->value;
+    lens->key = l->key;
+    lens->recursive = l->recursive;
+    lens->rec_internal = l->rec_internal;
+    lens->ctype_nullable = 1;
+    return make_lens_value(lens);
+}
+
+/* Build a square lens as
+ *   key REG . lns . del REG MATCHED
+ * where MATCHED is whatever the key lens matched (the inability to express
+ * this with other lenses makes the square primitve necessary
+ */
+struct value *lns_make_square(struct info *info,
+                              struct regexp *reg,
+                              struct lens *lns, int check) {
+    struct value *key = NULL, *del = NULL;
+    struct value *cnt1 = NULL, *cnt2 = NULL, *res = NULL;
+    struct lens *sqr = NULL;
+
+    res = lns_make_prim(L_KEY, ref(info), ref(reg), NULL);
+    if (EXN(res))
+        goto error;
+    key = res;
+
+    res = lns_make_prim(L_DEL, ref(info), ref(reg), NULL);
+    if (EXN(res))
+        goto error;
+    del = res;
+
+    // typechecking is handled when concatenating lenses
+    res = lns_make_concat(ref(info), ref(key->lens), ref(lns), check);
+    if (EXN(res))
+        goto error;
+    cnt1 = res;
+
+    res = lns_make_concat(ref(info), ref(cnt1->lens), ref(del->lens), check);
+    if (EXN(res))
+        goto error;
+    cnt2 = res;
+
+    sqr = make_lens_unop(L_SQUARE, ref(info), ref(cnt2->lens));
+    ERR_NOMEM(sqr == NULL, info);
+
+    for (int t=0; t < ntypes; t++)
+        ltype(sqr, t) = ref(ltype(cnt2->lens, t));
+    sqr->recursive = cnt2->lens->recursive;
+    sqr->rec_internal = cnt2->lens->rec_internal;
+    sqr->consumes_value = cnt2->lens->consumes_value;
+
+    res = make_lens_value(sqr);
+    ERR_NOMEM(res == NULL, info);
+    sqr = NULL;
+
+ error:
+    unref(info, info);
+    unref(reg, regexp);
+    unref(lns, lens);
+
+    unref(key, value);
+    unref(del, value);
+    unref(cnt1, value);
+    unref(cnt2, value);
+    unref(sqr, lens);
+    return res;
+}
+
+/*
+ * Lens primitives
+ */
+
+static struct regexp *make_regexp_from_string(struct info *info,
+                                              struct string *string) {
+    struct regexp *r;
+    make_ref(r);
+    if (r != NULL) {
+        r->info = ref(info);
+        r->pattern = ref(string);
+        r->nocase = 0;
+    }
+    return r;
+}
+
+static struct regexp *restrict_regexp(struct regexp *r) {
+    char *nre = NULL;
+    struct regexp *result = NULL;
+    size_t nre_len;
+    int ret;
+
+    ret = fa_restrict_alphabet(r->pattern->str, strlen(r->pattern->str),
+                               &nre, &nre_len,
+                               RESERVED_FROM, RESERVED_TO);
+    ERR_NOMEM(ret == REG_ESPACE || ret < 0, r->info);
+    BUG_ON(ret != 0, r->info, NULL);
+    ensure(nre_len == strlen(nre), r->info);
+
+    ret = regexp_c_locale(&nre, &nre_len);
+    ERR_NOMEM(ret < 0, r->info);
+
+    result = make_regexp(r->info, nre, r->nocase);
+    nre = NULL;
+    BUG_ON(regexp_compile(result) != 0, r->info,
+           "Could not compile restricted regexp");
+ done:
+    free(nre);
+    return result;
+ error:
+    unref(result, regexp);
+    goto done;
+}
+
+struct value *lns_make_prim(enum lens_tag tag, struct info *info,
+                            struct regexp *regexp, struct string *string) {
+    struct lens *lens = NULL;
+    struct value *exn = NULL;
+    struct fa *fa_slash = NULL;
+    struct fa *fa_key = NULL;
+    struct fa *fa_isect = NULL;
+
+    /* Typecheck */
+    if (tag == L_KEY) {
+        exn = str_to_fa(info, "(.|\n)*/(.|\n)*", &fa_slash, regexp->nocase);
+        if (exn != NULL)
+            goto error;
+
+        exn = regexp_to_fa(regexp, &fa_key);
+        if (exn != NULL)
+            goto error;
+
+        fa_isect = fa_intersect(fa_slash, fa_key);
+        if (! fa_is_basic(fa_isect, FA_EMPTY)) {
+            exn = make_exn_value(info,
+                                 "The key regexp /%s/ matches a '/'",
+                                 regexp->pattern->str);
+            goto error;
+        }
+        fa_free(fa_isect);
+        fa_free(fa_key);
+        fa_free(fa_slash);
+        fa_isect = fa_key = fa_slash = NULL;
+    } else if (tag == L_LABEL) {
+        if (strchr(string->str, SEP) != NULL) {
+            exn = make_exn_value(info,
+                                 "The label string \"%s\" contains a '/'",
+                                 string->str);
+            goto error;
+        }
+    } else if (tag == L_DEL && string != NULL) {
+        int cnt;
+        const char *dflt = string->str;
+        cnt = regexp_match(regexp, dflt, strlen(dflt), 0, NULL);
+        if (cnt != strlen(dflt)) {
+            char *s = escape(dflt, -1);
+            char *r = regexp_escape(regexp);
+            exn = make_exn_value(info,
+                   "del: the default value '%s' does not match /%s/",
+                   s, r);
+            FREE(s);
+            FREE(r);
+            goto error;
+        }
+    }
+
+    /* Build the actual lens */
+    lens = make_lens(tag, info);
+    lens->regexp = regexp;
+    lens->string = string;
+    lens->key = (tag == L_KEY || tag == L_LABEL || tag == L_SEQ);
+    lens->value = (tag == L_STORE || tag == L_VALUE);
+    lens->consumes_value = (tag == L_STORE || tag == L_VALUE);
+    lens->atype = regexp_make_empty(info);
+    /* Set the ctype */
+    if (tag == L_DEL || tag == L_STORE || tag == L_KEY) {
+        lens->ctype = ref(regexp);
+        lens->ctype_nullable = regexp_matches_empty(lens->ctype);
+    } else if (tag == L_LABEL || tag == L_VALUE
+               || tag == L_SEQ || tag == L_COUNTER) {
+        lens->ctype = regexp_make_empty(info);
+        lens->ctype_nullable = 1;
+    } else {
+        BUG_LENS_TAG(lens);
+        goto error;
+    }
+
+
+    /* Set the ktype */
+    if (tag == L_SEQ) {
+        lens->ktype =
+            make_regexp_from_string(info, (struct string *) digits_pat);
+        if (lens->ktype == NULL)
+            goto error;
+    } else if (tag == L_KEY) {
+        lens->ktype = restrict_regexp(lens->regexp);
+    } else if (tag == L_LABEL) {
+        lens->ktype = make_regexp_literal(info, lens->string->str);
+        if (lens->ktype == NULL)
+            goto error;
+    }
+
+    /* Set the vtype */
+    if (tag == L_STORE) {
+        lens->vtype = restrict_regexp(lens->regexp);
+    } else if (tag == L_VALUE) {
+        lens->vtype = make_regexp_literal(info, lens->string->str);
+    }
+
+    return make_lens_value(lens);
+ error:
+    fa_free(fa_isect);
+    fa_free(fa_key);
+    fa_free(fa_slash);
+    return exn;
+}
+
+/*
+ * Typechecking of lenses
+ */
+static struct value *disjoint_check(struct info *info, bool is_get,
+                                    struct regexp *r1, struct regexp *r2) {
+    struct fa *fa1 = NULL;
+    struct fa *fa2 = NULL;
+    struct fa *fa = NULL;
+    struct value *exn = NULL;
+    const char *const msg = is_get ? "union.get" : "tree union.put";
+
+    if (r1 == NULL || r2 == NULL)
+        return NULL;
+
+    exn = regexp_to_fa(r1, &fa1);
+    if (exn != NULL)
+        goto done;
+
+    exn = regexp_to_fa(r2, &fa2);
+    if (exn != NULL)
+        goto done;
+
+    fa = fa_intersect(fa1, fa2);
+    if (! fa_is_basic(fa, FA_EMPTY)) {
+        size_t xmpl_len;
+        char *xmpl;
+        fa_example(fa, &xmpl, &xmpl_len);
+        if (! is_get) {
+            char *fmt = enc_format(xmpl, xmpl_len);
+            if (fmt != NULL) {
+                FREE(xmpl);
+                xmpl = fmt;
+            }
+        }
+        exn = make_exn_value(ref(info),
+                             "overlapping lenses in %s", msg);
+
+        if (is_get)
+            exn_printf_line(exn, "Example matched by both: '%s'", xmpl);
+        else
+            exn_printf_line(exn, "Example matched by both: %s", xmpl);
+        free(xmpl);
+    }
+
+ done:
+    fa_free(fa);
+    fa_free(fa1);
+    fa_free(fa2);
+
+    return exn;
+}
+
+static struct value *typecheck_union(struct info *info,
+                                     struct lens *l1, struct lens *l2) {
+    struct value *exn = NULL;
+
+    exn = disjoint_check(info, true, l1->ctype, l2->ctype);
+    if (exn == NULL) {
+        exn = disjoint_check(info, false, l1->atype, l2->atype);
+    }
+    if (exn != NULL) {
+        char *fi = format_info(l1->info);
+        exn_printf_line(exn, "First lens: %s", fi);
+        free(fi);
+
+        fi = format_info(l2->info);
+        exn_printf_line(exn, "Second lens: %s", fi);
+        free(fi);
+    }
+    return exn;
+}
+
+static struct value *
+ambig_check(struct info *info, struct fa *fa1, struct fa *fa2,
+            enum lens_type typ,  struct lens *l1, struct lens *l2,
+            const char *msg, bool iterated) {
+    char *upv, *pv, *v;
+    size_t upv_len;
+    struct value *exn = NULL;
+    int r;
+
+    r = fa_ambig_example(fa1, fa2, &upv, &upv_len, &pv, &v);
+    if (r < 0) {
+        exn = make_exn_value(ref(info), "not enough memory");
+        if (exn != NULL) {
+            return exn;
+        } else {
+            ERR_REPORT(info, AUG_ENOMEM, NULL);
+            return exn_error();
+        }
+    }
+
+    if (upv != NULL) {
+        char *e_u, *e_up, *e_upv, *e_pv, *e_v;
+        char *s1, *s2;
+
+        if (typ == ATYPE) {
+            e_u = enc_format(upv, pv - upv);
+            e_up = enc_format(upv, v - upv);
+            e_upv = enc_format(upv, upv_len);
+            e_pv = enc_format(pv, strlen(pv));
+            e_v = enc_format(v, strlen(v));
+            lns_format_atype(l1, &s1);
+            lns_format_atype(l2, &s2);
+        } else {
+            e_u = escape(upv, pv - upv);
+            e_up = escape(upv, v - upv);
+            e_upv = escape(upv, -1);
+            e_pv = escape(pv, -1);
+            e_v = escape(v, -1);
+            s1 = regexp_escape(ltype(l1, typ));
+            s2 = regexp_escape(ltype(l2, typ));
+        }
+        exn = make_exn_value(ref(info), "%s", msg);
+        if (iterated) {
+            exn_printf_line(exn, "  Iterated regexp: /%s/", s1);
+        } else {
+            exn_printf_line(exn, "  First regexp: /%s/", s1);
+            exn_printf_line(exn, "  Second regexp: /%s/", s2);
+        }
+        exn_printf_line(exn, "  '%s' can be split into", e_upv);
+        exn_printf_line(exn, "  '%s|=|%s'\n", e_u, e_pv);
+        exn_printf_line(exn, " and");
+        exn_printf_line(exn, "  '%s|=|%s'\n", e_up, e_v);
+        free(e_u);
+        free(e_up);
+        free(e_upv);
+        free(e_pv);
+        free(e_v);
+        free(s1);
+        free(s2);
+    }
+    free(upv);
+    return exn;
+}
+
+static struct value *
+ambig_concat_check(struct info *info, const char *msg,
+                   enum lens_type typ, struct lens *l1, struct lens *l2) {
+    struct fa *fa1 = NULL;
+    struct fa *fa2 = NULL;
+    struct value *result = NULL;
+    struct regexp *r1 = ltype(l1, typ);
+    struct regexp *r2 = ltype(l2, typ);
+
+    if (r1 == NULL || r2 == NULL)
+        return NULL;
+
+    result = regexp_to_fa(r1, &fa1);
+    if (result != NULL)
+        goto done;
+
+    result = regexp_to_fa(r2, &fa2);
+    if (result != NULL)
+        goto done;
+
+    result = ambig_check(info, fa1, fa2, typ, l1, l2, msg, false);
+ done:
+    fa_free(fa1);
+    fa_free(fa2);
+    return result;
+}
+
+static struct value *typecheck_concat(struct info *info,
+                                      struct lens *l1, struct lens *l2) {
+    struct value *result = NULL;
+
+    result = ambig_concat_check(info, "ambiguous concatenation",
+                                CTYPE, l1, l2);
+    if (result == NULL) {
+        result = ambig_concat_check(info, "ambiguous tree concatenation",
+                                    ATYPE, l1, l2);
+    }
+    if (result != NULL) {
+        char *fi = format_info(l1->info);
+        exn_printf_line(result, "First lens: %s", fi);
+        free(fi);
+        fi = format_info(l2->info);
+        exn_printf_line(result, "Second lens: %s", fi);
+        free(fi);
+    }
+    return result;
+}
+
+static struct value *
+ambig_iter_check(struct info *info, const char *msg,
+                 enum lens_type typ, struct lens *l) {
+    struct fa *fas = NULL, *fa = NULL;
+    struct value *result = NULL;
+    struct regexp *r = ltype(l, typ);
+
+    if (r == NULL)
+        return NULL;
+
+    result = regexp_to_fa(r, &fa);
+    if (result != NULL)
+        goto done;
+
+    fas = fa_iter(fa, 0, -1);
+
+    result = ambig_check(info, fa, fas, typ, l, l, msg, true);
+
+ done:
+    fa_free(fa);
+    fa_free(fas);
+    return result;
+}
+
+static struct value *typecheck_iter(struct info *info, struct lens *l) {
+    struct value *result = NULL;
+
+    result = ambig_iter_check(info, "ambiguous iteration", CTYPE, l);
+    if (result == NULL) {
+        result = ambig_iter_check(info, "ambiguous tree iteration", ATYPE, l);
+    }
+    if (result != NULL) {
+        char *fi = format_info(l->info);
+        exn_printf_line(result, "Iterated lens: %s", fi);
+        free(fi);
+    }
+    return result;
+}
+
+static struct value *typecheck_maybe(struct info *info, struct lens *l) {
+    /* Check (r)? as (<e>|r) where <e> is the empty language */
+    struct value *exn = NULL;
+
+    if (l->ctype != NULL && regexp_matches_empty(l->ctype)) {
+        exn = make_exn_value(ref(info),
+                "illegal optional expression: /%s/ matches the empty word",
+                l->ctype->pattern->str);
+    }
+
+    /* Typecheck the put direction; the check passes if
+       (1) the atype does not match the empty string, because we can tell
+           from looking at tree nodes whether L should be applied or not
+       (2) L handles a value; with that, we know whether to apply L or not
+           depending on whether the current node has a non NULL value or not
+    */
+    if (exn == NULL && ! l->consumes_value) {
+        if (l->atype != NULL && regexp_matches_empty(l->atype)) {
+            exn = make_exn_value(ref(info),
+               "optional expression matches the empty tree but does not consume a value");
+        }
+    }
+    return exn;
+}
+
+void free_lens(struct lens *lens) {
+    if (lens == NULL)
+        return;
+    ensure(lens->ref == 0, lens->info);
+
+    if (debugging("lenses"))
+        dump_lens_tree(lens);
+    switch (lens->tag) {
+    case L_DEL:
+        unref(lens->regexp, regexp);
+        unref(lens->string, string);
+        break;
+    case L_STORE:
+    case L_KEY:
+        unref(lens->regexp, regexp);
+        break;
+    case L_LABEL:
+    case L_SEQ:
+    case L_COUNTER:
+    case L_VALUE:
+        unref(lens->string, string);
+        break;
+    case L_SUBTREE:
+    case L_STAR:
+    case L_MAYBE:
+    case L_SQUARE:
+        unref(lens->child, lens);
+        break;
+    case L_CONCAT:
+    case L_UNION:
+        for (int i=0; i < lens->nchildren; i++)
+            unref(lens->children[i], lens);
+        free(lens->children);
+        break;
+    case L_REC:
+        if (!lens->rec_internal) {
+            unref(lens->body, lens);
+            jmt_free(lens->jmt);
+        }
+        break;
+    default:
+        BUG_LENS_TAG(lens);
+        break;
+    }
+
+    for (int t=0; t < ntypes; t++)
+        unref(ltype(lens, t), regexp);
+
+    unref(lens->info, info);
+
+    free(lens);
+ error:
+    return;
+}
+
+void lens_release(struct lens *lens) {
+    if (lens == NULL)
+        return;
+
+    for (int t=0; t < ntypes; t++)
+        regexp_release(ltype(lens, t));
+
+    if (lens->tag == L_KEY || lens->tag == L_STORE)
+        regexp_release(lens->regexp);
+
+    if (lens->tag == L_SUBTREE || lens->tag == L_STAR
+        || lens->tag == L_MAYBE) {
+        lens_release(lens->child);
+    }
+
+    if (lens->tag == L_UNION || lens->tag == L_CONCAT) {
+        for (int i=0; i < lens->nchildren; i++) {
+            lens_release(lens->children[i]);
+        }
+    }
+
+    if (lens->tag == L_REC) {
+        jmt_free(lens->jmt);
+        lens->jmt = NULL;
+    }
+}
+
+/*
+ * Encoding of tree levels
+ */
+char *enc_format(const char *e, size_t len) {
+    size_t size = 0;
+    char *result = NULL, *r;
+    const char *k = e;
+
+    while (*k && k - e < len) {
+        char *eq,  *slash, *v;
+        eq = strchr(k, ENC_EQ_CH);
+        slash = strchr(eq, ENC_SLASH_CH);
+        assert(eq != NULL && slash != NULL);
+        v = eq + 1;
+
+        size += 6;     /* Surrounding braces */
+        if (k != eq)
+            size += 1 + (eq - k) + 1;
+        if (v != slash)
+            size += 4 + (slash - v) + 1;
+        k = slash + 1;
+    }
+    if (ALLOC_N(result, size + 1) < 0)
+        return NULL;
+
+    k = e;
+    r = result;
+    while (*k && k - e < len) {
+        char *eq,  *slash, *v;
+        eq = strchr(k, ENC_EQ_CH);
+        slash = strchr(eq, ENC_SLASH_CH);
+        assert(eq != NULL && slash != NULL);
+        v = eq + 1;
+
+        r = stpcpy(r, " { ");
+        if (k != eq) {
+            r = stpcpy(r, "\"");
+            r = stpncpy(r, k, eq - k);
+            r = stpcpy(r, "\"");
+        }
+        if (v != slash) {
+            r = stpcpy (r, " = \"");
+            r = stpncpy(r, v, slash - v);
+            r = stpcpy(r, "\"");
+        }
+        r = stpcpy(r, " }");
+        k = slash + 1;
+    }
+    return result;
+}
+
+static int lns_format_subtree_atype(struct lens *l, char **buf) {
+    char *k = NULL, *v = NULL;
+    const struct regexp *ktype = l->child->ktype;
+    const struct regexp *vtype = l->child->vtype;
+    int r, result = -1;
+
+    if (ktype != NULL) {
+        k = regexp_escape(ktype);
+        if (k == NULL)
+            goto done;
+    }
+    if (vtype != NULL) {
+        v = regexp_escape(vtype);
+        if (v == NULL)
+            goto done;
+        if (k == NULL)
+            r = xasprintf(buf, "{ = /%s/ }", k, v);
+        else
+            r = xasprintf(buf, "{ /%s/ = /%s/ }", k, v);
+    } else {
+        if (k == NULL)
+            r = xasprintf(buf, "{ }", k);
+        else
+            r = xasprintf(buf, "{ /%s/ }", k);
+    }
+    if (r < 0)
+        goto done;
+
+    result = 0;
+ done:
+    FREE(v);
+    FREE(k);
+    return result;
+}
+
+static int lns_format_rep_atype(struct lens *l, char **buf, char quant) {
+    char *a = NULL;
+    int r, result = -1;
+
+    r = lns_format_atype(l->child, &a);
+    if (r < 0)
+        goto done;
+    if (strlen(a) == 0) {
+        *buf = a;
+        a = NULL;
+        result = 0;
+        goto done;
+    }
+
+    if (l->child->tag == L_CONCAT || l->child->tag == L_UNION)
+        r = xasprintf(buf, "(%s)%c", a, quant);
+    else
+        r = xasprintf(buf, "%s%c", a, quant);
+
+    if (r < 0)
+        goto done;
+
+    result = 0;
+ done:
+    FREE(a);
+    return result;
+}
+
+static int lns_format_concat_atype(struct lens *l, char **buf) {
+    char **c = NULL, *s = NULL, *p;
+    int r, result = -1;
+    size_t len = 0, nconc = 0;
+
+    if (ALLOC_N(c, l->nchildren) < 0)
+        goto done;
+
+    for (int i=0; i < l->nchildren; i++) {
+        r = lns_format_atype(l->children[i], c+i);
+        if (r < 0)
+            goto done;
+        len += strlen(c[i]) + 2;
+        if (strlen(c[i]) > 0)
+            nconc += 1;
+        if (l->children[i]->tag == L_UNION)
+            len += 2;
+    }
+
+    if (ALLOC_N(s, len+1) < 0)
+        goto done;
+    p = s;
+    for (int i=0; i < l->nchildren; i++) {
+        bool needs_parens = nconc > 1 && l->children[i]->tag == L_UNION;
+        if (strlen(c[i]) == 0)
+            continue;
+        if (needs_parens)
+            *p++ = '(';
+        p = stpcpy(p, c[i]);
+        if (needs_parens)
+            *p++ = ')';
+    }
+
+    *buf = s;
+    s = NULL;
+    result = 0;
+ done:
+    if (c != NULL)
+        for (int i=0; i < l->nchildren; i++)
+            FREE(c[i]);
+    FREE(c);
+    FREE(s);
+    return result;
+}
+
+static int lns_format_union_atype(struct lens *l, char **buf) {
+    char **c = NULL, *s = NULL, *p;
+    int r, result = -1;
+    size_t len = 0;
+
+    if (ALLOC_N(c, l->nchildren) < 0)
+        goto done;
+
+    for (int i=0; i < l->nchildren; i++) {
+        r = lns_format_atype(l->children[i], c+i);
+        if (r < 0)
+            goto done;
+        len += strlen(c[i]) + 2;
+    }
+    len += l->nchildren - 1;
+
+    if (ALLOC_N(s, len+1) < 0)
+        goto done;
+
+    p = s;
+    for (int i=0; i < l->nchildren; i++) {
+        if (i > 0)
+            p = stpcpy(p, " | ");
+        if (strlen(c[i]) == 0)
+            p = stpcpy(p, "()");
+        else
+            p = stpcpy(p, c[i]);
+    }
+    *buf = s;
+    s = NULL;
+    result = 0;
+ done:
+    if (c != NULL)
+        for (int i=0; i < l->nchildren; i++)
+            FREE(c[i]);
+    FREE(c);
+    FREE(s);
+    return result;
+}
+
+static int lns_format_rec_atype(struct lens *l, char **buf) {
+    int r;
+
+    if (l->rec_internal) {
+        *buf = strdup("<<rec>>");
+        return (*buf == NULL) ? -1 : 0;
+    }
+
+    char *c = NULL;
+    r = lns_format_atype(l->body, &c);
+    if (r < 0)
+        return -1;
+    r = xasprintf(buf, "<<rec:%s>>", c);
+    free(c);
+    return (r < 0) ? -1 : 0;
+}
+
+int lns_format_atype(struct lens *l, char **buf) {
+    *buf = NULL;
+
+    switch(l->tag) {
+    case L_DEL:
+    case L_STORE:
+    case L_KEY:
+    case L_LABEL:
+    case L_VALUE:
+    case L_SEQ:
+    case L_COUNTER:
+        *buf = strdup("");
+        return (*buf == NULL) ? -1 : 0;
+        break;
+    case L_SUBTREE:
+        return lns_format_subtree_atype(l, buf);
+        break;
+    case L_STAR:
+        return lns_format_rep_atype(l, buf, '*');
+        break;
+    case L_MAYBE:
+        return lns_format_rep_atype(l, buf, '?');
+        break;
+    case L_CONCAT:
+        return lns_format_concat_atype(l, buf);
+        break;
+    case L_UNION:
+        return lns_format_union_atype(l, buf);
+        break;
+    case L_REC:
+        return lns_format_rec_atype(l, buf);
+        break;
+    case L_SQUARE:
+        return lns_format_concat_atype(l->child, buf);
+        break;
+    default:
+        BUG_LENS_TAG(l);
+        break;
+    };
+    return -1;
+}
+
+/*
+ * Recursive lenses
+ */
+struct value *lns_make_rec(struct info *info) {
+    struct lens *l = make_lens(L_REC, info);
+    l->recursive = 1;
+    l->rec_internal = 1;
+
+    return make_lens_value(l);
+}
+
+/* Transform a recursive lens into a recursive transition network
+ *
+ * First, we transform the lens into context free grammar, considering any
+ * nonrecursive lens as a terminal
+ *
+ * cfg: lens -> nonterminal -> production list
+ *
+ * cfg(primitive, N) -> N := regexp(primitive)
+ * cfg(l1 . l2, N)   -> N := N1 . N2 + cfg(l1, N1) + cfg(l2, N2)
+ * cfg(l1 | l2, N)   -> N := N1 | N2 + cfg(l1, N1) + cfg(l2, N2)
+ * cfg(l*, N)        -> N := N . N' | eps + cfg(l, N')
+ * cfg([ l ], N)     -> N := N' + cfg(l, N')
+ *
+ * We use the lenses as nonterminals themselves; this also means that our
+ * productions are normalized such that the RHS is either a terminal
+ * (regexp) or entirely consists of nonterminals
+ *
+ * In a few places, we need to know that a nonterminal corresponds to a
+ * subtree combinator ([ l ]); this is the main reason that the rule (cfg[
+ * l ], N) introduces a useless production N := N'.
+ *
+ * Computing the types for a recursive lens r is (fairly) straightforward,
+ * given the above grammar, which we convert to an automaton following
+ * http://arxiv.org/abs/cs/9910022; the only complication arises from the
+ * subtree combinator, since it can be used in recursive lenses to
+ * construct trees of arbitrary depth, but we need to approximate the types
+ * of r in a way that fits with our top-down tree automaton in put.c.
+ *
+ * To handle subtree combinators, remember that the type rules for a lens
+ * m = [ l ] are:
+ *
+ *   m.ktype = NULL
+ *   m.vtype = NULL
+ *   m.ctype = l.ctype
+ *   m.atype = enc(l.ktype, l.vtype)
+ *     ( enc is a function regexp -> regexp -> regexp)
+ *
+ * We compute types for r by modifying its automaton according to
+ * Nederhof's paper and reducing it to a regular expression of lenses. This
+ * has to happen in the following steps:
+ *   r.ktype : approximate by using [ .. ].ktype = NULL
+ *   r.vtype : same as r.ktype
+ *   r.ctype : approximate by treating [ l ] as l
+ *   r.atype : approximate by using r.ktype and r.vtype from above
+ *             in lens expressions [ f(r) ]
+ */
+
+/* Transitions go to a state and are labeled with a lens. For epsilon
+ * transitions, lens may be NULL. When lens is a simple (nonrecursive
+ * lens), PROD will be NULL. When we modify the automaton to splice
+ * nonterminals in, we remember the production for the nonterminal in PROD.
+ */
+struct trans {
+    struct state  *to;
+    struct lens   *lens;
+    struct regexp *re;
+};
+
+struct state {
+    struct state  *next;   /* Linked list for memory management */
+    size_t         ntrans;
+    struct trans  *trans;
+};
+
+/* Productions for lens LENS. Start state START and end state END. If we
+   start with START, END is the only accepting state. */
+struct prod {
+    struct lens  *lens;
+    struct state *start;
+    struct state *end;
+};
+
+/* A recursive transition network used to compute regular approximations
+ * to the types */
+struct rtn {
+    struct info *info;
+    size_t        nprod;
+    struct prod **prod;
+    struct state *states;  /* Linked list through next of all states in all
+                              prods; the states for each production are on
+                              the part of the list from prod->start to
+                              prod->end */
+    struct value *exn;
+    enum lens_type lens_type;
+    unsigned int check : 1;
+};
+
+#define RTN_BAIL(rtn) if ((rtn)->exn != NULL ||                     \
+                          (rtn)->info->error->code != AUG_NOERROR)  \
+                         goto error;
+
+static void free_prod(struct prod *prod) {
+    if (prod == NULL)
+        return;
+    unref(prod->lens, lens);
+    free(prod);
+}
+
+static void free_rtn(struct rtn *rtn) {
+    if (rtn == NULL)
+        return;
+    for (int i=0; i < rtn->nprod; i++)
+        free_prod(rtn->prod[i]);
+    free(rtn->prod);
+    list_for_each(s, rtn->states) {
+        for (int i=0; i < s->ntrans; i++) {
+            unref(s->trans[i].lens, lens);
+            unref(s->trans[i].re, regexp);
+        }
+        free(s->trans);
+    }
+    list_free(rtn->states);
+    unref(rtn->info, info);
+    unref(rtn->exn, value);
+    free(rtn);
+}
+
+static struct state *add_state(struct prod *prod) {
+    struct state *result = NULL;
+    int r;
+
+    r = ALLOC(result);
+    ERR_NOMEM(r < 0, prod->lens->info);
+
+    list_cons(prod->start->next, result);
+ error:
+    return result;
+}
+
+static struct trans *add_trans(struct rtn *rtn, struct state *state,
+                               struct state *to, struct lens *l) {
+    int r;
+    struct trans *result = NULL;
+
+    for (int i=0; i < state->ntrans; i++)
+        if (state->trans[i].to == to && state->trans[i].lens == l)
+            return state->trans + i;
+
+    r = REALLOC_N(state->trans, state->ntrans+1);
+    ERR_NOMEM(r < 0, rtn->info);
+
+    result = state->trans + state->ntrans;
+    state->ntrans += 1;
+
+    MEMZERO(result, 1);
+    result->to = to;
+    if (l != NULL) {
+        result->lens = ref(l);
+        result->re = ref(ltype(l, rtn->lens_type));
+    }
+ error:
+    return result;
+}
+
+static struct prod *make_prod(struct rtn *rtn, struct lens *l) {
+    struct prod *result = NULL;
+    int r;
+
+    r = ALLOC(result);
+    ERR_NOMEM(r < 0, l->info);
+
+    result->lens = ref(l);
+    r = ALLOC(result->start);
+    ERR_NOMEM(r < 0, l->info);
+
+    result->end = add_state(result);
+    ERR_BAIL(l->info);
+
+    result->end->next = rtn->states;
+    rtn->states = result->start;
+
+    return result;
+ error:
+    free_prod(result);
+    return NULL;
+}
+
+static struct prod *prod_for_lens(struct rtn *rtn, struct lens *l) {
+    if (l == NULL)
+        return NULL;
+    for (int i=0; i < rtn->nprod; i++) {
+        if (rtn->prod[i]->lens == l)
+            return rtn->prod[i];
+    }
+    return NULL;
+}
+
+static void rtn_dot(struct rtn *rtn, const char *stage) {
+    FILE *fp;
+    int r = 0;
+
+    fp = debug_fopen("rtn_%s_%s.dot", stage, lens_type_names[rtn->lens_type]);
+    if (fp == NULL)
+        return;
+
+    fprintf(fp, "digraph \"l1\" {\n  rankdir=LR;\n");
+    list_for_each(s, rtn->states) {
+        char *label = NULL;
+        for (int p=0; p < rtn->nprod; p++) {
+            if (s == rtn->prod[p]->start) {
+                r = xasprintf(&label, "s%d", p);
+            } else if (s == rtn->prod[p]->end) {
+                r = xasprintf(&label, "e%d", p);
+            }
+            ERR_NOMEM(r < 0, rtn->info);
+        }
+        if (label == NULL) {
+            r = xasprintf(&label, "%p", s);
+            ERR_NOMEM(r < 0, rtn->info);
+        }
+        fprintf(fp, "  n%p [label = \"%s\"];\n", s, label == NULL ? "" : label);
+        FREE(label);
+        for (int i=0; i < s->ntrans; i++) {
+            fprintf(fp, "  n%p -> n%p", s, s->trans[i].to);
+            if (s->trans[i].re != NULL) {
+                label = regexp_escape(s->trans[i].re);
+                for (char *t = label; *t; t++)
+                    if (*t == '\\')
+                        *t = '~';
+                fprintf(fp, " [ label = \"%s\" ]", label);
+                FREE(label);
+            }
+            fprintf(fp, ";\n");
+        }
+    }
+ error:
+    fprintf(fp, "}\n");
+    fclose(fp);
+}
+
+/* Add transitions to RTN corresponding to cfg(l, N) */
+static void rtn_rules(struct rtn *rtn, struct lens *l) {
+    if (! l->recursive)
+        return;
+
+    struct prod *prod = prod_for_lens(rtn, l);
+    if (prod != NULL)
+        return;
+
+    int r = REALLOC_N(rtn->prod, rtn->nprod+1);
+    ERR_NOMEM(r < 0, l->info);
+
+    prod =  make_prod(rtn, l);
+    rtn->prod[rtn->nprod] = prod;
+    RTN_BAIL(rtn);
+    rtn->nprod += 1;
+
+    struct state *start = prod->start;
+
+    switch (l->tag) {
+    case L_UNION:
+        /* cfg(l1|..|ln, N) -> N := N1 | N2 | ... | Nn */
+        for (int i=0; i < l->nchildren; i++) {
+            add_trans(rtn, start, prod->end, l->children[i]);
+            RTN_BAIL(rtn);
+            rtn_rules(rtn, l->children[i]);
+            RTN_BAIL(rtn);
+        }
+        break;
+    case L_CONCAT:
+        /* cfg(l1 . l2 ... ln, N) -> N := N1 . N2 ... Nn */
+        for (int i=0; i < l->nchildren-1; i++) {
+            struct state *s = add_state(prod);
+            RTN_BAIL(rtn);
+            add_trans(rtn, start, s, l->children[i]);
+            RTN_BAIL(rtn);
+            start = s;
+            rtn_rules(rtn, l->children[i]);
+            RTN_BAIL(rtn);
+        }
+        {
+            struct lens *c = l->children[l->nchildren - 1];
+            add_trans(rtn, start, prod->end, c);
+            RTN_BAIL(rtn);
+            rtn_rules(rtn, c);
+            RTN_BAIL(rtn);
+        }
+        break;
+    case L_STAR: {
+        /* cfg(l*, N) -> N := N . N' | eps */
+        struct state *s = add_state(prod);
+        RTN_BAIL(rtn);
+        add_trans(rtn, start, s, l);
+        RTN_BAIL(rtn);
+        add_trans(rtn, s, prod->end, l->child);
+        RTN_BAIL(rtn);
+        add_trans(rtn, start, prod->end, NULL);
+        RTN_BAIL(rtn);
+        rtn_rules(rtn, l->child);
+        RTN_BAIL(rtn);
+        break;
+    }
+    case L_SUBTREE:
+        switch (rtn->lens_type) {
+        case KTYPE:
+        case VTYPE:
+            /* cfg([ l ], N) -> N := eps */
+            add_trans(rtn, start, prod->end, NULL);
+            break;
+        case CTYPE:
+            /* cfg([ l ], N) -> N := N' plus cfg(l, N') */
+            add_trans(rtn, start, prod->end, l->child);
+            RTN_BAIL(rtn);
+            rtn_rules(rtn, l->child);
+            RTN_BAIL(rtn);
+            break;
+        case ATYPE: {
+            /* At this point, we have propagated ktype and vtype */
+            /* cfg([ l ], N) -> N := enc(l->ktype, l->vtype) */
+            struct trans *t = add_trans(rtn, start, prod->end, NULL);
+            RTN_BAIL(rtn);
+            t->re = subtree_atype(l->info, l->child->ktype, l->child->vtype);
+            break;
+        }
+        default:
+            BUG_ON(true, rtn->info, "Unexpected lens type %d", rtn->lens_type);
+            break;
+        }
+        break;
+    case L_MAYBE:
+        /* cfg(l?, N) -> N := N' | eps plus cfg(l, N') */
+        add_trans(rtn, start, prod->end, l->child);
+        RTN_BAIL(rtn);
+        add_trans(rtn, start, prod->end, NULL);
+        RTN_BAIL(rtn);
+        rtn_rules(rtn, l->child);
+        RTN_BAIL(rtn);
+        break;
+    case L_REC:
+        /* cfg(l, N) -> N := N' plus cfg(l->body, N') */
+        add_trans(rtn, start, prod->end, l->body);
+        RTN_BAIL(rtn);
+        rtn_rules(rtn, l->body);
+        RTN_BAIL(rtn);
+        break;
+    default:
+        BUG_LENS_TAG(l);
+        break;
+    }
+ error:
+    return;
+}
+
+/* Replace transition t with two epsilon transitions s => p->start and
+ * p->end => s->trans[i].to where s is the start of t. Instead of adding
+ * epsilon transitions, we expand the epsilon transitions.
+ */
+static void prod_splice(struct rtn *rtn,
+                        struct prod *from, struct prod *to, struct trans *t) {
+
+    add_trans(rtn, to->end, t->to, NULL);
+    ERR_BAIL(from->lens->info);
+    t->to = to->start;
+    unref(t->re, regexp);
+
+ error:
+    return;
+}
+
+static void rtn_splice(struct rtn *rtn, struct prod *prod) {
+    for (struct state *s = prod->start; s != prod->end; s = s->next) {
+        for (int i=0; i < s->ntrans; i++) {
+            struct prod *p = prod_for_lens(rtn, s->trans[i].lens);
+            if (p != NULL) {
+                prod_splice(rtn, prod, p, s->trans+i);
+                RTN_BAIL(rtn);
+            }
+        }
+    }
+ error:
+    return;
+}
+
+static struct rtn *rtn_build(struct lens *rec, enum lens_type lt) {
+    int r;
+    struct rtn *rtn;
+
+    r = ALLOC(rtn);
+    ERR_NOMEM(r < 0, rec->info);
+
+    rtn->info = ref(rec->info);
+    rtn->lens_type = lt;
+
+    rtn_rules(rtn, rec);
+    RTN_BAIL(rtn);
+    if (debugging("cf.approx"))
+        rtn_dot(rtn, "10-rules");
+
+    for (int i=0; i < rtn->nprod; i++) {
+        rtn_splice(rtn, rtn->prod[i]);
+        RTN_BAIL(rtn);
+    }
+    if (debugging("cf.approx"))
+        rtn_dot(rtn, "11-splice");
+
+ error:
+    return rtn;
+}
+
+/* Compare transitions lexicographically by (to, lens) */
+static int trans_to_cmp(const void *v1, const void *v2) {
+    const struct trans *t1 = v1;
+    const struct trans *t2 = v2;
+
+    if (t1->to != t2->to)
+        return (t1->to < t2->to) ? -1 : 1;
+
+    if (t1->lens == t2->lens)
+        return 0;
+    return (t1->lens < t2->lens) ? -1 : 1;
+}
+
+/* Collapse a transition S1 -> S -> S2 by adding a transition S1 -> S2 with
+ * lens R1 . (LOOP)* . R2 | R3 where R3 is the regexp on the possibly
+ * existing transition S1 -> S2. If LOOP is NULL or R3 does not exist,
+ * label the transition with a simplified regexp by treating NULL as
+ * epsilon */
+static void collapse_trans(struct rtn *rtn,
+                           struct state *s1, struct state *s2,
+                           struct regexp *r1, struct regexp *loop,
+                           struct regexp *r2) {
+
+    struct trans *t = NULL;
+    struct regexp *r = NULL;
+
+    for (int i=0; i < s1->ntrans; i++) {
+        if (s1->trans[i].to == s2) {
+            t = s1->trans + i;
+            break;
+        }
+    }
+
+    /* Set R = R1 . (LOOP)* . R2, treating NULL's as epsilon */
+    if (loop == NULL) {
+        if (r1 == NULL)
+            r = ref(r2);
+        else if (r2 == NULL)
+            r = ref(r1);
+        else
+            r = regexp_concat(rtn->info, r1, r2);
+    } else {
+        struct regexp *s = regexp_iter(rtn->info, loop, 0, -1);
+        ERR_NOMEM(s == NULL, rtn->info);
+        struct regexp *c = NULL;
+        if (r1 == NULL) {
+            c = s;
+            s = NULL;
+        } else {
+            c = regexp_concat(rtn->info, r1, s);
+            unref(s, regexp);
+            ERR_NOMEM(c == NULL, rtn->info);
+        }
+        if (r2 == NULL) {
+            r = c;
+            c = NULL;
+        } else {
+            r = regexp_concat(rtn->info, c, r2);
+            unref(c, regexp);
+            ERR_NOMEM(r == NULL, rtn->info);
+        }
+    }
+
+    if (t == NULL) {
+        t = add_trans(rtn, s1, s2, NULL);
+        ERR_NOMEM(t == NULL, rtn->info);
+        t->re = r;
+    } else if (t->re == NULL) {
+        if (r == NULL || regexp_matches_empty(r))
+            t->re = r;
+        else {
+            t->re = regexp_maybe(rtn->info, r);
+            unref(r, regexp);
+            ERR_NOMEM(t->re == NULL, rtn->info);
+        }
+    } else if (r == NULL) {
+        if (!regexp_matches_empty(t->re)) {
+            r = regexp_maybe(rtn->info, t->re);
+            unref(t->re, regexp);
+            t->re = r;
+            ERR_NOMEM(r == NULL, rtn->info);
+        }
+    } else {
+        struct regexp *u = regexp_union(rtn->info, r, t->re);
+        unref(r, regexp);
+        unref(t->re, regexp);
+        t->re = u;
+        ERR_NOMEM(u == NULL, rtn->info);
+    }
+
+    return;
+ error:
+    rtn->exn = exn_error();
+    return;
+}
+
+/* Reduce the automaton with start state rprod->start and only accepting
+ * state rprod->end so that we have a single transition rprod->start =>
+ * rprod->end labelled with the overall approximating regexp for the
+ * automaton.
+ *
+ * This is the same algorithm as fa_as_regexp in fa.c
+ */
+static struct regexp *rtn_reduce(struct rtn *rtn, struct lens *rec) {
+    struct prod *prod = prod_for_lens(rtn, rec);
+    int r;
+
+    ERR_THROW(prod == NULL, rtn->info, AUG_EINTERNAL,
+              "No production for recursive lens");
+
+    /* Eliminate epsilon transitions and turn transitions between the same
+     * two states into a regexp union */
+    list_for_each(s, rtn->states) {
+        qsort(s->trans, s->ntrans, sizeof(*s->trans), trans_to_cmp);
+        for (int i=0; i < s->ntrans; i++) {
+            int j = i+1;
+            for (;j < s->ntrans && s->trans[i].to == s->trans[j].to;
+                 j++);
+            if (j > i+1) {
+                struct regexp *u, **v;
+                r = ALLOC_N(v, j - i);
+                ERR_NOMEM(r < 0, rtn->info);
+                for (int k=i; k < j; k++)
+                    v[k-i] = s->trans[k].re;
+                u = regexp_union_n(rtn->info, j - i, v);
+                if (u == NULL) {
+                    // FIXME: The calling convention for regexp_union_n
+                    // is bad, since we can't distinguish between alloc
+                    // failure and unioning all NULL's
+                    for (int k=0; k < j-i; k++)
+                        if (v[k] != NULL) {
+                            FREE(v);
+                            ERR_NOMEM(true, rtn->info);
+                        }
+                }
+                FREE(v);
+                for (int k=i; k < j; k++) {
+                    unref(s->trans[k].lens, lens);
+                    unref(s->trans[k].re, regexp);
+                }
+                s->trans[i].re = u;
+                MEMMOVE(s->trans + (i+1),
+                        s->trans + j,
+                        s->ntrans - j);
+                s->ntrans -= j - (i + 1);
+            }
+        }
+    }
+
+    /* Introduce new start and end states with epsilon transitions to/from
+     * the old start and end states */
+    struct state *end = NULL;
+    struct state *start = NULL;
+    if (ALLOC(start) < 0 || ALLOC(end) < 0) {
+        FREE(start);
+        FREE(end);
+        ERR_NOMEM(true, rtn->info);
+    }
+    list_insert_before(start, prod->start, rtn->states);
+    end->next = prod->end->next;
+    prod->end->next = end;
+
+    add_trans(rtn, start, prod->start, NULL);
+    RTN_BAIL(rtn);
+    add_trans(rtn, prod->end, end, NULL);
+    RTN_BAIL(rtn);
+
+    prod->start = start;
+    prod->end = end;
+
+    /* Eliminate states S (except for INI and FIN) one by one:
+     *     Let LOOP the regexp for the transition S -> S if it exists, epsilon
+     *     otherwise.
+     *     For all S1, S2 different from S with S1 -> S -> S2
+     *       Let R1 the regexp of S1 -> S
+     *           R2 the regexp of S -> S2
+     *           R3 the regexp of S1 -> S2 (or the regexp matching nothing
+     *                                      if no such transition)
+     *        set the regexp on the transition S1 -> S2 to
+     *          R1 . (LOOP)* . R2 | R3 */
+    // FIXME: This does not go over all states
+    list_for_each(s, rtn->states) {
+        if (s == prod->end || s == prod->start)
+            continue;
+        struct regexp *loop = NULL;
+        for (int i=0; i < s->ntrans; i++) {
+            if (s == s->trans[i].to) {
+                ensure(loop == NULL, rtn->info);
+                loop = s->trans[i].re;
+            }
+        }
+        list_for_each(s1, rtn->states) {
+            if (s == s1)
+                continue;
+            for (int t1=0; t1 < s1->ntrans; t1++) {
+                if (s == s1->trans[t1].to) {
+                    for (int t2=0; t2 < s->ntrans; t2++) {
+                        struct state *s2 = s->trans[t2].to;
+                        if (s2 == s)
+                            continue;
+                        collapse_trans(rtn, s1, s2,
+                                       s1->trans[t1].re, loop,
+                                       s->trans[t2].re);
+                        RTN_BAIL(rtn);
+                    }
+                }
+            }
+        }
+    }
+
+    /* Find the overall regexp */
+    struct regexp *result = NULL;
+    for (int i=0; i < prod->start->ntrans; i++) {
+        if (prod->start->trans[i].to == prod->end) {
+            ensure(result == NULL, rtn->info);
+            result = ref(prod->start->trans[i].re);
+        }
+    }
+    return result;
+ error:
+    return NULL;
+}
+
+static void propagate_type(struct lens *l, enum lens_type lt) {
+    struct regexp **types = NULL;
+    int r;
+
+    if (! l->recursive || ltype(l, lt) != NULL)
+        return;
+
+    switch(l->tag) {
+    case L_CONCAT:
+        r = ALLOC_N(types, l->nchildren);
+        ERR_NOMEM(r < 0, l->info);
+        for (int i=0; i < l->nchildren; i++) {
+            propagate_type(l->children[i], lt);
+            types[i] = ltype(l->children[i], lt);
+        }
+        ltype(l, lt) = regexp_concat_n(l->info, l->nchildren, types);
+        FREE(types);
+        break;
+    case L_UNION:
+        r = ALLOC_N(types, l->nchildren);
+        ERR_NOMEM(r < 0, l->info);
+        for (int i=0; i < l->nchildren; i++) {
+            propagate_type(l->children[i], lt);
+            types[i] = ltype(l->children[i], lt);
+        }
+        ltype(l, lt) = regexp_union_n(l->info, l->nchildren, types);
+        FREE(types);
+        break;
+    case L_SUBTREE:
+        propagate_type(l->child, lt);
+        if (lt == ATYPE)
+            l->atype = subtree_atype(l->info, l->child->ktype, l->child->vtype);
+        if (lt == CTYPE)
+            l->ctype = ref(l->child->ctype);
+        break;
+    case L_STAR:
+        propagate_type(l->child, lt);
+        ltype(l, lt) = regexp_iter(l->info, ltype(l->child, lt), 0, -1);
+        break;
+    case L_MAYBE:
+        propagate_type(l->child, lt);
+        ltype(l, lt) = regexp_maybe(l->info, ltype(l->child, lt));
+        break;
+    case L_REC:
+        /* Nothing to do */
+        break;
+    case L_SQUARE:
+        propagate_type(l->child, lt);
+        ltype(l, lt) = ref(ltype(l->child, lt));
+        break;
+    default:
+        BUG_LENS_TAG(l);
+        break;
+    }
+
+ error:
+    FREE(types);
+}
+
+static struct value *typecheck(struct lens *l, int check);
+
+typedef struct value *typecheck_n_make(struct info *,
+                                       struct lens *, struct lens *, int);
+
+static struct info *merge_info(struct info *i1, struct info *i2) {
+    struct info *info;
+    make_ref(info);
+    ERR_NOMEM(info == NULL, i1);
+
+    info->filename = ref(i1->filename);
+    info->first_line = i1->first_line;
+    info->first_column = i1->first_column;
+    info->last_line    = i2->last_line;
+    info->last_column  = i2->last_column;
+    info->error        = i1->error;
+    return info;
+
+ error:
+    unref(info, info);
+    return NULL;
+}
+
+static struct value *typecheck_n(struct lens *l,
+                                 typecheck_n_make *make, int check) {
+    struct value *exn = NULL;
+    struct lens *acc = NULL;
+
+    ensure(l->tag == L_CONCAT || l->tag == L_UNION, l->info);
+    for (int i=0; i < l->nchildren; i++) {
+        exn = typecheck(l->children[i], check);
+        if (exn != NULL)
+            goto error;
+    }
+    acc = ref(l->children[0]);
+    for (int i=1; i < l->nchildren; i++) {
+        struct info *info = merge_info(acc->info, l->children[i]->info);
+        ERR_BAIL(acc->info);
+        exn = (*make)(info, acc, ref(l->children[i]), check);
+        if (EXN(exn))
+            goto error;
+        ensure(exn->tag == V_LENS, l->info);
+        acc = ref(exn->lens);
+        unref(exn, value);
+    }
+    l->value = acc->value;
+    l->key = acc->key;
+ error:
+    unref(acc, lens);
+    return exn;
+}
+
+static struct value *typecheck(struct lens *l, int check) {
+    struct value *exn = NULL;
+
+    /* Nonrecursive lenses are typechecked at build time */
+    if (! l->recursive)
+        return NULL;
+
+    switch(l->tag) {
+    case L_CONCAT:
+        exn = typecheck_n(l, lns_make_concat, check);
+        break;
+    case L_UNION:
+        exn = typecheck_n(l, lns_make_union, check);
+        break;
+    case L_SUBTREE:
+    case L_SQUARE:
+        exn = typecheck(l->child, check);
+        break;
+    case L_STAR:
+        if (check)
+            exn = typecheck_iter(l->info, l->child);
+        if (exn == NULL && l->value)
+            exn = make_exn_value(l->info, "Multiple stores in iteration");
+        if (exn == NULL && l->key)
+            exn = make_exn_value(l->info, "Multiple keys/labels in iteration");
+        break;
+    case L_MAYBE:
+        if (check)
+            exn = typecheck_maybe(l->info, l->child);
+        l->key = l->child->key;
+        l->value = l->child->value;
+        break;
+    case L_REC:
+        /* Nothing to do */
+        break;
+    default:
+        BUG_LENS_TAG(l);
+        break;
+    }
+
+    return exn;
+}
+
+static struct value *rtn_approx(struct lens *rec, enum lens_type lt) {
+    struct rtn *rtn = NULL;
+    struct value *result = NULL;
+
+    rtn = rtn_build(rec, lt);
+    RTN_BAIL(rtn);
+    ltype(rec, lt) = rtn_reduce(rtn, rec);
+    RTN_BAIL(rtn);
+    if (debugging("cf.approx"))
+        rtn_dot(rtn, "50-reduce");
+
+    propagate_type(rec->body, lt);
+    ERR_BAIL(rec->info);
+
+ done:
+    free_rtn(rtn);
+
+    if (debugging("cf.approx")) {
+        printf("approx %s  => ", lens_type_names[lt]);
+        print_regexp(stdout, ltype(rec, lt));
+        printf("\n");
+    }
+
+    return result;
+ error:
+    if (rtn->exn == NULL)
+        result = exn_error();
+    else
+        result = ref(rtn->exn);
+    goto done;
+}
+
+static struct value *
+exn_multiple_epsilons(struct lens *lens,
+                      struct lens *l1, struct lens *l2) {
+    char *fi = NULL;
+    struct value *exn = NULL;
+
+    exn = make_exn_value(ref(lens->info),
+                         "more than one nullable branch in a union");
+    fi = format_info(l1->info);
+    exn_printf_line(exn, "First nullable lens: %s", fi);
+    FREE(fi);
+
+    fi = format_info(l2->info);
+    exn_printf_line(exn, "Second nullable lens: %s", fi);
+    FREE(fi);
+
+    return exn;
+}
+
+/* Update lens->ctype_nullable and return 1 if there was a change,
+ * 0 if there was none */
+static int ctype_nullable(struct lens *lens, struct value **exn) {
+    int nullable = 0;
+    int ret = 0;
+    struct lens *null_lens = NULL;
+
+    if (! lens->recursive)
+        return 0;
+
+    switch(lens->tag) {
+    case L_CONCAT:
+        nullable = 1;
+        for (int i=0; i < lens->nchildren; i++) {
+            if (ctype_nullable(lens->children[i], exn))
+                ret = 1;
+            if (! lens->children[i]->ctype_nullable)
+                nullable = 0;
+        }
+        break;
+    case L_UNION:
+        for (int i=0; i < lens->nchildren; i++) {
+            if (ctype_nullable(lens->children[i], exn))
+                ret = 1;
+            if (lens->children[i]->ctype_nullable) {
+                if (nullable) {
+                    *exn = exn_multiple_epsilons(lens, null_lens,
+                                                 lens->children[i]);
+                    return 0;
+                }
+                nullable = 1;
+                null_lens = lens->children[i];
+            }
+        }
+        break;
+    case L_SUBTREE:
+    case L_SQUARE:
+        ret = ctype_nullable(lens->child, exn);
+        nullable = lens->child->ctype_nullable;
+        break;
+    case L_STAR:
+    case L_MAYBE:
+        nullable = 1;
+        break;
+    case L_REC:
+        nullable = lens->body->ctype_nullable;
+        break;
+    default:
+        BUG_LENS_TAG(lens);
+        break;
+    }
+    if (*exn != NULL)
+        return 0;
+    if (nullable != lens->ctype_nullable) {
+        ret = 1;
+        lens->ctype_nullable = nullable;
+    }
+    return ret;
+}
+
+struct value *lns_check_rec(struct info *info,
+                            struct lens *body, struct lens *rec,
+                            int check) {
+    /* The types in the order of approximation */
+    static const enum lens_type types[] = { KTYPE, VTYPE, ATYPE };
+    struct value *result = NULL;
+
+    ensure(rec->tag == L_REC, info);
+    ensure(rec->rec_internal, info);
+
+    /* The user might have written down a regular lens with 'let rec' */
+    if (! body->recursive) {
+        result = make_lens_value(ref(body));
+        ERR_NOMEM(result == NULL, info);
+        return result;
+    }
+
+    /* To help memory management, we avoid the cycle inherent ina recursive
+     * lens by using two instances of an L_REC lens. One is marked with
+     * rec_internal, and used inside the body of the lens. The other is the
+     * "toplevel" which receives external references.
+     *
+     * The internal instance of the recursive lens is REC, the external one
+     * is TOP, constructed below
+     */
+    rec->body = body;                          /* REC does not own BODY */
+
+    for (int i=0; i < ARRAY_CARDINALITY(types); i++) {
+        result = rtn_approx(rec, types[i]);
+        ERR_BAIL(info);
+    }
+
+    if (rec->atype == NULL) {
+        result = make_exn_value(ref(rec->info),
+        "recursive lens generates the empty language for its %s",
+         rec->ctype == NULL ? "ctype" : "atype");
+        goto error;
+    }
+
+    rec->key = rec->body->key;
+    rec->value = rec->body->value;
+    rec->consumes_value = rec->body->consumes_value;
+
+    while(ctype_nullable(rec->body, &result));
+    if (result != NULL)
+        goto error;
+    rec->ctype_nullable = rec->body->ctype_nullable;
+
+    result = typecheck(rec->body, check);
+    if (result != NULL)
+        goto error;
+
+    result = lns_make_rec(ref(rec->info));
+    struct lens *top = result->lens;
+    for (int t=0; t < ntypes; t++)
+        ltype(top, t) = ref(ltype(rec, t));
+    top->value = rec->value;
+    top->key = rec->key;
+    top->consumes_value = rec->consumes_value;
+    top->ctype_nullable = rec->ctype_nullable;
+    top->body = ref(body);
+    top->alias = rec;
+    top->rec_internal = 0;
+    rec->alias = top;
+
+    top->jmt = jmt_build(top);
+    ERR_BAIL(info);
+
+    return result;
+ error:
+    if (result != NULL && result->tag != V_EXN)
+        unref(result, value);
+    if (result == NULL)
+        result = exn_error();
+    return result;
+}
+
+#if ENABLE_DEBUG
+void dump_lens_tree(struct lens *lens){
+    static int count = 0;
+    FILE *fp;
+
+    fp = debug_fopen("lens_%02d_%s.dot", count++, ltag(lens));
+    if (fp == NULL)
+        return;
+
+    fprintf(fp, "digraph \"%s\" {\n", "lens");
+    dump_lens(fp, lens);
+    fprintf(fp, "}\n");
+
+    fclose(fp);
+}
+
+void dump_lens(FILE *out, struct lens *lens){
+    int i = 0;
+    struct regexp *re;
+
+    fprintf(out, "\"%p\" [ shape = box, label = \"%s\\n", lens, ltag(lens));
+
+    for (int t=0; t < ntypes; t++) {
+        re = ltype(lens, t);
+        if (re == NULL)
+            continue;
+        fprintf(out, "%s=",lens_type_names[t]);
+        print_regexp(out, re);
+        fprintf(out, "\\n");
+    }
+
+    fprintf(out, "recursive=%x\\n", lens->recursive);
+    fprintf(out, "rec_internal=%x\\n", lens->rec_internal);
+    fprintf(out, "consumes_value=%x\\n", lens->consumes_value);
+    fprintf(out, "ctype_nullable=%x\\n", lens->ctype_nullable);
+    fprintf(out, "\"];\n");
+    switch(lens->tag){
+    case L_DEL:
+        break;
+    case L_STORE:
+        break;
+    case L_VALUE:
+        break;
+    case L_KEY:
+        break;
+    case L_LABEL:
+        break;
+    case L_SEQ:
+        break;
+    case L_COUNTER:
+        break;
+    case L_CONCAT:
+        for(i = 0; i<lens->nchildren;i++){
+            fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->children[i]);
+            dump_lens(out, lens->children[i]);
+        }
+        break;
+    case L_UNION:
+        for(i = 0; i<lens->nchildren;i++){
+            fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->children[i]);
+            dump_lens(out, lens->children[i]);
+        }
+        break;
+    case L_SUBTREE:
+        fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->child);
+        dump_lens(out, lens->child);
+        break;
+    case L_STAR:
+        fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->child);
+        dump_lens(out, lens->child);
+
+        break;
+    case L_MAYBE:
+        fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->child);
+        dump_lens(out, lens->child);
+
+        break;
+    case L_REC:
+        if (lens->rec_internal == 0){
+            fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->child);
+            dump_lens(out, lens->body);
+        }
+        break;
+    case L_SQUARE:
+        fprintf(out, "\"%p\" -> \"%p\"\n", lens, lens->child);
+        dump_lens(out, lens->child);
+        break;
+    default:
+        fprintf(out, "ERROR\n");
+        break;
+    }
+}
+#endif
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/lens.h b/src/lens.h
new file mode 100644 (file)
index 0000000..420b26f
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * lens.h: Repreentation of lenses
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef LENS_H_
+#define LENS_H_
+
+#include "syntax.h"
+#include "fa.h"
+#include "jmt.h"
+
+/* keep in sync with tag name table */
+enum lens_tag {
+    L_DEL = 42,    /* Shift tag values so we fail fast(er) on bad pointers */
+    L_STORE,
+    L_VALUE,
+    L_KEY,
+    L_LABEL,
+    L_SEQ,
+    L_COUNTER,
+    L_CONCAT,
+    L_UNION,
+    L_SUBTREE,
+    L_STAR,
+    L_MAYBE,
+    L_REC,
+    L_SQUARE
+};
+
+/* A lens. The way the type information is computed is a little
+ * delicate. There are various regexps involved to form the final type:
+ *
+ * CTYPE - the concrete type, used to parse file -> tree
+ * ATYPE - the abstract type, used to parse tree -> file
+ * KTYPE - the 'key' type, matching the label that this lens
+ *         can produce, or NULL if no label is produced
+ * VTYPE - the 'value' type, matching the value that this lens
+ *         can produce, or NULL if no value is produce
+ *
+ * We distinguish between regular and recursive (context-free) lenses. Only
+ * L_REC and the combinators can be marked recursive.
+ *
+ * Types are computed at different times, depending on whether the lens is
+ * recursive or not. For non-recursive lenses, types are computed when the
+ * lens is constructed by one of the LNS_MAKE_* functions; for recursive
+ * lenses, we never compute an explicit ctype (since regular approximations
+ * of it are pretty much useless), we do however compute regular
+ * approximations of the ktype, vtype, and atype in LNS_CHECK_REC. That
+ * means that recursive lenses accept context free languages in the string
+ * -> tree direction, but only regular tree languages in the tree -> string
+ * direction.
+ *
+ * Any lens that uses a recursive lens somehow is marked as recursive
+ * itself.
+ */
+struct lens {
+    unsigned int              ref;
+    enum lens_tag             tag;
+    struct info              *info;
+    struct regexp            *ctype;  /* NULL when recursive == 1 */
+    struct regexp            *atype;
+    struct regexp            *ktype;
+    struct regexp            *vtype;
+    unsigned int              value : 1;
+    unsigned int              key : 1;
+    unsigned int              recursive : 1;
+    unsigned int              consumes_value : 1;
+    /* Whether we are inside a recursive lens or outside */
+    unsigned int              rec_internal : 1;
+    unsigned int              ctype_nullable : 1;
+    union {
+        /* Primitive lenses */
+        struct {                   /* L_DEL uses both */
+            /* L_DEL string set to NULL means it belongs to parent L_SQUARE lens
+             * and the put and create copy the current key
+             */
+            struct regexp *regexp; /* L_STORE, L_KEY */
+            struct string *string; /* L_VALUE, L_LABEL, L_SEQ, L_COUNTER */
+        };
+        /* Combinators */
+        struct lens *child;         /* L_SUBTREE, L_STAR, L_MAYBE, L_SQUARE */
+        struct {                    /* L_UNION, L_CONCAT */
+            unsigned int nchildren;
+            struct lens **children;
+        };
+        struct {
+            struct lens *body;      /* L_REC */
+            /* We represent a recursive lens as two instances of struct
+             * lens with L_REC. One has rec_internal set to 1, the other
+             * has it set to 0. The one with rec_internal is used within
+             * the body, the other is what is used from the 'outside'. This
+             * is necessary to break the cycles inherent in recursive
+             * lenses with reference counting. The link through alias is
+             * set up in lns_check_rec, and not reference counted.
+             *
+             * Generally, any lens used in the body of a recursive lens is
+             * marked with rec_internal == 1; lenses that use the recursive
+             * lens 'from the outside' are marked with rec_internal ==
+             * 0. In the latter case, we can assign types right away,
+             * except for the ctype, which we never have for any recursive
+             * lens.
+             */
+            struct lens *alias;
+            struct jmt  *jmt;
+        };
+    };
+};
+
+/* Constructors for various lens types. Constructor assumes ownership of
+ * arguments without incrementing. Caller owns returned lenses.
+ *
+ * The return type is VALUE instead of LENS so that we can return an
+ * exception iftypechecking fails.
+ */
+struct value *lns_make_prim(enum lens_tag tag, struct info *info,
+                            struct regexp *regexp, struct string *string);
+struct value *lns_make_union(struct info *, struct lens *, struct lens *,
+                             int check);
+struct value *lns_make_concat(struct info *, struct lens *, struct lens *,
+                              int check);
+struct value *lns_make_subtree(struct info *, struct lens *);
+struct value *lns_make_star(struct info *, struct lens *,
+                            int check);
+struct value *lns_make_plus(struct info *, struct lens *,
+                            int check);
+struct value *lns_make_maybe(struct info *, struct lens *,
+                             int check);
+struct value *lns_make_square(struct info *, struct regexp *, struct lens *,
+                              int check);
+
+/* Pretty-print a lens */
+char *format_lens(struct lens *l);
+
+/* Pretty-print the atype of a lens. Allocates BUF, which must be freed by
+ * the caller */
+int lns_format_atype(struct lens *, char **buf);
+
+/* Recursive lenses */
+struct value *lns_make_rec(struct info *info);
+struct value *lns_check_rec(struct info *info,
+                            struct lens *body, struct lens *rec,
+                            int check);
+
+/* Auxiliary data structures used during get/put/create */
+struct skel {
+    struct skel *next;
+    enum lens_tag tag;
+    union {
+        char        *text;    /* L_DEL */
+        struct skel *skels;   /* L_CONCAT, L_STAR */
+    };
+    /* Also tag == L_SUBTREE, with no data in the union */
+};
+
+struct lns_error {
+    struct lens  *lens;
+    int           pos;        /* Errors from get/parse */
+    char         *path;       /* Errors from put, pos will be -1 */
+    char         *message;
+};
+
+struct dict *make_dict(char *key, struct skel *skel, struct dict *subdict);
+void dict_lookup(const char *key, struct dict *dict,
+                 struct skel **skel, struct dict **subdict);
+int dict_append(struct dict **dict, struct dict *d2);
+void free_skel(struct skel *skel);
+void free_dict(struct dict *dict);
+void free_lns_error(struct lns_error *err);
+
+/* Parse text TEXT with LENS. INFO indicats where TEXT was read from.
+ *
+ * If ERR is non-NULL, *ERR is set to NULL on success, and to an error
+ * message on failure; the constructed tree is always returned. If ERR is
+ * NULL, return the tree on success, and NULL on failure.
+ *
+ * FLAGS controls what is printed and should be a set of flags from enum
+ * parse_flags
+ */
+struct tree *lns_get(struct info *info, struct lens *lens, const char *text,
+                     struct lns_error **err);
+struct skel *lns_parse(struct lens *lens, const char *text,
+                       struct dict **dict, struct lns_error **err);
+void lns_put(FILE *out, struct lens *lens, struct tree *tree,
+             const char *text, struct lns_error **err);
+
+/* Free up temporary data structures, most importantly compiled
+   regular expressions */
+void lens_release(struct lens *lens);
+void free_lens(struct lens *lens);
+
+/*
+ * Encoding of tree levels into strings
+ */
+
+/* Special characters used when encoding one level of the tree as a string.
+ * We encode one tree node as KEY . ENC_EQ . VALUE . ENC_SLASH; if KEY or
+ * VALUE are NULL, we use ENC_NULL, which is the empty string. This has the
+ * effect that NULL strings are treated the same as empty strings.
+ *
+ * This encoding is used both for actual trees in the put direction, and to
+ * produce regular expressions describing one level in the tree (we
+ * disregard subtrees)
+ *
+ * For this to work, neither ENC_EQ nor ENC_SLASH can be allowed in a
+ * VALUE; we do this behind the scenes by rewriting regular expressions for
+ * values.
+ */
+#define ENC_EQ        "\003"
+#define ENC_SLASH     "\004"
+#define ENC_NULL      ""
+#define ENC_EQ_CH     (ENC_EQ[0])
+#define ENC_SLASH_CH  (ENC_SLASH[0])
+
+/* The reserved range of characters that we do not allow in user-supplied
+   regular expressions, since we need them for internal bookkeeping.
+
+   This range must include the ENC_* characters
+*/
+#define RESERVED_FROM '\001'
+#define RESERVED_TO   ENC_SLASH_CH
+
+/* The length of the string S encoded */
+#define ENCLEN(s) ((s) == NULL ? strlen(ENC_NULL) : strlen(s))
+#define ENCSTR(s) ((s) == NULL ? ENC_NULL : s)
+
+/* Format an encoded level as
+ *    { key1 = value1 } { key2 = value2 } .. { keyN = valueN }
+ */
+char *enc_format(const char *e, size_t len);
+
+#if ENABLE_DEBUG
+void dump_lens_tree(struct lens *lens);
+void dump_lens(FILE *out, struct lens *lens);
+#endif
+
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/lexer.c b/src/lexer.c
new file mode 100644 (file)
index 0000000..e9808e3
--- /dev/null
@@ -0,0 +1,2362 @@
+#line 2 "lexer.c"
+#line 9 "lexer.l"
+/* config.h must precede flex's inclusion of <stdio.h>
+   in order for its _GNU_SOURCE definition to take effect.  */
+#include <config.h>
+
+
+
+#line 10 "lexer.c"
+
+#define  YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with  platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types. 
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t; 
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN               (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN              (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN              (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX               (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX              (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX              (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX              (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX             (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX             (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else  /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+   are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yyg->yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yyg->yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE augl_restart(yyin ,yyscanner )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+     *       access to the local variable yy_act. Since yyless() is a macro, it would break
+     *       existing scanners that call yyless() from OUTSIDE augl_lex. 
+     *       One obvious solution it to make yy_act a global. I tried that, and saw
+     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
+     *       normally declared as a register variable-- so it is not worth it.
+     */
+    #define  YY_LESS_LINENO(n) \
+            do { \
+                int yyl;\
+                for ( yyl = n; yyl < yyleng; ++yyl )\
+                    if ( yytext[yyl] == '\n' )\
+                        --yylineno;\
+            }while(0)
+    
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+               *yy_cp = yyg->yy_hold_char; \
+               YY_RESTORE_YY_MORE_OFFSET \
+               yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+               YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+               } \
+       while ( 0 )
+
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+       {
+       FILE *yy_input_file;
+
+       char *yy_ch_buf;                /* input buffer */
+       char *yy_buf_pos;               /* current position in input buffer */
+
+       /* Size of input buffer in bytes, not including room for EOB
+        * characters.
+        */
+       yy_size_t yy_buf_size;
+
+       /* Number of characters read into yy_ch_buf, not including EOB
+        * characters.
+        */
+       int yy_n_chars;
+
+       /* Whether we "own" the buffer - i.e., we know we created it,
+        * and can realloc() it to grow it, and should free() it to
+        * delete it.
+        */
+       int yy_is_our_buffer;
+
+       /* Whether this is an "interactive" input source; if so, and
+        * if we're using stdio for input, then we want to use getc()
+        * instead of fread(), to make sure we stop fetching input after
+        * each newline.
+        */
+       int yy_is_interactive;
+
+       /* Whether we're considered to be at the beginning of a line.
+        * If so, '^' rules will be active on the next match, otherwise
+        * not.
+        */
+       int yy_at_bol;
+
+    int yy_bs_lineno; /**< The line count. */
+    int yy_bs_column; /**< The column count. */
+    
+       /* Whether to try to fill the input buffer when we reach the
+        * end of it.
+        */
+       int yy_fill_buffer;
+
+       int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+       /* When an EOF's been seen but there's still some text to process
+        * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+        * shouldn't try reading from the input source any more.  We might
+        * still have a bunch of tokens to match, though, because of
+        * possible backing-up.
+        *
+        * When we actually see the EOF, we change the status to "new"
+        * (via augl_restart()), so that the user can continue scanning by
+        * just pointing yyin at a new input file.
+        */
+#define YY_BUFFER_EOF_PENDING 2
+
+       };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
+                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
+                          : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
+
+void augl_restart (FILE *input_file ,yyscan_t yyscanner );
+void augl__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE augl__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void augl__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void augl__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void augl_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void augl_pop_buffer_state (yyscan_t yyscanner );
+
+static void augl_ensure_buffer_stack (yyscan_t yyscanner );
+static void augl__load_buffer_state (yyscan_t yyscanner );
+static void augl__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+
+#define YY_FLUSH_BUFFER augl__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+
+YY_BUFFER_STATE augl__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE augl__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE augl__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+
+void *augl_alloc (yy_size_t ,yyscan_t yyscanner );
+void *augl_realloc (void *,yy_size_t ,yyscan_t yyscanner );
+void augl_free (void * ,yyscan_t yyscanner );
+
+#define yy_new_buffer augl__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+       { \
+       if ( ! YY_CURRENT_BUFFER ){ \
+        augl_ensure_buffer_stack (yyscanner); \
+               YY_CURRENT_BUFFER_LVALUE =    \
+            augl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+       } \
+       YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+       }
+
+#define yy_set_bol(at_bol) \
+       { \
+       if ( ! YY_CURRENT_BUFFER ){\
+        augl_ensure_buffer_stack (yyscanner); \
+               YY_CURRENT_BUFFER_LVALUE =    \
+            augl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+       } \
+       YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+       }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define augl_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+typedef int yy_state_type;
+
+#define yytext_ptr yytext_r
+
+static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
+static int yy_get_next_buffer (yyscan_t yyscanner );
+static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+       yyg->yytext_ptr = yy_bp; \
+       yyleng = (size_t) (yy_cp - yy_bp); \
+       yyg->yy_hold_char = *yy_cp; \
+       *yy_cp = '\0'; \
+       yyg->yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 29
+#define YY_END_OF_BUFFER 30
+/* This struct is not used in this scanner,
+   but its presence is necessary. */
+struct yy_trans_info
+       {
+       flex_int32_t yy_verify;
+       flex_int32_t yy_nxt;
+       };
+static yyconst flex_int16_t yy_accept[98] =
+    {   0,
+        1,    1,    1,    1,   30,   25,    1,    2,   25,   25,
+        7,    7,    7,   25,   23,   22,   22,   22,   22,   22,
+       22,   22,   22,   22,   22,   28,    1,   28,   28,   28,
+        1,    2,    3,    0,    4,    0,   24,   20,    0,    6,
+        0,    0,   23,   22,   22,   22,   22,   14,   22,   22,
+       22,   22,   22,   22,   26,   27,    0,    4,    5,    6,
+       21,   22,   22,   17,   22,   10,   22,   18,   22,   22,
+       22,    5,   21,   22,   22,   13,    0,   22,   22,   22,
+       16,   19,   22,    0,   22,   22,   22,   22,    0,    8,
+       12,   11,   22,    0,   15,    9,    0
+
+    } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    5,    1,    1,    1,    1,    1,    6,
+        7,    8,    9,    1,   10,   11,   12,   13,   13,   13,
+       13,   13,   13,   13,   13,   13,   13,    9,    9,    1,
+        9,   14,    9,    1,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+       15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
+        9,   16,    9,    1,   17,    1,   18,   17,   19,   20,
+
+       21,   22,   23,   17,   24,   17,   17,   25,   26,   27,
+       28,   29,   17,   30,   31,   32,   33,   17,   17,   34,
+       17,   17,    9,    9,    9,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst flex_int32_t yy_meta[35] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        2,    1,    3,    1,    3,    1,    4,    4,    4,    4,
+        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
+        4,    4,    4,    4
+    } ;
+
+static yyconst flex_int16_t yy_base[105] =
+    {   0,
+        0,    0,   33,   40,  145,  146,  142,  140,  139,   33,
+      133,  146,  126,   35,  128,    0,   23,  117,  110,  115,
+      107,  101,  112,  100,  110,  146,  128,  126,  120,  120,
+      124,  122,  120,   45,  146,   47,  146,  146,   41,   99,
+       42,    0,  111,    0,   89,   88,   87,    0,   28,   98,
+       85,   93,   85,   83,  146,  146,  110,   54,  146,   50,
+        0,   71,   63,    0,   59,   87,   55,    0,   66,   62,
+       53,   52,    0,   54,   58,    0,   63,   57,   47,   53,
+        0,    0,   51,   57,   56,   47,   52,   55,   50,    0,
+        0,    0,   47,   69,    0,  146,  146,   93,   97,  101,
+
+      104,  106,   36,  108
+    } ;
+
+static yyconst flex_int16_t yy_def[105] =
+    {   0,
+       97,    1,   98,   98,   97,   97,   97,   97,   97,   99,
+       97,   97,   97,  100,  101,  102,  102,  102,  102,  102,
+      102,  102,  102,  102,  102,   97,   97,   97,   97,   97,
+       97,   97,   97,   99,   97,   99,   97,   97,  100,   97,
+      100,  103,  101,  102,  102,  102,  102,  102,  102,  102,
+      102,  102,  102,  102,   97,   97,   97,   99,   97,  100,
+      104,  102,  102,  102,  102,  102,  102,  102,  102,  102,
+      102,  100,  104,  102,  102,  102,   97,  102,  102,  102,
+      102,  102,  102,   97,  102,  102,  102,  102,   97,  102,
+      102,  102,  102,   97,  102,   97,    0,   97,   97,   97,
+
+       97,   97,   97,   97
+    } ;
+
+static yyconst flex_int16_t yy_nxt[181] =
+    {   0,
+        6,    7,    8,    9,   10,   11,   12,   12,   12,   13,
+       12,   14,    6,    6,   15,    6,   16,   17,   16,   16,
+       16,   16,   18,   19,   20,   21,   16,   16,   22,   23,
+       24,   25,   16,   16,   27,    8,   28,   35,   29,   61,
+       30,   27,    8,   28,   45,   29,   40,   30,   36,   35,
+       41,   58,   40,   60,   65,   46,   41,   41,   35,   66,
+       36,   40,   36,   40,   77,   41,   95,   41,   94,   36,
+       96,   96,   93,   72,   92,   91,   90,   89,   88,   87,
+       86,   85,   83,   82,   81,   80,   79,   78,   77,   76,
+       75,   74,   84,   26,   26,   26,   26,   34,   34,   34,
+
+       34,   39,   39,   39,   39,   43,   43,   43,   44,   44,
+       73,   73,   33,   71,   70,   69,   68,   67,   64,   63,
+       62,   42,   59,   57,   32,   31,   56,   55,   33,   31,
+       54,   53,   52,   51,   50,   49,   48,   47,   42,   38,
+       37,   33,   32,   31,   97,    5,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97
+    } ;
+
+static yyconst flex_int16_t yy_chk[181] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        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,    3,    3,   10,    3,  103,
+        3,    4,    4,    4,   17,    4,   14,    4,   10,   34,
+       14,   36,   39,   41,   49,   17,   39,   41,   58,   49,
+       34,   60,   36,   72,   77,   60,   93,   72,   89,   58,
+       94,   94,   88,   60,   87,   86,   85,   84,   83,   80,
+       79,   78,   75,   74,   71,   70,   69,   67,   66,   65,
+       63,   62,   77,   98,   98,   98,   98,   99,   99,   99,
+
+       99,  100,  100,  100,  100,  101,  101,  101,  102,  102,
+      104,  104,   57,   54,   53,   52,   51,   50,   47,   46,
+       45,   43,   40,   33,   32,   31,   30,   29,   28,   27,
+       25,   24,   23,   22,   21,   20,   19,   18,   15,   13,
+       11,    9,    8,    7,    5,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97,
+       97,   97,   97,   97,   97,   97,   97,   97,   97,   97
+    } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[30] =
+    {   0,
+0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     };
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+#line 1 "lexer.l"
+/* Scanner for config specs   -*- C -*- */
+
+#line 15 "lexer.l"
+#include "syntax.h"
+#include "errcode.h"
+
+typedef struct info YYLTYPE;
+#define YYLTYPE_IS_DECLARED 1
+
+#include "parser.h"
+
+/* Advance of NUM lines. */
+# define LOCATION_LINES(Loc, Num)             \
+  (Loc).last_column = 0;                      \
+  (Loc).last_line += Num;
+
+/* Restart: move the first cursor to the last position. */
+# define LOCATION_STEP(Loc)                   \
+  (Loc).first_column = (Loc).last_column;     \
+  (Loc).first_line = (Loc).last_line;
+
+/* The lack of reference counting for filename is intentional */
+#define YY_USER_ACTION                                            \
+  do {                                                            \
+     yylloc->last_column += yyleng;                               \
+     yylloc->filename = augl_get_info(yyscanner)->filename;       \
+     yylloc->error = augl_get_info(yyscanner)->error;             \
+   } while(0);
+
+#define YY_USER_INIT LOCATION_STEP(*yylloc)
+
+#define YY_EXTRA_TYPE struct state *
+
+int augl_init_lexer(struct state *state, yyscan_t * scanner);
+void augl_close_lexer(yyscan_t *scanner);
+struct info *augl_get_info(yyscan_t yyscanner);
+
+static void loc_update(YYLTYPE *yylloc, const char *s, int len) {
+  for (int i=0; i < len; i++) {
+    if (s[i] == '\n') {
+      LOCATION_LINES(*yylloc, 1);
+    }
+  }
+}
+
+static char *regexp_literal(const char *s, int len) {
+  char *u = unescape(s, len);
+  size_t u_len = strlen(u);
+
+  if (u == NULL)
+    return NULL;
+
+  regexp_c_locale(&u, &u_len);
+
+  return u;
+}
+
+#line 585 "lexer.c"
+
+#define INITIAL 0
+#define COMMENT 1
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* Holds the entire state of the reentrant scanner. */
+struct yyguts_t
+    {
+
+    /* User-defined. Not touched by flex. */
+    YY_EXTRA_TYPE yyextra_r;
+
+    /* The rest are the same as the globals declared in the non-reentrant scanner. */
+    FILE *yyin_r, *yyout_r;
+    size_t yy_buffer_stack_top; /**< index of top of stack. */
+    size_t yy_buffer_stack_max; /**< capacity of stack. */
+    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+    char yy_hold_char;
+    int yy_n_chars;
+    int yyleng_r;
+    char *yy_c_buf_p;
+    int yy_init;
+    int yy_start;
+    int yy_did_buffer_switch_on_eof;
+    int yy_start_stack_ptr;
+    int yy_start_stack_depth;
+    int *yy_start_stack;
+    yy_state_type yy_last_accepting_state;
+    char* yy_last_accepting_cpos;
+
+    int yylineno_r;
+    int yy_flex_debug_r;
+
+    char *yytext_r;
+    int yy_more_flag;
+    int yy_more_len;
+
+    YYSTYPE * yylval_r;
+
+    YYLTYPE * yylloc_r;
+
+    }; /* end struct yyguts_t */
+
+static int yy_init_globals (yyscan_t yyscanner );
+
+    /* This must go here because YYSTYPE and YYLTYPE are included
+     * from bison output in section 1.*/
+    #    define yylval yyg->yylval_r
+    
+    #    define yylloc yyg->yylloc_r
+    
+int augl_lex_init (yyscan_t* scanner);
+
+int augl_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
+/* Accessor methods to globals.
+   These are made visible to non-reentrant scanners for convenience. */
+
+int augl_lex_destroy (yyscan_t yyscanner );
+
+int augl_get_debug (yyscan_t yyscanner );
+
+void augl_set_debug (int debug_flag ,yyscan_t yyscanner );
+
+YY_EXTRA_TYPE augl_get_extra (yyscan_t yyscanner );
+
+void augl_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+
+FILE *augl_get_in (yyscan_t yyscanner );
+
+void augl_set_in  (FILE * in_str ,yyscan_t yyscanner );
+
+FILE *augl_get_out (yyscan_t yyscanner );
+
+void augl_set_out  (FILE * out_str ,yyscan_t yyscanner );
+
+int augl_get_leng (yyscan_t yyscanner );
+
+char *augl_get_text (yyscan_t yyscanner );
+
+int augl_get_lineno (yyscan_t yyscanner );
+
+void augl_set_lineno (int line_number ,yyscan_t yyscanner );
+
+int augl_get_column  (yyscan_t yyscanner );
+
+void augl_set_column (int column_no ,yyscan_t yyscanner );
+
+YYSTYPE * augl_get_lval (yyscan_t yyscanner );
+
+void augl_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+
+       YYLTYPE *augl_get_lloc (yyscan_t yyscanner );
+    
+        void augl_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
+    
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int augl_wrap (yyscan_t yyscanner );
+#else
+extern int augl_wrap (yyscan_t yyscanner );
+#endif
+#endif
+
+    static void yyunput (int c,char *buf_ptr  ,yyscan_t yyscanner);
+    
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (yyscan_t yyscanner );
+#else
+static int input (yyscan_t yyscanner );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+               { \
+               int c = '*'; \
+               unsigned n; \
+               for ( n = 0; n < max_size && \
+                            (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+                       buf[n] = (char) c; \
+               if ( c == '\n' ) \
+                       buf[n++] = (char) c; \
+               if ( c == EOF && ferror( yyin ) ) \
+                       YY_FATAL_ERROR( "input in flex scanner failed" ); \
+               result = n; \
+               } \
+       else \
+               { \
+               errno=0; \
+               while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+                       { \
+                       if( errno != EINTR) \
+                               { \
+                               YY_FATAL_ERROR( "input in flex scanner failed" ); \
+                               break; \
+                               } \
+                       errno=0; \
+                       clearerr(yyin); \
+                       } \
+               }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int augl_lex \
+               (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
+
+#define YY_DECL int augl_lex \
+               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+       YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+       register yy_state_type yy_current_state;
+       register char *yy_cp, *yy_bp;
+       register int yy_act;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+#line 80 "lexer.l"
+
+#line 833 "lexer.c"
+
+    yylval = yylval_param;
+
+    yylloc = yylloc_param;
+
+       if ( !yyg->yy_init )
+               {
+               yyg->yy_init = 1;
+
+#ifdef YY_USER_INIT
+               YY_USER_INIT;
+#endif
+
+               if ( ! yyg->yy_start )
+                       yyg->yy_start = 1;      /* first start state */
+
+               if ( ! yyin )
+                       yyin = stdin;
+
+               if ( ! yyout )
+                       yyout = stdout;
+
+               if ( ! YY_CURRENT_BUFFER ) {
+                       augl_ensure_buffer_stack (yyscanner);
+                       YY_CURRENT_BUFFER_LVALUE =
+                               augl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+               }
+
+               augl__load_buffer_state(yyscanner );
+               }
+
+       while ( 1 )             /* loops until end-of-file is reached */
+               {
+               yy_cp = yyg->yy_c_buf_p;
+
+               /* Support of yytext. */
+               *yy_cp = yyg->yy_hold_char;
+
+               /* yy_bp points to the position in yy_ch_buf of the start of
+                * the current run.
+                */
+               yy_bp = yy_cp;
+
+               yy_current_state = yyg->yy_start;
+yy_match:
+               do
+                       {
+                       register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+                       if ( yy_accept[yy_current_state] )
+                               {
+                               yyg->yy_last_accepting_state = yy_current_state;
+                               yyg->yy_last_accepting_cpos = yy_cp;
+                               }
+                       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                               {
+                               yy_current_state = (int) yy_def[yy_current_state];
+                               if ( yy_current_state >= 98 )
+                                       yy_c = yy_meta[(unsigned int) yy_c];
+                               }
+                       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+                       ++yy_cp;
+                       }
+               while ( yy_current_state != 97 );
+               yy_cp = yyg->yy_last_accepting_cpos;
+               yy_current_state = yyg->yy_last_accepting_state;
+
+yy_find_action:
+               yy_act = yy_accept[yy_current_state];
+
+               YY_DO_BEFORE_ACTION;
+
+               if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+                       {
+                       int yyl;
+                       for ( yyl = 0; yyl < yyleng; ++yyl )
+                               if ( yytext[yyl] == '\n' )
+                                          
+    do{ yylineno++;
+        yycolumn=0;
+    }while(0)
+;
+                       }
+
+do_action:     /* This label is used only to access EOF actions. */
+
+               switch ( yy_act )
+       { /* beginning of action switch */
+                       case 0: /* must back up */
+                       /* undo the effects of YY_DO_BEFORE_ACTION */
+                       *yy_cp = yyg->yy_hold_char;
+                       yy_cp = yyg->yy_last_accepting_cpos;
+                       yy_current_state = yyg->yy_last_accepting_state;
+                       goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 83 "lexer.l"
+LOCATION_STEP(*yylloc);
+       YY_BREAK
+case 2:
+/* rule 2 can match eol */
+YY_RULE_SETUP
+#line 84 "lexer.l"
+LOCATION_LINES(*yylloc, yyleng); LOCATION_STEP(*yylloc);
+       YY_BREAK
+case 3:
+/* rule 3 can match eol */
+YY_RULE_SETUP
+#line 85 "lexer.l"
+LOCATION_LINES(*yylloc, yyleng/2); LOCATION_STEP(*yylloc);
+       YY_BREAK
+
+
+
+case 4:
+/* rule 4 can match eol */
+YY_RULE_SETUP
+#line 90 "lexer.l"
+{
+               loc_update(yylloc, yytext, yyleng);
+               yylval->string = unescape(yytext+1, yyleng-2);
+               return DQUOTED;
+  }
+       YY_BREAK
+case 5:
+/* rule 5 can match eol */
+YY_RULE_SETUP
+#line 96 "lexer.l"
+{
+               loc_update(yylloc, yytext, yyleng);
+               yylval->regexp.nocase = 1;
+               yylval->regexp.pattern = regexp_literal(yytext+1, yyleng-3);
+               return REGEXP;
+  }
+       YY_BREAK
+case 6:
+/* rule 6 can match eol */
+YY_RULE_SETUP
+#line 103 "lexer.l"
+{
+               loc_update(yylloc, yytext, yyleng);
+               yylval->regexp.nocase = 0;
+               yylval->regexp.pattern = regexp_literal(yytext+1, yyleng-2);
+               return REGEXP;
+  }
+       YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 110 "lexer.l"
+return yytext[0];
+       YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 112 "lexer.l"
+return KW_MODULE;
+       YY_BREAK
+case 9:
+/* rule 9 can match eol */
+*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
+yyg->yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 114 "lexer.l"
+return KW_LET_REC;
+       YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 116 "lexer.l"
+return KW_LET;
+       YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 117 "lexer.l"
+return KW_STRING;
+       YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 118 "lexer.l"
+return KW_REGEXP;
+       YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 119 "lexer.l"
+return KW_LENS;
+       YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 120 "lexer.l"
+return KW_IN;
+       YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 121 "lexer.l"
+return KW_AUTOLOAD;
+       YY_BREAK
+/* tests */
+case 16:
+YY_RULE_SETUP
+#line 124 "lexer.l"
+return KW_TEST;
+       YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 125 "lexer.l"
+return KW_GET;
+       YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 126 "lexer.l"
+return KW_PUT;
+       YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 127 "lexer.l"
+return KW_AFTER;
+       YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 129 "lexer.l"
+return ARROW;
+       YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 131 "lexer.l"
+{
+                   yylval->string = strndup(yytext, yyleng);
+                   return QIDENT;
+                }
+       YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 135 "lexer.l"
+{
+                   yylval->string = strndup(yytext, yyleng);
+                   return LIDENT;
+                }
+       YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 139 "lexer.l"
+{
+                   yylval->string = strndup(yytext, yyleng);
+                   return UIDENT;
+                }
+       YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 143 "lexer.l"
+{
+                   augl_get_extra(yyscanner)->comment_depth = 1;
+                   BEGIN(COMMENT);
+                }
+       YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 147 "lexer.l"
+{
+    report_error(augl_get_info(yyscanner)->error, AUG_ESYNTAX,
+                 "%s:%d:%d: Unexpected character %c",
+                 augl_get_info(yyscanner)->filename->str,
+                 yylineno, yylloc->first_column, yytext[0]);
+                }
+       YY_BREAK
+case YY_STATE_EOF(INITIAL):
+#line 154 "lexer.l"
+{
+                  augl_close_lexer(yyscanner);
+                  yyterminate();
+                }
+       YY_BREAK
+
+
+
+case 26:
+YY_RULE_SETUP
+#line 163 "lexer.l"
+{
+                   augl_get_extra(yyscanner)->comment_depth += 1;
+                }
+       YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 166 "lexer.l"
+{
+                   augl_get_extra(yyscanner)->comment_depth -= 1;
+                   if (augl_get_extra(yyscanner)->comment_depth == 0)
+                       BEGIN(INITIAL);
+                }
+       YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 171 "lexer.l"
+/* Skip */;
+       YY_BREAK
+case YY_STATE_EOF(COMMENT):
+#line 172 "lexer.l"
+{
+                  report_error(augl_get_info(yyscanner)->error, AUG_ESYNTAX,
+                               "%s:%d:%d: Missing *)",
+                               augl_get_info(yyscanner)->filename->str,
+                               yylineno, yylloc->first_column);
+                  augl_close_lexer(yyscanner);
+                  yyterminate();
+                }
+       YY_BREAK
+
+case 29:
+YY_RULE_SETUP
+#line 181 "lexer.l"
+YY_FATAL_ERROR( "flex scanner jammed" );
+       YY_BREAK
+#line 1145 "lexer.c"
+
+       case YY_END_OF_BUFFER:
+               {
+               /* Amount of text matched not including the EOB char. */
+               int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
+
+               /* Undo the effects of YY_DO_BEFORE_ACTION. */
+               *yy_cp = yyg->yy_hold_char;
+               YY_RESTORE_YY_MORE_OFFSET
+
+               if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+                       {
+                       /* We're scanning a new file or input source.  It's
+                        * possible that this happened because the user
+                        * just pointed yyin at a new source and called
+                        * augl_lex().  If so, then we have to assure
+                        * consistency between YY_CURRENT_BUFFER and our
+                        * globals.  Here is the right place to do so, because
+                        * this is the first action (other than possibly a
+                        * back-up) that will match for the new input source.
+                        */
+                       yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+                       YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+                       }
+
+               /* Note that here we test for yy_c_buf_p "<=" to the position
+                * of the first EOB in the buffer, since yy_c_buf_p will
+                * already have been incremented past the NUL character
+                * (since all states make transitions on EOB to the
+                * end-of-buffer state).  Contrast this with the test
+                * in input().
+                */
+               if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+                       { /* This was really a NUL. */
+                       yy_state_type yy_next_state;
+
+                       yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
+
+                       yy_current_state = yy_get_previous_state( yyscanner );
+
+                       /* Okay, we're now positioned to make the NUL
+                        * transition.  We couldn't have
+                        * yy_get_previous_state() go ahead and do it
+                        * for us because it doesn't know how to deal
+                        * with the possibility of jamming (and we don't
+                        * want to build jamming into it because then it
+                        * will run more slowly).
+                        */
+
+                       yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
+
+                       yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+
+                       if ( yy_next_state )
+                               {
+                               /* Consume the NUL. */
+                               yy_cp = ++yyg->yy_c_buf_p;
+                               yy_current_state = yy_next_state;
+                               goto yy_match;
+                               }
+
+                       else
+                               {
+                               yy_cp = yyg->yy_last_accepting_cpos;
+                               yy_current_state = yyg->yy_last_accepting_state;
+                               goto yy_find_action;
+                               }
+                       }
+
+               else switch ( yy_get_next_buffer( yyscanner ) )
+                       {
+                       case EOB_ACT_END_OF_FILE:
+                               {
+                               yyg->yy_did_buffer_switch_on_eof = 0;
+
+                               if ( augl_wrap(yyscanner ) )
+                                       {
+                                       /* Note: because we've taken care in
+                                        * yy_get_next_buffer() to have set up
+                                        * yytext, we can now set up
+                                        * yy_c_buf_p so that if some total
+                                        * hoser (like flex itself) wants to
+                                        * call the scanner after we return the
+                                        * YY_NULL, it'll still work - another
+                                        * YY_NULL will get returned.
+                                        */
+                                       yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
+
+                                       yy_act = YY_STATE_EOF(YY_START);
+                                       goto do_action;
+                                       }
+
+                               else
+                                       {
+                                       if ( ! yyg->yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+                                       }
+                               break;
+                               }
+
+                       case EOB_ACT_CONTINUE_SCAN:
+                               yyg->yy_c_buf_p =
+                                       yyg->yytext_ptr + yy_amount_of_matched_text;
+
+                               yy_current_state = yy_get_previous_state( yyscanner );
+
+                               yy_cp = yyg->yy_c_buf_p;
+                               yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+                               goto yy_match;
+
+                       case EOB_ACT_LAST_MATCH:
+                               yyg->yy_c_buf_p =
+                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
+
+                               yy_current_state = yy_get_previous_state( yyscanner );
+
+                               yy_cp = yyg->yy_c_buf_p;
+                               yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+                               goto yy_find_action;
+                       }
+               break;
+               }
+
+       default:
+               YY_FATAL_ERROR(
+                       "fatal flex scanner internal error--no action found" );
+       } /* end of action switch */
+               } /* end of scanning one token */
+} /* end of augl_lex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *     EOB_ACT_LAST_MATCH -
+ *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *     EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+       register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+       register char *source = yyg->yytext_ptr;
+       register int number_to_move, i;
+       int ret_val;
+
+       if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
+               YY_FATAL_ERROR(
+               "fatal flex scanner internal error--end of buffer missed" );
+
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+               { /* Don't try to fill the buffer, so this is an EOF. */
+               if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
+                       {
+                       /* We matched a single character, the EOB, so
+                        * treat this as a final EOF.
+                        */
+                       return EOB_ACT_END_OF_FILE;
+                       }
+
+               else
+                       {
+                       /* We matched some text prior to the EOB, first
+                        * process it.
+                        */
+                       return EOB_ACT_LAST_MATCH;
+                       }
+               }
+
+       /* Try to read more data. */
+
+       /* First move last chars to start of buffer. */
+       number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+
+       for ( i = 0; i < number_to_move; ++i )
+               *(dest++) = *(source++);
+
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+               /* don't do the read, it's not guaranteed to return an EOF,
+                * just force an EOF
+                */
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
+
+       else
+               {
+                       int num_to_read =
+                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+               while ( num_to_read <= 0 )
+                       { /* Not enough room in the buffer - grow it. */
+
+                       /* just a shorter name for the current buffer */
+                       YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+                       int yy_c_buf_p_offset =
+                               (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
+
+                       if ( b->yy_is_our_buffer )
+                               {
+                               int new_size = b->yy_buf_size * 2;
+
+                               if ( new_size <= 0 )
+                                       b->yy_buf_size += b->yy_buf_size / 8;
+                               else
+                                       b->yy_buf_size *= 2;
+
+                               b->yy_ch_buf = (char *)
+                                       /* Include room in for 2 EOB chars. */
+                                       augl_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+                               }
+                       else
+                               /* Can't grow it, we don't own it. */
+                               b->yy_ch_buf = 0;
+
+                       if ( ! b->yy_ch_buf )
+                               YY_FATAL_ERROR(
+                               "fatal error - scanner input buffer overflow" );
+
+                       yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+                       num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+                                               number_to_move - 1;
+
+                       }
+
+               if ( num_to_read > YY_READ_BUF_SIZE )
+                       num_to_read = YY_READ_BUF_SIZE;
+
+               /* Read in more data. */
+               YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+                       yyg->yy_n_chars, (size_t) num_to_read );
+
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+               }
+
+       if ( yyg->yy_n_chars == 0 )
+               {
+               if ( number_to_move == YY_MORE_ADJ )
+                       {
+                       ret_val = EOB_ACT_END_OF_FILE;
+                       augl_restart(yyin  ,yyscanner);
+                       }
+
+               else
+                       {
+                       ret_val = EOB_ACT_LAST_MATCH;
+                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+                               YY_BUFFER_EOF_PENDING;
+                       }
+               }
+
+       else
+               ret_val = EOB_ACT_CONTINUE_SCAN;
+
+       if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+               /* Extend the array by 50%, plus the number we really need. */
+               yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+               YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) augl_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+               if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+                       YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+       }
+
+       yyg->yy_n_chars += number_to_move;
+       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+       yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+       return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
+{
+       register yy_state_type yy_current_state;
+       register char *yy_cp;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       yy_current_state = yyg->yy_start;
+
+       for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
+               {
+               register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+               if ( yy_accept[yy_current_state] )
+                       {
+                       yyg->yy_last_accepting_state = yy_current_state;
+                       yyg->yy_last_accepting_cpos = yy_cp;
+                       }
+               while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                       {
+                       yy_current_state = (int) yy_def[yy_current_state];
+                       if ( yy_current_state >= 98 )
+                               yy_c = yy_meta[(unsigned int) yy_c];
+                       }
+               yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+               }
+
+       return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *     next_state = yy_try_NUL_trans( current_state );
+ */
+    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
+{
+       register int yy_is_jam;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
+       register char *yy_cp = yyg->yy_c_buf_p;
+
+       register YY_CHAR yy_c = 1;
+       if ( yy_accept[yy_current_state] )
+               {
+               yyg->yy_last_accepting_state = yy_current_state;
+               yyg->yy_last_accepting_cpos = yy_cp;
+               }
+       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+               {
+               yy_current_state = (int) yy_def[yy_current_state];
+               if ( yy_current_state >= 98 )
+                       yy_c = yy_meta[(unsigned int) yy_c];
+               }
+       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+       yy_is_jam = (yy_current_state == 97);
+
+       return yy_is_jam ? 0 : yy_current_state;
+}
+
+    static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
+{
+       register char *yy_cp;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+    yy_cp = yyg->yy_c_buf_p;
+
+       /* undo effects of setting up yytext */
+       *yy_cp = yyg->yy_hold_char;
+
+       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+               { /* need to shift things up to make room */
+               /* +2 for EOB chars. */
+               register int number_to_move = yyg->yy_n_chars + 2;
+               register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+                                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
+               register char *source =
+                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
+
+               while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+                       *--dest = *--source;
+
+               yy_cp += (int) (dest - source);
+               yy_bp += (int) (dest - source);
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+                       yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+
+               if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+                       YY_FATAL_ERROR( "flex scanner push-back overflow" );
+               }
+
+       *--yy_cp = (char) c;
+
+    if ( c == '\n' ){
+        --yylineno;
+    }
+
+       yyg->yytext_ptr = yy_bp;
+       yyg->yy_hold_char = *yy_cp;
+       yyg->yy_c_buf_p = yy_cp;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+    static int yyinput (yyscan_t yyscanner)
+#else
+    static int input  (yyscan_t yyscanner)
+#endif
+
+{
+       int c;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       *yyg->yy_c_buf_p = yyg->yy_hold_char;
+
+       if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+               {
+               /* yy_c_buf_p now points to the character we want to return.
+                * If this occurs *before* the EOB characters, then it's a
+                * valid NUL; if not, then we've hit the end of the buffer.
+                */
+               if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+                       /* This was really a NUL. */
+                       *yyg->yy_c_buf_p = '\0';
+
+               else
+                       { /* need more input */
+                       int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+                       ++yyg->yy_c_buf_p;
+
+                       switch ( yy_get_next_buffer( yyscanner ) )
+                               {
+                               case EOB_ACT_LAST_MATCH:
+                                       /* This happens because yy_g_n_b()
+                                        * sees that we've accumulated a
+                                        * token and flags that we need to
+                                        * try matching the token before
+                                        * proceeding.  But for input(),
+                                        * there's no matching to consider.
+                                        * So convert the EOB_ACT_LAST_MATCH
+                                        * to EOB_ACT_END_OF_FILE.
+                                        */
+
+                                       /* Reset buffer status. */
+                                       augl_restart(yyin ,yyscanner);
+
+                                       /*FALLTHROUGH*/
+
+                               case EOB_ACT_END_OF_FILE:
+                                       {
+                                       if ( augl_wrap(yyscanner ) )
+                                               return EOF;
+
+                                       if ( ! yyg->yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+#ifdef __cplusplus
+                                       return yyinput(yyscanner);
+#else
+                                       return input(yyscanner);
+#endif
+                                       }
+
+                               case EOB_ACT_CONTINUE_SCAN:
+                                       yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
+                                       break;
+                               }
+                       }
+               }
+
+       c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
+       *yyg->yy_c_buf_p = '\0';        /* preserve yytext */
+       yyg->yy_hold_char = *++yyg->yy_c_buf_p;
+
+       if ( c == '\n' )
+                  
+    do{ yylineno++;
+        yycolumn=0;
+    }while(0)
+;
+
+       return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * @param yyscanner The scanner object.
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+    void augl_restart  (FILE * input_file , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       if ( ! YY_CURRENT_BUFFER ){
+        augl_ensure_buffer_stack (yyscanner);
+               YY_CURRENT_BUFFER_LVALUE =
+            augl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+       }
+
+       augl__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
+       augl__load_buffer_state(yyscanner );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * @param yyscanner The scanner object.
+ */
+    void augl__switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       /* TODO. We should be able to replace this entire function body
+        * with
+        *              augl_pop_buffer_state();
+        *              augl_push_buffer_state(new_buffer);
+     */
+       augl_ensure_buffer_stack (yyscanner);
+       if ( YY_CURRENT_BUFFER == new_buffer )
+               return;
+
+       if ( YY_CURRENT_BUFFER )
+               {
+               /* Flush out information for old buffer. */
+               *yyg->yy_c_buf_p = yyg->yy_hold_char;
+               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+               }
+
+       YY_CURRENT_BUFFER_LVALUE = new_buffer;
+       augl__load_buffer_state(yyscanner );
+
+       /* We don't actually know whether we did this switch during
+        * EOF (augl_wrap()) processing, but the only time this flag
+        * is looked at is after augl_wrap() is called, so it's safe
+        * to go ahead and always set it.
+        */
+       yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+static void augl__load_buffer_state  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+       yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+       yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+       yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+       yyg->yy_hold_char = *yyg->yy_c_buf_p;
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * @param yyscanner The scanner object.
+ * @return the allocated buffer state.
+ */
+    YY_BUFFER_STATE augl__create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
+{
+       YY_BUFFER_STATE b;
+    
+       b = (YY_BUFFER_STATE) augl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in augl__create_buffer()" );
+
+       b->yy_buf_size = size;
+
+       /* yy_ch_buf has to be 2 characters longer than the size given because
+        * we need to put in 2 end-of-buffer characters.
+        */
+       b->yy_ch_buf = (char *) augl_alloc(b->yy_buf_size + 2 ,yyscanner );
+       if ( ! b->yy_ch_buf )
+               YY_FATAL_ERROR( "out of dynamic memory in augl__create_buffer()" );
+
+       b->yy_is_our_buffer = 1;
+
+       augl__init_buffer(b,file ,yyscanner);
+
+       return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with augl__create_buffer()
+ * @param yyscanner The scanner object.
+ */
+    void augl__delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       if ( ! b )
+               return;
+
+       if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+               YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+       if ( b->yy_is_our_buffer )
+               augl_free((void *) b->yy_ch_buf ,yyscanner );
+
+       augl_free((void *) b ,yyscanner );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a augl_restart() or at EOF.
+ */
+    static void augl__init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
+
+{
+       int oerrno = errno;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       augl__flush_buffer(b ,yyscanner);
+
+       b->yy_input_file = file;
+       b->yy_fill_buffer = 1;
+
+    /* If b is the current buffer, then augl__init_buffer was _probably_
+     * called from augl_restart() or through yy_get_next_buffer.
+     * In that case, we don't want to reset the lineno or column.
+     */
+    if (b != YY_CURRENT_BUFFER){
+        b->yy_bs_lineno = 1;
+        b->yy_bs_column = 0;
+    }
+
+        b->yy_is_interactive = 0;
+    
+       errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * @param yyscanner The scanner object.
+ */
+    void augl__flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+       if ( ! b )
+               return;
+
+       b->yy_n_chars = 0;
+
+       /* We always need two end-of-buffer characters.  The first causes
+        * a transition to the end-of-buffer state.  The second causes
+        * a jam in that state.
+        */
+       b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+       b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+       b->yy_buf_pos = &b->yy_ch_buf[0];
+
+       b->yy_at_bol = 1;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       if ( b == YY_CURRENT_BUFFER )
+               augl__load_buffer_state(yyscanner );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ *  the current state. This function will allocate the stack
+ *  if necessary.
+ *  @param new_buffer The new state.
+ *  @param yyscanner The scanner object.
+ */
+void augl_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+       if (new_buffer == NULL)
+               return;
+
+       augl_ensure_buffer_stack(yyscanner);
+
+       /* This block is copied from augl__switch_to_buffer. */
+       if ( YY_CURRENT_BUFFER )
+               {
+               /* Flush out information for old buffer. */
+               *yyg->yy_c_buf_p = yyg->yy_hold_char;
+               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+               }
+
+       /* Only push if top exists. Otherwise, replace top. */
+       if (YY_CURRENT_BUFFER)
+               yyg->yy_buffer_stack_top++;
+       YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+       /* copied from augl__switch_to_buffer. */
+       augl__load_buffer_state(yyscanner );
+       yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ *  The next element becomes the new top.
+ *  @param yyscanner The scanner object.
+ */
+void augl_pop_buffer_state (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+       if (!YY_CURRENT_BUFFER)
+               return;
+
+       augl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+       YY_CURRENT_BUFFER_LVALUE = NULL;
+       if (yyg->yy_buffer_stack_top > 0)
+               --yyg->yy_buffer_stack_top;
+
+       if (YY_CURRENT_BUFFER) {
+               augl__load_buffer_state(yyscanner );
+               yyg->yy_did_buffer_switch_on_eof = 1;
+       }
+}
+
+/* Allocates the stack if it does not exist.
+ *  Guarantees space for at least one push.
+ */
+static void augl_ensure_buffer_stack (yyscan_t yyscanner)
+{
+       int num_to_alloc;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+       if (!yyg->yy_buffer_stack) {
+
+               /* First allocation is just for 2 elements, since we don't know if this
+                * scanner will even need a stack. We use 2 instead of 1 to avoid an
+                * immediate realloc on the next call.
+         */
+               num_to_alloc = 1;
+               yyg->yy_buffer_stack = (struct yy_buffer_state**)augl_alloc
+                                                               (num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                               , yyscanner);
+               if ( ! yyg->yy_buffer_stack )
+                       YY_FATAL_ERROR( "out of dynamic memory in augl_ensure_buffer_stack()" );
+                                                                 
+               memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+                               
+               yyg->yy_buffer_stack_max = num_to_alloc;
+               yyg->yy_buffer_stack_top = 0;
+               return;
+       }
+
+       if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
+
+               /* Increase the buffer to prepare for a possible push. */
+               int grow_size = 8 /* arbitrary grow size */;
+
+               num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
+               yyg->yy_buffer_stack = (struct yy_buffer_state**)augl_realloc
+                                                               (yyg->yy_buffer_stack,
+                                                               num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                               , yyscanner);
+               if ( ! yyg->yy_buffer_stack )
+                       YY_FATAL_ERROR( "out of dynamic memory in augl_ensure_buffer_stack()" );
+
+               /* zero only the new slots.*/
+               memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+               yyg->yy_buffer_stack_max = num_to_alloc;
+       }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object. 
+ */
+YY_BUFFER_STATE augl__scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
+{
+       YY_BUFFER_STATE b;
+    
+       if ( size < 2 ||
+            base[size-2] != YY_END_OF_BUFFER_CHAR ||
+            base[size-1] != YY_END_OF_BUFFER_CHAR )
+               /* They forgot to leave room for the EOB's. */
+               return 0;
+
+       b = (YY_BUFFER_STATE) augl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in augl__scan_buffer()" );
+
+       b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
+       b->yy_buf_pos = b->yy_ch_buf = base;
+       b->yy_is_our_buffer = 0;
+       b->yy_input_file = 0;
+       b->yy_n_chars = b->yy_buf_size;
+       b->yy_is_interactive = 0;
+       b->yy_at_bol = 1;
+       b->yy_fill_buffer = 0;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       augl__switch_to_buffer(b ,yyscanner );
+
+       return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to augl_lex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ *       augl__scan_bytes() instead.
+ */
+YY_BUFFER_STATE augl__scan_string (yyconst char * yystr , yyscan_t yyscanner)
+{
+    
+       return augl__scan_bytes(yystr,strlen(yystr) ,yyscanner);
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to augl_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE augl__scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
+{
+       YY_BUFFER_STATE b;
+       char *buf;
+       yy_size_t n;
+       int i;
+    
+       /* Get memory for full buffer, including space for trailing EOB's. */
+       n = _yybytes_len + 2;
+       buf = (char *) augl_alloc(n ,yyscanner );
+       if ( ! buf )
+               YY_FATAL_ERROR( "out of dynamic memory in augl__scan_bytes()" );
+
+       for ( i = 0; i < _yybytes_len; ++i )
+               buf[i] = yybytes[i];
+
+       buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+       b = augl__scan_buffer(buf,n ,yyscanner);
+       if ( ! b )
+               YY_FATAL_ERROR( "bad buffer in augl__scan_bytes()" );
+
+       /* It's okay to grow etc. this buffer, and we should throw it
+        * away when we're done.
+        */
+       b->yy_is_our_buffer = 1;
+
+       return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+{
+       (void) fprintf( stderr, "%s\n", msg );
+       exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+               yytext[yyleng] = yyg->yy_hold_char; \
+               yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
+               yyg->yy_hold_char = *yyg->yy_c_buf_p; \
+               *yyg->yy_c_buf_p = '\0'; \
+               yyleng = yyless_macro_arg; \
+               } \
+       while ( 0 )
+
+/* Accessor  methods (get/set functions) to struct members. */
+
+/** Get the user-defined data for this scanner.
+ * @param yyscanner The scanner object.
+ */
+YY_EXTRA_TYPE augl_get_extra  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yyextra;
+}
+
+/** Get the current line number.
+ * @param yyscanner The scanner object.
+ */
+int augl_get_lineno  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    
+        if (! YY_CURRENT_BUFFER)
+            return 0;
+    
+    return yylineno;
+}
+
+/** Get the current column number.
+ * @param yyscanner The scanner object.
+ */
+int augl_get_column  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    
+        if (! YY_CURRENT_BUFFER)
+            return 0;
+    
+    return yycolumn;
+}
+
+/** Get the input stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *augl_get_in  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yyin;
+}
+
+/** Get the output stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *augl_get_out  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yyout;
+}
+
+/** Get the length of the current token.
+ * @param yyscanner The scanner object.
+ */
+int augl_get_leng  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yyleng;
+}
+
+/** Get the current token.
+ * @param yyscanner The scanner object.
+ */
+
+char *augl_get_text  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yytext;
+}
+
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * @param yyscanner The scanner object.
+ */
+void augl_set_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yyextra = user_defined ;
+}
+
+/** Set the current line number.
+ * @param line_number
+ * @param yyscanner The scanner object.
+ */
+void augl_set_lineno (int  line_number , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+        /* lineno is only valid if an input buffer exists. */
+        if (! YY_CURRENT_BUFFER )
+           yy_fatal_error( "augl_set_lineno called with no buffer" , yyscanner); 
+    
+    yylineno = line_number;
+}
+
+/** Set the current column.
+ * @param line_number
+ * @param yyscanner The scanner object.
+ */
+void augl_set_column (int  column_no , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+        /* column is only valid if an input buffer exists. */
+        if (! YY_CURRENT_BUFFER )
+           yy_fatal_error( "augl_set_column called with no buffer" , yyscanner); 
+    
+    yycolumn = column_no;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * @param yyscanner The scanner object.
+ * @see augl__switch_to_buffer
+ */
+void augl_set_in (FILE *  in_str , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yyin = in_str ;
+}
+
+void augl_set_out (FILE *  out_str , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yyout = out_str ;
+}
+
+int augl_get_debug  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yy_flex_debug;
+}
+
+void augl_set_debug (int  bdebug , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yy_flex_debug = bdebug ;
+}
+
+/* Accessor methods for yylval and yylloc */
+
+YYSTYPE * augl_get_lval  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yylval;
+}
+
+void augl_set_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yylval = yylval_param;
+}
+
+YYLTYPE *augl_get_lloc  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    return yylloc;
+}
+    
+void augl_set_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    yylloc = yylloc_param;
+}
+    
+/* User-visible API */
+
+/* augl_lex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+
+int augl_lex_init(yyscan_t* ptr_yy_globals)
+
+{
+    if (ptr_yy_globals == NULL){
+        errno = EINVAL;
+        return 1;
+    }
+
+    *ptr_yy_globals = (yyscan_t) augl_alloc ( sizeof( struct yyguts_t ), NULL );
+
+    if (*ptr_yy_globals == NULL){
+        errno = ENOMEM;
+        return 1;
+    }
+
+    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+    return yy_init_globals ( *ptr_yy_globals );
+}
+
+/* augl_lex_init_extra has the same functionality as augl_lex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to augl_alloc in
+ * the yyextra field.
+ */
+
+int augl_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+    struct yyguts_t dummy_yyguts;
+
+    augl_set_extra (yy_user_defined, &dummy_yyguts);
+
+    if (ptr_yy_globals == NULL){
+        errno = EINVAL;
+        return 1;
+    }
+       
+    *ptr_yy_globals = (yyscan_t) augl_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+       
+    if (*ptr_yy_globals == NULL){
+        errno = ENOMEM;
+        return 1;
+    }
+    
+    /* By setting to 0xAA, we expose bugs in
+    yy_init_globals. Leave at 0x00 for releases. */
+    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+    
+    augl_set_extra (yy_user_defined, *ptr_yy_globals);
+    
+    return yy_init_globals ( *ptr_yy_globals );
+}
+
+static int yy_init_globals (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+    /* Initialization is the same as for the non-reentrant scanner.
+     * This function is called from augl_lex_destroy(), so don't allocate here.
+     */
+
+    yyg->yy_buffer_stack = 0;
+    yyg->yy_buffer_stack_top = 0;
+    yyg->yy_buffer_stack_max = 0;
+    yyg->yy_c_buf_p = (char *) 0;
+    yyg->yy_init = 0;
+    yyg->yy_start = 0;
+
+    yyg->yy_start_stack_ptr = 0;
+    yyg->yy_start_stack_depth = 0;
+    yyg->yy_start_stack =  NULL;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+    yyin = stdin;
+    yyout = stdout;
+#else
+    yyin = (FILE *) 0;
+    yyout = (FILE *) 0;
+#endif
+
+    /* For future reference: Set errno on error, since we are called by
+     * augl_lex_init()
+     */
+    return 0;
+}
+
+/* augl_lex_destroy is for both reentrant and non-reentrant scanners. */
+int augl_lex_destroy  (yyscan_t yyscanner)
+{
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+    /* Pop the buffer stack, destroying each element. */
+       while(YY_CURRENT_BUFFER){
+               augl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+               YY_CURRENT_BUFFER_LVALUE = NULL;
+               augl_pop_buffer_state(yyscanner);
+       }
+
+       /* Destroy the stack itself. */
+       augl_free(yyg->yy_buffer_stack ,yyscanner);
+       yyg->yy_buffer_stack = NULL;
+
+    /* Destroy the start condition stack. */
+        augl_free(yyg->yy_start_stack ,yyscanner );
+        yyg->yy_start_stack = NULL;
+
+    /* Reset the globals. This is important in a non-reentrant scanner so the next time
+     * augl_lex() is called, initialization will occur. */
+    yy_init_globals( yyscanner);
+
+    /* Destroy the main struct (reentrant only). */
+    augl_free ( yyscanner , yyscanner );
+    yyscanner = NULL;
+    return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+{
+       register int i;
+       for ( i = 0; i < n; ++i )
+               s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+{
+       register int n;
+       for ( n = 0; s[n]; ++n )
+               ;
+
+       return n;
+}
+#endif
+
+void *augl_alloc (yy_size_t  size , yyscan_t yyscanner)
+{
+       return (void *) malloc( size );
+}
+
+void *augl_realloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
+{
+       /* The cast to (char *) in the following accommodates both
+        * implementations that use char* generic pointers, and those
+        * that use void* generic pointers.  It works with the latter
+        * because both ANSI C and C++ allow castless assignment from
+        * any pointer type to void*, and deal with argument conversions
+        * as though doing an assignment.
+        */
+       return (void *) realloc( (char *) ptr, size );
+}
+
+void augl_free (void * ptr , yyscan_t yyscanner)
+{
+       free( (char *) ptr );   /* see augl_realloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 181 "lexer.l"
+
+
+
+void augl_close_lexer(yyscan_t *scanner) {
+  FILE *fp = augl_get_in(scanner);
+
+  if (fp != NULL) {
+    fclose(fp);
+    augl_set_in(NULL, scanner);
+  }
+}
+
+int augl_init_lexer(struct state *state, yyscan_t *scanner) {
+  FILE *f;
+  struct string *name = state->info->filename;
+
+  f = fopen(name->str, "r");
+  if (f == NULL)
+    return -1;
+
+  if (augl_lex_init(scanner) != 0) {
+    fclose(f);
+    return -1;
+  }
+  augl_set_extra(state, *scanner);
+  augl_set_in(f, *scanner);
+  return 0;
+}
+
+struct info *augl_get_info(yyscan_t scanner) {
+  return augl_get_extra(scanner)->info;
+}
+
diff --git a/src/lexer.l b/src/lexer.l
new file mode 100644 (file)
index 0000000..acd83f2
--- /dev/null
@@ -0,0 +1,211 @@
+/* Scanner for config specs   -*- C -*- */
+%option 8bit never-interactive yylineno
+%option bison-bridge bison-locations
+%option reentrant noyywrap
+%option warn nodefault
+%option outfile="lex.yy.c" prefix="augl_"
+
+%top{
+/* config.h must precede flex's inclusion of <stdio.h>
+   in order for its _GNU_SOURCE definition to take effect.  */
+#include <config.h>
+}
+
+%{
+#include "syntax.h"
+#include "errcode.h"
+
+typedef struct info YYLTYPE;
+#define YYLTYPE_IS_DECLARED 1
+
+#include "parser.h"
+
+/* Advance of NUM lines. */
+# define LOCATION_LINES(Loc, Num)             \
+  (Loc).last_column = 0;                      \
+  (Loc).last_line += Num;
+
+/* Restart: move the first cursor to the last position. */
+# define LOCATION_STEP(Loc)                   \
+  (Loc).first_column = (Loc).last_column;     \
+  (Loc).first_line = (Loc).last_line;
+
+/* The lack of reference counting for filename is intentional */
+#define YY_USER_ACTION                                            \
+  do {                                                            \
+     yylloc->last_column += yyleng;                               \
+     yylloc->filename = augl_get_info(yyscanner)->filename;       \
+     yylloc->error = augl_get_info(yyscanner)->error;             \
+   } while(0);
+
+#define YY_USER_INIT LOCATION_STEP(*yylloc)
+
+#define YY_EXTRA_TYPE struct state *
+
+int augl_init_lexer(struct state *state, yyscan_t * scanner);
+void augl_close_lexer(yyscan_t *scanner);
+struct info *augl_get_info(yyscan_t yyscanner);
+
+static void loc_update(YYLTYPE *yylloc, const char *s, int len) {
+  for (int i=0; i < len; i++) {
+    if (s[i] == '\n') {
+      LOCATION_LINES(*yylloc, 1);
+    }
+  }
+}
+
+static char *regexp_literal(const char *s, int len) {
+  char *u = unescape(s, len);
+  size_t u_len = strlen(u);
+
+  if (u == NULL)
+    return NULL;
+
+  regexp_c_locale(&u, &u_len);
+
+  return u;
+}
+%}
+
+DIGIT [0-9]
+UID    [A-Z][A-Za-z0-9_]*
+LID    [a-z_][A-Za-z0-9_]*
+LETREC   let[ \t]+rec
+WS     [ \t\n]
+QID    {UID}\.{LID}
+ARROW  ->
+
+%s COMMENT
+
+%%
+<*>
+{
+  [ \t]*        LOCATION_STEP(*yylloc);
+  \n+           LOCATION_LINES(*yylloc, yyleng); LOCATION_STEP(*yylloc);
+  (\r\n)+       LOCATION_LINES(*yylloc, yyleng/2); LOCATION_STEP(*yylloc);
+}
+
+<INITIAL>
+{
+  \"([^\"]|\\\")*\"   {
+               loc_update(yylloc, yytext, yyleng);
+               yylval->string = unescape(yytext+1, yyleng-2);
+               return DQUOTED;
+  }
+
+  \/([^/]|\\\/)*\/i {
+               loc_update(yylloc, yytext, yyleng);
+               yylval->regexp.nocase = 1;
+               yylval->regexp.pattern = regexp_literal(yytext+1, yyleng-3);
+               return REGEXP;
+  }
+
+  \/([^/]|\\\/)*\/ {
+               loc_update(yylloc, yytext, yyleng);
+               yylval->regexp.nocase = 0;
+               yylval->regexp.pattern = regexp_literal(yytext+1, yyleng-2);
+               return REGEXP;
+  }
+
+  [|*?+()=:;\.\[\]{}-]    return yytext[0];
+
+  module        return KW_MODULE;
+
+  {LETREC}/{WS} return KW_LET_REC;
+
+  let           return KW_LET;
+  string        return KW_STRING;
+  regexp        return KW_REGEXP;
+  lens          return KW_LENS;
+  in            return KW_IN;
+  autoload      return KW_AUTOLOAD;
+
+  /* tests */
+  test          return KW_TEST;
+  get           return KW_GET;
+  put           return KW_PUT;
+  after         return KW_AFTER;
+
+  {ARROW}       return ARROW;
+
+  {QID}         {
+                   yylval->string = strndup(yytext, yyleng);
+                   return QIDENT;
+                }
+  {LID}         {
+                   yylval->string = strndup(yytext, yyleng);
+                   return LIDENT;
+                }
+  {UID}         {
+                   yylval->string = strndup(yytext, yyleng);
+                   return UIDENT;
+                }
+  \(\*          {
+                   augl_get_extra(yyscanner)->comment_depth = 1;
+                   BEGIN(COMMENT);
+                }
+  .             {
+    report_error(augl_get_info(yyscanner)->error, AUG_ESYNTAX,
+                 "%s:%d:%d: Unexpected character %c",
+                 augl_get_info(yyscanner)->filename->str,
+                 yylineno, yylloc->first_column, yytext[0]);
+                }
+
+  <<EOF>>       {
+                  augl_close_lexer(yyscanner);
+                  yyterminate();
+                }
+
+}
+
+<COMMENT>
+{
+  \(\*          {
+                   augl_get_extra(yyscanner)->comment_depth += 1;
+                }
+  \*\)          {
+                   augl_get_extra(yyscanner)->comment_depth -= 1;
+                   if (augl_get_extra(yyscanner)->comment_depth == 0)
+                       BEGIN(INITIAL);
+                }
+  .             /* Skip */;
+  <<EOF>>       {
+                  report_error(augl_get_info(yyscanner)->error, AUG_ESYNTAX,
+                               "%s:%d:%d: Missing *)",
+                               augl_get_info(yyscanner)->filename->str,
+                               yylineno, yylloc->first_column);
+                  augl_close_lexer(yyscanner);
+                  yyterminate();
+                }
+}
+%%
+
+void augl_close_lexer(yyscan_t *scanner) {
+  FILE *fp = augl_get_in(scanner);
+
+  if (fp != NULL) {
+    fclose(fp);
+    augl_set_in(NULL, scanner);
+  }
+}
+
+int augl_init_lexer(struct state *state, yyscan_t *scanner) {
+  FILE *f;
+  struct string *name = state->info->filename;
+
+  f = fopen(name->str, "r");
+  if (f == NULL)
+    return -1;
+
+  if (augl_lex_init(scanner) != 0) {
+    fclose(f);
+    return -1;
+  }
+  augl_set_extra(state, *scanner);
+  augl_set_in(f, *scanner);
+  return 0;
+}
+
+struct info *augl_get_info(yyscan_t scanner) {
+  return augl_get_extra(scanner)->info;
+}
diff --git a/src/list.h b/src/list.h
new file mode 100644 (file)
index 0000000..c757cc6
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * list.h: Simple generic list manipulation
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef LIST_H_
+#define LIST_H_
+
+#define list_append(head, tail)                                         \
+    do {                                                                \
+        if ((head) == NULL) {                                           \
+            head = tail;                                                \
+            break;                                                      \
+        }                                                               \
+        typeof(head) _p;                                                \
+        for (_p = (head); _p->next != NULL; _p = _p->next);             \
+        _p->next = (tail);                                              \
+    } while (0)
+
+#define list_for_each(iter, list)                                       \
+    for (typeof(list) (iter) = list; (iter) != NULL; (iter) = (iter)->next)
+
+#define list_remove(elt, list)                                          \
+    do {                                                                \
+        typeof(elt) _e = (elt);                                         \
+        if (_e == (list)) {                                             \
+            (list) = _e->next;                                          \
+        } else {                                                        \
+            typeof(_e) _p;                                              \
+            for (_p = (list); _p != NULL && _p->next != _e; _p = _p->next); \
+            if (_p != NULL)                                             \
+                _p->next = _e->next;                                    \
+        }                                                               \
+        _e->next = NULL;                                                \
+    } while(0)
+
+/* Insert NEW in list LIST before element AC. NEW->next must be null,
+   and ELT must really be on LIST, otherwise chaos will ensue
+*/
+#define list_insert_before(new, elt, list)                              \
+    do {                                                                \
+        if ((list) == NULL) {                                           \
+            (list) = (new);                                             \
+        } else if ((elt) == (list)) {                                   \
+            (new)->next = (elt);                                        \
+            (list) = (new);                                             \
+        } else {                                                        \
+            typeof(elt) _p;                                             \
+            for (_p = (list); _p != NULL && _p->next != (elt); _p = _p->next); \
+            if (_p != NULL) {                                           \
+                (new)->next = (elt);                                    \
+                _p->next = (new);                                       \
+            }                                                           \
+        }                                                               \
+    } while(0)
+
+#endif
+
+#define list_free(list)                                                 \
+    while ((list) != NULL) {                                            \
+        typeof(list) _p = list;                                         \
+        (list) = (list)->next;                                          \
+        free((void *) _p);                                              \
+    }
+
+#define list_length(len, list)                                          \
+    do {                                                                \
+        typeof(list) _p;                                                \
+        for (len=0, _p = (list); _p != NULL; len += 1, _p = _p->next);  \
+    } while(0)
+
+/* Make ELT the new head of LIST and set LIST to it */
+#define list_cons(list, elt)                                            \
+    do {                                                                \
+        typeof(elt) _e = (elt);                                         \
+        _e->next = (list);                                              \
+        (list) = _e;                                                    \
+    } while(0)
+
+#define list_reverse(list)                                              \
+    do {                                                                \
+        typeof(list) _head = (list);                                    \
+        typeof(list) _prev = NULL;                                      \
+        while (_head != NULL) {                                         \
+            typeof(list) _next = _head->next;                           \
+            _head->next = _prev;                                        \
+            _prev = _head;                                              \
+            _head = _next;                                              \
+        }                                                               \
+        (list) = _prev;                                                 \
+    } while (0)
+
+/* Append ELT to the end of LIST. TAIL must be NULL or a pointer to
+   the last element of LIST. ELT may also be a list
+*/
+#define list_tail_cons(list, tail, elt)                                 \
+    do {                                                                \
+        /* Append ELT at the end of LIST */                             \
+        if ((list) == NULL) {                                           \
+            (list) = (elt);                                             \
+        } else {                                                        \
+            if ((tail) == NULL)                                         \
+                for ((tail) = (list); (tail)->next != NULL;             \
+                     (tail) = (tail)->next);                            \
+            (tail)->next = (elt);                                       \
+        }                                                               \
+        /* Make sure TAIL is the last element on the combined LIST */   \
+        (tail) = (elt);                                                 \
+        if ((tail) != NULL)                                             \
+            while ((tail)->next != NULL)                                \
+                (tail) = (tail)->next;                                  \
+    } while(0)
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/memory.c b/src/memory.c
new file mode 100644 (file)
index 0000000..1644523
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * memory.c: safer memory allocation
+ *
+ * Copyright (C) 2008-2010 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "memory.h"
+
+
+/* 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
+   nonnegative.  This is a macro, not an inline function, so that it
+   works correctly even when SIZE_MAX < N.
+
+   By gnulib convention, SIZE_MAX represents overflow in size
+   calculations, so the conservative dividend to use here is
+   SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+   However, malloc (SIZE_MAX) fails on all known hosts where
+   sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
+   exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+   branch when S is known to be 1.  */
+# define xalloc_oversized(n, s) \
+    ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+
+
+/**
+ * mem_alloc_n:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of memory 'count' elements long,
+ * each with 'size' bytes. Return the address of the
+ * allocated memory in 'ptrptr'.  The newly allocated
+ * memory is filled with zeros.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int mem_alloc_n(void *ptrptr, size_t size, size_t count)
+{
+    if (size == 0 || count == 0) {
+        *(void **)ptrptr = NULL;
+        return 0;
+    }
+
+    *(void**)ptrptr = calloc(count, size);
+    if (*(void**)ptrptr == NULL)
+        return -1;
+    return 0;
+}
+
+/**
+ * virReallocN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements in array
+ *
+ * Resize the block of memory in 'ptrptr' to be an array of
+ * 'count' elements, each 'size' bytes in length. Update 'ptrptr'
+ * with the address of the newly allocated memory. On failure,
+ * 'ptrptr' is not changed and still points to the original memory
+ * block. The newly allocated memory is filled with zeros.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int mem_realloc_n(void *ptrptr, size_t size, size_t count)
+{
+    void *tmp;
+    if (size == 0 || count == 0) {
+        free(*(void **)ptrptr);
+        *(void **)ptrptr = NULL;
+        return 0;
+    }
+    if (xalloc_oversized(count, size)) {
+        errno = ENOMEM;
+        return -1;
+    }
+    tmp = realloc(*(void**)ptrptr, size * count);
+    if (!tmp)
+        return -1;
+    *(void**)ptrptr = tmp;
+    return 0;
+}
diff --git a/src/memory.h b/src/memory.h
new file mode 100644 (file)
index 0000000..4df7ca9
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * memory.c: safer memory allocation
+ *
+ * Copyright (C) 2008-2010 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+
+#ifndef MEMORY_H_
+#define MEMORY_H_
+
+#include "internal.h"
+
+/* Don't call these directly - use the macros below */
+int mem_alloc_n(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK;
+int mem_realloc_n(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK;
+
+
+/**
+ * ALLOC:
+ * @ptr: pointer to hold address of allocated memory
+ *
+ * Allocate sizeof(*ptr) bytes of memory and store
+ * the address of allocated memory in 'ptr'. Fill the
+ * newly allocated memory with zeros.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+#define ALLOC(ptr) mem_alloc_n(&(ptr), sizeof(*(ptr)), 1)
+
+/**
+ * ALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Fill the newly allocated memory with zeros.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+#define ALLOC_N(ptr, count) mem_alloc_n(&(ptr), sizeof(*(ptr)), (count))
+
+/**
+ * REALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Fill the newly allocated memory with zeros
+ *
+ * Returns -1 on failure, 0 on success
+ */
+#define REALLOC_N(ptr, count) mem_realloc_n(&(ptr), sizeof(*(ptr)), (count))
+
+/**
+ * FREE:
+ * @ptr: pointer holding address to be freed
+ *
+ * Free the memory stored in 'ptr' and update to point
+ * to NULL.
+ */
+#define FREE(ptr)                               \
+  do {                                          \
+    free(ptr);                                  \
+    (ptr) = NULL;                               \
+  } while(0)
+
+#endif /* __VIR_MEMORY_H_ */
diff --git a/src/parser.c b/src/parser.c
new file mode 100644 (file)
index 0000000..5ec9ad5
--- /dev/null
@@ -0,0 +1,2644 @@
+/* A Bison parser, made by GNU Bison 2.4.3.  */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+   
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+   2009, 2010 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/>.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+   
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+   simplifying the original so-called "semantic" parser.  */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+   infringing on user name space.  This should be done even for local
+   variables, as they might otherwise be expanded by user macros.
+   There are some unavoidable exceptions within include files to
+   define necessary library symbols; they are noted "INFRINGES ON
+   USER NAME SPACE" below.  */
+
+/* Identify Bison output.  */
+#define YYBISON 1
+
+/* Bison version.  */
+#define YYBISON_VERSION "2.4.3"
+
+/* Skeleton name.  */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers.  */
+#define YYPURE 1
+
+/* Push parsers.  */
+#define YYPUSH 0
+
+/* Pull parsers.  */
+#define YYPULL 1
+
+/* Using locations.  */
+#define YYLSP_NEEDED 1
+
+/* Substitute the variable and function names.  */
+#define yyparse         augl_parse
+#define yylex           augl_lex
+#define yyerror         augl_error
+#define yylval          augl_lval
+#define yychar          augl_char
+#define yydebug         augl_debug
+#define yynerrs         augl_nerrs
+#define yylloc          augl_lloc
+
+/* Copy the first part of user declarations.  */
+
+/* Line 189 of yacc.c  */
+#line 1 "parser.y"
+
+
+#include <config.h>
+
+#include "internal.h"
+#include "syntax.h"
+#include "list.h"
+#include "errcode.h"
+#include <stdio.h>
+
+/* Work around a problem on FreeBSD where Bison looks for _STDLIB_H
+ * to see if stdlib.h has been included, but the system includes
+ * use _STDLIB_H_
+ */
+#if HAVE_STDLIB_H && ! defined _STDLIB_H
+#  include <stdlib.h>
+#  define _STDLIB_H 1
+#endif
+
+#define YYDEBUG 1
+
+int augl_parse_file(struct augeas *aug, const char *name, struct term **term);
+
+typedef void *yyscan_t;
+typedef struct info YYLTYPE;
+#define YYLTYPE_IS_DECLARED 1
+/* The lack of reference counting on filename is intentional */
+# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
+  do {                                                                  \
+    (Current).filename = augl_get_info(scanner)->filename;              \
+    (Current).error = augl_get_info(scanner)->error;                    \
+    if (YYID (N)) {                                                     \
+        (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;          \
+        (Current).first_column = YYRHSLOC (Rhs, 1).first_column;        \
+        (Current).last_line    = YYRHSLOC (Rhs, N).last_line;           \
+        (Current).last_column  = YYRHSLOC (Rhs, N).last_column;         \
+    } else {                                                            \
+      (Current).first_line   = (Current).last_line   =                  \
+           YYRHSLOC (Rhs, 0).last_line;                                    \
+         (Current).first_column = (Current).last_column =                  \
+           YYRHSLOC (Rhs, 0).last_column;                                  \
+    }                                                                   \
+  } while (0)
+
+
+/* Line 189 of yacc.c  */
+#line 126 "parser.c"
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     DQUOTED = 258,
+     REGEXP = 259,
+     LIDENT = 260,
+     UIDENT = 261,
+     QIDENT = 262,
+     ARROW = 263,
+     KW_MODULE = 264,
+     KW_AUTOLOAD = 265,
+     KW_LET = 266,
+     KW_LET_REC = 267,
+     KW_IN = 268,
+     KW_STRING = 269,
+     KW_REGEXP = 270,
+     KW_LENS = 271,
+     KW_TEST = 272,
+     KW_GET = 273,
+     KW_PUT = 274,
+     KW_AFTER = 275
+   };
+#endif
+/* Tokens.  */
+#define DQUOTED 258
+#define REGEXP 259
+#define LIDENT 260
+#define UIDENT 261
+#define QIDENT 262
+#define ARROW 263
+#define KW_MODULE 264
+#define KW_AUTOLOAD 265
+#define KW_LET 266
+#define KW_LET_REC 267
+#define KW_IN 268
+#define KW_STRING 269
+#define KW_REGEXP 270
+#define KW_LENS 271
+#define KW_TEST 272
+#define KW_GET 273
+#define KW_PUT 274
+#define KW_AFTER 275
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 214 of yacc.c  */
+#line 89 "parser.y"
+
+  struct term    *term;
+  struct type    *type;
+  struct ident   *ident;
+  struct tree    *tree;
+  char           *string;
+  struct {
+    int             nocase;
+    char           *pattern;
+  } regexp;
+  int            intval;
+  enum quant_tag quant;
+
+
+
+/* Line 214 of yacc.c  */
+#line 218 "parser.c"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+/* "%code provides" blocks.  */
+
+/* Line 261 of yacc.c  */
+#line 46 "parser.y"
+
+#include "info.h"
+
+/* Track custom scanner state */
+struct state {
+  struct info *info;
+  unsigned int comment_depth;
+};
+
+
+
+
+/* Line 261 of yacc.c  */
+#line 255 "parser.c"
+
+/* Copy the second part of user declarations.  */
+
+/* Line 264 of yacc.c  */
+#line 114 "parser.y"
+
+/* Lexer */
+extern int augl_lex (YYSTYPE * yylval_param,struct info * yylloc_param ,yyscan_t yyscanner);
+int augl_init_lexer(struct state *state, yyscan_t * scanner);
+void augl_close_lexer(yyscan_t *scanner);
+int augl_lex_destroy (yyscan_t yyscanner );
+int augl_get_lineno (yyscan_t yyscanner );
+int augl_get_column  (yyscan_t yyscanner);
+struct info *augl_get_info(yyscan_t yyscanner);
+char *augl_get_text (yyscan_t yyscanner );
+
+static void augl_error(struct info *locp, struct term **term,
+                       yyscan_t scanner, const char *s);
+
+/* TERM construction */
+ static struct info *clone_info(struct info *locp);
+ static struct term *make_module(char *ident, char *autoload,
+                                 struct term *decls,
+                                 struct info *locp);
+
+ static struct term *make_bind(char *ident, struct term *params,
+                             struct term *exp, struct term *decls,
+                             struct info *locp);
+ static struct term *make_bind_rec(char *ident, struct term *exp,
+                                   struct term *decls, struct info *locp);
+ static struct term *make_let(char *ident, struct term *params,
+                              struct term *exp, struct term *body,
+                              struct info *locp);
+ static struct term *make_binop(enum term_tag tag,
+                               struct term *left, struct term *right,
+                               struct info *locp);
+ static struct term *make_unop(enum term_tag tag,
+                              struct term *exp, struct info *locp);
+ static struct term *make_ident(char *qname, struct info *locp);
+ static struct term *make_unit_term(struct info *locp);
+ static struct term *make_string_term(char *value, struct info *locp);
+ static struct term *make_regexp_term(char *pattern,
+                                      int nocase, struct info *locp);
+ static struct term *make_rep(struct term *exp, enum quant_tag quant,
+                             struct info *locp);
+
+ static struct term *make_get_test(struct term *lens, struct term *arg,
+                                   struct info *info);
+ static struct term *make_put_test(struct term *lens, struct term *arg,
+                                   struct term *cmds, struct info *info);
+ static struct term *make_test(struct term *test, struct term *result,
+                               enum test_result_tag tr_tag,
+                               struct term *decls, struct info *locp);
+ static struct term *make_tree_value(struct tree *, struct info*);
+ static struct tree *tree_concat(struct tree *, struct tree *);
+
+#define LOC_MERGE(a, b, c)                                              \
+ do {                                                                   \
+   (a).filename     = (b).filename;                                     \
+   (a).first_line   = (b).first_line;                                   \
+   (a).first_column = (b).first_column;                                 \
+   (a).last_line    = (c).last_line;                                    \
+   (a).last_column  = (c).last_column;                                  \
+   (a).error        = (b).error;                                        \
+ } while(0);
+
+
+
+/* Line 264 of yacc.c  */
+#line 325 "parser.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+#  define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+#  define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
+# else
+#  define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions.  */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+    int yyi;
+#endif
+{
+  return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols.  */
+
+# ifdef YYSTACK_USE_ALLOCA
+#  if YYSTACK_USE_ALLOCA
+#   ifdef __GNUC__
+#    define YYSTACK_ALLOC __builtin_alloca
+#   elif defined __BUILTIN_VA_ARG_INCR
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+#   elif defined _AIX
+#    define YYSTACK_ALLOC __alloca
+#   elif defined _MSC_VER
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+#    define alloca _alloca
+#   else
+#    define YYSTACK_ALLOC alloca
+#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#     ifndef _STDLIB_H
+#      define _STDLIB_H 1
+#     endif
+#    endif
+#   endif
+#  endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+   /* Pacify GCC's `empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+    /* The OS might guarantee only one guard page at the bottom of the stack,
+       and a page size can be as small as 4096 bytes.  So we cannot safely
+       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
+       to allow for a few compiler-allocated temporary stack slots.  */
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+#  endif
+# else
+#  define YYSTACK_ALLOC YYMALLOC
+#  define YYSTACK_FREE YYFREE
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+#  endif
+#  if (defined __cplusplus && ! defined _STDLIB_H \
+       && ! ((defined YYMALLOC || defined malloc) \
+            && (defined YYFREE || defined free)))
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   ifndef _STDLIB_H
+#    define _STDLIB_H 1
+#   endif
+#  endif
+#  ifndef YYMALLOC
+#   define YYMALLOC malloc
+#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifndef YYFREE
+#   define YYFREE free
+#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+     && (! defined __cplusplus \
+        || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
+            && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member.  */
+union yyalloc
+{
+  yytype_int16 yyss_alloc;
+  YYSTYPE yyvs_alloc;
+  YYLTYPE yyls_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next.  */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+   N elements.  */
+# define YYSTACK_BYTES(N) \
+     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+      + 2 * YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO.  The source and destination do
+   not overlap.  */
+# ifndef YYCOPY
+#  if defined __GNUC__ && 1 < __GNUC__
+#   define YYCOPY(To, From, Count) \
+      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+#  else
+#   define YYCOPY(To, From, Count)             \
+      do                                       \
+       {                                       \
+         YYSIZE_T yyi;                         \
+         for (yyi = 0; yyi < (Count); yyi++)   \
+           (To)[yyi] = (From)[yyi];            \
+       }                                       \
+      while (YYID (0))
+#  endif
+# endif
+
+/* Relocate STACK from its old location to the new one.  The
+   local variables YYSIZE and YYSTACKSIZE give the old and new number of
+   elements in the stack, and YYPTR gives the new location of the
+   stack.  Advance YYPTR to a properly aligned location for the next
+   stack.  */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack)                          \
+    do                                                                 \
+      {                                                                        \
+       YYSIZE_T yynewbytes;                                            \
+       YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
+       Stack = &yyptr->Stack_alloc;                                    \
+       yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+       yyptr += yynewbytes / sizeof (*yyptr);                          \
+      }                                                                        \
+    while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state.  */
+#define YYFINAL  4
+/* YYLAST -- Last index in YYTABLE.  */
+#define YYLAST   129
+
+/* YYNTOKENS -- Number of terminals.  */
+#define YYNTOKENS  36
+/* YYNNTS -- Number of nonterminals.  */
+#define YYNNTS  25
+/* YYNRULES -- Number of rules.  */
+#define YYNRULES  61
+/* YYNRULES -- Number of states.  */
+#define YYNSTATES  113
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+#define YYUNDEFTOK  2
+#define YYMAXUTOK   275
+
+#define YYTRANSLATE(YYX)                                               \
+  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
+static const yytype_uint8 yytranslate[] =
+{
+       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+      28,    29,    23,    32,     2,    26,    27,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,    33,    24,
+       2,    21,     2,    22,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,    30,     2,    31,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,    34,    25,    35,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,    20
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+   YYRHS.  */
+static const yytype_uint8 yyprhs[] =
+{
+       0,     0,     3,     9,    12,    13,    20,    26,    32,    38,
+      39,    43,    49,    51,    53,    61,    63,    67,    69,    73,
+      75,    77,    81,    83,    87,    89,    92,    94,    96,    98,
+     100,   104,   108,   111,   114,   116,   118,   120,   122,   124,
+     126,   128,   130,   133,   134,   140,   142,   144,   146,   150,
+     152,   154,   156,   158,   162,   167,   171,   176,   177,   180,
+     185,   187
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+static const yytype_int8 yyrhs[] =
+{
+      37,     0,    -1,     9,     6,    21,    38,    39,    -1,    10,
+       5,    -1,    -1,    11,     5,    52,    21,    42,    39,    -1,
+      12,     5,    21,    42,    39,    -1,    17,    40,    21,    42,
+      39,    -1,    17,    40,    21,    41,    39,    -1,    -1,    48,
+      18,    42,    -1,    48,    19,    48,    20,    42,    -1,    22,
+      -1,    23,    -1,    11,     5,    52,    21,    42,    13,    42,
+      -1,    43,    -1,    43,    24,    44,    -1,    44,    -1,    44,
+      25,    45,    -1,    45,    -1,    57,    -1,    45,    26,    46,
+      -1,    46,    -1,    46,    27,    47,    -1,    47,    -1,    47,
+      49,    -1,    49,    -1,    51,    -1,     3,    -1,     4,    -1,
+      28,    42,    29,    -1,    30,    42,    31,    -1,    28,    29,
+      -1,    48,    50,    -1,    48,    -1,    23,    -1,    32,    -1,
+      22,    -1,     5,    -1,     7,    -1,    18,    -1,    19,    -1,
+      53,    52,    -1,    -1,    28,    54,    33,    55,    29,    -1,
+       5,    -1,    18,    -1,    19,    -1,    56,     8,    55,    -1,
+      56,    -1,    14,    -1,    15,    -1,    16,    -1,    28,    55,
+      29,    -1,    57,    34,    59,    35,    -1,    34,    59,    35,
+      -1,    58,    34,    59,    35,    -1,    -1,    60,    58,    -1,
+      60,    21,     3,    58,    -1,     3,    -1,    -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
+static const yytype_uint16 yyrline[] =
+{
+       0,   179,   179,   182,   185,   187,   192,   197,   202,   208,
+     212,   214,   217,   219,   223,   228,   230,   232,   235,   237,
+     239,   242,   244,   247,   249,   252,   254,   257,   259,   261,
+     263,   265,   267,   270,   272,   275,   277,   279,   282,   284,
+     286,   288,   291,   294,   296,   299,   301,   303,   306,   308,
+     311,   313,   315,   317,   320,   322,   325,   330,   332,   336,
+     340,   342
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
+static const char *const yytname[] =
+{
+  "$end", "error", "$undefined", "DQUOTED", "REGEXP", "LIDENT", "UIDENT",
+  "QIDENT", "ARROW", "KW_MODULE", "KW_AUTOLOAD", "KW_LET", "KW_LET_REC",
+  "KW_IN", "KW_STRING", "KW_REGEXP", "KW_LENS", "KW_TEST", "KW_GET",
+  "KW_PUT", "KW_AFTER", "'='", "'?'", "'*'", "';'", "'|'", "'-'", "'.'",
+  "'('", "')'", "'['", "']'", "'+'", "':'", "'{'", "'}'", "$accept",
+  "start", "autoload", "decls", "test_exp", "test_special_res", "exp",
+  "composeexp", "unionexp", "minusexp", "catexp", "appexp", "aexp", "rexp",
+  "rep", "qid", "param_list", "param", "id", "type", "atype", "tree_const",
+  "tree_const2", "tree_branch", "tree_label", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+   token YYLEX-NUM.  */
+static const yytype_uint16 yytoknum[] =
+{
+       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
+     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
+     275,    61,    63,    42,    59,   124,    45,    46,    40,    41,
+      91,    93,    43,    58,   123,   125
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+static const yytype_uint8 yyr1[] =
+{
+       0,    36,    37,    38,    38,    39,    39,    39,    39,    39,
+      40,    40,    41,    41,    42,    42,    43,    43,    44,    44,
+      44,    45,    45,    46,    46,    47,    47,    48,    48,    48,
+      48,    48,    48,    49,    49,    50,    50,    50,    51,    51,
+      51,    51,    52,    52,    53,    54,    54,    54,    55,    55,
+      56,    56,    56,    56,    57,    57,    58,    58,    59,    59,
+      60,    60
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
+static const yytype_uint8 yyr2[] =
+{
+       0,     2,     5,     2,     0,     6,     5,     5,     5,     0,
+       3,     5,     1,     1,     7,     1,     3,     1,     3,     1,
+       1,     3,     1,     3,     1,     2,     1,     1,     1,     1,
+       3,     3,     2,     2,     1,     1,     1,     1,     1,     1,
+       1,     1,     2,     0,     5,     1,     1,     1,     3,     1,
+       1,     1,     1,     3,     4,     3,     4,     0,     2,     4,
+       1,     0
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
+   means the default is an error.  */
+static const yytype_uint8 yydefact[] =
+{
+       0,     0,     0,     0,     1,     4,     0,     9,     3,     0,
+       0,     0,     2,    43,     0,    28,    29,    38,    39,    40,
+      41,     0,     0,     0,     0,    27,     0,     0,    43,     0,
+       0,    32,    61,     0,    15,    17,    19,    22,    24,    34,
+      26,    20,     0,     0,     0,     0,    45,    46,    47,     0,
+       0,    42,     9,    43,    60,     0,    57,    30,     0,     0,
+       0,     0,    25,    37,    35,    36,    33,    61,    31,    12,
+      13,     9,     9,    10,     0,     0,     9,     6,     0,    55,
+       0,    58,    16,    18,    21,    23,     0,     8,     7,     0,
+      50,    51,    52,     0,     0,    49,     5,     0,    57,    61,
+      54,    11,     0,    44,     0,     0,    59,     0,    53,    48,
+       0,    56,    14
+};
+
+/* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int8 yydefgoto[] =
+{
+      -1,     2,     7,    12,    23,    71,    33,    34,    35,    36,
+      37,    38,    39,    40,    66,    25,    27,    28,    49,    94,
+      95,    41,    81,    55,    56
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+   STATE-NUM.  */
+#define YYPACT_NINF -90
+static const yytype_int8 yypact[] =
+{
+      -1,     8,    16,    -4,   -90,    14,    26,    53,   -90,    27,
+      29,    92,   -90,    11,    25,   -90,   -90,   -90,   -90,   -90,
+     -90,    50,    55,    28,    -6,   -90,     1,    30,    11,    55,
+      38,   -90,    44,    34,    52,    57,    51,    59,    92,    49,
+     -90,    64,    56,    22,    55,    92,   -90,   -90,   -90,    60,
+      55,   -90,    53,    11,   -90,    65,    80,   -90,    87,    92,
+      92,    92,   -90,   -90,   -90,   -90,   -90,    44,   -90,   -90,
+     -90,    53,    53,   -90,    82,    -5,    53,   -90,    83,   -90,
+     100,    73,    57,    51,    59,    92,    74,   -90,   -90,    55,
+     -90,   -90,   -90,    -5,    79,   104,   -90,    55,   -90,    44,
+     -90,   -90,    84,   -90,    -5,   101,    73,    81,   -90,   -90,
+      55,   -90,   -90
+};
+
+/* YYPGOTO[NTERM-NUM].  */
+static const yytype_int8 yypgoto[] =
+{
+     -90,   -90,   -90,   -34,   -90,   -90,   -22,   -90,    61,    66,
+      58,    62,    -9,   -37,   -90,   -90,   -23,   -90,   -90,   -89,
+     -90,   -90,    31,   -64,   -90
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
+   positive, shift that token.  If negative, reduce the rule which
+   number is the opposite.  If zero, do what YYDEFACT says.
+   If YYTABLE_NINF, syntax error.  */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+      42,    62,    24,    86,   102,    51,    46,    52,     1,    90,
+      91,    92,    44,    45,     3,   109,     4,     5,    77,    47,
+      48,    72,    73,    93,     6,    15,    16,    17,    76,    18,
+      78,     8,    13,    30,    14,   107,    74,    87,    88,    26,
+      19,    20,    96,    53,    69,    70,    29,    54,    62,    43,
+      21,    50,    22,    15,    16,    17,    32,    18,    15,    16,
+      17,    30,    18,    57,     9,    10,    30,   101,    19,    20,
+      11,    63,    64,    19,    20,   105,    58,    60,    21,    31,
+      22,    65,    59,    21,    32,    22,    61,    68,   112,    32,
+      15,    16,    17,    75,    18,    15,    16,    17,    67,    18,
+      79,    80,    89,    98,    97,    19,    20,    99,   103,   100,
+      19,    20,   104,   108,   110,    21,   111,    22,    84,    82,
+      21,    32,    22,    85,     0,    83,     0,     0,     0,   106
+};
+
+static const yytype_int8 yycheck[] =
+{
+      22,    38,    11,    67,    93,    28,     5,    29,     9,    14,
+      15,    16,    18,    19,     6,   104,     0,    21,    52,    18,
+      19,    43,    44,    28,    10,     3,     4,     5,    50,     7,
+      53,     5,     5,    11,     5,    99,    45,    71,    72,    28,
+      18,    19,    76,     5,    22,    23,    21,     3,    85,    21,
+      28,    21,    30,     3,     4,     5,    34,     7,     3,     4,
+       5,    11,     7,    29,    11,    12,    11,    89,    18,    19,
+      17,    22,    23,    18,    19,    97,    24,    26,    28,    29,
+      30,    32,    25,    28,    34,    30,    27,    31,   110,    34,
+       3,     4,     5,    33,     7,     3,     4,     5,    34,     7,
+      35,    21,    20,     3,    21,    18,    19,    34,    29,    35,
+      18,    19,     8,    29,    13,    28,    35,    30,    60,    58,
+      28,    34,    30,    61,    -1,    59,    -1,    -1,    -1,    98
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+   symbol of state STATE-NUM.  */
+static const yytype_uint8 yystos[] =
+{
+       0,     9,    37,     6,     0,    21,    10,    38,     5,    11,
+      12,    17,    39,     5,     5,     3,     4,     5,     7,    18,
+      19,    28,    30,    40,    48,    51,    28,    52,    53,    21,
+      11,    29,    34,    42,    43,    44,    45,    46,    47,    48,
+      49,    57,    42,    21,    18,    19,     5,    18,    19,    54,
+      21,    52,    42,     5,     3,    59,    60,    29,    24,    25,
+      26,    27,    49,    22,    23,    32,    50,    34,    31,    22,
+      23,    41,    42,    42,    48,    33,    42,    39,    52,    35,
+      21,    58,    44,    45,    46,    47,    59,    39,    39,    20,
+      14,    15,    16,    28,    55,    56,    39,    21,     3,    34,
+      35,    42,    55,    29,     8,    42,    58,    59,    29,    55,
+      13,    35,    42
+};
+
+#define yyerrok                (yyerrstatus = 0)
+#define yyclearin      (yychar = YYEMPTY)
+#define YYEMPTY                (-2)
+#define YYEOF          0
+
+#define YYACCEPT       goto yyacceptlab
+#define YYABORT                goto yyabortlab
+#define YYERROR                goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror.  This remains here temporarily
+   to ease the transition to the new meaning of YYERROR, for GCC.
+   Once GCC version 2 has supplanted version 1, this can go.  However,
+   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
+   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+   discussed.  */
+
+#define YYFAIL         goto yyerrlab
+#if defined YYFAIL
+  /* This is here to suppress warnings from the GCC cpp's
+     -Wunused-macros.  Normally we don't worry about that warning, but
+     some users do, and we want to make it easy for users to remove
+     YYFAIL uses, which will produce warnings from Bison 2.5.  */
+#endif
+
+#define YYRECOVERING()  (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value)                                 \
+do                                                             \
+  if (yychar == YYEMPTY && yylen == 1)                         \
+    {                                                          \
+      yychar = (Token);                                                \
+      yylval = (Value);                                                \
+      yytoken = YYTRANSLATE (yychar);                          \
+      YYPOPSTACK (1);                                          \
+      goto yybackup;                                           \
+    }                                                          \
+  else                                                         \
+    {                                                          \
+      yyerror (&yylloc, term, scanner, YY_("syntax error: cannot back up")); \
+      YYERROR;                                                 \
+    }                                                          \
+while (YYID (0))
+
+
+#define YYTERROR       1
+#define YYERRCODE      256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)                               \
+    do                                                                 \
+      if (YYID (N))                                                    \
+       {                                                               \
+         (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
+         (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
+         (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
+         (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
+       }                                                               \
+      else                                                             \
+       {                                                               \
+         (Current).first_line   = (Current).last_line   =              \
+           YYRHSLOC (Rhs, 0).last_line;                                \
+         (Current).first_column = (Current).last_column =              \
+           YYRHSLOC (Rhs, 0).last_column;                              \
+       }                                                               \
+    while (YYID (0))
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+   This macro was not mandated originally: define only if we know
+   we won't break user code: when these are the locations we know.  */
+
+#ifndef YY_LOCATION_PRINT
+# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+#  define YY_LOCATION_PRINT(File, Loc)                 \
+     fprintf (File, "%d.%d-%d.%d",                     \
+             (Loc).first_line, (Loc).first_column,     \
+             (Loc).last_line,  (Loc).last_column)
+# else
+#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments.  */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval, &yylloc, scanner)
+#endif
+
+/* Enable debugging if requested.  */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args)                       \
+do {                                           \
+  if (yydebug)                                 \
+    YYFPRINTF Args;                            \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                   \
+do {                                                                     \
+  if (yydebug)                                                           \
+    {                                                                    \
+      YYFPRINTF (stderr, "%s ", Title);                                          \
+      yy_symbol_print (stderr,                                           \
+                 Type, Value, Location, term, scanner); \
+      YYFPRINTF (stderr, "\n");                                                  \
+    }                                                                    \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct term **term, yyscan_t scanner)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, term, scanner)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+    YYLTYPE const * const yylocationp;
+    struct term **term;
+    yyscan_t scanner;
+#endif
+{
+  if (!yyvaluep)
+    return;
+  YYUSE (yylocationp);
+  YYUSE (term);
+  YYUSE (scanner);
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+  YYUSE (yyoutput);
+# endif
+  switch (yytype)
+    {
+      default:
+       break;
+    }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct term **term, yyscan_t scanner)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, term, scanner)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+    YYLTYPE const * const yylocationp;
+    struct term **term;
+    yyscan_t scanner;
+#endif
+{
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+  YY_LOCATION_PRINT (yyoutput, *yylocationp);
+  YYFPRINTF (yyoutput, ": ");
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, term, scanner);
+  YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included).                                                   |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+    yytype_int16 *yybottom;
+    yytype_int16 *yytop;
+#endif
+{
+  YYFPRINTF (stderr, "Stack now");
+  for (; yybottom <= yytop; yybottom++)
+    {
+      int yybot = *yybottom;
+      YYFPRINTF (stderr, " %d", yybot);
+    }
+  YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top)                           \
+do {                                                           \
+  if (yydebug)                                                 \
+    yy_stack_print ((Bottom), (Top));                          \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced.  |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct term **term, yyscan_t scanner)
+#else
+static void
+yy_reduce_print (yyvsp, yylsp, yyrule, term, scanner)
+    YYSTYPE *yyvsp;
+    YYLTYPE *yylsp;
+    int yyrule;
+    struct term **term;
+    yyscan_t scanner;
+#endif
+{
+  int yynrhs = yyr2[yyrule];
+  int yyi;
+  unsigned long int yylno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+            yyrule - 1, yylno);
+  /* The symbols being reduced.  */
+  for (yyi = 0; yyi < yynrhs; yyi++)
+    {
+      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
+      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+                      &(yyvsp[(yyi + 1) - (yynrhs)])
+                      , &(yylsp[(yyi + 1) - (yynrhs)])                , term, scanner);
+      YYFPRINTF (stderr, "\n");
+    }
+}
+
+# define YY_REDUCE_PRINT(Rule)         \
+do {                                   \
+  if (yydebug)                         \
+    yy_reduce_print (yyvsp, yylsp, Rule, term, scanner); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace.  It is left uninitialized so that
+   multiple parsers can coexist.  */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks.  */
+#ifndef        YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+   if the built-in stack extension method is used).
+
+   Do not make this value too large; the results are undefined if
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+   evaluated with infinite-precision integer arithmetic.  */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+\f
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+#  if defined __GLIBC__ && defined _STRING_H
+#   define yystrlen strlen
+#  else
+/* Return the length of YYSTR.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+    const char *yystr;
+#endif
+{
+  YYSIZE_T yylen;
+  for (yylen = 0; yystr[yylen]; yylen++)
+    continue;
+  return yylen;
+}
+#  endif
+# endif
+
+# ifndef yystpcpy
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+#   define yystpcpy stpcpy
+#  else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+   YYDEST.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+    char *yydest;
+    const char *yysrc;
+#endif
+{
+  char *yyd = yydest;
+  const char *yys = yysrc;
+
+  while ((*yyd++ = *yys++) != '\0')
+    continue;
+
+  return yyd - 1;
+}
+#  endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+   quotes and backslashes, so that it's suitable for yyerror.  The
+   heuristic is that double-quoting is unnecessary unless the string
+   contains an apostrophe, a comma, or backslash (other than
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
+   null, do not copy; instead, return the length of what the result
+   would have been.  */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+  if (*yystr == '"')
+    {
+      YYSIZE_T yyn = 0;
+      char const *yyp = yystr;
+
+      for (;;)
+       switch (*++yyp)
+         {
+         case '\'':
+         case ',':
+           goto do_not_strip_quotes;
+
+         case '\\':
+           if (*++yyp != '\\')
+             goto do_not_strip_quotes;
+           /* Fall through.  */
+         default:
+           if (yyres)
+             yyres[yyn] = *yyp;
+           yyn++;
+           break;
+
+         case '"':
+           if (yyres)
+             yyres[yyn] = '\0';
+           return yyn;
+         }
+    do_not_strip_quotes: ;
+    }
+
+  if (! yyres)
+    return yystrlen (yystr);
+
+  return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
+   including the terminating null byte.  If YYRESULT is null, do not
+   copy anything; just return the number of bytes that would be
+   copied.  As a special case, return 0 if an ordinary "syntax error"
+   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
+   size calculation.  */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
+{
+  int yyn = yypact[yystate];
+
+  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+    return 0;
+  else
+    {
+      int yytype = YYTRANSLATE (yychar);
+      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+      YYSIZE_T yysize = yysize0;
+      YYSIZE_T yysize1;
+      int yysize_overflow = 0;
+      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+      int yyx;
+
+# if 0
+      /* This is so xgettext sees the translatable formats that are
+        constructed on the fly.  */
+      YY_("syntax error, unexpected %s");
+      YY_("syntax error, unexpected %s, expecting %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+      char *yyfmt;
+      char const *yyf;
+      static char const yyunexpected[] = "syntax error, unexpected %s";
+      static char const yyexpecting[] = ", expecting %s";
+      static char const yyor[] = " or %s";
+      char yyformat[sizeof yyunexpected
+                   + sizeof yyexpecting - 1
+                   + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+                      * (sizeof yyor - 1))];
+      char const *yyprefix = yyexpecting;
+
+      /* Start YYX at -YYN if negative to avoid negative indexes in
+        YYCHECK.  */
+      int yyxbegin = yyn < 0 ? -yyn : 0;
+
+      /* Stay within bounds of both yycheck and yytname.  */
+      int yychecklim = YYLAST - yyn + 1;
+      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+      int yycount = 1;
+
+      yyarg[0] = yytname[yytype];
+      yyfmt = yystpcpy (yyformat, yyunexpected);
+
+      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+         {
+           if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+             {
+               yycount = 1;
+               yysize = yysize0;
+               yyformat[sizeof yyunexpected - 1] = '\0';
+               break;
+             }
+           yyarg[yycount++] = yytname[yyx];
+           yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+           yysize_overflow |= (yysize1 < yysize);
+           yysize = yysize1;
+           yyfmt = yystpcpy (yyfmt, yyprefix);
+           yyprefix = yyor;
+         }
+
+      yyf = YY_(yyformat);
+      yysize1 = yysize + yystrlen (yyf);
+      yysize_overflow |= (yysize1 < yysize);
+      yysize = yysize1;
+
+      if (yysize_overflow)
+       return YYSIZE_MAXIMUM;
+
+      if (yyresult)
+       {
+         /* Avoid sprintf, as that infringes on the user's name space.
+            Don't have undefined behavior even if the translation
+            produced a string with the wrong number of "%s"s.  */
+         char *yyp = yyresult;
+         int yyi = 0;
+         while ((*yyp = *yyf) != '\0')
+           {
+             if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+               {
+                 yyp += yytnamerr (yyp, yyarg[yyi++]);
+                 yyf += 2;
+               }
+             else
+               {
+                 yyp++;
+                 yyf++;
+               }
+           }
+       }
+      return yysize;
+    }
+}
+#endif /* YYERROR_VERBOSE */
+\f
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol.  |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct term **term, yyscan_t scanner)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep, yylocationp, term, scanner)
+    const char *yymsg;
+    int yytype;
+    YYSTYPE *yyvaluep;
+    YYLTYPE *yylocationp;
+    struct term **term;
+    yyscan_t scanner;
+#endif
+{
+  YYUSE (yyvaluep);
+  YYUSE (yylocationp);
+  YYUSE (term);
+  YYUSE (scanner);
+
+  if (!yymsg)
+    yymsg = "Deleting";
+  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+  switch (yytype)
+    {
+
+      default:
+       break;
+    }
+}
+
+/* Prevent warnings from -Wmissing-prototypes.  */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (struct term **term, yyscan_t scanner);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+
+
+/*-------------------------.
+| yyparse or yypush_parse.  |
+`-------------------------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+    void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (struct term **term, yyscan_t scanner)
+#else
+int
+yyparse (term, scanner)
+    struct term **term;
+    yyscan_t scanner;
+#endif
+#endif
+{
+/* The lookahead symbol.  */
+int yychar;
+
+/* The semantic value of the lookahead symbol.  */
+YYSTYPE yylval;
+
+/* Location data for the lookahead symbol.  */
+YYLTYPE yylloc;
+
+    /* Number of syntax errors so far.  */
+    int yynerrs;
+
+    int yystate;
+    /* Number of tokens to shift before error messages enabled.  */
+    int yyerrstatus;
+
+    /* The stacks and their tools:
+       `yyss': related to states.
+       `yyvs': related to semantic values.
+       `yyls': related to locations.
+
+       Refer to the stacks thru separate pointers, to allow yyoverflow
+       to reallocate them elsewhere.  */
+
+    /* The state stack.  */
+    yytype_int16 yyssa[YYINITDEPTH];
+    yytype_int16 *yyss;
+    yytype_int16 *yyssp;
+
+    /* The semantic value stack.  */
+    YYSTYPE yyvsa[YYINITDEPTH];
+    YYSTYPE *yyvs;
+    YYSTYPE *yyvsp;
+
+    /* The location stack.  */
+    YYLTYPE yylsa[YYINITDEPTH];
+    YYLTYPE *yyls;
+    YYLTYPE *yylsp;
+
+    /* The locations where the error started and ended.  */
+    YYLTYPE yyerror_range[3];
+
+    YYSIZE_T yystacksize;
+
+  int yyn;
+  int yyresult;
+  /* Lookahead token as an internal (translated) token number.  */
+  int yytoken;
+  /* The variables used to return semantic value and location from the
+     action routines.  */
+  YYSTYPE yyval;
+  YYLTYPE yyloc;
+
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
+
+  /* The number of symbols on the RHS of the reduced rule.
+     Keep to zero when no symbol should be popped.  */
+  int yylen = 0;
+
+  yytoken = 0;
+  yyss = yyssa;
+  yyvs = yyvsa;
+  yyls = yylsa;
+  yystacksize = YYINITDEPTH;
+
+  YYDPRINTF ((stderr, "Starting parse\n"));
+
+  yystate = 0;
+  yyerrstatus = 0;
+  yynerrs = 0;
+  yychar = YYEMPTY; /* Cause a token to be read.  */
+
+  /* Initialize stack pointers.
+     Waste one element of value and location stack
+     so that they stay on the same level as the state stack.
+     The wasted elements are never initialized.  */
+  yyssp = yyss;
+  yyvsp = yyvs;
+  yylsp = yyls;
+
+#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+  /* Initialize the default location before parsing starts.  */
+  yylloc.first_line   = yylloc.last_line   = 1;
+  yylloc.first_column = yylloc.last_column = 1;
+#endif
+
+/* User initialization code.  */
+
+/* Line 1251 of yacc.c  */
+#line 66 "parser.y"
+{
+  yylloc.first_line   = 1;
+  yylloc.first_column = 0;
+  yylloc.last_line    = 1;
+  yylloc.last_column  = 0;
+  yylloc.filename     = augl_get_info(scanner)->filename;
+  yylloc.error        = augl_get_info(scanner)->error;
+}
+
+/* Line 1251 of yacc.c  */
+#line 1504 "parser.c"
+  yylsp[0] = yylloc;
+
+  goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate.  |
+`------------------------------------------------------------*/
+ yynewstate:
+  /* In all cases, when you get here, the value and location stacks
+     have just been pushed.  So pushing a state here evens the stacks.  */
+  yyssp++;
+
+ yysetstate:
+  *yyssp = yystate;
+
+  if (yyss + yystacksize - 1 <= yyssp)
+    {
+      /* Get the current used size of the three stacks, in elements.  */
+      YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+      {
+       /* Give user a chance to reallocate the stack.  Use copies of
+          these so that the &'s don't force the real ones into
+          memory.  */
+       YYSTYPE *yyvs1 = yyvs;
+       yytype_int16 *yyss1 = yyss;
+       YYLTYPE *yyls1 = yyls;
+
+       /* Each stack pointer address is followed by the size of the
+          data in use in that stack, in bytes.  This used to be a
+          conditional around just the two extra args, but that might
+          be undefined if yyoverflow is a macro.  */
+       yyoverflow (YY_("memory exhausted"),
+                   &yyss1, yysize * sizeof (*yyssp),
+                   &yyvs1, yysize * sizeof (*yyvsp),
+                   &yyls1, yysize * sizeof (*yylsp),
+                   &yystacksize);
+
+       yyls = yyls1;
+       yyss = yyss1;
+       yyvs = yyvs1;
+      }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+      goto yyexhaustedlab;
+# else
+      /* Extend the stack our own way.  */
+      if (YYMAXDEPTH <= yystacksize)
+       goto yyexhaustedlab;
+      yystacksize *= 2;
+      if (YYMAXDEPTH < yystacksize)
+       yystacksize = YYMAXDEPTH;
+
+      {
+       yytype_int16 *yyss1 = yyss;
+       union yyalloc *yyptr =
+         (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+       if (! yyptr)
+         goto yyexhaustedlab;
+       YYSTACK_RELOCATE (yyss_alloc, yyss);
+       YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+       YYSTACK_RELOCATE (yyls_alloc, yyls);
+#  undef YYSTACK_RELOCATE
+       if (yyss1 != yyssa)
+         YYSTACK_FREE (yyss1);
+      }
+# endif
+#endif /* no yyoverflow */
+
+      yyssp = yyss + yysize - 1;
+      yyvsp = yyvs + yysize - 1;
+      yylsp = yyls + yysize - 1;
+
+      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+                 (unsigned long int) yystacksize));
+
+      if (yyss + yystacksize - 1 <= yyssp)
+       YYABORT;
+    }
+
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+  if (yystate == YYFINAL)
+    YYACCEPT;
+
+  goto yybackup;
+
+/*-----------.
+| yybackup.  |
+`-----------*/
+yybackup:
+
+  /* Do appropriate processing given the current state.  Read a
+     lookahead token if we need one and don't already have one.  */
+
+  /* First try to decide what to do without reference to lookahead token.  */
+  yyn = yypact[yystate];
+  if (yyn == YYPACT_NINF)
+    goto yydefault;
+
+  /* Not known => get a lookahead token if don't already have one.  */
+
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
+  if (yychar == YYEMPTY)
+    {
+      YYDPRINTF ((stderr, "Reading a token: "));
+      yychar = YYLEX;
+    }
+
+  if (yychar <= YYEOF)
+    {
+      yychar = yytoken = YYEOF;
+      YYDPRINTF ((stderr, "Now at end of input.\n"));
+    }
+  else
+    {
+      yytoken = YYTRANSLATE (yychar);
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+    }
+
+  /* If the proper action on seeing token YYTOKEN is to reduce or to
+     detect an error, take that action.  */
+  yyn += yytoken;
+  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+    goto yydefault;
+  yyn = yytable[yyn];
+  if (yyn <= 0)
+    {
+      if (yyn == 0 || yyn == YYTABLE_NINF)
+       goto yyerrlab;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
+
+  /* Shift the lookahead token.  */
+  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+  /* Discard the shifted token.  */
+  yychar = YYEMPTY;
+
+  yystate = yyn;
+  *++yyvsp = yylval;
+  *++yylsp = yylloc;
+  goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state.  |
+`-----------------------------------------------------------*/
+yydefault:
+  yyn = yydefact[yystate];
+  if (yyn == 0)
+    goto yyerrlab;
+  goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction.  |
+`-----------------------------*/
+yyreduce:
+  /* yyn is the number of a rule to reduce with.  */
+  yylen = yyr2[yyn];
+
+  /* If YYLEN is nonzero, implement the default value of the action:
+     `$$ = $1'.
+
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
+     users should not rely upon it.  Assigning to YYVAL
+     unconditionally makes the parser a bit smaller, and it avoids a
+     GCC warning that YYVAL may be used uninitialized.  */
+  yyval = yyvsp[1-yylen];
+
+  /* Default location.  */
+  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
+  YY_REDUCE_PRINT (yyn);
+  switch (yyn)
+    {
+        case 2:
+
+/* Line 1464 of yacc.c  */
+#line 180 "parser.y"
+    { (*term) = make_module((yyvsp[(2) - (5)].string), (yyvsp[(4) - (5)].string), (yyvsp[(5) - (5)].term), &(yylsp[(1) - (5)])); }
+    break;
+
+  case 3:
+
+/* Line 1464 of yacc.c  */
+#line 183 "parser.y"
+    { (yyval.string) = (yyvsp[(2) - (2)].string); }
+    break;
+
+  case 4:
+
+/* Line 1464 of yacc.c  */
+#line 185 "parser.y"
+    { (yyval.string) = NULL; }
+    break;
+
+  case 5:
+
+/* Line 1464 of yacc.c  */
+#line 188 "parser.y"
+    {
+         LOC_MERGE((yylsp[(1) - (6)]), (yylsp[(1) - (6)]), (yylsp[(5) - (6)]));
+         (yyval.term) = make_bind((yyvsp[(2) - (6)].string), (yyvsp[(3) - (6)].term), (yyvsp[(5) - (6)].term), (yyvsp[(6) - (6)].term), &(yylsp[(1) - (6)]));
+       }
+    break;
+
+  case 6:
+
+/* Line 1464 of yacc.c  */
+#line 193 "parser.y"
+    {
+         LOC_MERGE((yylsp[(1) - (5)]), (yylsp[(1) - (5)]), (yylsp[(4) - (5)]));
+         (yyval.term) = make_bind_rec((yyvsp[(2) - (5)].string), (yyvsp[(4) - (5)].term), (yyvsp[(5) - (5)].term), &(yylsp[(1) - (5)]));
+       }
+    break;
+
+  case 7:
+
+/* Line 1464 of yacc.c  */
+#line 198 "parser.y"
+    {
+         LOC_MERGE((yylsp[(1) - (5)]), (yylsp[(1) - (5)]), (yylsp[(4) - (5)]));
+         (yyval.term) = make_test((yyvsp[(2) - (5)].term), (yyvsp[(4) - (5)].term), TR_CHECK, (yyvsp[(5) - (5)].term), &(yylsp[(1) - (5)]));
+       }
+    break;
+
+  case 8:
+
+/* Line 1464 of yacc.c  */
+#line 203 "parser.y"
+    {
+         LOC_MERGE((yylsp[(1) - (5)]), (yylsp[(1) - (5)]), (yylsp[(4) - (5)]));
+         (yyval.term) = make_test((yyvsp[(2) - (5)].term), NULL, (yyvsp[(4) - (5)].intval), (yyvsp[(5) - (5)].term), &(yylsp[(1) - (5)]));
+       }
+    break;
+
+  case 9:
+
+/* Line 1464 of yacc.c  */
+#line 208 "parser.y"
+    { (yyval.term) = NULL; }
+    break;
+
+  case 10:
+
+/* Line 1464 of yacc.c  */
+#line 213 "parser.y"
+    { (yyval.term) = make_get_test((yyvsp[(1) - (3)].term), (yyvsp[(3) - (3)].term), &(yyloc)); }
+    break;
+
+  case 11:
+
+/* Line 1464 of yacc.c  */
+#line 215 "parser.y"
+    { (yyval.term) = make_put_test((yyvsp[(1) - (5)].term), (yyvsp[(3) - (5)].term), (yyvsp[(5) - (5)].term), &(yyloc)); }
+    break;
+
+  case 12:
+
+/* Line 1464 of yacc.c  */
+#line 218 "parser.y"
+    { (yyval.intval) = TR_PRINT; }
+    break;
+
+  case 13:
+
+/* Line 1464 of yacc.c  */
+#line 220 "parser.y"
+    { (yyval.intval) = TR_EXN; }
+    break;
+
+  case 14:
+
+/* Line 1464 of yacc.c  */
+#line 224 "parser.y"
+    {
+       LOC_MERGE((yylsp[(1) - (7)]), (yylsp[(1) - (7)]), (yylsp[(6) - (7)]));
+       (yyval.term) = make_let((yyvsp[(2) - (7)].string), (yyvsp[(3) - (7)].term), (yyvsp[(5) - (7)].term), (yyvsp[(7) - (7)].term), &(yylsp[(1) - (7)]));
+     }
+    break;
+
+  case 16:
+
+/* Line 1464 of yacc.c  */
+#line 231 "parser.y"
+    { (yyval.term) = make_binop(A_COMPOSE, (yyvsp[(1) - (3)].term), (yyvsp[(3) - (3)].term), &(yyloc)); }
+    break;
+
+  case 17:
+
+/* Line 1464 of yacc.c  */
+#line 233 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 18:
+
+/* Line 1464 of yacc.c  */
+#line 236 "parser.y"
+    { (yyval.term) = make_binop(A_UNION, (yyvsp[(1) - (3)].term), (yyvsp[(3) - (3)].term), &(yyloc)); }
+    break;
+
+  case 19:
+
+/* Line 1464 of yacc.c  */
+#line 238 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 20:
+
+/* Line 1464 of yacc.c  */
+#line 240 "parser.y"
+    { (yyval.term) = make_tree_value((yyvsp[(1) - (1)].tree), &(yylsp[(1) - (1)])); }
+    break;
+
+  case 21:
+
+/* Line 1464 of yacc.c  */
+#line 243 "parser.y"
+    { (yyval.term) = make_binop(A_MINUS, (yyvsp[(1) - (3)].term), (yyvsp[(3) - (3)].term), &(yyloc)); }
+    break;
+
+  case 22:
+
+/* Line 1464 of yacc.c  */
+#line 245 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 23:
+
+/* Line 1464 of yacc.c  */
+#line 248 "parser.y"
+    { (yyval.term) = make_binop(A_CONCAT, (yyvsp[(1) - (3)].term), (yyvsp[(3) - (3)].term), &(yyloc)); }
+    break;
+
+  case 24:
+
+/* Line 1464 of yacc.c  */
+#line 250 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 25:
+
+/* Line 1464 of yacc.c  */
+#line 253 "parser.y"
+    { (yyval.term) = make_binop(A_APP, (yyvsp[(1) - (2)].term), (yyvsp[(2) - (2)].term), &(yyloc)); }
+    break;
+
+  case 26:
+
+/* Line 1464 of yacc.c  */
+#line 255 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 27:
+
+/* Line 1464 of yacc.c  */
+#line 258 "parser.y"
+    { (yyval.term) = make_ident((yyvsp[(1) - (1)].string), &(yylsp[(1) - (1)])); }
+    break;
+
+  case 28:
+
+/* Line 1464 of yacc.c  */
+#line 260 "parser.y"
+    { (yyval.term) = make_string_term((yyvsp[(1) - (1)].string), &(yylsp[(1) - (1)])); }
+    break;
+
+  case 29:
+
+/* Line 1464 of yacc.c  */
+#line 262 "parser.y"
+    { (yyval.term) = make_regexp_term((yyvsp[(1) - (1)].regexp).pattern, (yyvsp[(1) - (1)].regexp).nocase, &(yylsp[(1) - (1)])); }
+    break;
+
+  case 30:
+
+/* Line 1464 of yacc.c  */
+#line 264 "parser.y"
+    { (yyval.term) = (yyvsp[(2) - (3)].term); }
+    break;
+
+  case 31:
+
+/* Line 1464 of yacc.c  */
+#line 266 "parser.y"
+    { (yyval.term) = make_unop(A_BRACKET, (yyvsp[(2) - (3)].term), &(yyloc)); }
+    break;
+
+  case 32:
+
+/* Line 1464 of yacc.c  */
+#line 268 "parser.y"
+    { (yyval.term) = make_unit_term(&(yyloc)); }
+    break;
+
+  case 33:
+
+/* Line 1464 of yacc.c  */
+#line 271 "parser.y"
+    { (yyval.term) = make_rep((yyvsp[(1) - (2)].term), (yyvsp[(2) - (2)].quant), &(yyloc)); }
+    break;
+
+  case 34:
+
+/* Line 1464 of yacc.c  */
+#line 273 "parser.y"
+    { (yyval.term) = (yyvsp[(1) - (1)].term); }
+    break;
+
+  case 35:
+
+/* Line 1464 of yacc.c  */
+#line 276 "parser.y"
+    { (yyval.quant) = Q_STAR; }
+    break;
+
+  case 36:
+
+/* Line 1464 of yacc.c  */
+#line 278 "parser.y"
+    { (yyval.quant) = Q_PLUS; }
+    break;
+
+  case 37:
+
+/* Line 1464 of yacc.c  */
+#line 280 "parser.y"
+    { (yyval.quant) = Q_MAYBE; }
+    break;
+
+  case 38:
+
+/* Line 1464 of yacc.c  */
+#line 283 "parser.y"
+    { (yyval.string) = (yyvsp[(1) - (1)].string); }
+    break;
+
+  case 39:
+
+/* Line 1464 of yacc.c  */
+#line 285 "parser.y"
+    { (yyval.string) = (yyvsp[(1) - (1)].string); }
+    break;
+
+  case 40:
+
+/* Line 1464 of yacc.c  */
+#line 287 "parser.y"
+    { (yyval.string) = strdup("get"); }
+    break;
+
+  case 41:
+
+/* Line 1464 of yacc.c  */
+#line 289 "parser.y"
+    { (yyval.string) = strdup("put"); }
+    break;
+
+  case 42:
+
+/* Line 1464 of yacc.c  */
+#line 292 "parser.y"
+    { (yyval.term) = (yyvsp[(2) - (2)].term); list_cons((yyval.term), (yyvsp[(1) - (2)].term)); }
+    break;
+
+  case 43:
+
+/* Line 1464 of yacc.c  */
+#line 294 "parser.y"
+    { (yyval.term) = NULL; }
+    break;
+
+  case 44:
+
+/* Line 1464 of yacc.c  */
+#line 297 "parser.y"
+    { (yyval.term) = make_param((yyvsp[(2) - (5)].string), (yyvsp[(4) - (5)].type), clone_info(&(yylsp[(1) - (5)]))); }
+    break;
+
+  case 45:
+
+/* Line 1464 of yacc.c  */
+#line 300 "parser.y"
+    { (yyval.string) = (yyvsp[(1) - (1)].string); }
+    break;
+
+  case 46:
+
+/* Line 1464 of yacc.c  */
+#line 302 "parser.y"
+    { (yyval.string) = strdup("get"); }
+    break;
+
+  case 47:
+
+/* Line 1464 of yacc.c  */
+#line 304 "parser.y"
+    { (yyval.string) = strdup("put"); }
+    break;
+
+  case 48:
+
+/* Line 1464 of yacc.c  */
+#line 307 "parser.y"
+    { (yyval.type) = make_arrow_type((yyvsp[(1) - (3)].type), (yyvsp[(3) - (3)].type)); }
+    break;
+
+  case 49:
+
+/* Line 1464 of yacc.c  */
+#line 309 "parser.y"
+    { (yyval.type) = (yyvsp[(1) - (1)].type); }
+    break;
+
+  case 50:
+
+/* Line 1464 of yacc.c  */
+#line 312 "parser.y"
+    { (yyval.type) = make_base_type(T_STRING); }
+    break;
+
+  case 51:
+
+/* Line 1464 of yacc.c  */
+#line 314 "parser.y"
+    { (yyval.type) = make_base_type(T_REGEXP); }
+    break;
+
+  case 52:
+
+/* Line 1464 of yacc.c  */
+#line 316 "parser.y"
+    { (yyval.type) = make_base_type(T_LENS); }
+    break;
+
+  case 53:
+
+/* Line 1464 of yacc.c  */
+#line 318 "parser.y"
+    { (yyval.type) = (yyvsp[(2) - (3)].type); }
+    break;
+
+  case 54:
+
+/* Line 1464 of yacc.c  */
+#line 321 "parser.y"
+    { (yyval.tree) = tree_concat((yyvsp[(1) - (4)].tree), (yyvsp[(3) - (4)].tree)); }
+    break;
+
+  case 55:
+
+/* Line 1464 of yacc.c  */
+#line 323 "parser.y"
+    { (yyval.tree) = tree_concat((yyvsp[(2) - (3)].tree), NULL); }
+    break;
+
+  case 56:
+
+/* Line 1464 of yacc.c  */
+#line 326 "parser.y"
+    {
+              (yyval.tree) = tree_concat((yyvsp[(1) - (4)].tree), (yyvsp[(3) - (4)].tree));
+            }
+    break;
+
+  case 57:
+
+/* Line 1464 of yacc.c  */
+#line 330 "parser.y"
+    { (yyval.tree) = NULL; }
+    break;
+
+  case 58:
+
+/* Line 1464 of yacc.c  */
+#line 333 "parser.y"
+    {
+               (yyval.tree) = make_tree((yyvsp[(1) - (2)].string), NULL, NULL, (yyvsp[(2) - (2)].tree));
+             }
+    break;
+
+  case 59:
+
+/* Line 1464 of yacc.c  */
+#line 337 "parser.y"
+    {
+               (yyval.tree) = make_tree((yyvsp[(1) - (4)].string), (yyvsp[(3) - (4)].string), NULL, (yyvsp[(4) - (4)].tree));
+             }
+    break;
+
+  case 61:
+
+/* Line 1464 of yacc.c  */
+#line 342 "parser.y"
+    { (yyval.string) = NULL; }
+    break;
+
+
+
+/* Line 1464 of yacc.c  */
+#line 2119 "parser.c"
+      default: break;
+    }
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+
+  *++yyvsp = yyval;
+  *++yylsp = yyloc;
+
+  /* Now `shift' the result of the reduction.  Determine what state
+     that goes to, based on the state we popped back to and the rule
+     number reduced by.  */
+
+  yyn = yyr1[yyn];
+
+  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+    yystate = yytable[yystate];
+  else
+    yystate = yydefgoto[yyn - YYNTOKENS];
+
+  goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+  /* If not already recovering from an error, report this error.  */
+  if (!yyerrstatus)
+    {
+      ++yynerrs;
+#if ! YYERROR_VERBOSE
+      yyerror (&yylloc, term, scanner, YY_("syntax error"));
+#else
+      {
+       YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+       if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+         {
+           YYSIZE_T yyalloc = 2 * yysize;
+           if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+             yyalloc = YYSTACK_ALLOC_MAXIMUM;
+           if (yymsg != yymsgbuf)
+             YYSTACK_FREE (yymsg);
+           yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+           if (yymsg)
+             yymsg_alloc = yyalloc;
+           else
+             {
+               yymsg = yymsgbuf;
+               yymsg_alloc = sizeof yymsgbuf;
+             }
+         }
+
+       if (0 < yysize && yysize <= yymsg_alloc)
+         {
+           (void) yysyntax_error (yymsg, yystate, yychar);
+           yyerror (&yylloc, term, scanner, yymsg);
+         }
+       else
+         {
+           yyerror (&yylloc, term, scanner, YY_("syntax error"));
+           if (yysize != 0)
+             goto yyexhaustedlab;
+         }
+      }
+#endif
+    }
+
+  yyerror_range[1] = yylloc;
+
+  if (yyerrstatus == 3)
+    {
+      /* If just tried and failed to reuse lookahead token after an
+        error, discard it.  */
+
+      if (yychar <= YYEOF)
+       {
+         /* Return failure if at end of input.  */
+         if (yychar == YYEOF)
+           YYABORT;
+       }
+      else
+       {
+         yydestruct ("Error: discarding",
+                     yytoken, &yylval, &yylloc, term, scanner);
+         yychar = YYEMPTY;
+       }
+    }
+
+  /* Else will try to reuse lookahead token after shifting the error
+     token.  */
+  goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
+
+  /* Pacify compilers like GCC when the user code never invokes
+     YYERROR and the label yyerrorlab therefore never appears in user
+     code.  */
+  if (/*CONSTCOND*/ 0)
+     goto yyerrorlab;
+
+  yyerror_range[1] = yylsp[1-yylen];
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYERROR.  */
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+  yystate = *yyssp;
+  goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
+yyerrlab1:
+  yyerrstatus = 3;     /* Each real token shifted decrements this.  */
+
+  for (;;)
+    {
+      yyn = yypact[yystate];
+      if (yyn != YYPACT_NINF)
+       {
+         yyn += YYTERROR;
+         if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+           {
+             yyn = yytable[yyn];
+             if (0 < yyn)
+               break;
+           }
+       }
+
+      /* Pop the current state because it cannot handle the error token.  */
+      if (yyssp == yyss)
+       YYABORT;
+
+      yyerror_range[1] = *yylsp;
+      yydestruct ("Error: popping",
+                 yystos[yystate], yyvsp, yylsp, term, scanner);
+      YYPOPSTACK (1);
+      yystate = *yyssp;
+      YY_STACK_PRINT (yyss, yyssp);
+    }
+
+  *++yyvsp = yylval;
+
+  yyerror_range[2] = yylloc;
+  /* Using YYLLOC is tempting, but would change the location of
+     the lookahead.  YYLOC is available though.  */
+  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
+  *++yylsp = yyloc;
+
+  /* Shift the error token.  */
+  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+  yystate = yyn;
+  goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here.  |
+`-------------------------------------*/
+yyacceptlab:
+  yyresult = 0;
+  goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here.  |
+`-----------------------------------*/
+yyabortlab:
+  yyresult = 1;
+  goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here.  |
+`-------------------------------------------------*/
+yyexhaustedlab:
+  yyerror (&yylloc, term, scanner, YY_("memory exhausted"));
+  yyresult = 2;
+  /* Fall through.  */
+#endif
+
+yyreturn:
+  if (yychar != YYEMPTY)
+     yydestruct ("Cleanup: discarding lookahead",
+                yytoken, &yylval, &yylloc, term, scanner);
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYABORT or YYACCEPT.  */
+  YYPOPSTACK (yylen);
+  YY_STACK_PRINT (yyss, yyssp);
+  while (yyssp != yyss)
+    {
+      yydestruct ("Cleanup: popping",
+                 yystos[*yyssp], yyvsp, yylsp, term, scanner);
+      YYPOPSTACK (1);
+    }
+#ifndef yyoverflow
+  if (yyss != yyssa)
+    YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+  if (yymsg != yymsgbuf)
+    YYSTACK_FREE (yymsg);
+#endif
+  /* Make sure YYID is used.  */
+  return YYID (yyresult);
+}
+
+
+
+/* Line 1684 of yacc.c  */
+#line 343 "parser.y"
+
+
+int augl_parse_file(struct augeas *aug, const char *name,
+                    struct term **term) {
+  yyscan_t          scanner;
+  struct state      state;
+  struct string  *sname = NULL;
+  struct info    info;
+  int result = -1;
+  int r;
+
+  *term = NULL;
+
+  r = make_ref(sname);
+  ERR_NOMEM(r < 0, aug);
+
+  sname->str = strdup(name);
+  ERR_NOMEM(sname->str == NULL, aug);
+
+  MEMZERO(&info, 1);
+  info.ref = UINT_MAX;
+  info.filename = sname;
+  info.error = aug->error;
+
+  MEMZERO(&state, 1);
+  state.info = &info;
+  state.comment_depth = 0;
+
+  if (augl_init_lexer(&state, &scanner) < 0) {
+    augl_error(&info, term, NULL, "file not found");
+    goto error;
+  }
+
+  yydebug = getenv("YYDEBUG") != NULL;
+  r = augl_parse(term, scanner);
+  augl_close_lexer(scanner);
+  augl_lex_destroy(scanner);
+  if (r == 1) {
+    augl_error(&info, term, NULL, "syntax error");
+    goto error;
+  } else if (r == 2) {
+    augl_error(&info, term, NULL, "parser ran out of memory");
+    ERR_NOMEM(1, aug);
+  }
+  result = 0;
+
+ error:
+  unref(sname, string);
+  // free TERM
+  return result;
+}
+
+// FIXME: Nothing here checks for alloc errors.
+static struct info *clone_info(struct info *locp) {
+  struct info *info;
+  make_ref(info);
+  info->filename     = ref(locp->filename);
+  info->first_line   = locp->first_line;
+  info->first_column = locp->first_column;
+  info->last_line    = locp->last_line;
+  info->last_column  = locp->last_column;
+  info->error        = locp->error;
+  return info;
+}
+
+static struct term *make_term_locp(enum term_tag tag, struct info *locp) {
+  struct info *info = clone_info(locp);
+  return make_term(tag, info);
+}
+
+static struct term *make_module(char *ident, char *autoload,
+                                struct term *decls,
+                                struct info *locp) {
+  struct term *term = make_term_locp(A_MODULE, locp);
+  term->mname = ident;
+  term->autoload = autoload;
+  term->decls = decls;
+  return term;
+}
+
+static struct term *make_bind(char *ident, struct term *params,
+                              struct term *exp, struct term *decls,
+                              struct info *locp) {
+  struct term *term = make_term_locp(A_BIND, locp);
+  if (params != NULL)
+    exp = build_func(params, exp);
+
+  term->bname = ident;
+  term->exp = exp;
+  list_cons(decls, term);
+  return decls;
+}
+
+static struct term *make_bind_rec(char *ident, struct term *exp,
+                                  struct term *decls, struct info *locp) {
+  /* Desugar let rec IDENT = EXP as
+   *  let IDENT =
+   *    let RLENS = (lns_make_rec) in
+   *    lns_check_rec ((lambda IDENT: EXP) RLENS) RLENS
+   * where RLENS is a brandnew recursive lens.
+   *
+   * That only works since we know that 'let rec' is only defined for lenses,
+   * not general purposes functions, i.e. we know that IDENT has type 'lens'
+   *
+   * The point of all this is that we make it possible to put a recursive
+   * lens (which is a placeholder for the actual recursion) into arbitrary
+   * places in some bigger lens and then have LNS_CHECK_REC rattle through
+   * to do the special-purpose typechecking.
+   */
+  char *id;
+  struct info *info = exp->info;
+  struct term *lambda = NULL, *rlens = NULL;
+  struct term *app1 = NULL, *app2 = NULL, *app3 = NULL;
+
+  id = strdup(ident);
+  if (id == NULL) goto error;
+
+  lambda = make_param(id, make_base_type(T_LENS), ref(info));
+  if (lambda == NULL) goto error;
+  id = NULL;
+
+  build_func(lambda, exp);
+
+  rlens = make_term(A_VALUE, ref(exp->info));
+  if (rlens == NULL) goto error;
+  rlens->value = lns_make_rec(ref(exp->info));
+  if (rlens->value == NULL) goto error;
+  rlens->type = make_base_type(T_LENS);
+
+  app1 = make_app_term(lambda, rlens, ref(info));
+  if (app1 == NULL) goto error;
+
+  id = strdup(LNS_CHECK_REC_NAME);
+  if (id == NULL) goto error;
+  app2 = make_app_ident(id, app1, ref(info));
+  if (app2 == NULL) goto error;
+  id = NULL;
+
+  app3 = make_app_term(app2, ref(rlens), ref(info));
+  if (app3 == NULL) goto error;
+
+  return make_bind(ident, NULL, app3, decls, locp);
+
+ error:
+  free(id);
+  unref(lambda, term);
+  unref(rlens, term);
+  unref(app1, term);
+  unref(app2, term);
+  unref(app3, term);
+  return NULL;
+}
+
+static struct term *make_let(char *ident, struct term *params,
+                             struct term *exp, struct term *body,
+                             struct info *locp) {
+  /* let f (x:string) = "f " . x in
+     f "a" . f "b" */
+  /* (lambda f: f "a" . f "b") (lambda x: "f " . x) */
+  /* (lambda IDENT: BODY) (lambda PARAMS: EXP) */
+  /* Desugar as (lambda IDENT: BODY) (lambda PARAMS: EXP) */
+  struct term *term = make_term_locp(A_LET, locp);
+  struct term *p = make_param(ident, NULL, ref(term->info));
+  term->left = build_func(p, body);
+  if (params != NULL)
+    term->right = build_func(params, exp);
+  else
+    term->right = exp;
+  return term;
+}
+
+static struct term *make_binop(enum term_tag tag,
+                              struct term *left, struct term *right,
+                              struct info *locp) {
+  assert(tag == A_COMPOSE || tag == A_CONCAT
+         || tag == A_UNION || tag == A_APP || tag == A_MINUS);
+  struct term *term = make_term_locp(tag, locp);
+  term->left = left;
+  term->right = right;
+  return term;
+}
+
+static struct term *make_unop(enum term_tag tag, struct term *exp,
+                             struct info *locp) {
+  assert(tag == A_BRACKET);
+  struct term *term = make_term_locp(tag, locp);
+  term->brexp = exp;
+  return term;
+}
+
+static struct term *make_ident(char *qname, struct info *locp) {
+  struct term *term = make_term_locp(A_IDENT, locp);
+  term->ident = make_string(qname);
+  return term;
+}
+
+static struct term *make_unit_term(struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_unit(ref(term->info));
+  term->type = make_base_type(T_UNIT);
+  return term;
+}
+
+static struct term *make_string_term(char *value, struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_value(V_STRING, ref(term->info));
+  term->value->string = make_string(value);
+  term->type = make_base_type(T_STRING);
+  return term;
+}
+
+static struct term *make_regexp_term(char *pattern, int nocase,
+                                     struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_value(V_REGEXP, ref(term->info));
+  term->type = make_base_type(T_REGEXP);
+  term->value->regexp = make_regexp(term->info, pattern, nocase);
+  return term;
+}
+
+static struct term *make_rep(struct term *exp, enum quant_tag quant,
+                            struct info *locp) {
+  struct term *term = make_term_locp(A_REP, locp);
+  term->quant = quant;
+  term->exp = exp;
+  return term;
+}
+
+static struct term *make_get_test(struct term *lens, struct term *arg,
+                                  struct info *locp) {
+  /* Return a term for "get" LENS ARG */
+  struct info *info = clone_info(locp);
+  struct term *term = make_app_ident(strdup("get"), lens, info);
+  term = make_app_term(term, arg, ref(info));
+  return term;
+}
+
+static struct term *make_put_test(struct term *lens, struct term *arg,
+                                  struct term *cmds, struct info *locp) {
+  /* Return a term for "put" LENS (CMDS ("get" LENS ARG)) ARG */
+  struct term *term = make_get_test(lens, arg, locp);
+  term = make_app_term(cmds, term, ref(term->info));
+  struct term *put = make_app_ident(strdup("put"), ref(lens), ref(term->info));
+  put = make_app_term(put, term, ref(term->info));
+  put = make_app_term(put, ref(arg), ref(term->info));
+  return put;
+}
+
+static struct term *make_test(struct term *test, struct term *result,
+                              enum test_result_tag tr_tag,
+                              struct term *decls, struct info *locp) {
+  struct term *term = make_term_locp(A_TEST, locp);
+  term->tr_tag = tr_tag;
+  term->test = test;
+  term->result = result;
+  term->next = decls;
+  return term;
+}
+
+static struct term *make_tree_value(struct tree *tree, struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  struct value *value = make_value(V_TREE, ref(term->info));
+  value->origin = make_tree_origin(tree);
+  term->type = make_base_type(T_TREE);
+  term->value = value;
+  return term;
+}
+
+static struct tree *tree_concat(struct tree *t1, struct tree *t2) {
+  if (t2 != NULL)
+    list_append(t1, t2);
+  return t1;
+}
+
+void augl_error(struct info *locp,
+                struct term **term,
+                yyscan_t scanner,
+                const char *s) {
+  struct info info;
+  struct string string;
+  MEMZERO(&info, 1);
+  info.ref = string.ref = UINT_MAX;
+  info.filename = &string;
+
+  if (locp != NULL) {
+    info.first_line   = locp->first_line;
+    info.first_column = locp->first_column;
+    info.last_line    = locp->last_line;
+    info.last_column  = locp->last_column;
+    info.filename->str = locp->filename->str;
+    info.error = locp->error;
+  } else if (scanner != NULL) {
+    info.first_line   = augl_get_lineno(scanner);
+    info.first_column = augl_get_column(scanner);
+    info.last_line    = augl_get_lineno(scanner);
+    info.last_column  = augl_get_column(scanner);
+    info.filename     = augl_get_info(scanner)->filename;
+    info.error        = augl_get_info(scanner)->error;
+  } else if (*term != NULL && (*term)->info != NULL) {
+    memcpy(&info, (*term)->info, sizeof(info));
+  } else {
+    info.first_line = info.last_line = 0;
+    info.first_column = info.last_column = 0;
+  }
+  syntax_error(&info, "%s", s);
+}
+
diff --git a/src/parser.h b/src/parser.h
new file mode 100644 (file)
index 0000000..11618cf
--- /dev/null
@@ -0,0 +1,147 @@
+/* A Bison parser, made by GNU Bison 2.4.3.  */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+   
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+   2009, 2010 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/>.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+   
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     DQUOTED = 258,
+     REGEXP = 259,
+     LIDENT = 260,
+     UIDENT = 261,
+     QIDENT = 262,
+     ARROW = 263,
+     KW_MODULE = 264,
+     KW_AUTOLOAD = 265,
+     KW_LET = 266,
+     KW_LET_REC = 267,
+     KW_IN = 268,
+     KW_STRING = 269,
+     KW_REGEXP = 270,
+     KW_LENS = 271,
+     KW_TEST = 272,
+     KW_GET = 273,
+     KW_PUT = 274,
+     KW_AFTER = 275
+   };
+#endif
+/* Tokens.  */
+#define DQUOTED 258
+#define REGEXP 259
+#define LIDENT 260
+#define UIDENT 261
+#define QIDENT 262
+#define ARROW 263
+#define KW_MODULE 264
+#define KW_AUTOLOAD 265
+#define KW_LET 266
+#define KW_LET_REC 267
+#define KW_IN 268
+#define KW_STRING 269
+#define KW_REGEXP 270
+#define KW_LENS 271
+#define KW_TEST 272
+#define KW_GET 273
+#define KW_PUT 274
+#define KW_AFTER 275
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 1685 of yacc.c  */
+#line 89 "parser.y"
+
+  struct term    *term;
+  struct type    *type;
+  struct ident   *ident;
+  struct tree    *tree;
+  char           *string;
+  struct {
+    int             nocase;
+    char           *pattern;
+  } regexp;
+  int            intval;
+  enum quant_tag quant;
+
+
+
+/* Line 1685 of yacc.c  */
+#line 107 "parser.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* "%code provides" blocks.  */
+
+/* Line 1685 of yacc.c  */
+#line 46 "parser.y"
+
+#include "info.h"
+
+/* Track custom scanner state */
+struct state {
+  struct info *info;
+  unsigned int comment_depth;
+};
+
+
+
+
+/* Line 1685 of yacc.c  */
+#line 148 "parser.h"
diff --git a/src/parser.y b/src/parser.y
new file mode 100644 (file)
index 0000000..4d579ef
--- /dev/null
@@ -0,0 +1,648 @@
+%{
+
+#include <config.h>
+
+#include "internal.h"
+#include "syntax.h"
+#include "list.h"
+#include "errcode.h"
+#include <stdio.h>
+
+/* Work around a problem on FreeBSD where Bison looks for _STDLIB_H
+ * to see if stdlib.h has been included, but the system includes
+ * use _STDLIB_H_
+ */
+#if HAVE_STDLIB_H && ! defined _STDLIB_H
+#  include <stdlib.h>
+#  define _STDLIB_H 1
+#endif
+
+#define YYDEBUG 1
+
+int augl_parse_file(struct augeas *aug, const char *name, struct term **term);
+
+typedef void *yyscan_t;
+typedef struct info YYLTYPE;
+#define YYLTYPE_IS_DECLARED 1
+/* The lack of reference counting on filename is intentional */
+# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
+  do {                                                                  \
+    (Current).filename = augl_get_info(scanner)->filename;              \
+    (Current).error = augl_get_info(scanner)->error;                    \
+    if (YYID (N)) {                                                     \
+        (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;          \
+        (Current).first_column = YYRHSLOC (Rhs, 1).first_column;        \
+        (Current).last_line    = YYRHSLOC (Rhs, N).last_line;           \
+        (Current).last_column  = YYRHSLOC (Rhs, N).last_column;         \
+    } else {                                                            \
+      (Current).first_line   = (Current).last_line   =                  \
+           YYRHSLOC (Rhs, 0).last_line;                                    \
+         (Current).first_column = (Current).last_column =                  \
+           YYRHSLOC (Rhs, 0).last_column;                                  \
+    }                                                                   \
+  } while (0)
+%}
+
+%code provides {
+#include "info.h"
+
+/* Track custom scanner state */
+struct state {
+  struct info *info;
+  unsigned int comment_depth;
+};
+
+}
+
+%locations
+%error-verbose
+%name-prefix="augl_"
+%defines
+%pure-parser
+%parse-param    {struct term **term}
+%parse-param    {yyscan_t scanner}
+%lex-param      {yyscan_t scanner}
+
+%initial-action {
+  @$.first_line   = 1;
+  @$.first_column = 0;
+  @$.last_line    = 1;
+  @$.last_column  = 0;
+  @$.filename     = augl_get_info(scanner)->filename;
+  @$.error        = augl_get_info(scanner)->error;
+};
+
+%token <string> DQUOTED   /* "foo" */
+%token <regexp> REGEXP    /* /[ \t]+/ */
+%token <string> LIDENT UIDENT QIDENT
+%token          ARROW
+
+/* Keywords */
+%token          KW_MODULE
+%token          KW_AUTOLOAD
+%token          KW_LET KW_LET_REC KW_IN
+%token          KW_STRING
+%token          KW_REGEXP
+%token          KW_LENS
+%token          KW_TEST KW_GET KW_PUT KW_AFTER
+
+%union {
+  struct term    *term;
+  struct type    *type;
+  struct ident   *ident;
+  struct tree    *tree;
+  char           *string;
+  struct {
+    int             nocase;
+    char           *pattern;
+  } regexp;
+  int            intval;
+  enum quant_tag quant;
+}
+
+%type<term>   start decls
+%type<term>   exp composeexp unionexp minusexp catexp appexp rexp aexp
+%type<term>   param param_list
+%type<string> qid id autoload
+%type<type>  type atype
+%type<quant> rep
+%type<term>  test_exp
+%type<intval> test_special_res
+%type<tree>  tree_const tree_const2 tree_branch
+%type<string> tree_label
+
+%{
+/* Lexer */
+extern int augl_lex (YYSTYPE * yylval_param,struct info * yylloc_param ,yyscan_t yyscanner);
+int augl_init_lexer(struct state *state, yyscan_t * scanner);
+void augl_close_lexer(yyscan_t *scanner);
+int augl_lex_destroy (yyscan_t yyscanner );
+int augl_get_lineno (yyscan_t yyscanner );
+int augl_get_column  (yyscan_t yyscanner);
+struct info *augl_get_info(yyscan_t yyscanner);
+char *augl_get_text (yyscan_t yyscanner );
+
+static void augl_error(struct info *locp, struct term **term,
+                       yyscan_t scanner, const char *s);
+
+/* TERM construction */
+ static struct info *clone_info(struct info *locp);
+ static struct term *make_module(char *ident, char *autoload,
+                                 struct term *decls,
+                                 struct info *locp);
+
+ static struct term *make_bind(char *ident, struct term *params,
+                             struct term *exp, struct term *decls,
+                             struct info *locp);
+ static struct term *make_bind_rec(char *ident, struct term *exp,
+                                   struct term *decls, struct info *locp);
+ static struct term *make_let(char *ident, struct term *params,
+                              struct term *exp, struct term *body,
+                              struct info *locp);
+ static struct term *make_binop(enum term_tag tag,
+                               struct term *left, struct term *right,
+                               struct info *locp);
+ static struct term *make_unop(enum term_tag tag,
+                              struct term *exp, struct info *locp);
+ static struct term *make_ident(char *qname, struct info *locp);
+ static struct term *make_unit_term(struct info *locp);
+ static struct term *make_string_term(char *value, struct info *locp);
+ static struct term *make_regexp_term(char *pattern,
+                                      int nocase, struct info *locp);
+ static struct term *make_rep(struct term *exp, enum quant_tag quant,
+                             struct info *locp);
+
+ static struct term *make_get_test(struct term *lens, struct term *arg,
+                                   struct info *info);
+ static struct term *make_put_test(struct term *lens, struct term *arg,
+                                   struct term *cmds, struct info *info);
+ static struct term *make_test(struct term *test, struct term *result,
+                               enum test_result_tag tr_tag,
+                               struct term *decls, struct info *locp);
+ static struct term *make_tree_value(struct tree *, struct info*);
+ static struct tree *tree_concat(struct tree *, struct tree *);
+
+#define LOC_MERGE(a, b, c)                                              \
+ do {                                                                   \
+   (a).filename     = (b).filename;                                     \
+   (a).first_line   = (b).first_line;                                   \
+   (a).first_column = (b).first_column;                                 \
+   (a).last_line    = (c).last_line;                                    \
+   (a).last_column  = (c).last_column;                                  \
+   (a).error        = (b).error;                                        \
+ } while(0);
+
+%}
+
+%%
+
+start: KW_MODULE UIDENT '=' autoload decls
+       { (*term) = make_module($2, $4, $5, &@1); }
+
+autoload: KW_AUTOLOAD LIDENT
+          { $$ = $2; }
+        | /* empty */
+          { $$ = NULL; }
+
+decls: KW_LET LIDENT param_list '=' exp decls
+       {
+         LOC_MERGE(@1, @1, @5);
+         $$ = make_bind($2, $3, $5, $6, &@1);
+       }
+     | KW_LET_REC LIDENT '=' exp decls
+       {
+         LOC_MERGE(@1, @1, @4);
+         $$ = make_bind_rec($2, $4, $5, &@1);
+       }
+     | KW_TEST test_exp '=' exp decls
+       {
+         LOC_MERGE(@1, @1, @4);
+         $$ = make_test($2, $4, TR_CHECK, $5, &@1);
+       }
+     | KW_TEST test_exp '=' test_special_res decls
+       {
+         LOC_MERGE(@1, @1, @4);
+         $$ = make_test($2, NULL, $4, $5, &@1);
+       }
+     | /* epsilon */
+       { $$ = NULL; }
+
+/* Test expressions and results */
+
+test_exp: aexp KW_GET exp
+          { $$ = make_get_test($1, $3, &@$); }
+        | aexp KW_PUT aexp KW_AFTER exp
+          { $$ = make_put_test($1, $3, $5, &@$); }
+
+test_special_res: '?'
+                  { $$ = TR_PRINT; }
+                | '*'
+                  { $$ = TR_EXN; }
+
+/* General expressions */
+exp: KW_LET LIDENT param_list '=' exp KW_IN  exp
+     {
+       LOC_MERGE(@1, @1, @6);
+       $$ = make_let($2, $3, $5, $7, &@1);
+     }
+   | composeexp
+
+composeexp: composeexp ';' unionexp
+     { $$ = make_binop(A_COMPOSE, $1, $3, &@$); }
+   | unionexp
+     { $$ = $1; }
+
+unionexp: unionexp '|' minusexp
+     { $$ = make_binop(A_UNION, $1, $3, &@$); }
+   | minusexp
+     { $$ = $1; }
+   | tree_const
+     { $$ = make_tree_value($1, &@1); }
+
+minusexp: minusexp '-' catexp
+     { $$ = make_binop(A_MINUS, $1, $3, &@$); }
+   | catexp
+     { $$ = $1; }
+
+catexp: catexp '.' appexp
+{ $$ = make_binop(A_CONCAT, $1, $3, &@$); }
+      | appexp
+{ $$ = $1; }
+
+appexp: appexp rexp
+        { $$ = make_binop(A_APP, $1, $2, &@$); }
+      | rexp
+        { $$ = $1; }
+
+aexp: qid
+      { $$ = make_ident($1, &@1); }
+    | DQUOTED
+      { $$ = make_string_term($1, &@1); }
+    | REGEXP
+      { $$ = make_regexp_term($1.pattern, $1.nocase, &@1); }
+    | '(' exp ')'
+      { $$ = $2; }
+    | '[' exp ']'
+      { $$ = make_unop(A_BRACKET, $2, &@$); }
+    | '(' ')'
+      { $$ = make_unit_term(&@$); }
+
+rexp: aexp rep
+      { $$ = make_rep($1, $2, &@$); }
+    | aexp
+      { $$ = $1; }
+
+rep: '*'
+     { $$ = Q_STAR; }
+   | '+'
+     { $$ = Q_PLUS; }
+   | '?'
+     { $$ = Q_MAYBE; }
+
+qid: LIDENT
+     { $$ = $1; }
+   | QIDENT
+     { $$ = $1; }
+   | KW_GET
+     { $$ = strdup("get"); }
+   | KW_PUT
+     { $$ = strdup("put"); }
+
+param_list: param param_list
+            { $$ = $2; list_cons($$, $1); }
+          | /* epsilon */
+            { $$ = NULL; }
+
+param: '(' id ':' type ')'
+       { $$ = make_param($2, $4, clone_info(&@1)); }
+
+id: LIDENT
+    { $$ = $1; }
+  | KW_GET
+    { $$ = strdup("get"); }
+  | KW_PUT
+    { $$ = strdup("put"); }
+
+type: atype ARROW type
+      { $$ = make_arrow_type($1, $3); }
+    | atype
+      { $$ = $1; }
+
+atype: KW_STRING
+       { $$ = make_base_type(T_STRING); }
+     | KW_REGEXP
+       { $$ = make_base_type(T_REGEXP); }
+     | KW_LENS
+       { $$ = make_base_type(T_LENS); }
+     | '(' type ')'
+       { $$ = $2; }
+
+tree_const: tree_const '{' tree_branch '}'
+            { $$ = tree_concat($1, $3); }
+          | '{' tree_branch '}'
+            { $$ = tree_concat($2, NULL); }
+
+tree_const2: tree_const2 '{' tree_branch '}'
+            {
+              $$ = tree_concat($1, $3);
+            }
+          | /* empty */
+            { $$ = NULL; }
+
+tree_branch: tree_label tree_const2
+             {
+               $$ = make_tree($1, NULL, NULL, $2);
+             }
+           | tree_label '=' DQUOTED tree_const2
+             {
+               $$ = make_tree($1, $3, NULL, $4);
+             }
+tree_label: DQUOTED
+          | /* empty */
+            { $$ = NULL; }
+%%
+
+int augl_parse_file(struct augeas *aug, const char *name,
+                    struct term **term) {
+  yyscan_t          scanner;
+  struct state      state;
+  struct string  *sname = NULL;
+  struct info    info;
+  int result = -1;
+  int r;
+
+  *term = NULL;
+
+  r = make_ref(sname);
+  ERR_NOMEM(r < 0, aug);
+
+  sname->str = strdup(name);
+  ERR_NOMEM(sname->str == NULL, aug);
+
+  MEMZERO(&info, 1);
+  info.ref = UINT_MAX;
+  info.filename = sname;
+  info.error = aug->error;
+
+  MEMZERO(&state, 1);
+  state.info = &info;
+  state.comment_depth = 0;
+
+  if (augl_init_lexer(&state, &scanner) < 0) {
+    augl_error(&info, term, NULL, "file not found");
+    goto error;
+  }
+
+  yydebug = getenv("YYDEBUG") != NULL;
+  r = augl_parse(term, scanner);
+  augl_close_lexer(scanner);
+  augl_lex_destroy(scanner);
+  if (r == 1) {
+    augl_error(&info, term, NULL, "syntax error");
+    goto error;
+  } else if (r == 2) {
+    augl_error(&info, term, NULL, "parser ran out of memory");
+    ERR_NOMEM(1, aug);
+  }
+  result = 0;
+
+ error:
+  unref(sname, string);
+  // free TERM
+  return result;
+}
+
+// FIXME: Nothing here checks for alloc errors.
+static struct info *clone_info(struct info *locp) {
+  struct info *info;
+  make_ref(info);
+  info->filename     = ref(locp->filename);
+  info->first_line   = locp->first_line;
+  info->first_column = locp->first_column;
+  info->last_line    = locp->last_line;
+  info->last_column  = locp->last_column;
+  info->error        = locp->error;
+  return info;
+}
+
+static struct term *make_term_locp(enum term_tag tag, struct info *locp) {
+  struct info *info = clone_info(locp);
+  return make_term(tag, info);
+}
+
+static struct term *make_module(char *ident, char *autoload,
+                                struct term *decls,
+                                struct info *locp) {
+  struct term *term = make_term_locp(A_MODULE, locp);
+  term->mname = ident;
+  term->autoload = autoload;
+  term->decls = decls;
+  return term;
+}
+
+static struct term *make_bind(char *ident, struct term *params,
+                              struct term *exp, struct term *decls,
+                              struct info *locp) {
+  struct term *term = make_term_locp(A_BIND, locp);
+  if (params != NULL)
+    exp = build_func(params, exp);
+
+  term->bname = ident;
+  term->exp = exp;
+  list_cons(decls, term);
+  return decls;
+}
+
+static struct term *make_bind_rec(char *ident, struct term *exp,
+                                  struct term *decls, struct info *locp) {
+  /* Desugar let rec IDENT = EXP as
+   *  let IDENT =
+   *    let RLENS = (lns_make_rec) in
+   *    lns_check_rec ((lambda IDENT: EXP) RLENS) RLENS
+   * where RLENS is a brandnew recursive lens.
+   *
+   * That only works since we know that 'let rec' is only defined for lenses,
+   * not general purposes functions, i.e. we know that IDENT has type 'lens'
+   *
+   * The point of all this is that we make it possible to put a recursive
+   * lens (which is a placeholder for the actual recursion) into arbitrary
+   * places in some bigger lens and then have LNS_CHECK_REC rattle through
+   * to do the special-purpose typechecking.
+   */
+  char *id;
+  struct info *info = exp->info;
+  struct term *lambda = NULL, *rlens = NULL;
+  struct term *app1 = NULL, *app2 = NULL, *app3 = NULL;
+
+  id = strdup(ident);
+  if (id == NULL) goto error;
+
+  lambda = make_param(id, make_base_type(T_LENS), ref(info));
+  if (lambda == NULL) goto error;
+  id = NULL;
+
+  build_func(lambda, exp);
+
+  rlens = make_term(A_VALUE, ref(exp->info));
+  if (rlens == NULL) goto error;
+  rlens->value = lns_make_rec(ref(exp->info));
+  if (rlens->value == NULL) goto error;
+  rlens->type = make_base_type(T_LENS);
+
+  app1 = make_app_term(lambda, rlens, ref(info));
+  if (app1 == NULL) goto error;
+
+  id = strdup(LNS_CHECK_REC_NAME);
+  if (id == NULL) goto error;
+  app2 = make_app_ident(id, app1, ref(info));
+  if (app2 == NULL) goto error;
+  id = NULL;
+
+  app3 = make_app_term(app2, ref(rlens), ref(info));
+  if (app3 == NULL) goto error;
+
+  return make_bind(ident, NULL, app3, decls, locp);
+
+ error:
+  free(id);
+  unref(lambda, term);
+  unref(rlens, term);
+  unref(app1, term);
+  unref(app2, term);
+  unref(app3, term);
+  return NULL;
+}
+
+static struct term *make_let(char *ident, struct term *params,
+                             struct term *exp, struct term *body,
+                             struct info *locp) {
+  /* let f (x:string) = "f " . x in
+     f "a" . f "b" */
+  /* (lambda f: f "a" . f "b") (lambda x: "f " . x) */
+  /* (lambda IDENT: BODY) (lambda PARAMS: EXP) */
+  /* Desugar as (lambda IDENT: BODY) (lambda PARAMS: EXP) */
+  struct term *term = make_term_locp(A_LET, locp);
+  struct term *p = make_param(ident, NULL, ref(term->info));
+  term->left = build_func(p, body);
+  if (params != NULL)
+    term->right = build_func(params, exp);
+  else
+    term->right = exp;
+  return term;
+}
+
+static struct term *make_binop(enum term_tag tag,
+                              struct term *left, struct term *right,
+                              struct info *locp) {
+  assert(tag == A_COMPOSE || tag == A_CONCAT
+         || tag == A_UNION || tag == A_APP || tag == A_MINUS);
+  struct term *term = make_term_locp(tag, locp);
+  term->left = left;
+  term->right = right;
+  return term;
+}
+
+static struct term *make_unop(enum term_tag tag, struct term *exp,
+                             struct info *locp) {
+  assert(tag == A_BRACKET);
+  struct term *term = make_term_locp(tag, locp);
+  term->brexp = exp;
+  return term;
+}
+
+static struct term *make_ident(char *qname, struct info *locp) {
+  struct term *term = make_term_locp(A_IDENT, locp);
+  term->ident = make_string(qname);
+  return term;
+}
+
+static struct term *make_unit_term(struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_unit(ref(term->info));
+  term->type = make_base_type(T_UNIT);
+  return term;
+}
+
+static struct term *make_string_term(char *value, struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_value(V_STRING, ref(term->info));
+  term->value->string = make_string(value);
+  term->type = make_base_type(T_STRING);
+  return term;
+}
+
+static struct term *make_regexp_term(char *pattern, int nocase,
+                                     struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  term->value = make_value(V_REGEXP, ref(term->info));
+  term->type = make_base_type(T_REGEXP);
+  term->value->regexp = make_regexp(term->info, pattern, nocase);
+  return term;
+}
+
+static struct term *make_rep(struct term *exp, enum quant_tag quant,
+                            struct info *locp) {
+  struct term *term = make_term_locp(A_REP, locp);
+  term->quant = quant;
+  term->exp = exp;
+  return term;
+}
+
+static struct term *make_get_test(struct term *lens, struct term *arg,
+                                  struct info *locp) {
+  /* Return a term for "get" LENS ARG */
+  struct info *info = clone_info(locp);
+  struct term *term = make_app_ident(strdup("get"), lens, info);
+  term = make_app_term(term, arg, ref(info));
+  return term;
+}
+
+static struct term *make_put_test(struct term *lens, struct term *arg,
+                                  struct term *cmds, struct info *locp) {
+  /* Return a term for "put" LENS (CMDS ("get" LENS ARG)) ARG */
+  struct term *term = make_get_test(lens, arg, locp);
+  term = make_app_term(cmds, term, ref(term->info));
+  struct term *put = make_app_ident(strdup("put"), ref(lens), ref(term->info));
+  put = make_app_term(put, term, ref(term->info));
+  put = make_app_term(put, ref(arg), ref(term->info));
+  return put;
+}
+
+static struct term *make_test(struct term *test, struct term *result,
+                              enum test_result_tag tr_tag,
+                              struct term *decls, struct info *locp) {
+  struct term *term = make_term_locp(A_TEST, locp);
+  term->tr_tag = tr_tag;
+  term->test = test;
+  term->result = result;
+  term->next = decls;
+  return term;
+}
+
+static struct term *make_tree_value(struct tree *tree, struct info *locp) {
+  struct term *term = make_term_locp(A_VALUE, locp);
+  struct value *value = make_value(V_TREE, ref(term->info));
+  value->origin = make_tree_origin(tree);
+  term->type = make_base_type(T_TREE);
+  term->value = value;
+  return term;
+}
+
+static struct tree *tree_concat(struct tree *t1, struct tree *t2) {
+  if (t2 != NULL)
+    list_append(t1, t2);
+  return t1;
+}
+
+void augl_error(struct info *locp,
+                struct term **term,
+                yyscan_t scanner,
+                const char *s) {
+  struct info info;
+  struct string string;
+  MEMZERO(&info, 1);
+  info.ref = string.ref = UINT_MAX;
+  info.filename = &string;
+
+  if (locp != NULL) {
+    info.first_line   = locp->first_line;
+    info.first_column = locp->first_column;
+    info.last_line    = locp->last_line;
+    info.last_column  = locp->last_column;
+    info.filename->str = locp->filename->str;
+    info.error = locp->error;
+  } else if (scanner != NULL) {
+    info.first_line   = augl_get_lineno(scanner);
+    info.first_column = augl_get_column(scanner);
+    info.last_line    = augl_get_lineno(scanner);
+    info.last_column  = augl_get_column(scanner);
+    info.filename     = augl_get_info(scanner)->filename;
+    info.error        = augl_get_info(scanner)->error;
+  } else if (*term != NULL && (*term)->info != NULL) {
+    memcpy(&info, (*term)->info, sizeof(info));
+  } else {
+    info.first_line = info.last_line = 0;
+    info.first_column = info.last_column = 0;
+  }
+  syntax_error(&info, "%s", s);
+}
diff --git a/src/pathx.c b/src/pathx.c
new file mode 100644 (file)
index 0000000..a4cdf48
--- /dev/null
@@ -0,0 +1,2602 @@
+/*
+ * pathx.c: handling path expressions
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <internal.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <memory.h>
+#include <ctype.h>
+
+#include "ref.h"
+#include "regexp.h"
+#include "errcode.h"
+
+static const char *const errcodes[] = {
+    "no error",
+    "empty name",
+    "illegal string literal",
+    "illegal number",
+    "string missing ending ' or \"",
+    "expected '='",
+    "allocation failed",
+    "unmatched '['",
+    "unmatched '('",
+    "expected a '/'",
+    "internal error",   /* PATHX_EINTERNAL */
+    "type error",       /* PATHX_ETYPE */
+    "undefined variable",               /* PATHX_ENOVAR */
+    "garbage at end of path expression",/* PATHX_EEND */
+    "can not expand tree from empty nodeset",  /* PATHX_ENONODES */
+    "wrong number of arguments in function call", /* PATHX_EARITY */
+    "invalid regular expression"        /* PATHX_EREGEXP */
+};
+
+/*
+ * Path expressions are strings that use a notation modelled on XPath.
+ */
+
+enum type {
+    T_NONE = 0,     /* Not a type */
+    T_NODESET,
+    T_BOOLEAN,
+    T_NUMBER,
+    T_STRING,
+    T_REGEXP
+};
+
+enum expr_tag {
+    E_FILTER,
+    E_BINARY,
+    E_VALUE,
+    E_VAR,
+    E_APP
+};
+
+enum binary_op {
+    OP_EQ,         /* '='  */
+    OP_NEQ,        /* '!=' */
+    OP_LT,         /* '<'  */
+    OP_LE,         /* '<=' */
+    OP_GT,         /* '>'  */
+    OP_GE,         /* '>=' */
+    OP_PLUS,       /* '+'  */
+    OP_MINUS,      /* '-'  */
+    OP_STAR,       /* '*'  */
+    OP_AND,        /* 'and' */
+    OP_OR,         /* 'or' */
+    OP_RE_MATCH,   /* '=~' */
+    OP_UNION       /* '|' */
+};
+
+struct pred {
+    int               nexpr;
+    struct expr     **exprs;
+};
+
+enum axis {
+    SELF,
+    CHILD,
+    DESCENDANT,
+    DESCENDANT_OR_SELF,
+    PARENT,
+    ANCESTOR,
+    ROOT,
+    PRECEDING_SIBLING,
+    FOLLOWING_SIBLING
+};
+
+/* This array is indexed by enum axis */
+static const char *const axis_names[] = {
+    "self",
+    "child",
+    "descendant",
+    "descendant-or-self",
+    "parent",
+    "ancestor",
+    "root",
+    "preceding-sibling",
+    "following-sibling"
+};
+
+static const char *const axis_sep = "::";
+
+/* Doubly linked list of location steps. Besides the information from the
+ * path expression, also contains information to iterate over a node set,
+ * in particular, the context node CTX for the step, and the current node
+ * CUR within that context.
+ */
+struct step {
+    struct step *next;
+    enum axis    axis;
+    char        *name;              /* NULL to match any name */
+    struct pred *predicates;
+};
+
+/* Iteration over the nodes on a step, ignoring the predicates */
+static struct tree *step_first(struct step *step, struct tree *ctx);
+static struct tree *step_next(struct step *step, struct tree *ctx,
+                              struct tree *node);
+
+struct pathx_symtab {
+    struct pathx_symtab *next;
+    char                *name;
+    struct value        *value;
+};
+
+struct pathx {
+    struct state   *state;
+    struct nodeset *nodeset;
+    int             node;
+    struct tree    *origin;
+};
+
+#define L_BRACK '['
+#define R_BRACK ']'
+
+struct locpath {
+    struct step *steps;
+};
+
+struct nodeset {
+    struct tree **nodes;
+    size_t        used;
+    size_t        size;
+};
+
+typedef uint32_t value_ind_t;
+
+struct value {
+    enum type tag;
+    union {
+        struct nodeset  *nodeset;     /* T_NODESET */
+        int              number;      /* T_NUMBER  */
+        char            *string;      /* T_STRING  */
+        bool             boolval;     /* T_BOOLEAN */
+        struct regexp   *regexp;      /* T_REGEXP  */
+    };
+};
+
+struct expr {
+    enum expr_tag tag;
+    enum type     type;
+    union {
+        struct {                       /* E_FILTER */
+            struct expr     *primary;
+            struct pred     *predicates;
+            struct locpath  *locpath;
+        };
+        struct {                       /* E_BINARY */
+            enum binary_op op;
+            struct expr *left;
+            struct expr *right;
+        };
+        value_ind_t      value_ind;    /* E_VALUE */
+        char            *ident;        /* E_VAR */
+        struct {                       /* E_APP */
+            const struct func *func;
+            struct expr       *args[];
+        };
+    };
+};
+
+struct locpath_trace {
+    unsigned int      maxns;
+    struct nodeset  **ns;
+    struct locpath   *lp;
+};
+
+/* Internal state of the evaluator/parser */
+struct state {
+    pathx_errcode_t errcode;
+    const char     *file;
+    int             line;
+    char           *errmsg;
+
+    const char     *txt;  /* Entire expression */
+    const char     *pos;  /* Current position within TXT during parsing */
+
+    struct tree *ctx; /* The current node */
+    uint            ctx_pos;
+    uint            ctx_len;
+
+    /* A table of all values. The table is dynamically reallocated, i.e.
+     * pointers to struct value should not be used across calls that
+     * might allocate new values
+     *
+     * value_pool[0] is always the boolean false, and value_pool[1]
+     * always the boolean true
+     */
+    struct value  *value_pool;
+    value_ind_t    value_pool_used;
+    value_ind_t    value_pool_size;
+    /* Stack of values (as indices into value_pool), with bottom of
+       stack in values[0] */
+    value_ind_t   *values;
+    size_t         values_used;
+    size_t         values_size;
+    /* Stack of expressions, with bottom of stack in exprs[0] */
+    struct expr  **exprs;
+    size_t         exprs_used;
+    size_t         exprs_size;
+    /* Trace of a locpath evaluation, needed by pathx_expand_tree.
+       Generally NULL, unless a trace is needed.
+     */
+    struct locpath_trace *locpath_trace;
+    /* Symbol table for variable lookups */
+    struct pathx_symtab *symtab;
+    /* Error structure, used to communicate errors to struct augeas;
+     * we never own this structure, and therefore never free it */
+    struct error        *error;
+};
+
+/* We consider NULL and the empty string to be equal */
+ATTRIBUTE_PURE
+static inline int streqx(const char *s1, const char *s2) {
+    if (s1 == NULL)
+        return (s2 == NULL || strlen(s2) == 0);
+    if (s2 == NULL)
+        return strlen(s1) == 0;
+    return STREQ(s1, s2);
+}
+
+/* Functions */
+
+typedef void (*func_impl_t)(struct state *state);
+
+struct func {
+    const char      *name;
+    unsigned int     arity;
+    enum type        type;
+    const enum type *arg_types;
+    func_impl_t      impl;
+};
+
+static void func_last(struct state *state);
+static void func_position(struct state *state);
+static void func_count(struct state *state);
+static void func_label(struct state *state);
+static void func_regexp(struct state *state);
+
+static const enum type const count_arg_types[] = { T_NODESET };
+static const enum type const regexp_arg_types[] = { T_STRING };
+
+static const struct func builtin_funcs[] = {
+    { .name = "last", .arity = 0, .type = T_NUMBER, .arg_types = NULL,
+      .impl = func_last },
+    { .name = "position", .arity = 0, .type = T_NUMBER, .arg_types = NULL,
+      .impl = func_position },
+    { .name = "label", .arity = 0, .type = T_STRING, .arg_types = NULL,
+      .impl = func_label },
+    { .name = "count", .arity = 1, .type = T_NUMBER,
+      .arg_types = count_arg_types,
+      .impl = func_count },
+    { .name = "regexp", .arity = 1, .type = T_REGEXP,
+      .arg_types = regexp_arg_types,
+      .impl =func_regexp }
+};
+
+#define CHECK_ERROR                                                     \
+    if (state->errcode != PATHX_NOERROR) return
+
+#define CHECK_ERROR_RET0                                                \
+    if (state->errcode != PATHX_NOERROR) return 0
+
+#define STATE_ERROR(state, err)                                         \
+    do {                                                                \
+        state->errcode = err;                                           \
+        state->file = __FILE__;                                         \
+        state->line = __LINE__;                                         \
+    } while (0)
+
+#define HAS_ERROR(state) (state->errcode != PATHX_NOERROR)
+
+#define STATE_ENOMEM STATE_ERROR(state, PATHX_ENOMEM)
+
+#define ENOMEM_ON_NULL(state, v)                                        \
+    do {                                                                \
+        if (v == NULL) {                                                \
+            STATE_ERROR(state, PATHX_ENOMEM);                           \
+            return NULL;                                                \
+        }                                                               \
+    } while (0);
+
+/*
+ * Free the various data structures
+ */
+
+static void free_expr(struct expr *expr);
+
+static void free_pred(struct pred *pred) {
+    if (pred == NULL)
+        return;
+
+    for (int i=0; i < pred->nexpr; i++) {
+        free_expr(pred->exprs[i]);
+    }
+    free(pred->exprs);
+    free(pred);
+}
+
+static void free_step(struct step *step) {
+    while (step != NULL) {
+        struct step *del = step;
+        step = del->next;
+        free(del->name);
+        free_pred(del->predicates);
+        free(del);
+    }
+}
+
+static void free_locpath(struct locpath *locpath) {
+    if (locpath == NULL)
+        return;
+    while (locpath->steps != NULL) {
+        struct step *step = locpath->steps;
+        locpath->steps = step->next;
+        free(step->name);
+        free_pred(step->predicates);
+        free(step);
+    }
+    free(locpath);
+}
+
+static void free_expr(struct expr *expr) {
+    if (expr == NULL)
+        return;
+    switch (expr->tag) {
+    case E_FILTER:
+        free_expr(expr->primary);
+        free_pred(expr->predicates);
+        free_locpath(expr->locpath);
+        break;
+    case E_BINARY:
+        free_expr(expr->left);
+        free_expr(expr->right);
+        break;
+    case E_VALUE:
+        break;
+    case E_VAR:
+        free(expr->ident);
+        break;
+    case E_APP:
+        for (int i=0; i < expr->func->arity; i++)
+            free_expr(expr->args[i]);
+        break;
+    default:
+        assert(0);
+    }
+    free(expr);
+}
+
+static void free_nodeset(struct nodeset *ns) {
+    if (ns != NULL) {
+        free(ns->nodes);
+        free(ns);
+    }
+}
+
+/* Free all objects used by VALUE, but not VALUE itself */
+static void release_value(struct value *v) {
+    if (v == NULL)
+        return;
+
+    switch (v->tag) {
+    case T_NODESET:
+        free_nodeset(v->nodeset);
+        break;
+    case T_STRING:
+        free(v->string);
+        break;
+    case T_BOOLEAN:
+    case T_NUMBER:
+        break;
+    case T_REGEXP:
+        unref(v->regexp, regexp);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+static void free_state(struct state *state) {
+    if (state == NULL)
+        return;
+
+    for(int i=0; i < state->exprs_used; i++)
+        free_expr(state->exprs[i]);
+    free(state->exprs);
+
+    for(int i=0; i < state->value_pool_used; i++)
+        release_value(state->value_pool + i);
+    free(state->value_pool);
+    free(state->values);
+    free(state);
+}
+
+void free_pathx(struct pathx *pathx) {
+    if (pathx == NULL)
+        return;
+    free_state(pathx->state);
+    free(pathx);
+}
+
+/*
+ * Nodeset helpers
+ */
+static struct nodeset *make_nodeset(struct state *state) {
+    struct nodeset *result;
+    if (ALLOC(result) < 0)
+        STATE_ENOMEM;
+    return result;
+}
+
+static void ns_add(struct nodeset *ns, struct tree *node,
+                   struct state *state) {
+    for (int i=0; i < ns->used; i++)
+        if (ns->nodes[i] == node)
+            return;
+    if (ns->used >= ns->size) {
+        size_t size = 2 * ns->size;
+        if (size < 10) size = 10;
+        if (REALLOC_N(ns->nodes, size) < 0)
+            STATE_ENOMEM;
+        ns->size = size;
+    }
+    ns->nodes[ns->used] = node;
+    ns->used += 1;
+}
+
+static struct nodeset *
+clone_nodeset(struct nodeset *ns, struct state *state)
+{
+    struct nodeset *clone;
+    if (ALLOC(clone) < 0) {
+        STATE_ENOMEM;
+        return NULL;
+    }
+    if (ALLOC_N(clone->nodes, ns->used) < 0) {
+        free(clone);
+        STATE_ENOMEM;
+        return NULL;
+    }
+    clone->used = ns->used;
+    clone->size = ns->used;
+    for (int i=0; i < ns->used; i++)
+        clone->nodes[i] = ns->nodes[i];
+    return clone;
+}
+
+/*
+ * Handling values
+ */
+static value_ind_t make_value(enum type tag, struct state *state) {
+    assert(tag != T_BOOLEAN);
+
+    if (state->value_pool_used >= state->value_pool_size) {
+        value_ind_t new_size = 2*state->value_pool_size;
+        if (new_size <= state->value_pool_size) {
+            STATE_ENOMEM;
+            return 0;
+        }
+        if (REALLOC_N(state->value_pool, new_size) < 0) {
+            STATE_ENOMEM;
+            return 0;
+        }
+        state->value_pool_size = new_size;
+    }
+    state->value_pool[state->value_pool_used].tag = tag;
+    state->value_pool[state->value_pool_used].nodeset = NULL;
+    return state->value_pool_used++;
+}
+
+ATTRIBUTE_UNUSED
+static value_ind_t clone_value(struct value *v, struct state *state) {
+    value_ind_t vind = make_value(v->tag, state);
+    CHECK_ERROR_RET0;
+    struct value *clone = state->value_pool + vind;
+
+    switch (v->tag) {
+    case T_NODESET:
+        clone->nodeset = clone_nodeset(v->nodeset, state);
+        break;
+    case T_NUMBER:
+        clone->number = v->number;
+        break;
+    case T_STRING:
+        clone->string = strdup(v->string);
+        if (clone->string == NULL) {
+            FREE(clone);
+            STATE_ENOMEM;
+        }
+        break;
+    case T_BOOLEAN:
+        clone->boolval = v->boolval;
+        break;
+    case T_REGEXP:
+        clone->regexp = ref(v->regexp);
+        break;
+    default:
+        assert(0);
+    }
+    return vind;
+}
+
+static value_ind_t pop_value_ind(struct state *state) {
+    if (state->values_used > 0) {
+        state->values_used -= 1;
+        return state->values[state->values_used];
+    } else {
+        STATE_ERROR(state, PATHX_EINTERNAL);
+        assert(0);
+        return 0;
+    }
+}
+
+static struct value *pop_value(struct state *state) {
+    value_ind_t vind = pop_value_ind(state);
+    if (HAS_ERROR(state))
+        return NULL;
+    return state->value_pool + vind;
+}
+
+static void push_value(value_ind_t vind, struct state *state) {
+    if (state->values_used >= state->values_size) {
+        size_t new_size = 2*state->values_size;
+        if (new_size == 0) new_size = 8;
+        if (REALLOC_N(state->values, new_size) < 0) {
+            STATE_ENOMEM;
+            return;
+        }
+        state->values_size = new_size;
+    }
+    state->values[state->values_used++] = vind;
+}
+
+static void push_boolean_value(int b, struct state *state) {
+    push_value(b != 0, state);
+}
+
+ATTRIBUTE_PURE
+static struct value *expr_value(struct expr *expr, struct state *state) {
+    return state->value_pool + expr->value_ind;
+}
+
+/*************************************************************************
+ * Evaluation
+ ************************************************************************/
+static void eval_expr(struct expr *expr, struct state *state);
+
+static void func_last(struct state *state) {
+    value_ind_t vind = make_value(T_NUMBER, state);
+    CHECK_ERROR;
+
+    state->value_pool[vind].number = state->ctx_len;
+    push_value(vind, state);
+}
+
+static void func_position(struct state *state) {
+    value_ind_t vind = make_value(T_NUMBER, state);
+    CHECK_ERROR;
+
+    state->value_pool[vind].number = state->ctx_pos;
+    push_value(vind, state);
+}
+
+static void func_count(struct state *state) {
+    value_ind_t vind = make_value(T_NUMBER, state);
+    CHECK_ERROR;
+
+    struct value *ns = pop_value(state);
+    state->value_pool[vind].number = ns->nodeset->used;
+    push_value(vind, state);
+}
+
+static void func_label(struct state *state) {
+    value_ind_t vind = make_value(T_STRING, state);
+    char *s;
+
+    CHECK_ERROR;
+
+    if (state->ctx->label)
+        s = strdup(state->ctx->label);
+    else
+        s = strdup("");
+    if (s == NULL) {
+        STATE_ENOMEM;
+        return;
+    }
+    state->value_pool[vind].string = s;
+    push_value(vind, state);
+}
+
+static void func_regexp(struct state *state) {
+    value_ind_t vind = make_value(T_REGEXP, state);
+    int r;
+
+    CHECK_ERROR;
+
+    struct value *str = pop_value(state);
+    assert(str->tag == T_STRING);
+
+    char *pat = strdup(str->string);
+    if (pat == NULL) {
+        STATE_ENOMEM;
+        return;
+    }
+
+    struct regexp *rx = make_regexp(NULL, pat, 0);
+    state->value_pool[vind].regexp = rx;
+    if (rx == NULL) {
+        FREE(pat);
+        STATE_ENOMEM;
+        return;
+    }
+    r = regexp_compile(rx);
+    if (r < 0) {
+        const char *msg;
+        regexp_check(rx, &msg);
+        state->errmsg = strdup(msg);
+        STATE_ERROR(state, PATHX_EREGEXP);
+        return;
+    }
+    push_value(vind, state);
+}
+
+static bool coerce_to_bool(struct value *v) {
+    switch (v->tag) {
+    case T_NODESET:
+        return v->nodeset->used > 0;
+        break;
+    case T_BOOLEAN:
+        return v->boolval;
+        break;
+    case T_NUMBER:
+        return v->number > 0;
+        break;
+    case T_STRING:
+        return strlen(v->string) > 0;
+        break;
+    case T_REGEXP:
+        return true;
+    default:
+        assert(0);
+        return false;
+    }
+}
+
+static int calc_eq_nodeset_nodeset(struct nodeset *ns1, struct nodeset *ns2,
+                                   int neq) {
+    for (int i1=0; i1 < ns1->used; i1++) {
+        struct tree *t1 = ns1->nodes[i1];
+        for (int i2=0; i2 < ns2->used; i2++) {
+            struct tree *t2 = ns2->nodes[i2];
+            if (neq) {
+                if (!streqx(t1->value, t2->value))
+                    return 1;
+            } else {
+                if (streqx(t1->value, t2->value))
+                    return 1;
+            }
+        }
+    }
+    return 0;
+}
+
+static int calc_eq_nodeset_string(struct nodeset *ns, const char *s,
+                                  int neq) {
+    for (int i=0; i < ns->used; i++) {
+        struct tree *t = ns->nodes[i];
+        if (neq) {
+            if (!streqx(t->value, s))
+                return 1;
+        } else {
+            if (streqx(t->value, s))
+                return 1;
+        }
+    }
+    return 0;
+}
+
+static void eval_eq(struct state *state, int neq) {
+    struct value *r = pop_value(state);
+    struct value *l = pop_value(state);
+    int res;
+
+    if (l->tag == T_NODESET && r->tag == T_NODESET) {
+        res = calc_eq_nodeset_nodeset(l->nodeset, r->nodeset, neq);
+    } else if (l->tag == T_NODESET) {
+        res = calc_eq_nodeset_string(l->nodeset, r->string, neq);
+    } else if (r->tag == T_NODESET) {
+        res = calc_eq_nodeset_string(r->nodeset, l->string, neq);
+    } else if (l->tag == T_NUMBER && r->tag == T_NUMBER) {
+        if (neq)
+            res = (l->number != r->number);
+        else
+            res = (l->number == r->number);
+    } else {
+        assert(l->tag == T_STRING);
+        assert(r->tag == T_STRING);
+        res = streqx(l->string, r->string);
+        if (neq)
+            res = !res;
+    }
+    CHECK_ERROR;
+
+    push_boolean_value(res, state);
+}
+
+static void eval_arith(struct state *state, enum binary_op op) {
+    value_ind_t vind = make_value(T_NUMBER, state);
+    struct value *r = pop_value(state);
+    struct value *l = pop_value(state);
+    int res;
+
+    assert(l->tag == T_NUMBER);
+    assert(r->tag == T_NUMBER);
+
+    CHECK_ERROR;
+
+    if (op == OP_PLUS)
+        res = l->number + r->number;
+    else if (op == OP_MINUS)
+        res = l->number - r->number;
+    else if (op == OP_STAR)
+        res = l->number * r->number;
+    else
+        assert(0);
+
+    state->value_pool[vind].number = res;
+    push_value(vind, state);
+}
+
+static void eval_rel(struct state *state, bool greater, bool equal) {
+    struct value *r, *l;
+    int res;
+
+    /* We always check l < r or l <= r */
+    if (greater) {
+        l = pop_value(state);
+        r = pop_value(state);
+    } else {
+        r = pop_value(state);
+        l = pop_value(state);
+    }
+    if (l->tag == T_NUMBER) {
+        if (equal)
+            res = (l->number <= r->number);
+        else
+            res = (l->number < r->number);
+    } else if (l->tag == T_STRING) {
+        int cmp = strcmp(l->string, r->string);
+        if (equal)
+            res = cmp <= 0;
+        else
+            res = cmp < 0;
+    } else {
+        assert(0);
+    }
+
+    push_boolean_value(res, state);
+}
+
+static void eval_and_or(struct state *state, enum binary_op op) {
+    struct value *r = pop_value(state);
+    struct value *l = pop_value(state);
+    bool left = coerce_to_bool(l);
+    bool right = coerce_to_bool(r);
+
+
+    if (op == OP_AND)
+        push_boolean_value(left && right, state);
+    else
+        push_boolean_value(left || right, state);
+}
+
+static bool eval_re_match_str(struct state *state, struct regexp *rx,
+                              const char *str) {
+    int r;
+
+    if (str == NULL)
+        str = "";
+
+    r = regexp_match(rx, str, strlen(str), 0, NULL);
+    if (r == -2) {
+        STATE_ERROR(state, PATHX_EINTERNAL);
+    } else if (r == -3) {
+        /* We should never get this far; func_regexp should catch
+         * invalid regexps */
+        assert(false);
+    }
+    return r == strlen(str);
+}
+
+static void eval_union(struct state *state) {
+    value_ind_t vind = make_value(T_NODESET, state);
+    struct value *r = pop_value(state);
+    struct value *l = pop_value(state);
+    struct nodeset *res = NULL;
+
+    assert(l->tag == T_NODESET);
+    assert(r->tag == T_NODESET);
+
+    CHECK_ERROR;
+
+    res = clone_nodeset(l->nodeset, state);
+    CHECK_ERROR;
+    for (int i=0; i < r->nodeset->used; i++) {
+        ns_add(res, r->nodeset->nodes[i], state);
+        CHECK_ERROR;
+    }
+    state->value_pool[vind].nodeset = res;
+    push_value(vind, state);
+}
+
+static void eval_re_match(struct state *state) {
+    struct value *rx  = pop_value(state);
+    struct value *v = pop_value(state);
+
+    bool result = false;
+
+    if (v->tag == T_STRING) {
+        result = eval_re_match_str(state, rx->regexp, v->string);
+        CHECK_ERROR;
+    } else if (v->tag == T_NODESET) {
+        for (int i=0; i < v->nodeset->used && result == false; i++) {
+            struct tree *t = v->nodeset->nodes[i];
+            result = eval_re_match_str(state, rx->regexp, t->value);
+            CHECK_ERROR;
+        }
+    }
+    push_boolean_value(result, state);
+}
+
+static void eval_binary(struct expr *expr, struct state *state) {
+    eval_expr(expr->left, state);
+    eval_expr(expr->right, state);
+    CHECK_ERROR;
+
+    switch (expr->op) {
+    case OP_EQ:
+        eval_eq(state, 0);
+        break;
+    case OP_NEQ:
+        eval_eq(state, 1);
+        break;
+    case OP_LT:
+        eval_rel(state, false, false);
+        break;
+    case OP_LE:
+        eval_rel(state, false, true);
+        break;
+    case OP_GT:
+        eval_rel(state, true, false);
+        break;
+    case OP_GE:
+        eval_rel(state, true, true);
+        break;
+    case OP_MINUS:
+    case OP_PLUS:
+    case OP_STAR:
+        eval_arith(state, expr->op);
+        break;
+    case OP_AND:
+    case OP_OR:
+        eval_and_or(state, expr->op);
+        break;
+    case OP_UNION:
+        eval_union(state);
+        break;
+    case OP_RE_MATCH:
+        eval_re_match(state);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+static void eval_app(struct expr *expr, struct state *state) {
+    assert(expr->tag == E_APP);
+
+    for (int i=0; i < expr->func->arity; i++) {
+        eval_expr(expr->args[i], state);
+        CHECK_ERROR;
+    }
+    expr->func->impl(state);
+}
+
+static bool eval_pred(struct expr *expr, struct state *state) {
+    eval_expr(expr, state);
+    CHECK_ERROR_RET0;
+
+    struct value *v = pop_value(state);
+    switch(v->tag) {
+    case T_BOOLEAN:
+        return v->boolval;
+    case T_NUMBER:
+        return (state->ctx_pos == v->number);
+    case T_NODESET:
+        return v->nodeset->used > 0;
+    default:
+        assert(0);
+        return false;
+    }
+}
+
+static void ns_remove(struct nodeset *ns, int ind) {
+    memmove(ns->nodes + ind, ns->nodes + ind+1,
+            sizeof(ns->nodes[0]) * (ns->used - (ind+1)));
+    ns->used -= 1;
+}
+
+/*
+ * Remove all nodes from NS for which one of PRED is false
+ */
+static void ns_filter(struct nodeset *ns, struct pred *predicates,
+                      struct state *state) {
+    if (predicates == NULL)
+        return;
+
+    struct tree *old_ctx = state->ctx;
+    uint old_ctx_len = state->ctx_len;
+    uint old_ctx_pos = state->ctx_pos;
+
+    for (int p=0; p < predicates->nexpr; p++) {
+        state->ctx_len = ns->used;
+        state->ctx_pos = 1;
+        for (int i=0; i < ns->used; state->ctx_pos++) {
+            state->ctx = ns->nodes[i];
+            bool match = eval_pred(predicates->exprs[p], state);
+            CHECK_ERROR;
+            if (match) {
+                i+=1;
+            } else {
+                ns_remove(ns, i);
+            }
+        }
+    }
+
+    state->ctx = old_ctx;
+    state->ctx_pos = old_ctx_pos;
+    state->ctx_len = old_ctx_len;
+}
+
+/* Return an array of nodesets, one for each step in the locpath.
+ *
+ * On return, (*NS)[0] will contain state->ctx, and (*NS)[*MAXNS] will
+ * contain the nodes that matched the entire locpath
+ */
+static void ns_from_locpath(struct locpath *lp, uint *maxns,
+                            struct nodeset ***ns,
+                            const struct nodeset *root,
+                            struct state *state) {
+    struct tree *old_ctx = state->ctx;
+
+    *maxns = 0;
+    *ns = NULL;
+    list_for_each(step, lp->steps)
+        *maxns += 1;
+    if (ALLOC_N(*ns, *maxns+1) < 0) {
+        STATE_ERROR(state, PATHX_ENOMEM);
+        goto error;
+    }
+    for (int i=0; i <= *maxns; i++) {
+        (*ns)[i] = make_nodeset(state);
+        if (HAS_ERROR(state))
+            goto error;
+    }
+    if (root == NULL) {
+        ns_add((*ns)[0], state->ctx, state);
+    } else {
+        for (int i=0; i < root->used; i++)
+            ns_add((*ns)[0], root->nodes[i], state);
+    }
+    CHECK_ERROR;
+
+    uint cur_ns = 0;
+    list_for_each(step, lp->steps) {
+        struct nodeset *work = (*ns)[cur_ns];
+        struct nodeset *next = (*ns)[cur_ns + 1];
+        for (int i=0; i < work->used; i++) {
+            for (struct tree *node = step_first(step, work->nodes[i]);
+                 node != NULL;
+                 node = step_next(step, work->nodes[i], node))
+                ns_add(next, node, state);
+        }
+        ns_filter(next, step->predicates, state);
+        CHECK_ERROR;
+        cur_ns += 1;
+    }
+
+    state->ctx = old_ctx;
+    return;
+ error:
+    if (*ns != NULL) {
+        for (int i=0; i <= *maxns; i++)
+            free_nodeset((*ns)[i]);
+        FREE(*ns);
+    }
+    state->ctx = old_ctx;
+    return;
+}
+
+static void eval_filter(struct expr *expr, struct state *state) {
+    struct locpath *lp = expr->locpath;
+    struct nodeset **ns = NULL;
+    struct locpath_trace *lpt = state->locpath_trace;
+    uint maxns;
+
+    state->locpath_trace = NULL;
+    if (expr->primary == NULL) {
+        ns_from_locpath(lp, &maxns, &ns, NULL, state);
+    } else {
+        eval_expr(expr->primary, state);
+        CHECK_ERROR;
+        value_ind_t primary_ind = pop_value_ind(state);
+        struct value *primary = state->value_pool + primary_ind;
+        assert(primary->tag == T_NODESET);
+        ns_filter(primary->nodeset, expr->predicates, state);
+        /* Evaluating predicates might have reallocated the value_pool */
+        primary = state->value_pool + primary_ind;
+        ns_from_locpath(lp, &maxns, &ns, primary->nodeset, state);
+    }
+    CHECK_ERROR;
+
+    value_ind_t vind = make_value(T_NODESET, state);
+    CHECK_ERROR;
+    state->value_pool[vind].nodeset = ns[maxns];
+    push_value(vind, state);
+
+    if (lpt != NULL) {
+        assert(lpt->ns == NULL);
+        assert(lpt->lp == NULL);
+        lpt->maxns = maxns;
+        lpt->ns = ns;
+        lpt->lp = lp;
+        state->locpath_trace = lpt;
+    } else {
+        for (int i=0; i < maxns; i++)
+            free_nodeset(ns[i]);
+        FREE(ns);
+    }
+}
+
+static struct value *lookup_var(const char *ident, struct state *state) {
+    list_for_each(tab, state->symtab) {
+        if (STREQ(ident, tab->name))
+            return tab->value;
+    }
+    return NULL;
+}
+
+static void eval_var(struct expr *expr, struct state *state) {
+    struct value *v = lookup_var(expr->ident, state);
+    value_ind_t vind = clone_value(v, state);
+    CHECK_ERROR;
+    push_value(vind, state);
+}
+
+static void eval_expr(struct expr *expr, struct state *state) {
+    CHECK_ERROR;
+    switch (expr->tag) {
+    case E_FILTER:
+        eval_filter(expr, state);
+        break;
+    case E_BINARY:
+        eval_binary(expr, state);
+        break;
+    case E_VALUE:
+        push_value(expr->value_ind, state);
+        break;
+    case E_VAR:
+        eval_var(expr, state);
+        break;
+    case E_APP:
+        eval_app(expr, state);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+/*************************************************************************
+ * Typechecker
+ *************************************************************************/
+
+static void check_expr(struct expr *expr, struct state *state);
+
+/* Typecheck a list of predicates. A predicate is a function of
+ * one of the following types:
+ *
+ * T_NODESET -> T_BOOLEAN
+ * T_NUMBER  -> T_BOOLEAN  (position test)
+ * T_BOOLEAN -> T_BOOLEAN
+ */
+static void check_preds(struct pred *pred, struct state *state) {
+    if (pred == NULL)
+        return;
+    for (int i=0; i < pred->nexpr; i++) {
+        struct expr *e = pred->exprs[i];
+        check_expr(e, state);
+        CHECK_ERROR;
+        if (e->type != T_NODESET && e->type != T_NUMBER &&
+            e->type != T_BOOLEAN) {
+            STATE_ERROR(state, PATHX_ETYPE);
+            return;
+        }
+    }
+}
+
+static void check_filter(struct expr *expr, struct state *state) {
+    assert(expr->tag == E_FILTER);
+    struct locpath *locpath = expr->locpath;
+
+    if (expr->primary != NULL) {
+        check_expr(expr->primary, state);
+        if (expr->primary->type != T_NODESET) {
+            STATE_ERROR(state, PATHX_ETYPE);
+            return;
+        }
+        check_preds(expr->predicates, state);
+        CHECK_ERROR;
+    }
+    list_for_each(s, locpath->steps) {
+        check_preds(s->predicates, state);
+        CHECK_ERROR;
+    }
+    expr->type = T_NODESET;
+}
+
+static void check_app(struct expr *expr, struct state *state) {
+    assert(expr->tag == E_APP);
+    for (int i=0; i < expr->func->arity; i++) {
+        check_expr(expr->args[i], state);
+        CHECK_ERROR;
+        if (expr->args[i]->type != expr->func->arg_types[i]) {
+            STATE_ERROR(state, PATHX_ETYPE);
+            return;
+        }
+    }
+    expr->type = expr->func->type;
+}
+
+/* Check the binary operators. Type rules:
+ *
+ * '=', '!='  : T_NODESET -> T_NODESET -> T_BOOLEAN
+ *              T_STRING  -> T_NODESET -> T_BOOLEAN
+ *              T_NODESET -> T_STRING  -> T_BOOLEAN
+ *              T_NUMBER  -> T_NUMBER  -> T_BOOLEAN
+ *
+ * '>', '>=',
+ * '<', '<='  : T_NUMBER -> T_NUMBER -> T_BOOLEAN
+ *              T_STRING -> T_STRING -> T_BOOLEAN
+ * '+', '-', '*': T_NUMBER -> T_NUMBER -> T_NUMBER
+ *
+ * 'and', 'or': T_BOOLEAN -> T_BOOLEAN -> T_BOOLEAN
+ * '=~'       : T_STRING  -> T_REGEXP  -> T_BOOLEAN
+ *              T_NODESET -> T_REGEXP  -> T_BOOLEAN
+ *
+ * '|'        : T_NODESET -> T_NODESET -> T_NODESET
+ *
+ * Any type can be coerced to T_BOOLEAN (see coerce_to_bool)
+ */
+static void check_binary(struct expr *expr, struct state *state) {
+    check_expr(expr->left, state);
+    check_expr(expr->right, state);
+    CHECK_ERROR;
+
+    enum type l = expr->left->type;
+    enum type r = expr->right->type;
+    int  ok = 1;
+    enum type res;
+
+    switch(expr->op) {
+    case OP_EQ:
+    case OP_NEQ:
+        ok = ((l == T_NODESET || l == T_STRING)
+              && (r == T_NODESET || r == T_STRING))
+            || (l == T_NUMBER && r == T_NUMBER);;
+        res = T_BOOLEAN;
+        break;
+    case OP_LT:
+    case OP_LE:
+    case OP_GT:
+    case OP_GE:
+        ok = (l == T_NUMBER && r == T_NUMBER)
+            || (l == T_STRING && r == T_STRING);
+        res = T_BOOLEAN;
+        break;
+    case OP_PLUS:
+    case OP_MINUS:
+    case OP_STAR:
+        ok =  (l == T_NUMBER && r == T_NUMBER);
+        res = T_NUMBER;
+        break;
+    case OP_UNION:
+        ok = (l == T_NODESET && r == T_NODESET);
+        res = T_NODESET;
+        break;
+    case OP_AND:
+    case OP_OR:
+        ok = 1;
+        res = T_BOOLEAN;
+        break;
+    case OP_RE_MATCH:
+        ok = ((l == T_STRING || l == T_NODESET) && r == T_REGEXP);
+        res = T_BOOLEAN;
+        break;
+    default:
+        assert(0);
+    }
+    if (! ok) {
+        STATE_ERROR(state, PATHX_ETYPE);
+    } else {
+        expr->type = res;
+    }
+}
+
+static void check_var(struct expr *expr, struct state *state) {
+    struct value *v = lookup_var(expr->ident, state);
+    if (v == NULL) {
+        STATE_ERROR(state, PATHX_ENOVAR);
+        return;
+    }
+    expr->type = v->tag;
+}
+
+/* Typecheck an expression */
+static void check_expr(struct expr *expr, struct state *state) {
+    CHECK_ERROR;
+    switch(expr->tag) {
+    case E_FILTER:
+        check_filter(expr, state);
+        break;
+    case E_BINARY:
+        check_binary(expr, state);
+        break;
+    case E_VALUE:
+        expr->type = expr_value(expr, state)->tag;
+        break;
+    case E_VAR:
+        check_var(expr, state);
+        break;
+    case E_APP:
+        check_app(expr, state);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+/*
+ * Utility functions for the parser
+ */
+
+static void skipws(struct state *state) {
+    while (isspace(*state->pos)) state->pos += 1;
+}
+
+static int match(struct state *state, char m) {
+    skipws(state);
+
+    if (*state->pos == '\0')
+        return 0;
+    if (*state->pos == m) {
+        state->pos += 1;
+        return 1;
+    }
+    return 0;
+}
+
+static int peek(struct state *state, const char *chars) {
+    return strchr(chars, *state->pos) != NULL;
+}
+
+/* Return 1 if STATE->POS starts with TOKEN, followed by optional
+ * whitespace, followed by FOLLOW. In that case, STATE->POS is set to the
+ * first character after FOLLOW. Return 0 otherwise and leave STATE->POS
+ * unchanged.
+ */
+static int looking_at(struct state *state, const char *token,
+                      const char *follow) {
+    if (STREQLEN(state->pos, token, strlen(token))) {
+        const char *p = state->pos + strlen(token);
+        while (isspace(*p)) p++;
+        if (STREQLEN(p, follow, strlen(follow))) {
+            state->pos = p + strlen(follow);
+            return 1;
+        }
+    }
+    return 0;
+}
+
+/*************************************************************************
+ * The parser
+ *************************************************************************/
+
+static void parse_expr(struct state *state);
+
+static struct expr* pop_expr(struct state *state) {
+    if (state->exprs_used > 0) {
+        state->exprs_used -= 1;
+        return state->exprs[state->exprs_used];
+    } else {
+        STATE_ERROR(state, PATHX_EINTERNAL);
+        assert(0);
+        return NULL;
+    }
+}
+
+static void push_expr(struct expr *expr, struct state *state) {
+    if (state->exprs_used >= state->exprs_size) {
+        size_t new_size = 2*state->exprs_size;
+        if (new_size == 0) new_size = 8;
+        if (REALLOC_N(state->exprs, new_size) < 0) {
+            STATE_ENOMEM;
+            return;
+        }
+        state->exprs_size = new_size;
+    }
+    state->exprs[state->exprs_used++] = expr;
+}
+
+static void push_new_binary_op(enum binary_op op, struct state *state) {
+    struct expr *expr = NULL;
+    if (ALLOC(expr) < 0) {
+        STATE_ENOMEM;
+        return;
+    }
+
+    expr->tag = E_BINARY;
+    expr->op  = op;
+    expr->right = pop_expr(state);
+    expr->left = pop_expr(state);
+    push_expr(expr, state);
+}
+
+/*
+ * Name ::= /[^][/=) \t\n]+/
+ */
+static char *parse_name(struct state *state) {
+    const char *s = state->pos;
+    char *result;
+
+    while (*state->pos != '\0' &&
+           *state->pos != L_BRACK && *state->pos != SEP &&
+           *state->pos != R_BRACK && *state->pos != '=' &&
+           *state->pos != ')' &&
+           !isspace(*state->pos)) {
+        if (*state->pos == '\\') {
+            state->pos += 1;
+            if (*state->pos == '\0') {
+                STATE_ERROR(state, PATHX_ENAME);
+                return NULL;
+            }
+        }
+        state->pos += 1;
+    }
+
+    if (state->pos == s) {
+        STATE_ERROR(state, PATHX_ENAME);
+        return NULL;
+    }
+
+    result = strndup(s, state->pos - s);
+    if (result == NULL) {
+        STATE_ENOMEM;
+        return NULL;
+    }
+
+    char *p = result;
+    for (char *t = result; *t != '\0'; t++, p++) {
+        if (*t == '\\')
+            t += 1;
+        *p = *t;
+    }
+    *p = '\0';
+
+    return result;
+}
+
+/*
+ * Predicate    ::= "[" Expr "]" *
+ */
+static struct pred *parse_predicates(struct state *state) {
+    struct pred *pred = NULL;
+    int nexpr = 0;
+
+    while (match(state, L_BRACK)) {
+        parse_expr(state);
+        nexpr += 1;
+        CHECK_ERROR_RET0;
+
+        if (! match(state, R_BRACK)) {
+            STATE_ERROR(state, PATHX_EPRED);
+            return NULL;
+        }
+        skipws(state);
+    }
+
+    if (nexpr == 0)
+        return NULL;
+
+    if (ALLOC(pred) < 0) {
+        STATE_ENOMEM;
+        return NULL;
+    }
+    pred->nexpr = nexpr;
+
+    if (ALLOC_N(pred->exprs, nexpr) < 0) {
+        free_pred(pred);
+        STATE_ENOMEM;
+        return NULL;
+    }
+
+    for (int i = nexpr - 1; i >= 0; i--)
+        pred->exprs[i] = pop_expr(state);
+
+    return pred;
+}
+
+/*
+ * Step ::= AxisSpecifier NameTest Predicate* | '.' | '..'
+ * AxisSpecifier ::= AxisName '::' | <epsilon>
+ * AxisName ::= 'ancestor'
+ *            | 'ancestor-or-self'
+ *            | 'child'
+ *            | 'descendant'
+ *            | 'descendant-or-self'
+ *            | 'parent'
+ *            | 'self'
+ *            | 'root'
+ */
+static struct step *parse_step(struct state *state) {
+    struct step *step;
+    int explicit_axis = 0, allow_predicates = 1;
+
+    if (ALLOC(step) < 0) {
+        STATE_ENOMEM;
+        return NULL;
+    }
+
+    step->axis = CHILD;
+    for (int i = 0; i < ARRAY_CARDINALITY(axis_names); i++) {
+        if (looking_at(state, axis_names[i], "::")) {
+            step->axis = i;
+            explicit_axis = 1;
+            break;
+        }
+    }
+
+    if (! match(state, '*')) {
+        step->name = parse_name(state);
+        if (HAS_ERROR(state))
+            goto error;
+        if (! explicit_axis) {
+            if (STREQ(step->name, ".") || STREQ(step->name, "..")) {
+                step->axis = STREQ(step->name, ".") ? SELF : PARENT;
+                FREE(step->name);
+                allow_predicates = 0;
+            }
+        }
+    }
+
+    if (allow_predicates) {
+        step->predicates = parse_predicates(state);
+        if (HAS_ERROR(state))
+            goto error;
+    }
+
+    return step;
+
+ error:
+    free_step(step);
+    return NULL;
+}
+
+static struct step *make_step(enum axis axis, struct state *state) {
+    struct step *result = NULL;
+
+    if (ALLOC(result) < 0) {
+        STATE_ENOMEM;
+        return NULL;
+    }
+    result->axis = axis;
+    return result;
+}
+
+/*
+ * RelativeLocationPath ::= Step
+ *                        | RelativeLocationPath '/' Step
+ *                        | AbbreviatedRelativeLocationPath
+ * AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
+ *
+ * The above is the same as
+ * RelativeLocationPath ::= Step ('/' Step | '//' Step)*
+ */
+static struct locpath *
+parse_relative_location_path(struct state *state) {
+    struct step *step = NULL;
+    struct locpath *locpath = NULL;
+
+    step = parse_step(state);
+    CHECK_ERROR_RET0;
+
+    if (ALLOC(locpath) < 0) {
+        STATE_ENOMEM;
+        goto error;
+    }
+    list_append(locpath->steps, step);
+    step = NULL;
+
+    while (match(state, '/')) {
+        if (*state->pos == '/') {
+            state->pos += 1;
+            step = make_step(DESCENDANT_OR_SELF, state);
+            ENOMEM_ON_NULL(state, step);
+            list_append(locpath->steps, step);
+        }
+        step = parse_step(state);
+        if (HAS_ERROR(state))
+            goto error;
+        list_append(locpath->steps, step);
+        step = NULL;
+    }
+    return locpath;
+
+ error:
+    free_step(step);
+    free_locpath(locpath);
+    return NULL;
+}
+
+/*
+ * LocationPath ::= RelativeLocationPath | AbsoluteLocationPath
+ * AbsoluteLocationPath ::= '/' RelativeLocationPath?
+ *                        | AbbreviatedAbsoluteLocationPath
+ * AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath
+ *
+ */
+static void parse_location_path(struct state *state) {
+    struct expr *expr = NULL;
+    struct locpath *locpath = NULL;
+
+    if (match(state, '/')) {
+        if (*state->pos == '/') {
+            state->pos += 1;
+            locpath = parse_relative_location_path(state);
+            if (HAS_ERROR(state))
+                return;
+            struct step *step = make_step(DESCENDANT_OR_SELF, state);
+            if (HAS_ERROR(state))
+                goto error;
+            list_cons(locpath->steps, step);
+        } else {
+            if (*state->pos != '\0') {
+                locpath = parse_relative_location_path(state);
+            } else {
+                if (ALLOC(locpath) < 0)
+                    goto err_nomem;
+            }
+            struct step *step = make_step(ROOT, state);
+            if (HAS_ERROR(state))
+                goto error;
+            list_cons(locpath->steps, step);
+        }
+    } else {
+        locpath = parse_relative_location_path(state);
+    }
+
+    if (ALLOC(expr) < 0)
+        goto err_nomem;
+    expr->tag = E_FILTER;
+    expr->locpath = locpath;
+    push_expr(expr, state);
+    return;
+
+ err_nomem:
+    STATE_ENOMEM;
+ error:
+    free_expr(expr);
+    free_locpath(locpath);
+    return;
+}
+
+/*
+ * Number       ::= /[0-9]+/
+ */
+static void parse_number(struct state *state) {
+    struct expr *expr = NULL;
+    unsigned long val;
+    char *end;
+
+    errno = 0;
+    val = strtoul(state->pos, &end, 10);
+    if (errno || end == state->pos || (int) val != val) {
+        STATE_ERROR(state, PATHX_ENUMBER);
+        return;
+    }
+
+    state->pos = end;
+
+    if (ALLOC(expr) < 0)
+        goto err_nomem;
+    expr->tag = E_VALUE;
+    expr->value_ind = make_value(T_NUMBER, state);
+    if (HAS_ERROR(state))
+        goto error;
+    expr_value(expr, state)->number = val;
+
+    push_expr(expr, state);
+    return;
+
+ err_nomem:
+    STATE_ENOMEM;
+ error:
+    free_expr(expr);
+    return;
+}
+
+/*
+ * Literal ::= '"' /[^"]* / '"' | "'" /[^']* / "'"
+ */
+static void parse_literal(struct state *state) {
+    char delim;
+    const char *s;
+    struct expr *expr = NULL;
+
+    if (*state->pos == '"')
+        delim = '"';
+    else if (*state->pos == '\'')
+        delim = '\'';
+    else {
+        STATE_ERROR(state, PATHX_ESTRING);
+        return;
+    }
+    state->pos += 1;
+
+    s = state->pos;
+    while (*state->pos != '\0' && *state->pos != delim) state->pos += 1;
+
+    if (*state->pos != delim) {
+        STATE_ERROR(state, PATHX_EDELIM);
+        return;
+    }
+    state->pos += 1;
+
+    if (ALLOC(expr) < 0)
+        goto err_nomem;
+    expr->tag = E_VALUE;
+    expr->value_ind = make_value(T_STRING, state);
+    if (HAS_ERROR(state))
+        goto error;
+    expr_value(expr, state)->string = strndup(s, state->pos - s - 1);
+    if (expr_value(expr, state)->string == NULL)
+        goto err_nomem;
+
+    push_expr(expr, state);
+    return;
+
+ err_nomem:
+    STATE_ENOMEM;
+ error:
+    free_expr(expr);
+    return;
+}
+
+/*
+ * FunctionCall ::= Name '(' ( Expr ( ',' Expr )* )? ')'
+ */
+static void parse_function_call(struct state *state) {
+    const struct func *func = NULL;
+    struct expr *expr = NULL;
+    int nargs = 0;
+
+    for (int i=0; i < ARRAY_CARDINALITY(builtin_funcs); i++) {
+        if (looking_at(state, builtin_funcs[i].name, "("))
+            func = builtin_funcs + i;
+    }
+    if (func == NULL) {
+        STATE_ERROR(state, PATHX_ENAME);
+        return;
+    }
+
+    if (! match(state, ')')) {
+        do {
+            nargs += 1;
+            parse_expr(state);
+            CHECK_ERROR;
+        } while (match(state, ','));
+
+        if (! match(state, ')')) {
+            STATE_ERROR(state, PATHX_EPAREN);
+            return;
+        }
+    }
+
+    if (nargs != func->arity) {
+        STATE_ERROR(state, PATHX_EARITY);
+        return;
+    }
+
+    if (ALLOC(expr) < 0) {
+        STATE_ENOMEM;
+        return;
+    }
+    expr->tag = E_APP;
+    if (ALLOC_N(expr->args, nargs) < 0) {
+        free_expr(expr);
+        STATE_ENOMEM;
+        return;
+    }
+    expr->func = func;
+    for (int i = nargs - 1; i >= 0; i--)
+        expr->args[i] = pop_expr(state);
+
+    push_expr(expr, state);
+}
+
+/*
+ * VariableReference ::= '$' /[a-zA-Z_][a-zA-Z0-9_]* /
+ *
+ * The '$' is consumed by parse_primary_expr
+ */
+static void parse_var(struct state *state) {
+    const char *id = state->pos;
+    struct expr *expr = NULL;
+
+    if (!isalpha(*id) && *id != '_') {
+        STATE_ERROR(state, PATHX_ENAME);
+        return;
+    }
+    id++;
+    while (isalpha(*id) || isdigit(*id) || *id == '_')
+        id += 1;
+
+    if (ALLOC(expr) < 0)
+        goto err_nomem;
+    expr->tag = E_VAR;
+    expr->ident = strndup(state->pos, id - state->pos);
+    if (expr->ident == NULL)
+        goto err_nomem;
+
+    push_expr(expr, state);
+    state->pos = id;
+    return;
+ err_nomem:
+    STATE_ENOMEM;
+    free_expr(expr);
+    return;
+}
+
+/*
+ * PrimaryExpr ::= Literal
+ *               | Number
+ *               | FunctionCall
+ *               | VariableReference
+ *               | '(' Expr ')'
+ *
+ */
+static void parse_primary_expr(struct state *state) {
+    if (peek(state, "'\"")) {
+        parse_literal(state);
+    } else if (peek(state, "0123456789")) {
+        parse_number(state);
+    } else if (match(state, '(')) {
+        parse_expr(state);
+        CHECK_ERROR;
+        if (! match(state, ')')) {
+            STATE_ERROR(state, PATHX_EPAREN);
+            return;
+        }
+    } else if (match(state, '$')) {
+        parse_var(state);
+    } else {
+        parse_function_call(state);
+    }
+}
+
+static int looking_at_primary_expr(struct state *state) {
+    const char *s = state->pos;
+    /* Is it a Number, Literal or VariableReference ? */
+    if (peek(state, "$'\"0123456789"))
+        return 1;
+
+    /* Or maybe a function call, i.e. a word followed by a '(' ?
+     * Note that our function names are only [a-zA-Z]+
+     */
+    while (*s != '\0' && isalpha(*s)) s++;
+    while (*s != '\0' && isspace(*s)) s++;
+    return *s == '(';
+}
+
+/*
+ * PathExpr ::= LocationPath
+ *            | FilterExpr
+ *            | FilterExpr '/' RelativeLocationPath
+ *            | FilterExpr '//' RelativeLocationPath
+ *
+ * FilterExpr ::= PrimaryExpr Predicate
+ *
+ * The grammar is ambiguous here: the expression '42' can either be the
+ * number 42 (a PrimaryExpr) or the RelativeLocationPath 'child::42'. The
+ * reason for this ambiguity is that we allow node names like '42' in the
+ * tree; rather than forbid them, we resolve the ambiguity by always
+ * parsing '42' as a number, and requiring that the user write the
+ * RelativeLocationPath in a different form, e.g. 'child::42' or './42'.
+ */
+static void parse_path_expr(struct state *state) {
+    struct expr *expr = NULL;
+    struct pred *predicates = NULL;
+    struct locpath *locpath = NULL;
+
+    if (looking_at_primary_expr(state)) {
+        parse_primary_expr(state);
+        CHECK_ERROR;
+        predicates = parse_predicates(state);
+        CHECK_ERROR;
+        if (match(state, '/')) {
+            if (match(state, '/')) {
+                locpath = parse_relative_location_path(state);
+                if (HAS_ERROR(state))
+                    goto error;
+
+                struct step *step = make_step(DESCENDANT_OR_SELF, state);
+                if (HAS_ERROR(state))
+                    return;
+                list_cons(locpath->steps, step);
+            } else {
+                if (*state->pos == '\0') {
+                    STATE_ERROR(state, PATHX_EEND);
+                    goto error;
+                }
+                locpath = parse_relative_location_path(state);
+            }
+        }
+        /* A PathExpr without predicates and locpath is
+         * just a PrimaryExpr
+         */
+        if (predicates == NULL && locpath == NULL)
+            return;
+        /* To make evaluation easier, we parse something like
+         *   $var[pred] as $var[pred]/.
+         */
+        if (locpath == NULL) {
+            if (ALLOC(locpath) < 0)
+                goto error;
+            if (ALLOC(locpath->steps) < 0)
+                goto error;
+            locpath->steps->axis = SELF;
+        }
+        if (ALLOC(expr) < 0)
+            goto error;
+        expr->tag = E_FILTER;
+        expr->predicates = predicates;
+        expr->primary    = pop_expr(state);
+        expr->locpath    = locpath;
+        push_expr(expr, state);
+    } else {
+        parse_location_path(state);
+    }
+    return;
+ error:
+    free_expr(expr);
+    free_pred(predicates);
+    free_locpath(locpath);
+    return;
+}
+
+/*
+ * UnionExpr ::= PathExpr ('|' PathExpr)*
+ */
+static void parse_union_expr(struct state *state) {
+    parse_path_expr(state);
+    CHECK_ERROR;
+    while (match(state, '|')) {
+        parse_path_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(OP_UNION, state);
+    }
+}
+
+/*
+ * MultiplicativeExpr ::= UnionExpr ('*' UnionExpr)*
+ */
+static void parse_multiplicative_expr(struct state *state) {
+    parse_union_expr(state);
+    CHECK_ERROR;
+    while (match(state, '*')) {
+        parse_union_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(OP_STAR, state);
+    }
+}
+
+/*
+ * AdditiveExpr ::= MultiplicativeExpr (AdditiveOp MultiplicativeExpr)*
+ * AdditiveOp   ::= '+' | '-'
+ */
+static void parse_additive_expr(struct state *state) {
+    parse_multiplicative_expr(state);
+    CHECK_ERROR;
+    while (*state->pos == '+' || *state->pos == '-') {
+        enum binary_op op = (*state->pos == '+') ? OP_PLUS : OP_MINUS;
+        state->pos += 1;
+        skipws(state);
+        parse_multiplicative_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(op, state);
+    }
+}
+
+/*
+ * RelationalExpr ::= AdditiveExpr (RelationalOp AdditiveExpr)?
+ * RelationalOp ::= ">" | "<" | ">=" | "<="
+ */
+static void parse_relational_expr(struct state *state) {
+    parse_additive_expr(state);
+    CHECK_ERROR;
+    if (*state->pos == '<' || *state->pos == '>') {
+        enum binary_op op = (*state->pos == '<') ? OP_LT : OP_GT;
+        state->pos += 1;
+        if (*state->pos == '=') {
+            op = (op == OP_LT) ? OP_LE : OP_GE;
+            state->pos += 1;
+        }
+        skipws(state);
+        parse_additive_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(op, state);
+    }
+}
+
+/*
+ * EqualityExpr ::= RelationalExpr (EqualityOp RelationalExpr)? | ReMatchExpr
+ * EqualityOp ::= "=" | "!="
+ * ReMatchExpr ::= RelationalExpr "=~" RelationalExpr
+ */
+static void parse_equality_expr(struct state *state) {
+    parse_relational_expr(state);
+    CHECK_ERROR;
+    if (*state->pos == '=' && state->pos[1] == '~') {
+        state->pos += 2;
+        skipws(state);
+        parse_relational_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(OP_RE_MATCH, state);
+    } else if (*state->pos == '=' ||
+        (*state->pos == '!' && state->pos[1] == '=')) {
+        enum binary_op op = (*state->pos == '=') ? OP_EQ : OP_NEQ;
+        state->pos += (op == OP_EQ) ? 1 : 2;
+        skipws(state);
+        parse_relational_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(op, state);
+    }
+}
+
+/*
+ * AndExpr ::= EqualityExpr ('and' EqualityExpr)*
+ */
+static void parse_and_expr(struct state *state) {
+    parse_equality_expr(state);
+    CHECK_ERROR;
+    while (*state->pos == 'a' && state->pos[1] == 'n'
+        && state->pos[2] == 'd') {
+        state->pos += 3;
+        skipws(state);
+        parse_equality_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(OP_AND, state);
+    }
+}
+
+/*
+ * OrExpr ::= AndExpr ('or' AndExpr)*
+ */
+static void parse_or_expr(struct state *state) {
+    parse_and_expr(state);
+    CHECK_ERROR;
+    while (*state->pos == 'o' && state->pos[1] == 'r') {
+        state->pos += 2;
+        skipws(state);
+        parse_and_expr(state);
+        CHECK_ERROR;
+        push_new_binary_op(OP_OR, state);
+    }
+}
+
+/*
+ * Expr ::= OrExpr
+ */
+static void parse_expr(struct state *state) {
+    skipws(state);
+    parse_or_expr(state);
+}
+
+static void store_error(struct pathx *pathx) {
+    const char *pathx_msg = NULL;
+    const char *path = pathx->state->txt;
+    const pathx_errcode_t errcode = pathx->state->errcode;
+    struct error *err = pathx->state->error;
+
+    char *pos_str = pathx->state->errmsg;
+    pathx->state->errmsg = NULL;
+
+    if (err == NULL || errcode == PATHX_NOERROR || err->code != AUG_NOERROR)
+        return;
+
+    int pos;
+    pathx_msg = pathx_error(pathx, NULL, &pos);
+
+    bool has_msg = pos_str != NULL;
+    int pos_str_len = pos_str == NULL ? 0 : strlen(pos_str);
+    if (REALLOC_N(pos_str, pos_str_len + strlen(path) + 8) >= 0) {
+        if (has_msg) {
+            strcat(pos_str, " in ");
+            strncat(pos_str, path, pos);
+        } else {
+            /* initialize pos_str explicitly, path might be "" */
+            pos_str[0] = '\0';
+            strncat(pos_str, path, pos);
+        }
+        strcat(pos_str, "|=|");
+        strcat(pos_str, path + pos);
+    }
+
+    err->code = errcode == PATHX_ENOMEM ? AUG_ENOMEM : AUG_EPATHX;
+    err->minor = errcode;
+    err->details = pos_str;
+    pos_str = NULL;
+    err->minor_details = pathx_msg;
+}
+
+int pathx_parse(const struct tree *tree,
+                struct error *err,
+                const char *txt,
+                bool need_nodeset,
+                struct pathx_symtab *symtab,
+                struct pathx **pathx) {
+    struct state *state = NULL;
+
+    *pathx = NULL;
+
+    if (ALLOC(*pathx) < 0)
+        goto oom;
+
+    (*pathx)->origin = (struct tree *) tree;
+
+    /* Set up state */
+    if (ALLOC((*pathx)->state) < 0)
+        goto oom;
+    state = (*pathx)->state;
+
+    state->errcode = PATHX_NOERROR;
+    state->errmsg = NULL;
+    state->txt = txt;
+    state->pos = txt;
+    state->symtab = symtab;
+    state->error = err;
+
+    if (ALLOC_N(state->value_pool, 8) < 0) {
+        STATE_ENOMEM;
+        goto done;
+    }
+    state->value_pool_size = 8;
+    state->value_pool[0].tag = T_BOOLEAN;
+    state->value_pool[0].boolval = 0;
+    state->value_pool[1].tag = T_BOOLEAN;
+    state->value_pool[1].boolval = 1;
+    state->value_pool_used = 2;
+
+    /* Parse */
+    parse_expr(state);
+    if (HAS_ERROR(state))
+        goto done;
+    if (state->pos != state->txt + strlen(state->txt)) {
+        STATE_ERROR(state, PATHX_EEND);
+        goto done;
+    }
+
+    if (state->exprs_used != 1) {
+        STATE_ERROR(state, PATHX_EINTERNAL);
+        goto done;
+    }
+
+    /* Typecheck */
+    check_expr(state->exprs[0], state);
+    if (HAS_ERROR(state))
+        goto done;
+
+    if (need_nodeset && state->exprs[0]->type != T_NODESET) {
+        STATE_ERROR(state, PATHX_ETYPE);
+        goto done;
+    }
+
+ done:
+    store_error(*pathx);
+    return state->errcode;
+ oom:
+    free_pathx(*pathx);
+    *pathx = NULL;
+    if (err != NULL)
+        err->code = AUG_ENOMEM;
+    return PATHX_ENOMEM;
+}
+
+/*************************************************************************
+ * Searching in the tree
+ *************************************************************************/
+
+static bool step_matches(struct step *step, struct tree *tree) {
+    return (step->name == NULL || streqx(step->name, tree->label));
+}
+
+static struct tree *tree_prev(struct tree *pos) {
+    struct tree *node = NULL;
+    if (pos != pos->parent->children) {
+        for (node = pos->parent->children;
+             node->next != pos;
+             node = node->next);
+    }
+    return node;
+}
+
+static struct tree *step_first(struct step *step, struct tree *ctx) {
+    struct tree *node = NULL;
+    switch (step->axis) {
+    case SELF:
+    case DESCENDANT_OR_SELF:
+        node = ctx;
+        break;
+    case CHILD:
+    case DESCENDANT:
+        node = ctx->children;
+        break;
+    case PARENT:
+    case ANCESTOR:
+        node = ctx->parent;
+        break;
+    case ROOT:
+        while (ctx->parent != ctx)
+            ctx = ctx->parent;
+        node = ctx;
+        break;
+    case PRECEDING_SIBLING:
+        node = tree_prev(ctx);
+        break;
+    case FOLLOWING_SIBLING:
+        node = ctx->next;
+        break;
+    default:
+        assert(0);
+    }
+    if (node == NULL)
+        return NULL;
+    if (step_matches(step, node))
+        return node;
+    return step_next(step, ctx, node);
+}
+
+static struct tree *step_next(struct step *step, struct tree *ctx,
+                              struct tree *node) {
+    while (node != NULL) {
+        switch (step->axis) {
+        case SELF:
+            node = NULL;
+            break;
+        case CHILD:
+            node = node->next;
+            break;
+        case DESCENDANT:
+        case DESCENDANT_OR_SELF:
+            if (node->children != NULL) {
+                node = node->children;
+            } else {
+                while (node->next == NULL && node != ctx)
+                    node = node->parent;
+                if (node == ctx)
+                    node = NULL;
+                else
+                    node = node->next;
+            }
+            break;
+        case PARENT:
+        case ROOT:
+            node = NULL;
+            break;
+        case ANCESTOR:
+            if (node->parent == node)
+                node = NULL;
+            else
+                node = node->parent;
+            break;
+        case PRECEDING_SIBLING:
+            node = tree_prev(node);
+            break;
+        case FOLLOWING_SIBLING:
+            node = node->next;
+            break;
+        default:
+            assert(0);
+        }
+        if (node != NULL && step_matches(step, node))
+            break;
+    }
+    return node;
+}
+
+static struct value *pathx_eval(struct pathx *pathx) {
+    struct state *state = pathx->state;
+    state->ctx = pathx->origin;
+    state->ctx_pos = 1;
+    state->ctx_len = 1;
+    eval_expr(state->exprs[0], state);
+    if (HAS_ERROR(state))
+        return NULL;
+
+    if (state->values_used != 1) {
+        STATE_ERROR(state, PATHX_EINTERNAL);
+        return NULL;
+    }
+    return pop_value(state);
+}
+
+struct tree *pathx_next(struct pathx *pathx) {
+    if (pathx->node + 1 < pathx->nodeset->used)
+        return pathx->nodeset->nodes[++pathx->node];
+    return NULL;
+}
+
+/* Find the first node in TREE matching PATH. */
+struct tree *pathx_first(struct pathx *pathx) {
+    if (pathx->nodeset == NULL) {
+        struct value *v = pathx_eval(pathx);
+
+        if (HAS_ERROR(pathx->state))
+            goto error;
+        assert(v->tag == T_NODESET);
+        pathx->nodeset = v->nodeset;
+    }
+    pathx->node = 0;
+    if (pathx->nodeset->used == 0)
+        return NULL;
+    else
+        return pathx->nodeset->nodes[0];
+ error:
+    store_error(pathx);
+    return NULL;
+}
+
+/* Find a node in the tree that matches the longest prefix of PATH.
+ *
+ * Return 1 if a node was found that exactly matches PATH, 0 if an incomplete
+ * prefix matches, and -1 if more than one node in the tree match.
+ *
+ * TMATCH is set to the tree node that matches, and SMATCH to the next step
+ * after the one where TMATCH matched. If no node matches or multiple nodes
+ * at the same depth match, TMATCH and SMATCH will be NULL. When exactly
+ * one node matches, TMATCH will be that node, and SMATCH will be NULL.
+ */
+static int locpath_search(struct locpath_trace *lpt,
+                          struct tree **tmatch, struct step **smatch) {
+    int last;
+    int result = -1;
+
+    for (last=lpt->maxns; last >= 0 && lpt->ns[last]->used == 0; last--);
+    if (last < 0) {
+        *smatch = lpt->lp->steps;
+        result = 1;
+        goto done;
+    }
+    if (lpt->ns[last]->used > 1) {
+        result = -1;
+        goto done;
+    }
+    result = 0;
+    *tmatch = lpt->ns[last]->nodes[0];
+    *smatch = lpt->lp->steps;
+    for (int i=0; i < last; i++)
+        *smatch = (*smatch)->next;
+ done:
+    for (int i=0; i < lpt->maxns; i++)
+        free_nodeset(lpt->ns[i]);
+    FREE(lpt->ns);
+    return result;
+}
+
+/* Expand the tree ROOT so that it contains all components of PATH. PATH
+ * must have been initialized against ROOT by a call to PATH_FIND_ONE.
+ *
+ * Return the first segment that was created by this operation, or NULL on
+ * error.
+ */
+int pathx_expand_tree(struct pathx *path, struct tree **tree) {
+    int r;
+    struct step *step = NULL;
+    struct locpath_trace lpt;
+    struct tree *first_child = NULL;
+    struct value *v = NULL;
+
+    MEMZERO(&lpt, 1);
+    path->state->locpath_trace = &lpt;
+    v = pathx_eval(path);
+    path->state->locpath_trace = NULL;
+    if (HAS_ERROR(path->state))
+        goto error;
+
+    if (lpt.maxns == 0) {
+        if (v->tag != T_NODESET || v->nodeset->used == 0) {
+            STATE_ERROR(path->state, PATHX_ENONODES);
+            goto error;
+        }
+        if (v->nodeset->used > 1)
+            goto error;
+        *tree = v->nodeset->nodes[0];
+        return 0;
+    }
+
+    *tree = path->origin;
+    r = locpath_search(&lpt, tree, &step);
+    if (r == -1)
+        return -1;
+
+    if (step == NULL)
+        return 0;
+
+    struct tree *parent = *tree;
+    if (parent == NULL)
+        parent = path->origin;
+
+    list_for_each(s, step) {
+        if (s->name == NULL || s->axis != CHILD)
+            goto error;
+        struct tree *t = make_tree(strdup(s->name), NULL, parent, NULL);
+        if (first_child == NULL)
+            first_child = t;
+        if (t == NULL || t->label == NULL)
+            goto error;
+        list_append(parent->children, t);
+        parent = t;
+    }
+
+    while (first_child->children != NULL)
+        first_child = first_child->children;
+
+    *tree = first_child;
+    return 1;
+
+ error:
+    if (first_child != NULL) {
+        list_remove(first_child, first_child->parent->children);
+        free_tree(first_child);
+    }
+    *tree = NULL;
+    store_error(path);
+    return -1;
+}
+
+int pathx_find_one(struct pathx *path, struct tree **tree) {
+    *tree = pathx_first(path);
+    if (HAS_ERROR(path->state))
+        return -1;
+    return path->nodeset->used;
+}
+
+struct error *err_of_pathx(struct pathx *px) {
+    return px->state->error;
+}
+
+const char *pathx_error(struct pathx *path, const char **txt, int *pos) {
+    int errcode = PATHX_ENOMEM;
+
+    if (path != NULL) {
+        if (path->state->errcode < ARRAY_CARDINALITY(errcodes))
+            errcode = path->state->errcode;
+        else
+            errcode = PATHX_EINTERNAL;
+    }
+
+    if (txt)
+        *txt = path->state->txt;
+
+    if (pos)
+        *pos = path->state->pos - path->state->txt;
+
+    return errcodes[errcode];
+}
+
+/*
+ * Symbol tables
+ */
+static struct pathx_symtab
+*make_symtab(struct pathx_symtab *symtab, const char *name,
+             struct value *value)
+{
+    struct pathx_symtab *new;
+    char *n = NULL;
+
+    n = strdup(name);
+    if (n == NULL)
+        return NULL;
+
+    if (ALLOC(new) < 0) {
+        free(n);
+        return NULL;
+    }
+    new->name = n;
+    new->value = value;
+    if (symtab == NULL) {
+        return new;
+    } else {
+        new->next = symtab->next;
+        symtab->next = new;
+    }
+    return symtab;
+}
+
+void free_symtab(struct pathx_symtab *symtab) {
+
+    while (symtab != NULL) {
+        struct pathx_symtab *del = symtab;
+        symtab = del->next;
+        free(del->name);
+        release_value(del->value);
+        free(del->value);
+        free(del);
+    }
+}
+
+struct pathx_symtab *pathx_get_symtab(struct pathx *pathx) {
+    return pathx->state->symtab;
+}
+
+static int pathx_symtab_set(struct pathx_symtab **symtab,
+                            const char *name, struct value *v) {
+    int found = 0;
+
+    list_for_each(tab, *symtab) {
+        if (STREQ(tab->name, name)) {
+            release_value(tab->value);
+            free(tab->value);
+            tab->value = v;
+            found = 1;
+            break;
+        }
+    }
+
+    if (!found) {
+        struct pathx_symtab *new = NULL;
+
+        new = make_symtab(*symtab, name, v);
+        if (new == NULL)
+            goto error;
+        *symtab = new;
+    }
+    return 0;
+ error:
+    return -1;
+}
+
+int pathx_symtab_define(struct pathx_symtab **symtab,
+                        const char *name, struct pathx *px) {
+    int r;
+    struct value *value = NULL, *v = NULL;
+    struct state *state = px->state;
+
+    value = pathx_eval(px);
+    if (HAS_ERROR(px->state))
+        goto error;
+
+    if (ALLOC(v) < 0) {
+        STATE_ENOMEM;
+        goto error;
+    }
+
+    *v = *value;
+    value->tag = T_BOOLEAN;
+
+    r = pathx_symtab_set(symtab, name, v);
+    if (r < 0) {
+        STATE_ENOMEM;
+        goto error;
+    }
+
+    if (v->tag == T_NODESET)
+        return v->nodeset->used;
+    else
+        return 0;
+ error:
+    release_value(value);
+    free(value);
+    release_value(v);
+    free(v);
+    store_error(px);
+    return -1;
+}
+
+int pathx_symtab_undefine(struct pathx_symtab **symtab, const char *name) {
+    struct pathx_symtab *del = NULL;
+
+    for(del = *symtab;
+        del != NULL && !STREQ(del->name, name);
+        del = del->next);
+    if (del == NULL)
+        return 0;
+    list_remove(del, *symtab);
+    free_symtab(del);
+    return 0;
+}
+
+int pathx_symtab_assign_tree(struct pathx_symtab **symtab,
+                             const char *name, struct tree *tree) {
+    struct value *v = NULL;
+    int r;
+
+    if (ALLOC(v) < 0)
+        goto error;
+
+    v->tag = T_NODESET;
+    if (ALLOC(v->nodeset) < 0)
+        goto error;
+    if (ALLOC_N(v->nodeset->nodes, 1) < 0)
+        goto error;
+    v->nodeset->used = 1;
+    v->nodeset->size = 1;
+    v->nodeset->nodes[0] = tree;
+
+    r = pathx_symtab_set(symtab, name, v);
+    if (r < 0)
+        goto error;
+    return 1;
+ error:
+    release_value(v);
+    free(v);
+    return -1;
+}
+
+void pathx_symtab_remove_descendants(struct pathx_symtab *symtab,
+                                     const struct tree *tree) {
+    list_for_each(tab, symtab) {
+        if (tab->value->tag != T_NODESET)
+            continue;
+        struct nodeset *ns = tab->value->nodeset;
+        for (int i=0; i < ns->used;) {
+            struct tree *t = ns->nodes[i];
+            while (t != t->parent && t != tree)
+                t = t->parent;
+            if (t == tree)
+                ns_remove(ns, i);
+            else
+                i += 1;
+        }
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/put.c b/src/put.c
new file mode 100644 (file)
index 0000000..122ef84
--- /dev/null
+++ b/src/put.c
@@ -0,0 +1,832 @@
+/*
+ * put.c:
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <stdarg.h>
+#include "regexp.h"
+#include "memory.h"
+#include "lens.h"
+#include "errcode.h"
+
+/* Data structure to keep track of where we are in the tree. The split
+ * describes a sublist of the list of siblings in the current tree. The
+ * put_* functions don't operate on the tree directly, instead they operate
+ * on a split.
+ *
+ * The TREE field points to the first tree node for the current invocation
+ * of put_*, FOLLOW points to the first sibling following TREE that is not
+ * part of the split anymore (NULL if we are talking about all the siblings
+ * of TREE)
+ *
+ * ENC is a string containing the encoding of the current position in the
+ * tree.  The encoding is
+ *   <label>=<value>/<label>=<value>/.../<label>=<value>/
+ * where the label/value pairs come from TREE and its
+ * siblings. The encoding uses ENC_EQ instead of the '=' above to avoid
+ * clashes with legitimate values, and encodes NULL values as ENC_NULL.
+ */
+struct split {
+    struct split *next;
+    struct tree  *tree;
+    struct tree  *follow;
+    char         *enc;
+    size_t        start;
+    size_t        end;
+};
+
+struct state {
+    FILE             *out;
+    struct split     *split;
+    const char       *key;
+    const char       *value;
+    struct dict      *dict;
+    struct skel      *skel;
+    char             *path;   /* Position in the tree, for errors */
+    size_t            pos;
+    struct lns_error *error;
+};
+
+static void create_lens(struct lens *lens, struct state *state);
+static void put_lens(struct lens *lens, struct state *state);
+
+static void put_error(struct state *state, struct lens *lens,
+                      const char *format, ...)
+{
+    va_list ap;
+    int r;
+
+    if (state->error != NULL)
+        return;
+
+    CALLOC(state->error, 1);
+    state->error->lens = ref(lens);
+    state->error->pos  = -1;
+    if (strlen(state->path) == 0) {
+        state->error->path = strdup("");
+    } else {
+        state->error->path = strdup(state->path);
+    }
+
+    va_start(ap, format);
+    r = vasprintf(&state->error->message, format, ap);
+    va_end(ap);
+    if (r == -1)
+        state->error->message = NULL;
+}
+
+ATTRIBUTE_PURE
+static int enclen(const char *key, const char *value) {
+    return ENCLEN(key) + strlen(ENC_EQ) + ENCLEN(value)
+        + strlen(ENC_SLASH);
+}
+
+static char *encpcpy(char *e, const char *key, const char *value) {
+    e = stpcpy(e, ENCSTR(key));
+    e = stpcpy(e, ENC_EQ);
+    e = stpcpy(e, ENCSTR(value));
+    e = stpcpy(e, ENC_SLASH);
+    return e;
+}
+
+static void regexp_match_error(struct state *state, struct lens *lens,
+                               int count, struct split *split) {
+    // FIXME: Split the regexp and encoding back
+    // into something resembling a tree level
+    char *text = NULL;
+    char *pat = NULL;
+
+    lns_format_atype(lens, &pat);
+    text = enc_format(split->enc + split->start, split->end - split->start);
+
+    if (count == -1) {
+        put_error(state, lens,
+                  "Failed to match \n    %s\n  with tree\n   %s",
+                  pat, text);
+    } else if (count == -2) {
+        put_error(state, lens,
+                  "Internal error matching\n    %s\n  with tree\n   %s",
+                  pat, text);
+    } else if (count == -3) {
+        /* Should have been caught by the typechecker */
+        put_error(state, lens, "Syntax error in tree schema\n    %s", pat);
+    }
+    free(pat);
+    free(text);
+}
+
+static void free_split(struct split *split) {
+    if (split == NULL)
+        return;
+
+    free(split->enc);
+    free(split);
+}
+
+/* Encode the list of TREE's children as a string.
+ */
+static struct split *make_split(struct tree *tree) {
+    struct split *split;
+
+    if (ALLOC(split) < 0)
+        return NULL;
+
+    split->tree = tree;
+    list_for_each(t, tree) {
+        split->end += enclen(t->label, t->value);
+    }
+
+    if (ALLOC_N(split->enc, split->end + 1) < 0)
+        goto error;
+
+    char *enc = split->enc;
+    list_for_each(t, tree) {
+        enc = encpcpy(enc, t->label, t->value);
+    }
+    return split;
+ error:
+    free_split(split);
+    return NULL;
+}
+
+static struct split *split_append(struct split **split, struct split *tail,
+                                  struct tree *tree, struct tree *follow,
+                                  char *enc, size_t start, size_t end) {
+    struct split *sp;
+    CALLOC(sp, 1);
+    sp->tree = tree;
+    sp->follow = follow;
+    sp->enc = enc;
+    sp->start = start;
+    sp->end = end;
+    list_tail_cons(*split, tail, sp);
+    return tail;
+}
+
+static struct split *next_split(struct state *state) {
+    if (state->split != NULL) {
+        state->split = state->split->next;
+        if (state->split != NULL)
+            state->pos = state->split->end;
+    }
+    return state->split;
+}
+
+static struct split *set_split(struct state *state, struct split *split) {
+    state->split = split;
+    if (split != NULL)
+        state->pos = split->end;
+    return split;
+}
+
+/* Refine a tree split OUTER according to the L_CONCAT lens LENS */
+static struct split *split_concat(struct state *state, struct lens *lens) {
+    assert(lens->tag == L_CONCAT);
+
+    int count = 0;
+    struct split *outer = state->split;
+    struct re_registers regs;
+    struct split *split = NULL, *tail = NULL;
+    struct regexp *atype = lens->atype;
+
+    /* Fast path for leaf nodes, which will always lead to an empty split */
+    // FIXME: This doesn't match the empty encoding
+    if (outer->tree == NULL && strlen(outer->enc) == 0
+        && regexp_is_empty_pattern(atype)) {
+        for (int i=0; i < lens->nchildren; i++) {
+            tail = split_append(&split, tail, NULL, NULL,
+                                outer->enc, 0, 0);
+        }
+        return split;
+    }
+
+    MEMZERO(&regs, 1);
+    count = regexp_match(atype, outer->enc, outer->end,
+                         outer->start, &regs);
+    if (count >= 0 && count != outer->end - outer->start)
+        count = -1;
+    if (count < 0) {
+        regexp_match_error(state, lens, count, outer);
+        goto error;
+    }
+
+    struct tree *cur = outer->tree;
+    int reg = 1;
+    for (int i=0; i < lens->nchildren; i++) {
+        assert(reg < regs.num_regs);
+        assert(regs.start[reg] != -1);
+        struct tree *follow = cur;
+        for (int j = regs.start[reg]; j < regs.end[reg]; j++) {
+            if (outer->enc[j] == ENC_SLASH_CH)
+                follow = follow->next;
+        }
+        tail = split_append(&split, tail, cur, follow,
+                            outer->enc, regs.start[reg], regs.end[reg]);
+        cur = follow;
+        reg += 1 + regexp_nsub(lens->children[i]->atype);
+    }
+    assert(reg < regs.num_regs);
+ done:
+    free(regs.start);
+    free(regs.end);
+    return split;
+ error:
+    free_split(split);
+    split = NULL;
+    goto done;
+}
+
+static struct split *split_iter(struct state *state, struct lens *lens) {
+    assert(lens->tag == L_STAR);
+
+    int count = 0;
+    struct split *outer = state->split;
+    struct split *split = NULL;
+    struct regexp *atype = lens->child->atype;
+
+    struct tree *cur = outer->tree;
+    int pos = outer->start;
+    struct split *tail = NULL;
+    while (pos < outer->end) {
+        count = regexp_match(atype, outer->enc, outer->end, pos, NULL);
+        if (count == -1) {
+            break;
+        } else if (count < -1) {
+            regexp_match_error(state, lens->child, count, outer);
+            goto error;
+        }
+
+        struct tree *follow = cur;
+        for (int j = pos; j < pos + count; j++) {
+            if (outer->enc[j] == ENC_SLASH_CH)
+                follow = follow->next;
+        }
+        tail = split_append(&split, tail, cur, follow,
+                            outer->enc, pos, pos + count);
+        cur = follow;
+        pos += count;
+    }
+    return split;
+ error:
+    free_split(split);
+    return NULL;
+}
+
+/* Check if LENS applies to the current split in STATE */
+static int applies(struct lens *lens, struct state *state) {
+    int count;
+    struct split *split = state->split;
+
+    count = regexp_match(lens->atype, split->enc, split->end,
+                         split->start, NULL);
+    if (count < -1) {
+        regexp_match_error(state, lens, count, split);
+        return 0;
+    }
+
+    if (count != split->end - split->start)
+        return 0;
+    if (count == 0 && lens->value)
+        return state->value != NULL;
+    return 1;
+}
+
+/* Print TEXT to OUT, translating common escapes like \n */
+static void print_escaped_chars(FILE *out, const char *text) {
+    for (const char *c = text; *c != '\0'; c++) {
+        if (*c == '\\') {
+            char x;
+            c += 1;
+            if (*c == '\0') {
+                fputc(*c, out);
+                break;
+            }
+            switch(*c) {
+            case 'a':
+                x = '\a';
+                break;
+            case 'b':
+                x = '\b';
+                break;
+            case 'f':
+                x = '\f';
+                break;
+            case 'n':
+                x = '\n';
+                break;
+            case 'r':
+                x = '\r';
+                break;
+            case 't':
+                x = '\t';
+                break;
+            case 'v':
+                x = '\v';
+                break;
+            default:
+                x = *c;
+                break;
+            }
+            fputc(x, out);
+        } else {
+            fputc(*c, out);
+        }
+    }
+}
+
+/*
+ * Check whether SKEL has the skeleton type required by LENS
+ */
+
+static int skel_instance_of(struct lens *lens, struct skel *skel) {
+    if (skel == NULL)
+        return 0;
+
+    switch (lens->tag) {
+    case L_DEL: {
+        int count;
+        if (skel->tag != L_DEL)
+            return 0;
+        count = regexp_match(lens->regexp, skel->text, strlen(skel->text),
+                           0, NULL);
+        return count == strlen(skel->text);
+    }
+    case L_STORE:
+        return skel->tag == L_STORE;
+    case L_KEY:
+        return skel->tag == L_KEY;
+    case L_LABEL:
+        return skel->tag == L_LABEL;
+    case L_VALUE:
+        return skel->tag == L_VALUE;
+    case L_SEQ:
+        return skel->tag == L_SEQ;
+    case L_COUNTER:
+        return skel->tag == L_COUNTER;
+    case L_CONCAT:
+        {
+            struct skel *s = skel->skels;
+            for (int i=0; i < lens->nchildren; i++) {
+                if (! skel_instance_of(lens->children[i], s))
+                    return 0;
+                s = s->next;
+            }
+            return 1;
+        }
+        break;
+    case L_UNION:
+        {
+            for (int i=0; i < lens->nchildren; i++) {
+                if (skel_instance_of(lens->children[i], skel))
+                    return 1;
+            }
+            return 0;
+        }
+        break;
+    case L_SUBTREE:
+        return skel->tag == L_SUBTREE;
+    case L_MAYBE:
+        return skel->tag == L_MAYBE || skel_instance_of(lens->child, skel);
+    case L_STAR:
+        if (skel->tag != lens->tag)
+            return 0;
+        if (lens->tag == L_MAYBE &&
+            skel->skels != NULL && skel->skels->next != NULL)
+            return 0;
+        list_for_each(s, skel->skels) {
+            if (! skel_instance_of(lens->child, s))
+                return 0;
+        }
+        return 1;
+    case L_REC:
+        return skel_instance_of(lens->body, skel);
+    case L_SQUARE:
+        return skel->tag == L_SQUARE;
+    default:
+        BUG_ON(true, lens->info, "illegal lens tag %d", lens->tag);
+        break;
+    }
+ error:
+    return 0;
+}
+
+/*
+ * put
+ */
+static void put_subtree(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_SUBTREE);
+    struct state oldstate = *state;
+    struct split oldsplit = *state->split;
+    size_t oldpathlen = strlen(state->path);
+
+    struct tree *tree = state->split->tree;
+    struct split *split = NULL;
+
+    state->key = tree->label;
+    state->value = tree->value;
+    pathjoin(&state->path, 1, state->key);
+
+    split = make_split(tree->children);
+    set_split(state, split);
+
+    dict_lookup(tree->label, state->dict, &state->skel, &state->dict);
+    if (state->skel == NULL || ! skel_instance_of(lens->child, state->skel)) {
+        create_lens(lens->child, state);
+    } else {
+        put_lens(lens->child, state);
+    }
+    assert(state->error != NULL || state->split->next == NULL);
+
+    oldstate.error = state->error;
+    oldstate.path = state->path;
+    *state = oldstate;
+    *state->split= oldsplit;
+    free_split(split);
+    state->path[oldpathlen] = '\0';
+}
+
+static void put_del(ATTRIBUTE_UNUSED struct lens *lens, struct state *state) {
+    assert(lens->tag == L_DEL);
+    assert(state->skel != NULL);
+    assert(state->skel->tag == L_DEL);
+    if (lens->string != NULL) {
+    fprintf(state->out, "%s", state->skel->text);
+    } else {
+    /* L_DEL with NULL string: replicate the current key */
+        fprintf(state->out, "%s", state->key);
+    }
+}
+
+static void put_union(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_UNION);
+
+    for (int i=0; i < lens->nchildren; i++) {
+        struct lens *l = lens->children[i];
+        if (applies(l, state)) {
+            if (skel_instance_of(l, state->skel))
+                put_lens(l, state);
+            else
+                create_lens(l, state);
+            return;
+        }
+    }
+    put_error(state, lens, "None of the alternatives in the union match");
+}
+
+static void put_concat(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_CONCAT);
+    struct split *oldsplit = state->split;
+    struct skel *oldskel = state->skel;
+
+    struct split *split = split_concat(state, lens);
+
+    state->skel = state->skel->skels;
+    set_split(state, split);
+    for (int i=0; i < lens->nchildren; i++) {
+        if (state->split == NULL) {
+            put_error(state, lens,
+                      "Not enough components in concat");
+            list_free(split);
+            return;
+        }
+        put_lens(lens->children[i], state);
+        state->skel = state->skel->next;
+        next_split(state);
+    }
+    list_free(split);
+    set_split(state, oldsplit);
+    state->skel = oldskel;
+}
+
+static void error_quant_star(struct split *last_split, struct lens *lens,
+                             struct state *state) {
+    struct tree *child = NULL;
+    if (last_split != NULL) {
+        if (last_split->follow != NULL) {
+            child = last_split->follow;
+        } else {
+            for (child = last_split->tree;
+                 child != NULL && child->next != NULL;
+                 child = child->next);
+        }
+    }
+    if (child == NULL) {
+        put_error(state, lens, "Malformed child node");
+    } else {
+        put_error(state, lens, "Malformed child node '%s'", child->label);
+    }
+}
+
+static void put_quant_star(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_STAR);
+    struct split *oldsplit = state->split;
+    struct skel *oldskel = state->skel;
+    struct split *last_split = NULL;
+
+    struct split *split = split_iter(state, lens);
+
+    state->skel = state->skel->skels;
+    set_split(state, split);
+    last_split = state->split;
+    while (state->split != NULL && state->skel != NULL) {
+        put_lens(lens->child, state);
+        state->skel = state->skel->next;
+        last_split = state->split;
+        next_split(state);
+    }
+    while (state->split != NULL) {
+        create_lens(lens->child, state);
+        last_split = state->split;
+        next_split(state);
+    }
+    if (state->pos != oldsplit->end)
+        error_quant_star(last_split, lens, state);
+    list_free(split);
+    set_split(state, oldsplit);
+    state->skel = oldskel;
+}
+
+static void put_quant_maybe(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_MAYBE);
+    struct lens *child = lens->child;
+
+    if (applies(child, state)) {
+        if (skel_instance_of(child, state->skel))
+            put_lens(child, state);
+        else
+            create_lens(child, state);
+    }
+}
+
+static void put_store(struct lens *lens, struct state *state) {
+    if (state->value == NULL) {
+        put_error(state, lens,
+                  "Can not store a nonexistent (NULL) value");
+    } else if (regexp_match(lens->regexp, state->value, strlen(state->value),
+                            0, NULL) != strlen(state->value)) {
+        char *pat = regexp_escape(lens->regexp);
+        put_error(state, lens,
+                  "Value '%s' does not match regexp /%s/ in store lens",
+                  state->value, pat);
+        free(pat);
+    } else {
+        fprintf(state->out, "%s", state->value);
+    }
+}
+
+static void put_rec(struct lens *lens, struct state *state) {
+    put_lens(lens->body, state);
+}
+
+static void put_square(struct lens *lens, struct state *state) {
+    struct skel *oldskel = state->skel;
+    state->skel = state->skel->skels;
+    put_lens(lens->child, state);
+    state->skel = oldskel;
+}
+
+static void put_lens(struct lens *lens, struct state *state) {
+    if (state->error != NULL)
+        return;
+
+    switch(lens->tag) {
+    case L_DEL:
+        put_del(lens, state);
+        break;
+    case L_STORE:
+        put_store(lens, state);
+        break;
+    case L_KEY:
+        fprintf(state->out, "%s", state->key);
+        break;
+    case L_LABEL:
+    case L_VALUE:
+        /* Nothing to do */
+        break;
+    case L_SEQ:
+        /* Nothing to do */
+        break;
+    case L_COUNTER:
+        /* Nothing to do */
+        break;
+    case L_CONCAT:
+        put_concat(lens, state);
+        break;
+    case L_UNION:
+        put_union(lens, state);
+        break;
+    case L_SUBTREE:
+        put_subtree(lens, state);
+        break;
+    case L_STAR:
+        put_quant_star(lens, state);
+        break;
+    case L_MAYBE:
+        put_quant_maybe(lens, state);
+        break;
+    case L_REC:
+        put_rec(lens, state);
+        break;
+    case L_SQUARE:
+        put_square(lens, state);
+        break;
+    default:
+        assert(0);
+        break;
+    }
+}
+
+static void create_subtree(struct lens *lens, struct state *state) {
+    put_subtree(lens, state);
+}
+
+static void create_del(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_DEL);
+    if (lens->string != NULL) {
+        print_escaped_chars(state->out, lens->string->str);
+    } else {
+        /* L_DEL with NULL string: replicate the current key */
+        print_escaped_chars(state->out, state->key);
+    }
+
+}
+
+static void create_union(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_UNION);
+
+    for (int i=0; i < lens->nchildren; i++) {
+        if (applies(lens->children[i], state)) {
+            create_lens(lens->children[i], state);
+            return;
+        }
+    }
+    put_error(state, lens, "None of the alternatives in the union match");
+}
+
+static void create_concat(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_CONCAT);
+    struct split *oldsplit = state->split;
+
+    struct split *split = split_concat(state, lens);
+
+    set_split(state, split);
+    for (int i=0; i < lens->nchildren; i++) {
+        if (state->split == NULL) {
+            put_error(state, lens,
+                      "Not enough components in concat");
+            list_free(split);
+            return;
+        }
+        create_lens(lens->children[i], state);
+        next_split(state);
+    }
+    list_free(split);
+    set_split(state, oldsplit);
+}
+
+static void create_quant_star(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_STAR);
+    struct split *oldsplit = state->split;
+    struct split *last_split = NULL;
+
+    struct split *split = split_iter(state, lens);
+
+    set_split(state, split);
+    last_split = state->split;
+    while (state->split != NULL) {
+        create_lens(lens->child, state);
+        last_split = state->split;
+        next_split(state);
+    }
+    if (state->pos != oldsplit->end)
+        error_quant_star(last_split, lens, state);
+    list_free(split);
+    set_split(state, oldsplit);
+}
+
+static void create_quant_maybe(struct lens *lens, struct state *state) {
+    assert(lens->tag == L_MAYBE);
+
+    if (applies(lens->child, state)) {
+        create_lens(lens->child, state);
+    }
+}
+
+static void create_rec(struct lens *lens, struct state *state) {
+    create_lens(lens->body, state);
+}
+
+static void create_lens(struct lens *lens, struct state *state) {
+    if (state->error != NULL)
+        return;
+    switch(lens->tag) {
+    case L_DEL:
+        create_del(lens, state);
+        break;
+    case L_STORE:
+        put_store(lens, state);
+        break;
+    case L_KEY:
+        fprintf(state->out, "%s", state->key);
+        break;
+    case L_LABEL:
+    case L_VALUE:
+        /* Nothing to do */
+        break;
+    case L_SEQ:
+        /* Nothing to do */
+        break;
+    case L_COUNTER:
+        /* Nothing to do */
+        break;
+    case L_CONCAT:
+        create_concat(lens, state);
+        break;
+    case L_UNION:
+        create_union(lens, state);
+        break;
+    case L_SUBTREE:
+        create_subtree(lens, state);
+        break;
+    case L_STAR:
+        create_quant_star(lens, state);
+        break;
+    case L_MAYBE:
+        create_quant_maybe(lens, state);
+        break;
+    case L_REC:
+        create_rec(lens, state);
+        break;
+    case L_SQUARE:
+        create_concat(lens->child, state);
+        break;
+    default:
+        assert(0);
+        break;
+    }
+}
+
+void lns_put(FILE *out, struct lens *lens, struct tree *tree,
+             const char *text, struct lns_error **err) {
+    struct state state;
+    struct lns_error *err1;
+
+    if (err != NULL)
+        *err = NULL;
+    if (tree == NULL)
+        return;
+
+    MEMZERO(&state, 1);
+    state.path = strdup("");
+    state.skel = lns_parse(lens, text, &state.dict, &err1);
+
+    if (err1 != NULL) {
+        if (err != NULL)
+            *err = err1;
+        else
+            free_lns_error(err1);
+        return;
+    }
+    state.out = out;
+    state.split = make_split(tree);
+    state.key = tree->label;
+    put_lens(lens, &state);
+
+    free(state.path);
+    free_split(state.split);
+    free_skel(state.skel);
+    free_dict(state.dict);
+    if (err != NULL) {
+        *err = state.error;
+    } else {
+        free_lns_error(state.error);
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/ref.c b/src/ref.c
new file mode 100644 (file)
index 0000000..fb3807a
--- /dev/null
+++ b/src/ref.c
@@ -0,0 +1,46 @@
+/*
+ * ref.c: reference counting
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "ref.h"
+#include <stdlib.h>
+
+int ref_make_ref(void *ptrptr, size_t size, size_t ref_ofs) {
+    *(void**) ptrptr = calloc(1, size);
+    if (*(void **)ptrptr == NULL) {
+        return -1;
+    } else {
+        void *ptr = *(void **)ptrptr;
+        *((ref_t *) ((char*) ptr + ref_ofs)) = 1;
+        return 0;
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/ref.h b/src/ref.h
new file mode 100644 (file)
index 0000000..586132a
--- /dev/null
+++ b/src/ref.h
@@ -0,0 +1,79 @@
+/*
+ * ref.h: reference counting macros
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef REF_H_
+#define REF_H_
+
+#include <limits.h>
+#include <stddef.h>
+
+/* Reference counting for pointers to structs with a REF field of type ref_t
+ *
+ * When a pointer to such a struct is passed into a function that stores
+ * it, the function can either "receive ownership", meaning it does not
+ * increment the reference count, or it can "take ownership", meaning it
+ * increments the reference count. In the first case, the reference is now
+ * owned by wherever the function stored it, and not the caller anymore; in
+ * the second case, the caller and whereever the reference was stored both
+ * own the reference.
+ */
+// FIXME: This is not threadsafe; incr/decr ref needs to be protected
+
+#define REF_MAX UINT_MAX
+
+typedef unsigned int ref_t;
+
+int ref_make_ref(void *ptrptr, size_t size, size_t ref_ofs);
+
+#define make_ref(var)                                           \
+    ref_make_ref(&(var), sizeof(*(var)), offsetof(typeof(*(var)), ref))
+
+#define make_ref_err(var) if (make_ref(var) < 0) goto error
+
+#define ref(s) (((s) == NULL || (s)->ref == REF_MAX) ? (s) : ((s)->ref++, (s)))
+
+#define unref(s, t)                                                     \
+    do {                                                                \
+        if ((s) != NULL && (s)->ref != REF_MAX) {                       \
+            assert((s)->ref > 0);                                       \
+            if (--(s)->ref == 0) {                                      \
+                /*memset(s, 255, sizeof(*s));*/                         \
+                free_##t(s);                                            \
+            }                                                           \
+        }                                                               \
+        (s) = NULL;                                                     \
+    } while(0)
+
+/* Make VAR uncollectable and pin it in memory for eternity */
+#define ref_pin(var)   (var)->ref = REF_MAX
+
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/regexp.c b/src/regexp.c
new file mode 100644 (file)
index 0000000..14020af
--- /dev/null
@@ -0,0 +1,497 @@
+/*
+ * regexp.c:
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+#include <regex.h>
+
+#include "internal.h"
+#include "syntax.h"
+#include "memory.h"
+#include "errcode.h"
+
+static const struct string empty_pattern_string = {
+    .ref = REF_MAX, .str = (char *) "()"
+};
+
+static const struct string *const empty_pattern = &empty_pattern_string;
+
+char *regexp_escape(const struct regexp *r) {
+    char *pat = NULL;
+
+    if (r == NULL)
+        return strdup("");
+
+#if !HAVE_USELOCALE
+    char *nre = NULL;
+    int ret;
+    size_t nre_len;
+
+    /* Use a range with from > to to force conversion of ranges into
+     * short form */
+    ret = fa_restrict_alphabet(r->pattern->str, strlen(r->pattern->str),
+                               &nre, &nre_len, 2, 1);
+    if (ret == 0) {
+        pat = escape(nre, nre_len);
+        free(nre);
+    }
+#endif
+
+    if (pat == NULL)
+        pat = escape(r->pattern->str, -1);
+
+    if (pat == NULL)
+        return NULL;
+
+    /* Remove unneeded '()' from pat */
+    for (int changed = 1; changed;) {
+        changed = 0;
+        for (char *p = pat; *p != '\0'; p++) {
+            if (*p == '(' && p[1] == ')') {
+                memmove(p, p+2, strlen(p+2)+1);
+                changed = 1;
+            }
+        }
+    }
+
+    if (pat[0] == '(' && pat[strlen(pat)-1] == ')') {
+        int level = 1;
+        for (int i=1; i < strlen(pat)-1; i++) {
+            if (pat[i] == '(')
+                level += 1;
+            if (pat[i] == ')')
+                level -= 1;
+            if (level == 0)
+                break;
+        }
+        if (level == 1) {
+            memmove(pat, pat+1, strlen(pat+1)+1);
+            pat[strlen(pat)-1] = '\0';
+        }
+    }
+
+    return pat;
+}
+
+void print_regexp(FILE *out, struct regexp *r) {
+    if (r == NULL) {
+        fprintf(out, "<NULL>");
+        return;
+    }
+
+    fputc('/', out);
+    if (r->pattern == NULL)
+        fprintf(out, "%p", r);
+    else {
+        char *rx;
+        size_t rx_len;
+        fa_restrict_alphabet(r->pattern->str, strlen(r->pattern->str),
+                             &rx, &rx_len, 2, 1);
+        print_chars(out, rx, rx_len);
+        FREE(rx);
+    }
+    fputc('/', out);
+    if (r->nocase)
+        fputc('i', out);
+}
+
+struct regexp *make_regexp(struct info *info, char *pat, int nocase) {
+    struct regexp *regexp;
+
+    make_ref(regexp);
+    regexp->info = ref(info);
+
+    make_ref(regexp->pattern);
+    regexp->pattern->str = pat;
+    regexp->nocase = nocase;
+    return regexp;
+}
+
+void free_regexp(struct regexp *regexp) {
+    if (regexp == NULL)
+        return;
+    assert(regexp->ref == 0);
+    unref(regexp->info, info);
+    unref(regexp->pattern, string);
+    if (regexp->re != NULL) {
+        regfree(regexp->re);
+        free(regexp->re);
+    }
+    free(regexp);
+}
+
+int regexp_is_empty_pattern(struct regexp *r) {
+    for (char *s = r->pattern->str; *s; s++) {
+        if (*s != '(' && *s != ')')
+            return 0;
+    }
+    return 1;
+}
+
+struct regexp *make_regexp_literal(struct info *info, const char *text) {
+    char *pattern, *p;
+
+    /* Escape special characters in text since it should be taken
+       literally */
+    CALLOC(pattern, 2*strlen(text)+1);
+    p = pattern;
+    for (const char *t = text; *t != '\0'; t++) {
+        if ((*t == '\\') && t[1]) {
+            *p++ = *t++;
+            *p++ = *t;
+        } else if (strchr(".|{}[]()+*?", *t) != NULL) {
+            *p++ = '\\';
+            *p++ = *t;
+        } else {
+            *p++ = *t;
+        }
+    }
+    return make_regexp(info, pattern, 0);
+}
+
+struct regexp *
+regexp_union(struct info *info, struct regexp *r1, struct regexp *r2) {
+    struct regexp *r[2];
+
+    r[0] = r1;
+    r[1] = r2;
+    return regexp_union_n(info, 2, r);
+}
+
+char *regexp_expand_nocase(struct regexp *r) {
+    const char *p = r->pattern->str;
+    char *s = NULL;
+    size_t len;
+    int ret;
+
+    if (! r->nocase)
+        return strdup(p);
+
+    ret = fa_expand_nocase(p, strlen(p), &s, &len);
+    ERR_NOMEM(ret == REG_ESPACE, r->info);
+    BUG_ON(ret != REG_NOERROR, r->info, NULL);
+ error:
+    return s;
+}
+
+struct regexp *
+regexp_union_n(struct info *info, int n, struct regexp **r) {
+    size_t len = 0;
+    char *pat = NULL, *p, *expanded = NULL;
+    int nnocase = 0, npresent = 0;
+    int ret;
+
+    for (int i=0; i < n; i++)
+        if (r[i] != NULL) {
+            len += strlen(r[i]->pattern->str) + strlen("()|");
+            npresent += 1;
+            if (r[i]->nocase)
+                nnocase += 1;
+        }
+
+    bool mixedcase = nnocase > 0 && nnocase < npresent;
+
+    if (len == 0)
+        return NULL;
+
+    if (ALLOC_N(pat, len) < 0)
+        return NULL;
+
+    p = pat;
+    int added = 0;
+    for (int i=0; i < n; i++) {
+        if (r[i] == NULL)
+            continue;
+        if (added > 0)
+            *p++ = '|';
+        *p++ = '(';
+        if (mixedcase && r[i]->nocase) {
+            expanded = regexp_expand_nocase(r[i]);
+            ERR_BAIL(r[i]->info);
+            len += strlen(expanded) - strlen(r[i]->pattern->str);
+            ret = REALLOC_N(pat, len);
+            ERR_NOMEM(ret < 0, info);
+            p = pat + strlen(pat);
+            p = stpcpy(p, expanded);
+            FREE(expanded);
+        } else {
+            p = stpcpy(p, r[i]->pattern->str);
+        }
+        *p++ = ')';
+        added += 1;
+    }
+    *p = '\0';
+    return make_regexp(info, pat, nnocase == npresent);
+ error:
+    FREE(expanded);
+    FREE(pat);
+    return NULL;
+}
+
+struct regexp *
+regexp_concat(struct info *info, struct regexp *r1, struct regexp *r2) {
+    struct regexp *r[2];
+
+    r[0] = r1;
+    r[1] = r2;
+    return regexp_concat_n(info, 2, r);
+}
+
+struct regexp *
+regexp_concat_n(struct info *info, int n, struct regexp **r) {
+    size_t len = 0;
+    char *pat = NULL, *p, *expanded = NULL;
+    int nnocase = 0, npresent = 0;
+    int ret;
+
+    for (int i=0; i < n; i++)
+        if (r[i] != NULL) {
+            len += strlen(r[i]->pattern->str) + strlen("()");
+            npresent += 1;
+            if (r[i]->nocase)
+                nnocase += 1;
+        }
+
+    bool mixedcase = nnocase > 0 && nnocase < npresent;
+
+    if (len == 0)
+        return NULL;
+
+    len += 1;
+    if (ALLOC_N(pat, len) < 0)
+        return NULL;
+
+    p = pat;
+    for (int i=0; i < n; i++) {
+        if (r[i] == NULL)
+            continue;
+        *p++ = '(';
+        if (mixedcase && r[i]->nocase) {
+            expanded = regexp_expand_nocase(r[i]);
+            ERR_BAIL(r[i]->info);
+            len += strlen(expanded) - strlen(r[i]->pattern->str);
+            ret = REALLOC_N(pat, len);
+            ERR_NOMEM(ret < 0, info);
+            p = pat + strlen(pat);
+            p = stpcpy(p, expanded);
+            FREE(expanded);
+        } else {
+            p = stpcpy(p, r[i]->pattern->str);
+        }
+        *p++ = ')';
+    }
+    *p = '\0';
+    return make_regexp(info, pat, nnocase == npresent);
+ error:
+    FREE(expanded);
+    FREE(pat);
+    return NULL;
+}
+
+static struct fa *regexp_to_fa(struct regexp *r) {
+    const char *p = r->pattern->str;
+    int ret;
+    struct fa *fa = NULL;
+
+    ret = fa_compile(p, strlen(p), &fa);
+    ERR_NOMEM(ret == REG_ESPACE, r->info);
+    BUG_ON(ret != REG_NOERROR, r->info, NULL);
+
+    if (r->nocase) {
+        ret = fa_nocase(fa);
+        ERR_NOMEM(ret < 0, r->info);
+    }
+    return fa;
+
+ error:
+    fa_free(fa);
+    return NULL;
+}
+
+struct regexp *
+regexp_minus(struct info *info, struct regexp *r1, struct regexp *r2) {
+    struct regexp *result = NULL;
+    struct fa *fa = NULL, *fa1 = NULL, *fa2 = NULL;
+    int r;
+    char *s = NULL;
+    size_t s_len;
+
+    fa1 = regexp_to_fa(r1);
+    ERR_BAIL(r1->info);
+
+    fa2 = regexp_to_fa(r2);
+    ERR_BAIL(r2->info);
+
+    fa = fa_minus(fa1, fa2);
+    if (fa == NULL)
+        goto error;
+
+    r = fa_as_regexp(fa, &s, &s_len);
+    if (r < 0)
+        goto error;
+
+    if (s == NULL) {
+        /* FA is the empty set, which we can't represent as a regexp */
+        goto error;
+    }
+
+    if (regexp_c_locale(&s, NULL) < 0)
+        goto error;
+
+    result = make_regexp(info, s, fa_is_nocase(fa));
+    s = NULL;
+
+ done:
+    fa_free(fa);
+    fa_free(fa1);
+    fa_free(fa2);
+    free(s);
+    return result;
+ error:
+    unref(result, regexp);
+    goto done;
+}
+
+
+struct regexp *
+regexp_iter(struct info *info, struct regexp *r, int min, int max) {
+    const char *p;
+    char *s;
+    int ret = 0;
+
+    if (r == NULL)
+        return NULL;
+
+    p = r->pattern->str;
+    if ((min == 0 || min == 1) && max == -1) {
+        char q = (min == 0) ? '*' : '+';
+        ret = asprintf(&s, "(%s)%c", p, q);
+    } else if (min == max) {
+        ret = asprintf(&s, "(%s){%d}", p, min);
+    } else {
+        ret = asprintf(&s, "(%s){%d,%d}", p, min, max);
+    }
+    return (ret == -1) ? NULL : make_regexp(info, s, r->nocase);
+}
+
+struct regexp *
+regexp_maybe(struct info *info, struct regexp *r) {
+    const char *p;
+    char *s;
+    int ret;
+
+    if (r == NULL)
+        return NULL;
+    p = r->pattern->str;
+    ret = asprintf(&s, "(%s)?", p);
+    return (ret == -1) ? NULL : make_regexp(info, s, r->nocase);
+}
+
+struct regexp *regexp_make_empty(struct info *info) {
+    struct regexp *regexp;
+
+    make_ref(regexp);
+    if (regexp != NULL) {
+        regexp->info = ref(info);
+        /* Casting away the CONST for EMPTY_PATTERN is ok since it
+           is protected against changes because REF == REF_MAX */
+        regexp->pattern = (struct string *) empty_pattern;
+        regexp->nocase = 0;
+    }
+    return regexp;
+}
+
+static int regexp_compile_internal(struct regexp *r, const char **c) {
+    /* See the GNU regex manual or regex.h in gnulib for
+     * an explanation of these flags. They are set so that the regex
+     * matcher interprets regular expressions the same way that libfa
+     * does
+     */
+    static const reg_syntax_t syntax =
+        RE_CONTEXT_INDEP_OPS|RE_CONTEXT_INVALID_OPS|RE_DOT_NOT_NULL
+        |RE_INTERVALS|RE_NO_BK_BRACES|RE_NO_BK_PARENS|RE_NO_BK_REFS
+        |RE_NO_BK_VBAR|RE_NO_EMPTY_RANGES
+        |RE_NO_POSIX_BACKTRACKING|RE_CONTEXT_INVALID_DUP|RE_NO_GNU_OPS;
+    reg_syntax_t old_syntax = re_syntax_options;
+
+    *c = NULL;
+
+    if (r->re == NULL)
+        CALLOC(r->re, 1);
+
+    re_syntax_options = syntax;
+    if (r->nocase)
+        re_syntax_options |= RE_ICASE;
+    *c = re_compile_pattern(r->pattern->str, strlen(r->pattern->str), r->re);
+    re_syntax_options = old_syntax;
+
+    r->re->regs_allocated = REGS_REALLOCATE;
+    if (*c != NULL)
+        return -1;
+    return 0;
+}
+
+int regexp_compile(struct regexp *r) {
+    const char *c;
+
+    return regexp_compile_internal(r, &c);
+}
+
+int regexp_check(struct regexp *r, const char **msg) {
+    return regexp_compile_internal(r, msg);
+}
+
+int regexp_match(struct regexp *r,
+                 const char *string, const int size,
+                 const int start, struct re_registers *regs) {
+    if (r->re == NULL) {
+        if (regexp_compile(r) == -1)
+            return -3;
+    }
+    return re_match(r->re, string, size, start, regs);
+}
+
+int regexp_matches_empty(struct regexp *r) {
+    return regexp_match(r, "", 0, 0, NULL) == 0;
+}
+
+int regexp_nsub(struct regexp *r) {
+    if (r->re == NULL)
+        if (regexp_compile(r) == -1)
+            return -1;
+    return r->re->re_nsub;
+}
+
+void regexp_release(struct regexp *regexp) {
+    if (regexp != NULL && regexp->re != NULL) {
+        regfree(regexp->re);
+        FREE(regexp->re);
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/regexp.h b/src/regexp.h
new file mode 100644 (file)
index 0000000..221252c
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * regexp.h: wrappers for regexp handling
+ *
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#ifndef REGEXP_H_
+#define REGEXP_H_
+
+#include <stdio.h>
+#include <regex.h>
+
+struct regexp {
+    unsigned int              ref;
+    struct info              *info;
+    struct string            *pattern;
+    struct re_pattern_buffer *re;
+    unsigned int              nocase : 1;
+};
+
+void print_regexp(FILE *out, struct regexp *regexp);
+
+/* Make a regexp with pattern PAT, which is not copied. Ownership
+ * of INFO is taken.
+ */
+struct regexp *make_regexp(struct info *info, char *pat, int nocase);
+
+/* Return 1 if R is an empty pattern, i.e. one consisting of nothing but
+   '(' and ')' characters, 0 otherwise */
+int regexp_is_empty_pattern(struct regexp *r);
+
+/* Make a regexp that matches TEXT literally; the string TEXT
+ * is not used by the returned rgexp and must be freed by the caller
+ */
+struct regexp *make_regexp_literal(struct info *info, const char *text);
+
+/* Do not call directly, use UNREF instead */
+void free_regexp(struct regexp *regexp);
+
+/* Compile R->PATTERN into R->RE; return -1 and print an error
+ * if compilation fails. Return 0 otherwise
+ */
+int regexp_compile(struct regexp *r);
+
+/* Check the syntax of R->PATTERN; return -1 if the pattern has a syntax
+ * error, and a string indicating the error in *C. Return 0 if the pattern
+ * is a valid regular expression.
+ */
+int regexp_check(struct regexp *r, const char **msg);
+
+/* Call RE_MATCH on R->RE and return its result; if R hasn't been compiled
+ * yet, compile it. Return -3 if compilation fails
+ */
+int regexp_match(struct regexp *r, const char *string, const int size,
+                 const int start, struct re_registers *regs);
+
+/* Return 1 if R matches the empty string, 0 otherwise */
+int regexp_matches_empty(struct regexp *r);
+
+/* Return the number of subexpressions (parentheses) inside R. May cause
+ * compilation of R; return -1 if compilation fails.
+ */
+int regexp_nsub(struct regexp *r);
+
+struct regexp *
+regexp_union(struct info *, struct regexp *r1, struct regexp *r2);
+
+struct regexp *
+regexp_concat(struct info *, struct regexp *r1, struct regexp *r2);
+
+struct regexp *
+regexp_union_n(struct info *, int n, struct regexp **r);
+
+struct regexp *
+regexp_concat_n(struct info *, int n, struct regexp **r);
+
+struct regexp *
+regexp_iter(struct info *info, struct regexp *r, int min, int max);
+
+/* Return a new REGEXP that matches all the words matched by R1 but
+ * not by R2
+ */
+struct regexp *
+regexp_minus(struct info *info, struct regexp *r1, struct regexp *r2);
+
+struct regexp *
+regexp_maybe(struct info *info, struct regexp *r);
+
+struct regexp *regexp_make_empty(struct info *);
+
+/* Free up temporary data structures, most importantly compiled
+   regular expressions */
+void regexp_release(struct regexp *regexp);
+
+/* Produce a printable representation of R */
+char *regexp_escape(const struct regexp *r);
+
+/* If R is case-insensitive, expand its pattern so that it matches the same
+ * string even when used in a case-sensitive match. */
+char *regexp_expand_nocase(struct regexp *r);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/syntax.c b/src/syntax.c
new file mode 100644 (file)
index 0000000..4f6bbb3
--- /dev/null
@@ -0,0 +1,2052 @@
+/*
+ * syntax.c:
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <assert.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <ctype.h>
+#include <glob.h>
+#include <argz.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "memory.h"
+#include "syntax.h"
+#include "augeas.h"
+#include "transform.h"
+#include "errcode.h"
+
+/* Extension of source files */
+#define AUG_EXT ".aug"
+
+#define LNS_TYPE_CHECK(ctx) ((ctx)->aug->flags & AUG_TYPE_CHECK)
+
+static const char *const builtin_module = "Builtin";
+
+static const struct type string_type    = { .ref = UINT_MAX, .tag = T_STRING };
+static const struct type regexp_type    = { .ref = UINT_MAX, .tag = T_REGEXP };
+static const struct type lens_type      = { .ref = UINT_MAX, .tag = T_LENS };
+static const struct type tree_type      = { .ref = UINT_MAX, .tag = T_TREE };
+static const struct type filter_type    = { .ref = UINT_MAX, .tag = T_FILTER };
+static const struct type transform_type =
+                                       { .ref = UINT_MAX, .tag = T_TRANSFORM };
+static const struct type unit_type      = { .ref = UINT_MAX, .tag = T_UNIT };
+
+const struct type *const t_string    = &string_type;
+const struct type *const t_regexp    = &regexp_type;
+const struct type *const t_lens      = &lens_type;
+const struct type *const t_tree      = &tree_type;
+const struct type *const t_filter    = &filter_type;
+const struct type *const t_transform = &transform_type;
+const struct type *const t_unit      = &unit_type;
+
+static const char *const type_names[] = {
+    "string", "regexp", "lens", "tree", "filter",
+    "transform", "unit", "function", NULL
+};
+
+/* The anonymous identifier which we will never bind */
+static const char const anon_ident[] = "_";
+
+static void print_value(FILE *out, struct value *v);
+
+/* The evaluation context with all loaded modules and the bindings for the
+ * module we are working on in LOCAL
+ */
+struct ctx {
+    const char     *name;     /* The module we are working on */
+    struct augeas  *aug;
+    struct binding *local;
+};
+
+static void format_error(struct info *info, aug_errcode_t code,
+                         const char *format, va_list ap) {
+    struct error *error = info->error;
+    char *si = NULL, *sf = NULL, *sd = NULL;
+    int r;
+
+    error->code = code;
+    /* Only syntax errors are cumulative */
+    if (code != AUG_ESYNTAX)
+        FREE(error->details);
+
+    si = format_info(info);
+    r = vasprintf(&sf, format, ap);
+    if (r < 0)
+        sf = NULL;
+    if (error->details != NULL) {
+        r = xasprintf(&sd, "%s\n%s%s", error->details,
+                      (si == NULL) ? "(no location)" : si,
+                      (sf == NULL) ? "(no details)" : sf);
+    } else {
+        r = xasprintf(&sd, "%s%s",
+                      (si == NULL) ? "(no location)" : si,
+                      (sf == NULL) ? "(no details)" : sf);
+    }
+    if (r >= 0) {
+        free(error->details);
+        error->details = sd;
+    }
+    free(si);
+    free(sf);
+}
+
+void syntax_error(struct info *info, const char *format, ...) {
+    struct error *error = info->error;
+    va_list ap;
+
+    if (error->code != AUG_NOERROR && error->code != AUG_ESYNTAX)
+        return;
+
+       va_start(ap, format);
+    format_error(info, AUG_ESYNTAX, format, ap);
+    va_end(ap);
+}
+
+void fatal_error(struct info *info, const char *format, ...) {
+    struct error *error = info->error;
+    va_list ap;
+
+    if (error->code == AUG_EINTERNAL)
+        return;
+
+       va_start(ap, format);
+    format_error(info, AUG_EINTERNAL, format, ap);
+    va_end(ap);
+}
+
+static void free_param(struct param *param) {
+    if (param == NULL)
+        return;
+    assert(param->ref == 0);
+    unref(param->info, info);
+    unref(param->name, string);
+    unref(param->type, type);
+    free(param);
+}
+
+void free_term(struct term *term) {
+    if (term == NULL)
+        return;
+    assert(term->ref == 0);
+    switch(term->tag) {
+    case A_MODULE:
+        free(term->mname);
+        free(term->autoload);
+        unref(term->decls, term);
+        break;
+    case A_BIND:
+        free(term->bname);
+        unref(term->exp, term);
+        break;
+    case A_COMPOSE:
+    case A_UNION:
+    case A_MINUS:
+    case A_CONCAT:
+    case A_APP:
+    case A_LET:
+        unref(term->left, term);
+        unref(term->right, term);
+        break;
+    case A_VALUE:
+        unref(term->value, value);
+        break;
+    case A_IDENT:
+        unref(term->ident, string);
+        break;
+    case A_BRACKET:
+        unref(term->brexp, term);
+        break;
+    case A_FUNC:
+        unref(term->param, param);
+        unref(term->body, term);
+        break;
+    case A_REP:
+        unref(term->rexp, term);
+        break;
+    case A_TEST:
+        unref(term->test, term);
+        unref(term->result, term);
+        break;
+    default:
+        assert(0);
+        break;
+    }
+    unref(term->next, term);
+    unref(term->info, info);
+    unref(term->type, type);
+    free(term);
+}
+
+static void free_binding(struct binding *binding) {
+    if (binding == NULL)
+        return;
+    assert(binding->ref == 0);
+    unref(binding->next, binding);
+    unref(binding->ident, string);
+    unref(binding->type, type);
+    unref(binding->value, value);
+    free(binding);
+}
+
+void free_module(struct module *module) {
+    if (module == NULL)
+        return;
+    assert(module->ref == 0);
+    free(module->name);
+    unref(module->next, module);
+    unref(module->bindings, binding);
+    unref(module->autoload, transform);
+    free(module);
+}
+
+void free_type(struct type *type) {
+    if (type == NULL)
+        return;
+    assert(type->ref == 0);
+
+    if (type->tag == T_ARROW) {
+        unref(type->dom, type);
+        unref(type->img, type);
+    }
+    free(type);
+}
+
+static void free_exn(struct exn *exn) {
+    if (exn == NULL)
+        return;
+
+    unref(exn->info, info);
+    free(exn->message);
+    for (int i=0; i < exn->nlines; i++) {
+        free(exn->lines[i]);
+    }
+    free(exn->lines);
+    free(exn);
+}
+
+void free_value(struct value *v) {
+    if (v == NULL)
+        return;
+    assert(v->ref == 0);
+
+    switch(v->tag) {
+    case V_STRING:
+        unref(v->string, string);
+        break;
+    case V_REGEXP:
+        unref(v->regexp, regexp);
+        break;
+    case V_LENS:
+        unref(v->lens, lens);
+        break;
+    case V_TREE:
+        free_tree(v->origin);
+        break;
+    case V_FILTER:
+        unref(v->filter, filter);
+        break;
+    case V_TRANSFORM:
+        unref(v->transform, transform);
+        break;
+    case V_NATIVE:
+        if (v->native)
+            unref(v->native->type, type);
+        free(v->native);
+        break;
+    case V_CLOS:
+        unref(v->func, term);
+        unref(v->bindings, binding);
+        break;
+    case V_EXN:
+        free_exn(v->exn);
+        break;
+    case V_UNIT:
+        break;
+    default:
+        assert(0);
+    }
+    unref(v->info, info);
+    free(v);
+}
+
+/*
+ * Creation of (some) terms. Others are in parser.y
+ * Refernce counted arguments are now owned by the returned object, i.e.
+ * the make_* functions do not increment the count.
+ * Returned objects have a referece count of 1.
+ */
+struct term *make_term(enum term_tag tag, struct info *info) {
+  struct term *term;
+  if (make_ref(term) < 0) {
+      unref(info, info);
+  } else {
+      term->tag = tag;
+      term->info = info;
+  }
+  return term;
+}
+
+struct term *make_param(char *name, struct type *type, struct info *info) {
+  struct term *term = make_term(A_FUNC, info);
+  if (term == NULL)
+      goto error;
+  make_ref_err(term->param);
+  term->param->info = ref(term->info);
+  make_ref_err(term->param->name);
+  term->param->name->str = name;
+  term->param->type = type;
+  return term;
+ error:
+  unref(term, term);
+  return NULL;
+}
+
+struct value *make_value(enum value_tag tag, struct info *info) {
+    struct value *value = NULL;
+    if (make_ref(value) < 0) {
+        unref(info, info);
+    } else {
+        value->tag = tag;
+        value->info = info;
+    }
+    return value;
+}
+
+struct value *make_unit(struct info *info) {
+    return make_value(V_UNIT, info);
+}
+
+struct term *make_app_term(struct term *lambda, struct term *arg,
+                           struct info *info) {
+  struct term *app = make_term(A_APP, info);
+  if (app == NULL) {
+      unref(lambda, term);
+      unref(arg, term);
+  } else {
+      app->left = lambda;
+      app->right = arg;
+  }
+  return app;
+}
+
+struct term *make_app_ident(char *id, struct term *arg, struct info *info) {
+    struct term *ident = make_term(A_IDENT, ref(info));
+    ident->ident = make_string(id);
+    if (ident->ident == NULL) {
+        unref(arg, term);
+        unref(info, info);
+        unref(ident, term);
+        return NULL;
+    }
+    return make_app_term(ident, arg, info);
+}
+
+struct term *build_func(struct term *params, struct term *exp) {
+  assert(params->tag == A_FUNC);
+  if (params->next != NULL)
+    exp = build_func(params->next, exp);
+
+  params->body = exp;
+  params->next = NULL;
+  return params;
+}
+
+/* Ownership is taken as needed */
+static struct value *make_closure(struct term *func, struct binding *bnds) {
+    struct value *v = NULL;
+    if (make_ref(v) == 0) {
+        v->tag  = V_CLOS;
+        v->info = ref(func->info);
+        v->func = ref(func);
+        v->bindings = ref(bnds);
+    }
+    return v;
+}
+
+struct value *make_exn_value(struct info *info,
+                             const char *format, ...) {
+    va_list ap;
+    int r;
+    struct value *v;
+    char *message;
+
+    va_start(ap, format);
+    r = vasprintf(&message, format, ap);
+    va_end(ap);
+    if (r == -1)
+        return NULL;
+
+    v = make_value(V_EXN, ref(info));
+    CALLOC(v->exn, 1);
+    v->exn->info = info;
+    v->exn->message = message;
+
+    return v;
+}
+
+void exn_add_lines(struct value *v, int nlines, ...) {
+    assert(v->tag == V_EXN);
+
+    va_list ap;
+    if (REALLOC_N(v->exn->lines, v->exn->nlines + nlines) == -1)
+        return;
+    va_start(ap, nlines);
+    for (int i=0; i < nlines; i++) {
+        char *line = va_arg(ap, char *);
+        v->exn->lines[v->exn->nlines + i] = line;
+    }
+    va_end(ap);
+    v->exn->nlines += nlines;
+}
+
+void exn_printf_line(struct value *exn, const char *format, ...) {
+    va_list ap;
+    int r;
+    char *line;
+
+    va_start(ap, format);
+    r = vasprintf(&line, format, ap);
+    va_end(ap);
+    if (r >= 0)
+        exn_add_lines(exn, 1, line);
+}
+
+struct value *exn_error(void) {
+    static const struct exn exn = {
+        .info = NULL, .seen = 1, .error = 1,
+        .message = (char *) "Error during evaluation",
+        .nlines = 0, .lines = NULL };
+    static const struct value value = {
+        .ref = REF_MAX, /* Protect against being freed */
+        .info = NULL, .tag = V_EXN,
+        { .exn = (struct exn *) &exn } };
+    return (struct value *) &value;
+}
+
+/*
+ * Modules
+ */
+static int load_module(struct augeas *aug, const char *name);
+static char *module_basename(const char *modname);
+
+struct module *module_create(const char *name) {
+    struct module *module;
+    make_ref(module);
+    module->name = strdup(name);
+    return module;
+}
+
+static struct module *module_find(struct module *module, const char *name) {
+    list_for_each(e, module) {
+        if (STRCASEEQ(e->name, name))
+            return e;
+    }
+    return NULL;
+}
+
+static struct binding *bnd_lookup(struct binding *bindings, const char *name) {
+    list_for_each(b, bindings) {
+        if (STREQ(b->ident->str, name))
+            return b;
+    }
+    return NULL;
+}
+
+static char *modname_of_qname(const char *qname) {
+    char *dot = strchr(qname, '.');
+    if (dot == NULL)
+        return NULL;
+
+    return strndup(qname, dot - qname);
+}
+
+static int lookup_internal(struct augeas *aug, const char *ctx_modname,
+                           const char *name, struct binding **bnd) {
+    char *modname = modname_of_qname(name);
+
+    *bnd = NULL;
+
+    if (modname == NULL) {
+        struct module *builtin =
+            module_find(aug->modules, builtin_module);
+        assert(builtin != NULL);
+        *bnd = bnd_lookup(builtin->bindings, name);
+        return 0;
+    }
+
+ qual_lookup:
+    list_for_each(module, aug->modules) {
+        if (STRCASEEQ(module->name, modname)) {
+            *bnd = bnd_lookup(module->bindings, name + strlen(modname) + 1);
+            free(modname);
+            return 0;
+        }
+    }
+    /* Try to load the module */
+    if (streqv(modname, ctx_modname)) {
+        free(modname);
+        return 0;
+    }
+    int loaded = load_module(aug, modname) == 0;
+    if (loaded)
+        goto qual_lookup;
+
+    free(modname);
+    return -1;
+}
+
+struct lens *lens_lookup(struct augeas *aug, const char *qname) {
+    struct binding *bnd = NULL;
+
+    if (lookup_internal(aug, NULL, qname, &bnd) < 0)
+        return NULL;
+    if (bnd == NULL || bnd->value->tag != V_LENS)
+        return NULL;
+    return bnd->value->lens;
+}
+
+static struct binding *ctx_lookup_bnd(struct info *info,
+                                      struct ctx *ctx, const char *name) {
+    struct binding *b = NULL;
+    int nlen = strlen(ctx->name);
+
+    if (STREQLEN(ctx->name, name, nlen) && name[nlen] == '.')
+        name += nlen + 1;
+
+    b = bnd_lookup(ctx->local, name);
+    if (b != NULL)
+        return b;
+
+    if (ctx->aug != NULL) {
+        int r;
+        r = lookup_internal(ctx->aug, ctx->name, name, &b);
+        if (r == 0)
+            return b;
+        char *modname = modname_of_qname(name);
+        syntax_error(info, "Could not load module %s for %s",
+                     modname, name);
+        free(modname);
+        return NULL;
+    }
+    return NULL;
+}
+
+static struct value *ctx_lookup(struct info *info,
+                                struct ctx *ctx, struct string *ident) {
+    struct binding *b = ctx_lookup_bnd(info, ctx, ident->str);
+    return b == NULL ? NULL : b->value;
+}
+
+static struct type *ctx_lookup_type(struct info *info,
+                                    struct ctx *ctx, struct string *ident) {
+    struct binding *b = ctx_lookup_bnd(info, ctx, ident->str);
+    return b == NULL ? NULL : b->type;
+}
+
+/* Takes ownership as needed */
+static struct binding *bind_type(struct binding **bnds,
+                                 const char *name, struct type *type) {
+    struct binding *binding;
+
+    if (STREQ(name, anon_ident))
+        return NULL;
+    make_ref(binding);
+    make_ref(binding->ident);
+    binding->ident->str = strdup(name);
+    binding->type = ref(type);
+    list_cons(*bnds, binding);
+
+    return binding;
+}
+
+/* Takes ownership as needed */
+static void bind_param(struct binding **bnds, struct param *param,
+                       struct value *v) {
+    struct binding *b;
+    make_ref(b);
+    b->ident = ref(param->name);
+    b->type  = ref(param->type);
+    b->value = ref(v);
+    ref(*bnds);
+    list_cons(*bnds, b);
+}
+
+static void unbind_param(struct binding **bnds, ATTRIBUTE_UNUSED struct param *param) {
+    struct binding *b = *bnds;
+    assert(b->ident == param->name);
+    assert(b->next != *bnds);
+    *bnds = b->next;
+    unref(b, binding);
+}
+
+/* Takes ownership of VALUE */
+static void bind(struct binding **bnds,
+                 const char *name, struct type *type, struct value *value) {
+    struct binding *b = NULL;
+
+    if (STRNEQ(name, anon_ident)) {
+        b = bind_type(bnds, name, type);
+        b->value = ref(value);
+    }
+}
+
+/*
+ * Some debug printing
+ */
+
+static char *type_string(struct type *t);
+
+static void dump_bindings(struct binding *bnds) {
+    list_for_each(b, bnds) {
+        char *st = type_string(b->type);
+        fprintf(stderr, "    %s: %s", b->ident->str, st);
+        fprintf(stderr, " = ");
+        print_value(stderr, b->value);
+        fputc('\n', stderr);
+        free(st);
+    }
+}
+
+static void dump_module(struct module *module) {
+    if (module == NULL)
+        return;
+    fprintf(stderr, "Module %s\n:", module->name);
+    dump_bindings(module->bindings);
+    dump_module(module->next);
+}
+
+ATTRIBUTE_UNUSED
+static void dump_ctx(struct ctx *ctx) {
+    fprintf(stderr, "Context: %s\n", ctx->name);
+    dump_bindings(ctx->local);
+    if (ctx->aug != NULL) {
+        list_for_each(m, ctx->aug->modules)
+            dump_module(m);
+    }
+}
+
+/*
+ * Values
+ */
+static void print_tree(FILE *out, int indent, struct tree *tree) {
+    list_for_each(t, tree) {
+        for (int i=0; i < indent; i++) fputc(' ', out);
+        fprintf(out, "{ ");
+        if (t->label != NULL)
+            fprintf(out, "\"%s\"", t->label);
+        if (t->value != NULL)
+            fprintf(out, " = \"%s\"", t->value);
+        if (t->children != NULL) {
+            fputc('\n', out);
+            print_tree(out, indent + 2, t->children);
+            for (int i=0; i < indent; i++) fputc(' ', out);
+        } else {
+            fputc(' ', out);
+        }
+        fprintf(out, "}\n");
+    }
+}
+
+static void print_value(FILE *out, struct value *v) {
+    if (v == NULL) {
+        fprintf(out, "<null>");
+        return;
+    }
+
+    switch(v->tag) {
+    case V_STRING:
+        fprintf(out, "\"%s\"", v->string->str);
+        break;
+    case V_REGEXP:
+        fprintf(out, "/%s/", v->regexp->pattern->str);
+        break;
+    case V_LENS:
+        fprintf(out, "<lens:");
+        print_info(out, v->lens->info);
+        fprintf(out, ">");
+        break;
+    case V_TREE:
+        print_tree(out, 0, v->origin);
+        break;
+    case V_FILTER:
+        fprintf(out, "<filter:");
+        list_for_each(f, v->filter) {
+            fprintf(out, "%c%s%c", f->include ? '+' : '-', f->glob->str,
+                   (f->next != NULL) ? ':' : '>');
+        }
+        break;
+    case V_TRANSFORM:
+        fprintf(out, "<transform:");
+        print_info(out, v->transform->lens->info);
+        fprintf(out, ">");
+        break;
+    case V_NATIVE:
+        fprintf(out, "<native:");
+        print_info(out, v->info);
+        fprintf(out, ">");
+        break;
+    case V_CLOS:
+        fprintf(out, "<closure:");
+        print_info(out, v->func->info);
+        fprintf(out, ">");
+        break;
+    case V_EXN:
+        if (! v->exn->seen) {
+            print_info(out, v->exn->info);
+            fprintf(out, "exception: %s\n", v->exn->message);
+            for (int i=0; i < v->exn->nlines; i++) {
+                fprintf(out, "    %s\n", v->exn->lines[i]);
+            }
+            v->exn->seen = 1;
+        }
+        break;
+    case V_UNIT:
+        fprintf(out, "()");
+        break;
+    default:
+        assert(0);
+        break;
+    }
+}
+
+static int value_equal(struct value *v1, struct value *v2) {
+    if (v1 == NULL && v2 == NULL)
+        return 1;
+    if (v1 == NULL || v2 == NULL)
+        return 0;
+    if (v1->tag != v2->tag)
+        return 0;
+    switch (v1->tag) {
+    case V_STRING:
+        return STREQ(v1->string->str, v2->string->str);
+        break;
+    case V_REGEXP:
+        // FIXME: Should probably build FA's and compare them
+        return STREQ(v1->regexp->pattern->str, v2->regexp->pattern->str);
+        break;
+    case V_LENS:
+        return v1->lens == v2->lens;
+        break;
+    case V_TREE:
+        return tree_equal(v1->origin->children, v2->origin->children);
+        break;
+    case V_FILTER:
+        return v1->filter == v2->filter;
+        break;
+    case V_TRANSFORM:
+        return v1->transform == v2->transform;
+        break;
+    case V_NATIVE:
+        return v1->native == v2->native;
+        break;
+    case V_CLOS:
+        return v1->func == v2->func && v1->bindings == v2->bindings;
+        break;
+    default:
+        assert(0);
+        abort();
+        break;
+    }
+}
+
+/*
+ * Types
+ */
+struct type *make_arrow_type(struct type *dom, struct type *img) {
+  struct type *type;
+  make_ref(type);
+  type->tag = T_ARROW;
+  type->dom = ref(dom);
+  type->img = ref(img);
+  return type;
+}
+
+struct type *make_base_type(enum type_tag tag) {
+    if (tag == T_STRING)
+        return (struct type *) t_string;
+    else if (tag == T_REGEXP)
+        return (struct type *) t_regexp;
+    else if (tag == T_LENS)
+        return (struct type *) t_lens;
+    else if (tag == T_TREE)
+        return (struct type *) t_tree;
+    else if (tag == T_FILTER)
+        return (struct type *) t_filter;
+    else if (tag == T_TRANSFORM)
+        return (struct type *) t_transform;
+    else if (tag == T_UNIT)
+        return (struct type *) t_unit;
+    assert(0);
+    abort();
+}
+
+static const char *type_name(struct type *t) {
+    for (int i = 0; type_names[i] != NULL; i++)
+        if (i == t->tag)
+            return type_names[i];
+    assert(0);
+    abort();
+}
+
+static char *type_string(struct type *t) {
+    if (t->tag == T_ARROW) {
+        char *s = NULL;
+        int r;
+        char *sd = type_string(t->dom);
+        char *si = type_string(t->img);
+        if (t->dom->tag == T_ARROW)
+            r = asprintf(&s, "(%s) -> %s", sd, si);
+        else
+            r = asprintf(&s, "%s -> %s", sd, si);
+        free(sd);
+        free(si);
+        return (r == -1) ? NULL : s;
+    } else {
+        return strdup(type_name(t));
+    }
+}
+
+/* Decide whether T1 is a subtype of T2. The only subtype relations are
+ * T_STRING <: T_REGEXP and the usual subtyping of functions based on
+ * comparing domains/images
+ *
+ * Return 1 if T1 is a subtype of T2, 0 otherwise
+ */
+static int subtype(struct type *t1, struct type *t2) {
+    if (t1 == t2)
+        return 1;
+    /* We only promote T_STRING => T_REGEXP, no automatic conversion
+       of strings/regexps to lenses (yet) */
+    if (t1->tag == T_STRING)
+        return (t2->tag == T_STRING || t2->tag == T_REGEXP);
+    if (t1->tag == T_ARROW && t2->tag == T_ARROW) {
+        return subtype(t2->dom, t1->dom)
+            && subtype(t1->img, t2->img);
+    }
+    return t1->tag == t2->tag;
+}
+
+static int type_equal(struct type *t1, struct type *t2) {
+    return (t1 == t2) || (subtype(t1, t2) && subtype(t2, t1));
+}
+
+/* Return a type T with subtype(T, T1) && subtype(T, T2) */
+static struct type *type_meet(struct type *t1, struct type *t2);
+
+/* Return a type T with subtype(T1, T) && subtype(T2, T) */
+static struct type *type_join(struct type *t1, struct type *t2) {
+    if (t1->tag == T_STRING) {
+        if (t2->tag == T_STRING)
+            return ref(t1);
+        else if (t2->tag == T_REGEXP)
+            return ref(t2);
+    } else if (t1->tag == T_REGEXP) {
+        if (t2->tag == T_STRING || t2->tag == T_REGEXP)
+            return ref(t1);
+    } else if (t1->tag == T_ARROW) {
+        if (t2->tag != T_ARROW)
+            return NULL;
+        struct type *dom = type_meet(t1->dom, t2->dom);
+        struct type *img = type_join(t1->img, t2->img);
+        if (dom == NULL || img == NULL) {
+            unref(dom, type);
+            unref(img, type);
+            return NULL;
+        }
+        return make_arrow_type(dom, img);
+    } else if (type_equal(t1, t2)) {
+        return ref(t1);
+    }
+    return NULL;
+}
+
+/* Return a type T with subtype(T, T1) && subtype(T, T2) */
+static struct type *type_meet(struct type *t1, struct type *t2) {
+    if (t1->tag == T_STRING) {
+        if (t2->tag == T_STRING || t2->tag == T_REGEXP)
+            return ref(t1);
+    } else if (t1->tag == T_REGEXP) {
+        if (t2->tag == T_STRING || t2->tag == T_REGEXP)
+            return ref(t2);
+    } else if (t1->tag == T_ARROW) {
+        if (t2->tag != T_ARROW)
+            return NULL;
+        struct type *dom = type_join(t1->dom, t2->dom);
+        struct type *img = type_meet(t1->img, t2->img);
+        if (dom == NULL || img == NULL) {
+            unref(dom, type);
+            unref(img, type);
+            return NULL;
+        }
+        return make_arrow_type(dom, img);
+    } else if (type_equal(t1, t2)) {
+        return ref(t1);
+    }
+    return NULL;
+}
+
+static struct type *value_type(struct value *v) {
+    switch(v->tag) {
+    case V_STRING:
+        return make_base_type(T_STRING);
+    case V_REGEXP:
+        return make_base_type(T_REGEXP);
+    case V_LENS:
+        return make_base_type(T_LENS);
+    case V_TREE:
+        return make_base_type(T_TREE);
+    case V_FILTER:
+        return make_base_type(T_FILTER);
+    case V_TRANSFORM:
+        return make_base_type(T_TRANSFORM);
+    case V_UNIT:
+        return make_base_type(T_UNIT);
+    case V_NATIVE:
+        return ref(v->native->type);
+    case V_CLOS:
+        return ref(v->func->type);
+    case V_EXN:   /* Fail on exceptions */
+    default:
+        assert(0);
+        abort();
+    }
+}
+
+/* Coerce V to the type T. Currently, only T_STRING can be coerced to
+ * T_REGEXP. Returns a value that is owned by the caller. Trying to perform
+ * an impossible coercion is a fatal error. Receives ownership of V.
+ */
+static struct value *coerce(struct value *v, struct type *t) {
+    struct type *vt = value_type(v);
+    if (type_equal(vt, t)) {
+        unref(vt, type);
+        return v;
+    }
+    if (vt->tag == T_STRING && t->tag == T_REGEXP) {
+        struct value *rxp = make_value(V_REGEXP, ref(v->info));
+        rxp->regexp = make_regexp_literal(v->info, v->string->str);
+        unref(v, value);
+        unref(vt, type);
+        return rxp;
+    }
+    return make_exn_value(v->info, "Type %s can not be coerced to %s",
+                          type_name(vt), type_name(t));
+}
+
+/* Return one of the expected types (passed as ...).
+   Does not give ownership of the returned type */
+static struct type *expect_types_arr(struct info *info,
+                                     struct type *act,
+                                     int ntypes, struct type *allowed[]) {
+    struct type *result = NULL;
+
+    for (int i=0; i < ntypes; i++) {
+        if (subtype(act, allowed[i])) {
+            result = allowed[i];
+            break;
+        }
+    }
+    if (result == NULL) {
+        int len = 0;
+        for (int i=0; i < ntypes; i++) {
+            len += strlen(type_name(allowed[i]));
+        }
+        len += (ntypes - 1) * 4 + 1;
+        char *allowed_names;
+        CALLOC(allowed_names, len);
+        for (int i=0; i < ntypes; i++) {
+            if (i > 0)
+                strcat(allowed_names, (i == ntypes - 1) ? ", or " : ", ");
+            strcat(allowed_names, type_name(allowed[i]));
+        }
+        char *act_str = type_string(act);
+        syntax_error(info, "type error: expected %s but found %s",
+                     allowed_names, act_str);
+        free(act_str);
+        free(allowed_names);
+    }
+    return result;
+}
+
+static struct type *expect_types(struct info *info,
+                                 struct type *act, int ntypes, ...) {
+    va_list ap;
+    struct type *allowed[ntypes];
+
+    va_start(ap, ntypes);
+    for (int i=0; i < ntypes; i++)
+        allowed[i] = va_arg(ap, struct type *);
+    va_end(ap);
+    return expect_types_arr(info, act, ntypes, allowed);
+}
+
+static struct value *apply(struct term *app, struct ctx *ctx);
+
+typedef struct value *(*impl0)(struct info *);
+typedef struct value *(*impl1)(struct info *, struct value *);
+typedef struct value *(*impl2)(struct info *, struct value *, struct value *);
+typedef struct value *(*impl3)(struct info *, struct value *, struct value *,
+                               struct value *);
+typedef struct value *(*impl4)(struct info *, struct value *, struct value *,
+                               struct value *, struct value *);
+typedef struct value *(*impl5)(struct info *, struct value *, struct value *,
+                               struct value *, struct value *, struct value *);
+
+static struct value *native_call(struct info *info,
+                                 struct native *func, struct ctx *ctx) {
+    struct value *argv[func->argc];
+    struct binding *b = ctx->local;
+    struct value *result;
+
+    for (int i = func->argc - 1; i >= 0; i--) {
+        argv[i] = b->value;
+        b = b->next;
+    }
+
+    switch(func->argc) {
+    case 0:
+        result = ((impl0) *func->impl)(info);
+        break;
+    case 1:
+        result = ((impl1) *func->impl)(info, argv[0]);
+        break;
+    case 2:
+        result = ((impl2) *func->impl)(info, argv[0], argv[1]);
+        break;
+    case 3:
+        result = ((impl3) *func->impl)(info, argv[0], argv[1], argv[2]);
+        break;
+    case 4:
+        result = ((impl4) *func->impl)(info, argv[0], argv[1], argv[2], argv[3]);
+        break;
+    case 5:
+        result = ((impl5) *func->impl)(info, argv[0], argv[1], argv[2], argv[3],
+                                       argv[4]);
+        break;
+    default:
+        assert(0);
+        abort();
+        break;
+    }
+
+    return result;
+}
+
+static void type_error1(struct info *info, const char *msg, struct type *type) {
+    char *s = type_string(type);
+    syntax_error(info, "Type error: ");
+    syntax_error(info, msg, s);
+    free(s);
+}
+
+static void type_error2(struct info *info, const char *msg,
+                        struct type *type1, struct type *type2) {
+    char *s1 = type_string(type1);
+    char *s2 = type_string(type2);
+    syntax_error(info, "Type error: ");
+    syntax_error(info, msg, s1, s2);
+    free(s1);
+    free(s2);
+}
+
+static void type_error_binop(struct info *info, const char *opname,
+                             struct type *type1, struct type *type2) {
+    char *s1 = type_string(type1);
+    char *s2 = type_string(type2);
+    syntax_error(info, "Type error: ");
+    syntax_error(info, "%s of %s and %s is not possible", opname, s1, s2);
+    free(s1);
+    free(s2);
+}
+
+static int check_exp(struct term *term, struct ctx *ctx);
+
+static struct type *require_exp_type(struct term *term, struct ctx *ctx,
+                                     int ntypes, struct type *allowed[]) {
+    int r = 1;
+
+    if (term->type == NULL) {
+        r = check_exp(term, ctx);
+        if (! r)
+            return NULL;
+    }
+
+    return expect_types_arr(term->info, term->type, ntypes, allowed);
+}
+
+static int check_compose(struct term *term, struct ctx *ctx) {
+    struct type *tl = NULL, *tr = NULL;
+
+    if (! check_exp(term->left, ctx))
+        return 0;
+    tl = term->left->type;
+
+    if (tl->tag == T_ARROW) {
+        /* Composition of functions f: a -> b and g: c -> d is defined as
+           (f . g) x = g (f x) and is type correct if b <: c yielding a
+           function with type a -> d */
+        if (! check_exp(term->right, ctx))
+            return 0;
+        tr = term->right->type;
+        if (tr->tag != T_ARROW)
+            goto print_error;
+        if (! subtype(tl->img, tr->dom))
+            goto print_error;
+        term->type = make_arrow_type(tl->dom, tr->img);
+    } else if (tl->tag == T_UNIT) {
+        if (! check_exp(term->right, ctx))
+            return 0;
+        term->type = ref(term->right->type);
+    } else {
+        goto print_error;
+    }
+    return 1;
+ print_error:
+    type_error_binop(term->info,
+                     "composition", term->left->type, term->right->type);
+    return 0;
+}
+
+static int check_binop(const char *opname, struct term *term,
+                       struct ctx *ctx, int ntypes, ...) {
+    va_list ap;
+    struct type *allowed[ntypes];
+    struct type *tl = NULL, *tr = NULL;
+
+    va_start(ap, ntypes);
+    for (int i=0; i < ntypes; i++)
+        allowed[i] = va_arg(ap, struct type *);
+    va_end(ap);
+
+    tl = require_exp_type(term->left, ctx, ntypes, allowed);
+    if (tl == NULL)
+        return 0;
+
+    tr = require_exp_type(term->right, ctx, ntypes, allowed);
+    if (tr == NULL)
+        return 0;
+
+    term->type = type_join(tl, tr);
+    if (term->type == NULL)
+        goto print_error;
+    return 1;
+ print_error:
+    type_error_binop(term->info, opname, term->left->type, term->right->type);
+    return 0;
+}
+
+static int check_value(struct value *v) {
+    const char *msg;
+
+    if (v->tag == V_REGEXP) {
+        if (regexp_check(v->regexp, &msg) == -1) {
+            syntax_error(v->info, "Invalid regular expression: %s", msg);
+            return 0;
+        }
+    }
+    return 1;
+}
+
+/* Return 1 if TERM passes, 0 otherwise */
+static int check_exp(struct term *term, struct ctx *ctx) {
+    int result = 1;
+    assert(term->type == NULL || term->tag == A_VALUE || term->ref > 1);
+    if (term->type != NULL && term->tag != A_VALUE)
+        return 1;
+
+    switch (term->tag) {
+    case A_UNION:
+        result = check_binop("union", term, ctx, 2, t_regexp, t_lens);
+        break;
+    case A_MINUS:
+        result = check_binop("minus", term, ctx, 1, t_regexp);
+        break;
+    case A_COMPOSE:
+        result = check_compose(term, ctx);
+        break;
+    case A_CONCAT:
+        result = check_binop("concatenation", term, ctx,
+                             4, t_string, t_regexp, t_lens, t_filter);
+        break;
+    case A_LET:
+        {
+            result = check_exp(term->right, ctx);
+            if (result) {
+                struct term *func = term->left;
+                assert(func->tag == A_FUNC);
+                assert(func->param->type == NULL);
+                func->param->type = ref(term->right->type);
+
+                result = check_exp(func, ctx);
+                if (result) {
+                    term->tag = A_APP;
+                    term->type = ref(func->type->img);
+                }
+            }
+        }
+        break;
+    case A_APP:
+        result = check_exp(term->left, ctx) & check_exp(term->right, ctx);
+        if (result) {
+            if (term->left->type->tag != T_ARROW) {
+                type_error1(term->info,
+                            "expected function in application but found %s",
+                            term->left->type);
+                result = 0;
+            };
+        }
+        if (result) {
+            result = expect_types(term->info,
+                                  term->right->type,
+                                  1, term->left->type->dom) != NULL;
+            if (! result) {
+                type_error_binop(term->info, "application",
+                                 term->left->type, term->right->type);
+                result = 0;
+            }
+        }
+        if (result)
+            term->type = ref(term->left->type->img);
+        break;
+    case A_VALUE:
+        result = check_value(term->value);
+        break;
+    case A_IDENT:
+        {
+            struct type *t = ctx_lookup_type(term->info, ctx, term->ident);
+            if (t == NULL) {
+                syntax_error(term->info, "Undefined variable %s",
+                             term->ident->str);
+                result = 0;
+            } else {
+                term->type = ref(t);
+            }
+        }
+        break;
+    case A_BRACKET:
+        result = check_exp(term->brexp, ctx);
+        if (result) {
+            term->type = ref(expect_types(term->info, term->brexp->type,
+                                          1, t_lens));
+            if (term->type == NULL) {
+                type_error1(term->info,
+                             "[..] is only defined for lenses, not for %s",
+                            term->brexp->type);
+                result = 0;
+            }
+        }
+        break;
+    case A_FUNC:
+        {
+            bind_param(&ctx->local, term->param, NULL);
+            result = check_exp(term->body, ctx);
+            if (result) {
+                term->type =
+                    make_arrow_type(term->param->type, term->body->type);
+            }
+            unbind_param(&ctx->local, term->param);
+        }
+        break;
+    case A_REP:
+        result = check_exp(term->exp, ctx);
+        if (result) {
+            term->type = ref(expect_types(term->info, term->exp->type, 2,
+                                          t_regexp, t_lens));
+            if (term->type == NULL) {
+                type_error1(term->info,
+                            "Incompatible types: repetition is only defined"
+                            " for regexp and lens, not for %s",
+                            term->exp->type);
+                result = 0;
+            }
+        }
+        break;
+    default:
+        assert(0);
+        break;
+    }
+    assert(!result || term->type != NULL);
+    return result;
+}
+
+static int check_decl(struct term *term, struct ctx *ctx) {
+    assert(term->tag == A_BIND || term->tag == A_TEST);
+
+    if (term->tag == A_BIND) {
+        if (!check_exp(term->exp, ctx))
+            return 0;
+        term->type = ref(term->exp->type);
+
+        if (bnd_lookup(ctx->local, term->bname) != NULL) {
+            syntax_error(term->info,
+                         "the name %s is already defined", term->bname);
+            return 0;
+        }
+        bind_type(&ctx->local, term->bname, term->type);
+    } else if (term->tag == A_TEST) {
+        if (!check_exp(term->test, ctx))
+            return 0;
+        if (term->result != NULL) {
+            if (!check_exp(term->result, ctx))
+                return 0;
+            if (! type_equal(term->test->type, term->result->type)) {
+                type_error2(term->info,
+                            "expected test result of type %s but got %s",
+                            term->result->type, term->test->type);
+                return 0;
+            }
+        } else {
+            if (expect_types(term->info, term->test->type, 2,
+                             t_string, t_tree) == NULL)
+                return 0;
+        }
+        term->type = ref(term->test->type);
+    } else {
+        assert(0);
+    }
+    return 1;
+}
+
+static int typecheck(struct term *term, struct augeas *aug) {
+    int ok = 1;
+    struct ctx ctx;
+    char *fname;
+    const char *basenam;
+
+    assert(term->tag == A_MODULE);
+
+    /* Check that the module name is consistent with the filename */
+    fname = module_basename(term->mname);
+
+    basenam = strrchr(term->info->filename->str, SEP);
+    if (basenam == NULL)
+        basenam = term->info->filename->str;
+    else
+        basenam += 1;
+    if (STRNEQ(fname, basenam)) {
+        syntax_error(term->info,
+                     "The module %s must be in a file named %s",
+                     term->mname, fname);
+        free(fname);
+        return 0;
+    }
+    free(fname);
+
+    ctx.aug = aug;
+    ctx.local = NULL;
+    ctx.name = term->mname;
+    list_for_each(dcl, term->decls) {
+        ok &= check_decl(dcl, &ctx);
+    }
+    unref(ctx.local, binding);
+    return ok;
+}
+
+static struct value *compile_exp(struct info *, struct term *, struct ctx *);
+
+static struct value *compile_union(struct term *exp, struct ctx *ctx) {
+    struct value *v1 = compile_exp(exp->info, exp->left, ctx);
+    if (EXN(v1))
+        return v1;
+    struct value *v2 = compile_exp(exp->info, exp->right, ctx);
+    if (EXN(v2)) {
+        unref(v1, value);
+        return v2;
+    }
+
+    struct type *t = exp->type;
+    struct info *info = exp->info;
+    struct value *v = NULL;
+
+    v1 = coerce(v1, t);
+    if (EXN(v1))
+        return v1;
+    v2 = coerce(v2, t);
+    if (EXN(v2)) {
+        unref(v1, value);
+        return v2;
+    }
+
+    if (t->tag == T_REGEXP) {
+        v = make_value(V_REGEXP, ref(info));
+        v->regexp = regexp_union(info, v1->regexp, v2->regexp);
+    } else if (t->tag == T_LENS) {
+        struct lens *l1 = v1->lens;
+        struct lens *l2 = v2->lens;
+        v = lns_make_union(ref(info), ref(l1), ref(l2), LNS_TYPE_CHECK(ctx));
+    } else {
+        fatal_error(info, "Tried to union a %s and a %s to yield a %s",
+                    type_name(exp->left->type), type_name(exp->right->type),
+                    type_name(t));
+    }
+    unref(v1, value);
+    unref(v2, value);
+    return v;
+}
+
+static struct value *compile_minus(struct term *exp, struct ctx *ctx) {
+    struct value *v1 = compile_exp(exp->info, exp->left, ctx);
+    if (EXN(v1))
+        return v1;
+    struct value *v2 = compile_exp(exp->info, exp->right, ctx);
+    if (EXN(v2)) {
+        unref(v1, value);
+        return v2;
+    }
+
+    struct type *t = exp->type;
+    struct info *info = exp->info;
+    struct value *v;
+
+    v1 = coerce(v1, t);
+    v2 = coerce(v2, t);
+    if (t->tag == T_REGEXP) {
+        struct regexp *re1 = v1->regexp;
+        struct regexp *re2 = v2->regexp;
+        struct regexp *re = regexp_minus(info, re1, re2);
+        if (re == NULL) {
+            v = make_exn_value(ref(info),
+                   "Regular expression subtraction 'r1 - r2' failed");
+            exn_printf_line(v, "r1: /%s/", re1->pattern->str);
+            exn_printf_line(v, "r2: /%s/", re2->pattern->str);
+        } else {
+            v = make_value(V_REGEXP, ref(info));
+            v->regexp = re;
+        }
+    } else {
+        fatal_error(info, "Tried to subtract a %s and a %s to yield a %s",
+                    type_name(exp->left->type), type_name(exp->right->type),
+                    type_name(t));
+    }
+    unref(v1, value);
+    unref(v2, value);
+    return v;
+}
+
+static struct value *compile_compose(struct term *exp, struct ctx *ctx) {
+    struct type *t = exp->type;
+    struct info *info = exp->info;
+    struct value *v;
+
+    if (t->tag == T_ARROW) {
+        // FIXME: This is really crufty, and should be desugared in the
+        // parser so that we don't have to do all this manual type
+        // computation. Should we write function compostion as
+        // concatenation instead of using a separate syntax ?
+
+        /* Build lambda x: exp->right (exp->left x) as a closure */
+        char *var = strdup("@0");
+        struct term *param = make_param(var, ref(exp->left->type->dom),
+                                        ref(info));
+        param->type = ref(exp->left->type);
+        struct term *ident = make_term(A_IDENT, ref(info));
+        ident->ident = ref(param->param->name);
+        ident->type = ref(param->type);
+        struct term *app = make_app_term(ref(exp->left), ident, ref(info));
+        app->type = ref(app->left->type->img);
+        app = make_app_term(ref(exp->right), app, ref(info));
+        app->type = ref(app->left->type->img);
+
+        struct term *func = build_func(param, app);
+
+        assert(type_equal(func->type, exp->type));
+        v = make_closure(func, ctx->local);
+        unref(func, term);
+    } else {
+        v = compile_exp(exp->info, exp->left, ctx);
+        unref(v, value);
+        v = compile_exp(exp->info, exp->right, ctx);
+    }
+    return v;
+}
+
+static struct value *compile_concat(struct term *exp, struct ctx *ctx) {
+    struct value *v1 = compile_exp(exp->info, exp->left, ctx);
+    if (EXN(v1))
+        return v1;
+    struct value *v2 = compile_exp(exp->info, exp->right, ctx);
+    if (EXN(v2)) {
+        unref(v1, value);
+        return v2;
+    }
+
+    struct type *t = exp->type;
+    struct info *info = exp->info;
+    struct value *v;
+
+    v1 = coerce(v1, t);
+    v2 = coerce(v2, t);
+    if (t->tag == T_STRING) {
+        const char *s1 = v1->string->str;
+        const char *s2 = v2->string->str;
+        v = make_value(V_STRING, ref(info));
+        make_ref(v->string);
+        CALLOC(v->string->str, strlen(s1) + strlen(s2) + 1);
+        char *s = v->string->str;
+        strcpy(s, s1);
+        strcat(s, s2);
+    } else if (t->tag == T_REGEXP) {
+        v = make_value(V_REGEXP, ref(info));
+        v->regexp = regexp_concat(info, v1->regexp, v2->regexp);
+    } else if (t->tag == T_FILTER) {
+        struct filter *f1 = v1->filter;
+        struct filter *f2 = v2->filter;
+        v = make_value(V_FILTER, ref(info));
+        if (v2->ref == 1 && f2->ref == 1) {
+            list_append(f2, ref(f1));
+            v->filter = ref(f2);
+        } else if (v1->ref == 1 && f1->ref == 1) {
+            list_append(f1, ref(f2));
+            v->filter = ref(f1);
+        } else {
+            struct filter *cf1, *cf2;
+            cf1 = make_filter(ref(f1->glob), f1->include);
+            cf2 = make_filter(ref(f2->glob), f2->include);
+            cf1->next = ref(f1->next);
+            cf2->next = ref(f2->next);
+            list_append(cf1, cf2);
+            v->filter = cf1;
+        }
+    } else if (t->tag == T_LENS) {
+        struct lens *l1 = v1->lens;
+        struct lens *l2 = v2->lens;
+        v = lns_make_concat(ref(info), ref(l1), ref(l2), LNS_TYPE_CHECK(ctx));
+    } else {
+        fatal_error(info, "Tried to concat a %s and a %s to yield a %s",
+                    type_name(exp->left->type), type_name(exp->right->type),
+                    type_name(t));
+    }
+    unref(v1, value);
+    unref(v2, value);
+    return v;
+}
+
+static struct value *apply(struct term *app, struct ctx *ctx) {
+    struct value *f = compile_exp(app->info, app->left, ctx);
+    struct value *result = NULL;
+    struct ctx lctx;
+
+    if (EXN(f))
+        return f;
+
+    struct value *arg = compile_exp(app->info, app->right, ctx);
+    if (EXN(arg)) {
+        unref(f, value);
+        return arg;
+    }
+
+    assert(f->tag == V_CLOS);
+
+    lctx.aug = ctx->aug;
+    lctx.local = ref(f->bindings);
+    lctx.name = ctx->name;
+
+    arg = coerce(arg, f->func->param->type);
+    if (arg == NULL)
+        goto done;
+
+    bind_param(&lctx.local, f->func->param, arg);
+    result = compile_exp(app->info, f->func->body, &lctx);
+    unref(result->info, info);
+    result->info = ref(app->info);
+    unbind_param(&lctx.local, f->func->param);
+
+ done:
+    unref(lctx.local, binding);
+    unref(arg, value);
+    unref(f, value);
+    return result;
+}
+
+static struct value *compile_bracket(struct term *exp, struct ctx *ctx) {
+    struct value *arg = compile_exp(exp->info, exp->brexp, ctx);
+    if (EXN(arg))
+        return arg;
+    assert(arg->tag == V_LENS);
+
+    struct value *v = lns_make_subtree(ref(exp->info), ref(arg->lens));
+    unref(arg, value);
+
+    return v;
+}
+
+static struct value *compile_rep(struct term *rep, struct ctx *ctx) {
+    struct value *arg = compile_exp(rep->info, rep->rexp, ctx);
+    struct value *v = NULL;
+
+    if (EXN(arg))
+        return arg;
+
+    arg = coerce(arg, rep->type);
+    if (rep->type->tag == T_REGEXP) {
+        int min, max;
+        if (rep->quant == Q_STAR) {
+            min = 0; max = -1;
+        } else if (rep->quant == Q_PLUS) {
+            min = 1; max = -1;
+        } else if (rep->quant == Q_MAYBE) {
+            min = 0; max = 1;
+        } else {
+            assert(0);
+            abort();
+        }
+        v = make_value(V_REGEXP, ref(rep->info));
+        v->regexp = regexp_iter(rep->info, arg->regexp, min, max);
+    } else if (rep->type->tag == T_LENS) {
+        int c = LNS_TYPE_CHECK(ctx);
+        if (rep->quant == Q_STAR) {
+            v = lns_make_star(ref(rep->info), ref(arg->lens), c);
+        } else if (rep->quant == Q_PLUS) {
+            v = lns_make_plus(ref(rep->info), ref(arg->lens), c);
+        } else if (rep->quant == Q_MAYBE) {
+            v = lns_make_maybe(ref(rep->info), ref(arg->lens), c);
+        } else {
+            assert(0);
+        }
+    } else {
+        fatal_error(rep->info, "Tried to repeat a %s to yield a %s",
+                    type_name(rep->rexp->type), type_name(rep->type));
+    }
+    unref(arg, value);
+    return v;
+}
+
+static struct value *compile_exp(struct info *info,
+                                 struct term *exp, struct ctx *ctx) {
+    struct value *v = NULL;
+
+    switch (exp->tag) {
+    case A_COMPOSE:
+        v = compile_compose(exp, ctx);
+        break;
+    case A_UNION:
+        v = compile_union(exp, ctx);
+        break;
+    case A_MINUS:
+        v = compile_minus(exp, ctx);
+        break;
+    case A_CONCAT:
+        v = compile_concat(exp, ctx);
+        break;
+    case A_APP:
+        v = apply(exp, ctx);
+        break;
+    case A_VALUE:
+        if (exp->value->tag == V_NATIVE) {
+            v = native_call(info, exp->value->native, ctx);
+        } else {
+            v = ref(exp->value);
+        }
+        break;
+    case A_IDENT:
+        v = ref(ctx_lookup(exp->info, ctx, exp->ident));
+        break;
+    case A_BRACKET:
+        v = compile_bracket(exp, ctx);
+        break;
+    case A_FUNC:
+        v = make_closure(exp, ctx->local);
+        break;
+    case A_REP:
+        v = compile_rep(exp, ctx);
+        break;
+    default:
+        assert(0);
+        break;
+    }
+
+    return v;
+}
+
+static int compile_test(struct term *term, struct ctx *ctx) {
+    struct value *actual = compile_exp(term->info, term->test, ctx);
+    struct value *expect = NULL;
+    int ret = 1;
+
+    if (term->tr_tag == TR_EXN) {
+        if (!EXN(actual)) {
+            printf("Test run should have produced exception, but produced\n");
+            print_value(stdout, actual);
+            printf("\n");
+            ret = 0;
+        }
+    } else {
+        if (EXN(actual)) {
+            print_info(stdout, term->info);
+            printf("exception thrown in test\n");
+            print_value(stdout, actual);
+            printf("\n");
+            ret = 0;
+        } else if (term->tr_tag == TR_CHECK) {
+            expect = compile_exp(term->info, term->result, ctx);
+            if (EXN(expect))
+                goto done;
+            if (! value_equal(actual, expect)) {
+                printf("Test failure:");
+                print_info(stdout, term->info);
+                printf("\n");
+                printf(" Expected:\n");
+                print_value(stdout, expect);
+                printf("\n");
+                printf(" Actual:\n");
+                print_value(stdout, actual);
+                printf("\n");
+                ret = 0;
+            }
+        } else {
+            printf("Test result: ");
+            print_info(stdout, term->info);
+            printf("\n");
+            if (actual->tag == V_TREE) {
+                print_tree(stdout, 2, actual->origin->children);
+            } else {
+                print_value(stdout, actual);
+            }
+            printf("\n");
+        }
+    }
+ done:
+    reset_error(term->info->error);
+    unref(actual, value);
+    unref(expect, value);
+    return ret;
+}
+
+static int compile_decl(struct term *term, struct ctx *ctx) {
+    if (term->tag == A_BIND) {
+        int result;
+
+        struct value *v = compile_exp(term->info, term->exp, ctx);
+        bind(&ctx->local, term->bname, term->type, v);
+
+        if (EXN(v) && !v->exn->seen) {
+            struct error *error = term->info->error;
+            struct memstream ms;
+
+            init_memstream(&ms);
+
+            syntax_error(term->info, "Failed to compile %s",
+                         term->bname);
+            fprintf(ms.stream, "%s\n", error->details);
+            print_value(ms.stream, v);
+            close_memstream(&ms);
+
+            v->exn->seen = 1;
+            free(error->details);
+            error->details = ms.buf;
+        }
+        result = ! EXN(v);
+        unref(v, value);
+        return result;
+    } else if (term->tag == A_TEST) {
+        return compile_test(term, ctx);
+    }
+    assert(0);
+    abort();
+}
+
+static struct module *compile(struct term *term, struct augeas *aug) {
+    struct ctx ctx;
+    struct transform *autoload = NULL;
+    assert(term->tag == A_MODULE);
+
+    ctx.aug = aug;
+    ctx.local = NULL;
+    ctx.name = term->mname;
+    list_for_each(dcl, term->decls) {
+        if (!compile_decl(dcl, &ctx))
+            goto error;
+    }
+
+    if (term->autoload != NULL) {
+        struct binding *bnd = bnd_lookup(ctx.local, term->autoload);
+        if (bnd == NULL) {
+            syntax_error(term->info, "Undefined transform in autoload %s",
+                         term->autoload);
+            goto error;
+        }
+        if (expect_types(term->info, bnd->type, 1, t_transform) == NULL)
+            goto error;
+        autoload = bnd->value->transform;
+    }
+    struct module *module = module_create(term->mname);
+    module->bindings = ctx.local;
+    module->autoload = ref(autoload);
+    return module;
+ error:
+    unref(ctx.local, binding);
+    return NULL;
+}
+
+/*
+ * Defining native functions
+ */
+static struct info *
+make_native_info(struct error *error, const char *fname, int line) {
+    struct info *info;
+    if (make_ref(info) < 0)
+        goto error;
+    info->first_line = info->last_line = line;
+    info->first_column = info->last_column = 0;
+    info->error = error;
+    if (make_ref(info->filename) < 0)
+        goto error;
+    info->filename->str = strdup(fname);
+    return info;
+ error:
+    unref(info, info);
+    return NULL;
+}
+
+int define_native_intl(const char *file, int line,
+                       struct error *error,
+                       struct module *module, const char *name,
+                       int argc, void *impl, ...) {
+    assert(argc > 0);  /* We have no unit type */
+    assert(argc <= 5);
+    va_list ap;
+    enum type_tag tag;
+    struct term *params = NULL, *body = NULL, *func = NULL;
+    struct type *type;
+    struct value *v = NULL;
+    struct info *info = NULL;
+    struct ctx ctx;
+
+    info = make_native_info(error, file, line);
+    if (info == NULL)
+        goto error;
+
+    va_start(ap, impl);
+    for (int i=0; i < argc; i++) {
+        struct term *pterm;
+        char ident[10];
+        tag = va_arg(ap, enum type_tag);
+        type = make_base_type(tag);
+        snprintf(ident, 10, "@%d", i);
+        pterm = make_param(strdup(ident), type, ref(info));
+        list_append(params, pterm);
+    }
+    tag = va_arg(ap, enum type_tag);
+    va_end(ap);
+
+    type = make_base_type(tag);
+
+    make_ref(v);
+    if (v == NULL)
+        goto error;
+    v->tag = V_NATIVE;
+    v->info = info;
+    info = NULL;
+
+    if (ALLOC(v->native) < 0)
+        goto error;
+    v->native->argc = argc;
+    v->native->type = type;
+    v->native->impl = impl;
+
+    make_ref(body);
+    if (body == NULL)
+        goto error;
+    body->info = ref(info);
+    body->type = ref(type);
+    body->tag = A_VALUE;
+    body->value = v;
+    v = NULL;
+
+    func = build_func(params, body);
+    if (func == NULL)
+        goto error;
+    body = NULL;
+
+    ctx.aug = NULL;
+    ctx.local = ref(module->bindings);
+    ctx.name = module->name;
+    if (! check_exp(func, &ctx)) {
+        fatal_error(info, "Typechecking native %s failed",
+                    name);
+        abort();
+    }
+    v = make_closure(func, ctx.local);
+    if (v == NULL) {
+        unref(module->bindings, binding);
+        goto error;
+    }
+    bind(&ctx.local, name, func->type, v);
+    unref(v, value);
+    unref(func, term);
+    unref(module->bindings, binding);
+
+    module->bindings = ctx.local;
+    return 0;
+ error:
+    unref(v, value);
+    unref(body, term);
+    unref(func, term);
+    return -1;
+}
+
+
+/* Defined in parser.y */
+int augl_parse_file(struct augeas *aug, const char *name, struct term **term);
+
+static char *module_basename(const char *modname) {
+    char *fname;
+
+    if (asprintf(&fname, "%s" AUG_EXT, modname) == -1)
+        return NULL;
+    for (int i=0; i < strlen(modname); i++)
+        fname[i] = tolower(fname[i]);
+    return fname;
+}
+
+static char *module_filename(struct augeas *aug, const char *modname) {
+    char *dir = NULL;
+    char *filename = NULL;
+    char *name = module_basename(modname);
+
+    while ((dir = argz_next(aug->modpathz, aug->nmodpath, dir)) != NULL) {
+        int len = strlen(name) + strlen(dir) + 2;
+        struct stat st;
+
+        if (REALLOC_N(filename, len) == -1)
+            goto error;
+        sprintf(filename, "%s/%s", dir, name);
+        if (stat(filename, &st) == 0)
+            goto done;
+    }
+ error:
+    FREE(filename);
+ done:
+    free(name);
+    return filename;
+}
+
+int load_module_file(struct augeas *aug, const char *filename) {
+    struct term *term = NULL;
+    int result = -1;
+
+    augl_parse_file(aug, filename, &term);
+    ERR_BAIL(aug);
+
+    if (! typecheck(term, aug))
+        goto error;
+
+    struct module *module = compile(term, aug);
+    ERR_THROW(module == NULL, aug, AUG_ESYNTAX,
+              "Failed to load %s", filename);
+
+    list_append(aug->modules, module);
+    result = 0;
+ error:
+    // FIXME: This leads to a bad free of a string used in a del lens
+    // To reproduce run lenses/tests/test_yum.aug
+    unref(term, term);
+    return result;
+}
+
+static int load_module(struct augeas *aug, const char *name) {
+    char *filename = NULL;
+
+    if (module_find(aug->modules, name) != NULL)
+        return 0;
+
+    if ((filename = module_filename(aug, name)) == NULL)
+        return -1;
+
+    if (load_module_file(aug, filename) == -1)
+        goto error;
+
+    free(filename);
+    return 0;
+
+ error:
+    free(filename);
+    return -1;
+}
+
+int interpreter_init(struct augeas *aug) {
+    int r;
+
+    aug->modules = builtin_init(aug->error);
+
+    if (aug->flags & AUG_NO_MODL_AUTOLOAD)
+        return 0;
+
+    // For now, we just load every file on the search path
+    const char *dir = NULL;
+    glob_t globbuf;
+    int gl_flags = GLOB_NOSORT;
+
+    MEMZERO(&globbuf, 1);
+
+    while ((dir = argz_next(aug->modpathz, aug->nmodpath, dir)) != NULL) {
+        char *globpat;
+        r = asprintf(&globpat, "%s/*.aug", dir);
+        ERR_NOMEM(r < 0, aug);
+
+        r = glob(globpat, gl_flags, NULL, &globbuf);
+        if (r != 0 && r != GLOB_NOMATCH) {
+            /* This really has to be an allocation failure; glob is not
+             * supposed to return GLOB_ABORTED here */
+            aug_errcode_t code =
+                r == GLOB_NOSPACE ? AUG_ENOMEM : AUG_EINTERNAL;
+            ERR_REPORT(aug, code, "glob failure for %s", globpat);
+            free(globpat);
+            goto error;
+        }
+        gl_flags |= GLOB_APPEND;
+        free(globpat);
+    }
+
+    for (int i=0; i < globbuf.gl_pathc; i++) {
+        char *name, *p, *q;
+        p = strrchr(globbuf.gl_pathv[i], SEP);
+        if (p == NULL)
+            p = globbuf.gl_pathv[i];
+        else
+            p += 1;
+        q = strchr(p, '.');
+        name = strndup(p, q - p);
+        name[0] = toupper(name[0]);
+        if (load_module(aug, name) == -1)
+            goto error;
+        free(name);
+    }
+    globfree(&globbuf);
+    return 0;
+ error:
+    globfree(&globbuf);
+    return -1;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/syntax.h b/src/syntax.h
new file mode 100644 (file)
index 0000000..379e18d
--- /dev/null
@@ -0,0 +1,295 @@
+/*
+ * syntax.h: Data types to represent language syntax
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#ifndef SYNTAX_H_
+#define SYNTAX_H_
+
+#include <limits.h>
+#include "internal.h"
+#include "lens.h"
+#include "ref.h"
+#include "fa.h"
+#include "regexp.h"
+#include "info.h"
+
+void syntax_error(struct info *info, const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 2, 3);
+
+void fatal_error(struct info *info, const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 2, 3);
+
+enum term_tag {
+    A_MODULE,
+    A_BIND,              /* Module scope binding of a name */
+    A_LET,               /* local LET .. IN binding */
+    A_COMPOSE,
+    A_UNION,
+    A_MINUS,
+    A_CONCAT,
+    A_APP,
+    A_VALUE,
+    A_IDENT,
+    A_BRACKET,
+    A_FUNC,
+    A_REP,
+    A_TEST
+};
+
+enum test_result_tag {
+    TR_CHECK,
+    TR_PRINT,
+    TR_EXN
+};
+
+enum quant_tag {
+    Q_STAR,
+    Q_PLUS,
+    Q_MAYBE
+};
+
+struct term {
+    struct term *next;
+    unsigned int ref;
+    struct info *info;
+    struct type *type;                /* Filled in by the typechecker */
+    enum term_tag tag;
+    union {
+        struct {                       /* A_MODULE */
+            char          *mname;
+            char          *autoload;
+            struct term   *decls;
+        };
+        struct {                       /* A_BIND */
+            char          *bname;
+            struct term   *exp;
+        };
+        struct {              /* A_COMPOSE, A_UNION, A_CONCAT, A_APP, A_LET */
+            struct term *left;
+            struct term *right;
+        };
+        struct value    *value;         /* A_VALUE */
+        struct term     *brexp;         /* A_BRACKET */
+        struct string   *ident;         /* A_IDENT */
+        struct {                        /* A_REP */
+            enum quant_tag quant;
+            struct term  *rexp;
+        };
+        struct {                       /* A_FUNC */
+            struct param *param;
+            struct term   *body;
+        };
+        struct {                       /* A_TEST */
+            enum test_result_tag tr_tag;
+            struct term         *test;
+            struct term         *result;
+        };
+    };
+};
+
+struct param {
+    struct info   *info;
+    unsigned int   ref;
+    struct string *name;
+    struct type   *type;
+};
+
+struct native {
+    unsigned int argc;
+    struct type *type;
+    struct value *(*impl)(void);
+};
+
+/* An exception in the interpreter. Some exceptions are reported directly
+ * into the central struct error; an exception for those is only generated
+ * to follow the control flow for exceptions. Such exceptions have both
+ * seen and error set to 1. They are the only exceptions with error == 1.
+ * When error == 1, none of the other fields in the exn will be usable.
+ */
+struct exn {
+    struct info *info;
+    unsigned int seen : 1;      /* Whether the user has seen this EXN */
+    unsigned int error : 1;
+    char        *message;
+    size_t       nlines;
+    char       **lines;
+};
+
+/*
+ * Values in the interpreter
+ */
+enum value_tag {
+    V_STRING,
+    V_REGEXP,
+    V_LENS,
+    V_TREE,
+    V_FILTER,
+    V_TRANSFORM,
+    V_NATIVE,
+    V_EXN,
+    V_CLOS,
+    V_UNIT
+};
+
+#define EXN(v) ((v)->tag == V_EXN)
+
+struct value {
+    unsigned int   ref;
+    struct info   *info;
+    enum value_tag tag;
+    /* Nothing in this union for V_UNIT */
+    union {
+        struct string  *string;  /* V_STRING */
+        struct regexp  *regexp;  /* V_REGEXP */
+        struct lens    *lens;    /* V_LENS */
+        struct native  *native;  /* V_NATIVE */
+        struct tree    *origin;  /* V_TREE */
+        struct filter  *filter;  /* V_FILTER */
+        struct transform *transform; /* V_TRANSFORM */
+        struct exn     *exn;     /* V_EXN */
+        struct {                 /* V_CLOS */
+            struct term     *func;
+            struct binding  *bindings;
+        };
+    };
+};
+
+/* Return an exception value with error == 1 (and seen == 1) */
+struct value *exn_error(void);
+
+/* All types except for T_ARROW (functions) are simple. Subtype relations
+ * for the simple types:
+ *   T_STRING <: T_REGEXP
+ * and the usual subtype relation for functions.
+ */
+enum type_tag {
+    T_STRING,
+    T_REGEXP,
+    T_LENS,
+    T_TREE,
+    T_FILTER,
+    T_TRANSFORM,
+    T_ARROW,
+    T_UNIT
+};
+
+struct type {
+    unsigned int   ref;
+    enum type_tag  tag;
+    struct type   *dom;    /* T_ARROW */
+    struct type   *img;    /* T_ARROW */
+};
+
+struct binding {
+    unsigned int    ref;
+    struct binding *next;
+    struct string  *ident;
+    struct type    *type;
+    struct value   *value;
+};
+
+/* A module maps names to TYPE * VALUE. */
+struct module {
+    unsigned int       ref;
+    struct module     *next;     /* Only used for the global list of modules */
+    struct transform  *autoload;
+    char              *name;
+    struct binding    *bindings;
+};
+
+struct type *make_arrow_type(struct type *dom, struct type *img);
+struct type *make_base_type(enum type_tag tag);
+/* Do not call this directly. Use unref(t, type) instead */
+void free_type(struct type *type);
+
+/* Constructors for some terms in syntax.c Constructor assumes ownership of
+ * arguments without incrementing. Caller owns returned objects.
+ */
+struct term *make_term(enum term_tag tag, struct info *info);
+void free_term(struct term *term);
+struct term *make_param(char *name, struct type *type, struct info *info);
+struct value *make_value(enum value_tag tag, struct info *info);
+struct value *make_unit(struct info *info);
+struct term *make_app_term(struct term *func, struct term *arg,
+                           struct info *info);
+struct term *make_app_ident(char *id, struct term *func, struct info *info);
+
+/* Make an EXN value
+ * Receive ownership of INFO
+ *
+ * FORMAT and following arguments are printed to a new string. Caller must
+ * clean those up.
+ */
+struct value *make_exn_value(struct info *info, const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 2, 3);
+
+/* Add NLINES lines (passed as const char *) to EXN, which must be a
+ * value with tag V_EXN, created by MAKE_EXN_VALUE.
+ *
+ * The strings belong to EXN * after the call.
+ */
+void exn_add_lines(struct value *exn, int nlines, ...);
+
+void exn_printf_line(struct value *exn, const char *format, ...)
+    ATTRIBUTE_FORMAT(printf, 2, 3);
+
+/* Do not call these directly, use UNREF instead */
+void free_value(struct value *v);
+void free_module(struct module *module);
+
+/* Turn a list of PARAMS (represented as terms tagged as A_FUNC with the
+ * param in PARAM) into nested A_FUNC terms
+ */
+struct term *build_func(struct term *params, struct term *exp);
+
+struct module *module_create(const char *name);
+
+#define define_native(error, module, name, argc, impl, types ...)       \
+    define_native_intl(__FILE__, __LINE__, error, module, name,         \
+                       argc, impl, ## types)
+
+ATTRIBUTE_RETURN_CHECK
+int define_native_intl(const char *fname, int line,
+                       struct error *error,
+                       struct module *module, const char *name,
+                       int argc, void *impl, ...);
+
+struct module *builtin_init(struct error *);
+
+int load_module_file(struct augeas *aug, const char *filename);
+
+/* The name of the builtin function that checks recursive lenses */
+#define LNS_CHECK_REC_NAME "lns_check_rec"
+
+int interpreter_init(struct augeas *aug);
+
+struct lens *lens_lookup(struct augeas *aug, const char *qname);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/transform.c b/src/transform.c
new file mode 100644 (file)
index 0000000..d5629b2
--- /dev/null
@@ -0,0 +1,1168 @@
+/*
+ * transform.c: support for building and running transformers
+ *
+ * Copyright (C) 2007-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <fnmatch.h>
+#include <glob.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <selinux/selinux.h>
+#include <stdbool.h>
+
+#include "internal.h"
+#include "memory.h"
+#include "augeas.h"
+#include "syntax.h"
+#include "transform.h"
+#include "errcode.h"
+
+static const int fnm_flags = FNM_PATHNAME;
+static const int glob_flags = GLOB_NOSORT;
+
+/* Extension for newly created files */
+#define EXT_AUGNEW ".augnew"
+/* Extension for backup files */
+#define EXT_AUGSAVE ".augsave"
+
+/* Loaded files are tracked underneath METATREE. When a file with name
+ * FNAME is loaded, certain entries are made under METATREE / FNAME:
+ *   path      : path where tree for FNAME is put
+ *   mtime     : time of last modification of the file as reported by stat(2)
+ *   lens/info : information about where the applied lens was loaded from
+ *   lens/id   : unique hexadecimal id of the lens
+ *   error     : indication of errors during processing FNAME, or NULL
+ *               if processing succeeded
+ *   error/pos : position in file where error occured (for get errors)
+ *   error/path: path to tree node where error occurred (for put errors)
+ *   error/message : human-readable error message
+ */
+static const char *const s_path = "path";
+static const char *const s_lens = "lens";
+static const char *const s_info = "info";
+static const char *const s_mtime = "mtime";
+
+static const char *const s_error = "error";
+/* These are all put underneath "error" */
+static const char *const s_pos     = "pos";
+static const char *const s_message = "message";
+static const char *const s_line    = "line";
+static const char *const s_char    = "char";
+
+/*
+ * Filters
+ */
+struct filter *make_filter(struct string *glb, unsigned int include) {
+    struct filter *f;
+    make_ref(f);
+    f->glob = glb;
+    f->include = include;
+    return f;
+}
+
+void free_filter(struct filter *f) {
+    if (f == NULL)
+        return;
+    assert(f->ref == 0);
+    unref(f->next, filter);
+    unref(f->glob, string);
+    free(f);
+}
+
+static const char *pathbase(const char *path) {
+    const char *p = strrchr(path, SEP);
+    return (p == NULL) ? path : p + 1;
+}
+
+static bool is_excl(struct tree *f) {
+    return streqv(f->label, "excl") && f->value != NULL;
+}
+
+static bool is_incl(struct tree *f) {
+    return streqv(f->label, "incl") && f->value != NULL;
+}
+
+static bool is_regular_file(const char *path) {
+    int r;
+    struct stat st;
+
+    r = stat(path, &st);
+    if (r < 0)
+        return false;
+    return S_ISREG(st.st_mode);
+}
+
+static char *mtime_as_string(struct augeas *aug, const char *fname) {
+    int r;
+    struct stat st;
+    char *result = NULL;
+
+    if (fname == NULL) {
+        result = strdup("0");
+        ERR_NOMEM(result == NULL, aug);
+        goto done;
+    }
+
+    r = stat(fname, &st);
+    if (r < 0) {
+        /* If we fail to stat, silently ignore the error
+         * and report an impossible mtime */
+        result = strdup("0");
+        ERR_NOMEM(result == NULL, aug);
+    } else {
+        r = xasprintf(&result, "%ld", (long) st.st_mtime);
+        ERR_NOMEM(r < 0, aug);
+    }
+ done:
+    return result;
+ error:
+    FREE(result);
+    return NULL;
+}
+
+static bool file_current(struct augeas *aug, const char *fname,
+                         struct tree *finfo) {
+    struct tree *mtime = tree_child(finfo, s_mtime);
+    struct tree *file = NULL, *path = NULL;
+    int r;
+    struct stat st;
+    int64_t mtime_i;
+
+    if (mtime == NULL || mtime->value == NULL)
+        return false;
+
+    r = xstrtoint64(mtime->value, 10, &mtime_i);
+    if (r < 0) {
+        /* Ignore silently and err on the side of caution */
+        return false;
+    }
+
+    r = stat(fname, &st);
+    if (r < 0)
+        return false;
+
+    if (mtime_i != (int64_t) st.st_mtime)
+        return false;
+
+    path = tree_child(finfo, s_path);
+    if (path == NULL)
+        return false;
+
+    file = tree_find(aug, path->value);
+    return (file != NULL && ! file->dirty);
+}
+
+static int filter_generate(struct tree *xfm, const char *root,
+                           int *nmatches, char ***matches) {
+    glob_t globbuf;
+    int gl_flags = glob_flags;
+    int r;
+    int ret = 0;
+
+    *nmatches = 0;
+    *matches = NULL;
+    MEMZERO(&globbuf, 1);
+
+    list_for_each(f, xfm->children) {
+        char *globpat = NULL;
+        if (! is_incl(f))
+            continue;
+        pathjoin(&globpat, 2, root, f->value);
+        r = glob(globpat, gl_flags, NULL, &globbuf);
+        free(globpat);
+
+        if (r != 0 && r != GLOB_NOMATCH) {
+            ret = -1;
+            goto error;
+        }
+        gl_flags |= GLOB_APPEND;
+    }
+
+    char **pathv = NULL;
+    int pathc = globbuf.gl_pathc, pathind = 0;
+
+    if (ALLOC_N(pathv, pathc) < 0)
+        goto error;
+
+    for (int i=0; i < pathc; i++) {
+        const char *path = globbuf.gl_pathv[i];
+        bool include = true;
+
+        list_for_each(e, xfm->children) {
+            if (! is_excl(e))
+                continue;
+
+            if (strchr(e->value, SEP) == NULL)
+                path = pathbase(path);
+            if ((r = fnmatch(e->value, path, fnm_flags)) == 0) {
+                include = false;
+            }
+        }
+
+        if (include)
+            include = is_regular_file(globbuf.gl_pathv[i]);
+
+        if (include) {
+            pathv[pathind] = strdup(globbuf.gl_pathv[i]);
+            if (pathv[pathind] == NULL)
+                goto error;
+            pathind += 1;
+        }
+    }
+    pathc = pathind;
+
+    if (REALLOC_N(pathv, pathc) == -1)
+        goto error;
+
+    *matches = pathv;
+    *nmatches = pathc;
+ done:
+    globfree(&globbuf);
+    return ret;
+ error:
+    if (pathv != NULL)
+        for (int i=0; i < pathc; i++)
+            free(pathv[i]);
+    free(pathv);
+    ret = -1;
+    goto done;
+}
+
+static int filter_matches(struct tree *xfm, const char *path) {
+    int found = 0;
+    list_for_each(f, xfm->children) {
+        if (is_incl(f) && fnmatch(f->value, path, fnm_flags) == 0) {
+            found = 1;
+            break;
+        }
+    }
+    if (! found)
+        return 0;
+    list_for_each(f, xfm->children) {
+        if (is_excl(f) && (fnmatch(f->value, path, fnm_flags) == 0))
+            return 0;
+    }
+    return 1;
+}
+
+/*
+ * Transformers
+ */
+struct transform *make_transform(struct lens *lens, struct filter *filter) {
+    struct transform *xform;
+    make_ref(xform);
+    xform->lens = lens;
+    xform->filter = filter;
+    return xform;
+}
+
+void free_transform(struct transform *xform) {
+    if (xform == NULL)
+        return;
+    assert(xform->ref == 0);
+    unref(xform->lens, lens);
+    unref(xform->filter, filter);
+    free(xform);
+}
+
+static char *err_path(const char *filename) {
+    char *result = NULL;
+    if (filename == NULL)
+        pathjoin(&result, 2, AUGEAS_META_FILES, s_error);
+    else
+        pathjoin(&result, 3, AUGEAS_META_FILES, filename, s_error);
+    return result;
+}
+
+ATTRIBUTE_FORMAT(printf, 4, 5)
+static void err_set(struct augeas *aug,
+                    struct tree *err_info, const char *sub,
+                    const char *format, ...) {
+    int r;
+    va_list ap;
+    char *value = NULL;
+    struct tree *tree = NULL;
+
+    va_start(ap, format);
+    r = vasprintf(&value, format, ap);
+    va_end(ap);
+    if (r < 0)
+        value = NULL;
+    ERR_NOMEM(r < 0, aug);
+
+    tree = tree_child_cr(err_info, sub);
+    ERR_NOMEM(tree == NULL, aug);
+
+    r = tree_set_value(tree, value);
+    ERR_NOMEM(r < 0, aug);
+
+ error:
+    free(value);
+}
+
+/* Record an error in the tree. The error will show up underneath
+ * /augeas/FILENAME/error. PATH is the path to the toplevel node in the
+ * tree where the lens application happened. When STATUS is NULL, just
+ * clear any error associated with FILENAME in the tree.
+ */
+static int store_error(struct augeas *aug,
+                       const char *filename, const char *path,
+                       const char *status, int errnum,
+                       const struct lns_error *err, const char *text) {
+    struct tree *err_info = NULL, *finfo = NULL;
+    char *fip = NULL;
+    int r;
+    int result = -1;
+
+    r = pathjoin(&fip, 2, AUGEAS_META_FILES, filename);
+    ERR_NOMEM(r < 0, aug);
+
+    finfo = tree_find_cr(aug, fip);
+    ERR_BAIL(aug);
+
+    if (status != NULL) {
+        err_info = tree_child_cr(finfo, s_error);
+        ERR_NOMEM(err_info == NULL, aug);
+
+        r = tree_set_value(err_info, status);
+        ERR_NOMEM(r < 0, aug);
+
+        /* Errors from err_set are ignored on purpose. We try
+         * to report as much as we can */
+        if (err != NULL) {
+            if (err->pos >= 0) {
+                size_t line, ofs;
+                err_set(aug, err_info, s_pos, "%d", err->pos);
+                if (text != NULL) {
+                    calc_line_ofs(text, err->pos, &line, &ofs);
+                    err_set(aug, err_info, s_line, "%zd", line);
+                    err_set(aug, err_info, s_char, "%zd", ofs);
+                }
+            }
+            if (err->path != NULL) {
+                err_set(aug, err_info, s_path, "%s%s", path, err->path);
+            }
+            if (err->lens != NULL) {
+                char *fi = format_info(err->lens->info);
+                if (fi != NULL) {
+                    err_set(aug, err_info, s_lens, "%s", fi);
+                    free(fi);
+                }
+            }
+            err_set(aug, err_info, s_message, "%s", err->message);
+        } else if (errnum != 0) {
+            const char *msg = strerror(errnum);
+            err_set(aug, err_info, s_message, "%s", msg);
+        }
+    } else {
+        /* No error, nuke the error node if it exists */
+        err_info = tree_child(finfo, s_error);
+        if (err_info != NULL) {
+            tree_unlink_children(aug, err_info);
+            pathx_symtab_remove_descendants(aug->symtab, err_info);
+            tree_unlink(err_info);
+        }
+    }
+
+    tree_clean(finfo);
+    result = 0;
+ error:
+    free(fip);
+    return result;
+}
+
+/* Set up the file information in the /augeas tree.
+ *
+ * NODE must be the path to the file contents, and start with /files.
+ * LENS is the lens used to transform the file.
+ * Create entries under /augeas/NODE with some metadata about the file.
+ *
+ * Returns 0 on success, -1 on error
+ */
+static int add_file_info(struct augeas *aug, const char *node,
+                         struct lens *lens, const char *lens_name,
+                         const char *filename) {
+    struct tree *file, *tree;
+    char *tmp = NULL;
+    int r;
+    char *path = NULL;
+    int result = -1;
+
+    if (lens == NULL)
+        return -1;
+
+    r = pathjoin(&path, 2, AUGEAS_META_TREE, node);
+    ERR_NOMEM(r < 0, aug);
+
+    file = tree_find_cr(aug, path);
+    ERR_BAIL(aug);
+
+    /* Set 'path' */
+    tree = tree_child_cr(file, s_path);
+    ERR_NOMEM(tree == NULL, aug);
+    r = tree_set_value(tree, node);
+    ERR_NOMEM(r < 0, aug);
+
+    /* Set 'mtime' */
+    tmp = mtime_as_string(aug, filename);
+    ERR_BAIL(aug);
+    tree = tree_child_cr(file, s_mtime);
+    ERR_NOMEM(tree == NULL, aug);
+    tree_store_value(tree, &tmp);
+
+    /* Set 'lens/info' */
+    tmp = format_info(lens->info);
+    ERR_NOMEM(tmp == NULL, aug);
+    tree = tree_path_cr(file, 2, s_lens, s_info);
+    ERR_NOMEM(tree == NULL, aug);
+    r = tree_set_value(tree, tmp);
+    ERR_NOMEM(r < 0, aug);
+    FREE(tmp);
+
+    /* Set 'lens' */
+    tree = tree->parent;
+    r = tree_set_value(tree, lens_name);
+    ERR_NOMEM(r < 0, aug);
+
+    tree_clean(file);
+
+    result = 0;
+ error:
+    free(path);
+    free(tmp);
+    return result;
+}
+
+static char *append_newline(char *text, size_t len) {
+    /* Try to append a newline; this is a big hack to work */
+    /* around the fact that lenses generally break if the  */
+    /* file does not end with a newline. */
+    if (len == 0 || text[len-1] != '\n') {
+        if (REALLOC_N(text, len+2) == 0) {
+            text[len] = '\n';
+            text[len+1] = '\0';
+        }
+    }
+    return text;
+}
+
+/* Turn the file name FNAME, which starts with aug->root, into
+ * a path in the tree underneath /files */
+static char *file_name_path(struct augeas *aug, const char *fname) {
+    char *path = NULL;
+
+    pathjoin(&path, 2, AUGEAS_FILES_TREE, fname + strlen(aug->root) - 1);
+    return path;
+}
+
+static int load_file(struct augeas *aug, struct lens *lens,
+                     const char *lens_name, char *filename) {
+    char *text = NULL;
+    const char *err_status = NULL;
+    struct aug_file *file = NULL;
+    struct tree *tree = NULL;
+    char *path = NULL;
+    struct lns_error *err = NULL;
+    struct span *span = NULL;
+    int result = -1, r, text_len = 0;
+
+    path = file_name_path(aug, filename);
+    ERR_NOMEM(path == NULL, aug);
+
+    r = add_file_info(aug, path, lens, lens_name, filename);
+    if (r < 0)
+        goto done;
+
+    text = xread_file(filename);
+    if (text == NULL) {
+        err_status = "read_failed";
+        goto done;
+    }
+    text_len = strlen(text);
+    text = append_newline(text, text_len);
+
+    struct info *info;
+    make_ref(info);
+    make_ref(info->filename);
+    info->filename->str = strdup(filename);
+    info->error = aug->error;
+    info->flags = aug->flags;
+    info->first_line = 1;
+
+    if (aug->flags & AUG_ENABLE_SPAN) {
+        span = make_span(info);
+        ERR_NOMEM(span == NULL, info);
+    }
+
+    tree = lns_get(info, lens, text, &err);
+
+    unref(info, info);
+
+    if (err != NULL) {
+        err_status = "parse_failed";
+        goto done;
+    }
+
+    tree_replace(aug, path, tree);
+
+    /* top level node span entire file length */
+    if (span != NULL) {
+        tree->parent->span = span;
+        tree->parent->span->span_start = 0;
+        tree->parent->span->span_end = text_len;
+    }
+
+    tree = NULL;
+
+    result = 0;
+ done:
+    store_error(aug, filename + strlen(aug->root) - 1, path, err_status,
+                errno, err, text);
+ error:
+    free_lns_error(err);
+    free(path);
+    free_tree(tree);
+    free(file);
+    free(text);
+    return result;
+}
+
+/* The lens for a transform can be referred to in one of two ways:
+ * either by a fully qualified name "Module.lens" or by the special
+ * syntax "@Module"; the latter means we should take the lens from the
+ * autoload transform for Module
+ */
+static struct lens *lens_from_name(struct augeas *aug, const char *name) {
+    struct lens *result = NULL;
+
+    if (name[0] == '@') {
+        struct module *modl = NULL;
+        for (modl = aug->modules;
+             modl != NULL && !streqv(modl->name, name + 1);
+             modl = modl->next);
+        ERR_THROW(modl == NULL, aug, AUG_ENOLENS,
+                  "Could not find module %s", name + 1);
+        ERR_THROW(modl->autoload == NULL, aug, AUG_ENOLENS,
+                  "No autoloaded lens in module %s", name + 1);
+        result = modl->autoload->lens;
+    } else {
+        result = lens_lookup(aug, name);
+    }
+    ERR_THROW(result == NULL, aug, AUG_ENOLENS,
+              "Can not find lens %s", name);
+    return result;
+ error:
+    return NULL;
+}
+
+const char *xfm_lens_name(struct tree *xfm) {
+    struct tree *l = tree_child(xfm, s_lens);
+
+    if (l == NULL)
+        return "(unknown)";
+    if (l->value == NULL)
+        return "(noname)";
+    return l->value;
+}
+
+static struct lens *xfm_lens(struct augeas *aug,
+                             struct tree *xfm, const char **lens_name) {
+    struct tree *l = NULL;
+
+    for (l = xfm->children;
+         l != NULL && !streqv("lens", l->label);
+         l = l->next);
+
+    if (l == NULL || l->value == NULL)
+        return NULL;
+    *lens_name = l->value;
+
+    return lens_from_name(aug, l->value);
+}
+
+static void xfm_error(struct tree *xfm, const char *msg) {
+    char *v = strdup(msg);
+    char *l = strdup("error");
+
+    if (l == NULL || v == NULL)
+        return;
+    tree_append(xfm, l, v);
+}
+
+int transform_validate(struct augeas *aug, struct tree *xfm) {
+    struct tree *l = NULL;
+
+    for (struct tree *t = xfm->children; t != NULL; ) {
+        if (streqv(t->label, "lens"))
+            l = t;
+        if (streqv(t->label, "error")) {
+            struct tree *del = t;
+            t = del->next;
+            tree_unlink(del);
+        } else {
+            t = t->next;
+        }
+    }
+
+    if (l == NULL) {
+        xfm_error(xfm, "missing a child with label 'lens'");
+        return -1;
+    }
+    if (l->value == NULL) {
+        xfm_error(xfm, "the 'lens' node does not contain a lens name");
+        return -1;
+    }
+    lens_from_name(aug, l->value);
+    if (HAS_ERR(aug)) {
+        xfm_error(xfm, aug->error->details);
+        return -1;
+    }
+    return 0;
+}
+
+void transform_file_error(struct augeas *aug, const char *status,
+                          const char *filename, const char *format, ...) {
+    char *ep = err_path(filename);
+    struct tree *err;
+    char *msg;
+    va_list ap;
+    int r;
+
+    err = tree_find_cr(aug, ep);
+    if (err == NULL)
+        return;
+
+    tree_unlink_children(aug, err);
+    tree_set_value(err, status);
+
+    err = tree_child_cr(err, s_message);
+    if (err == NULL)
+        return;
+
+    va_start(ap, format);
+    r = vasprintf(&msg, format, ap);
+    va_end(ap);
+    if (r < 0)
+        return;
+    tree_set_value(err, msg);
+    free(msg);
+}
+
+static struct tree *file_info(struct augeas *aug, const char *fname) {
+    char *path = NULL;
+    struct tree *result = NULL;
+    int r;
+
+    r = pathjoin(&path, 2, AUGEAS_META_FILES, fname);
+    ERR_NOMEM(r < 0, aug);
+
+    result = tree_find(aug, path);
+    ERR_BAIL(aug);
+ error:
+    free(path);
+    return result;
+}
+
+int transform_load(struct augeas *aug, struct tree *xfm) {
+    int nmatches = 0;
+    char **matches;
+    const char *lens_name;
+    struct lens *lens = xfm_lens(aug, xfm, &lens_name);
+    int r;
+
+    if (lens == NULL) {
+        // FIXME: Record an error and return 0
+        return -1;
+    }
+    r = filter_generate(xfm, aug->root, &nmatches, &matches);
+    if (r == -1)
+        return -1;
+    for (int i=0; i < nmatches; i++) {
+        const char *filename = matches[i] + strlen(aug->root) - 1;
+        struct tree *finfo = file_info(aug, filename);
+        if (finfo != NULL && !finfo->dirty &&
+            tree_child(finfo, s_lens) != NULL) {
+            const char *s = xfm_lens_name(finfo);
+            char *fpath = file_name_path(aug, matches[i]);
+            transform_file_error(aug, "mxfm_load", filename,
+              "Lenses %s and %s could be used to load this file",
+                                 s, lens_name);
+            aug_rm(aug, fpath);
+            free(fpath);
+        } else if (!file_current(aug, matches[i], finfo)) {
+            load_file(aug, lens, lens_name, matches[i]);
+        }
+        if (finfo != NULL)
+            finfo->dirty = 0;
+        FREE(matches[i]);
+    }
+    lens_release(lens);
+    free(matches);
+    return 0;
+}
+
+int transform_applies(struct tree *xfm, const char *path) {
+    if (STRNEQLEN(path, AUGEAS_FILES_TREE, strlen(AUGEAS_FILES_TREE))
+        || path[strlen(AUGEAS_FILES_TREE)] != SEP)
+        return 0;
+    return filter_matches(xfm, path + strlen(AUGEAS_FILES_TREE));
+}
+
+static int transfer_file_attrs(const char *from, const char *to,
+                               const char **err_status) {
+    struct stat st;
+    int ret = 0;
+    int selinux_enabled = (is_selinux_enabled() > 0);
+    security_context_t con = NULL;
+
+    ret = lstat(from, &st);
+    if (ret < 0) {
+        *err_status = "replace_stat";
+        return -1;
+    }
+    if (selinux_enabled) {
+        if (lgetfilecon(from, &con) < 0 && errno != ENOTSUP) {
+            *err_status = "replace_getfilecon";
+            return -1;
+        }
+    }
+
+    if (lchown(to, st.st_uid, st.st_gid) < 0) {
+        *err_status = "replace_chown";
+        return -1;
+    }
+    if (chmod(to, st.st_mode) < 0) {
+        *err_status = "replace_chmod";
+        return -1;
+    }
+    if (selinux_enabled && con != NULL) {
+        if (lsetfilecon(to, con) < 0 && errno != ENOTSUP) {
+            *err_status = "replace_setfilecon";
+            return -1;
+        }
+        freecon(con);
+    }
+    return 0;
+}
+
+/* Try to rename FROM to TO. If that fails with an error other than EXDEV
+ * or EBUSY, return -1. If the failure is EXDEV or EBUSY (which we assume
+ * means that FROM or TO is a bindmounted file), and COPY_IF_RENAME_FAILS
+ * is true, copy the contents of FROM into TO and delete FROM.
+ *
+ * Return 0 on success (either rename succeeded or we copied the contents
+ * over successfully), -1 on failure.
+ */
+static int clone_file(const char *from, const char *to,
+                      const char **err_status, int copy_if_rename_fails) {
+    FILE *from_fp = NULL, *to_fp = NULL;
+    char buf[BUFSIZ];
+    size_t len;
+    int result = -1;
+
+    if (rename(from, to) == 0)
+        return 0;
+    if ((errno != EXDEV && errno != EBUSY) || !copy_if_rename_fails) {
+        *err_status = "rename";
+        return -1;
+    }
+
+    /* rename not possible, copy file contents */
+    from_fp = fopen(from, "r");
+    if (!(from_fp = fopen(from, "r"))) {
+        *err_status = "clone_open_src";
+        goto done;
+    }
+
+    if (!(to_fp = fopen(to, "w"))) {
+        *err_status = "clone_open_dst";
+        goto done;
+    }
+
+    if (transfer_file_attrs(from, to, err_status) < 0)
+        goto done;
+
+    while ((len = fread(buf, 1, BUFSIZ, from_fp)) > 0) {
+        if (fwrite(buf, 1, len, to_fp) != len) {
+            *err_status = "clone_write";
+            goto done;
+        }
+    }
+    if (ferror(from_fp)) {
+        *err_status = "clone_read";
+        goto done;
+    }
+    if (fflush(to_fp) != 0) {
+        *err_status = "clone_flush";
+        goto done;
+    }
+    if (fsync(fileno(to_fp)) < 0) {
+        *err_status = "clone_sync";
+        goto done;
+    }
+    result = 0;
+ done:
+    fclose(from_fp);
+    if (fclose(to_fp) != 0)
+        result = -1;
+    if (result != 0)
+        unlink(to);
+    if (result == 0)
+        unlink(from);
+    return result;
+}
+
+static char *strappend(const char *s1, const char *s2) {
+    size_t len = strlen(s1) + strlen(s2);
+    char *result = NULL, *p;
+
+    if (ALLOC_N(result, len + 1) < 0)
+        return NULL;
+
+    p = stpcpy(result, s1);
+    stpcpy(p, s2);
+    return result;
+}
+
+static int file_saved_event(struct augeas *aug, const char *path) {
+    const char *saved = strrchr(AUGEAS_EVENTS_SAVED, SEP) + 1;
+    struct pathx *px;
+    struct tree *dummy;
+    int r;
+
+    px = pathx_aug_parse(aug, aug->origin, AUGEAS_EVENTS_SAVED "[last()]",
+                         true);
+    ERR_BAIL(aug);
+
+    if (pathx_find_one(px, &dummy) == 1) {
+        r = tree_insert(px, saved, 0);
+        if (r < 0)
+            goto error;
+    }
+
+    if (! tree_set(px, path))
+        goto error;
+
+    free_pathx(px);
+    return 0;
+ error:
+    free_pathx(px);
+    return -1;
+}
+
+/*
+ * Save TREE->CHILDREN into the file PATH using the lens from XFORM. Errors
+ * are noted in the /augeas/files hierarchy in AUG->ORIGIN under
+ * PATH/error.
+ *
+ * Writing the file happens by first writing into PATH.augnew, transferring
+ * all file attributes of PATH to PATH.augnew, and then renaming
+ * PATH.augnew to PATH. If the rename fails, and the entry
+ * AUGEAS_COPY_IF_FAILURE exists in AUG->ORIGIN, PATH is overwritten by
+ * copying file contents
+ *
+ * Return 0 on success, -1 on failure.
+ */
+int transform_save(struct augeas *aug, struct tree *xfm,
+                   const char *path, struct tree *tree) {
+    FILE *fp = NULL;
+    char *augnew = NULL, *augorig = NULL, *augsave = NULL;
+    char *augorig_canon = NULL;
+    int   augorig_exists;
+    int   copy_if_rename_fails = 0;
+    char *text = NULL;
+    const char *filename = path + strlen(AUGEAS_FILES_TREE) + 1;
+    const char *err_status = NULL;
+    char *dyn_err_status = NULL;
+    struct lns_error *err = NULL;
+    const char *lens_name;
+    struct lens *lens = xfm_lens(aug, xfm, &lens_name);
+    int result = -1, r;
+
+    errno = 0;
+
+    if (lens == NULL) {
+        err_status = "lens_name";
+        goto done;
+    }
+
+    copy_if_rename_fails =
+        aug_get(aug, AUGEAS_COPY_IF_RENAME_FAILS, NULL) == 1;
+
+    if (asprintf(&augorig, "%s%s", aug->root, filename) == -1) {
+        augorig = NULL;
+        goto done;
+    }
+
+    if (access(augorig, R_OK) == 0) {
+        text = xread_file(augorig);
+    } else {
+        text = strdup("");
+    }
+
+    if (text == NULL) {
+        err_status = "put_read";
+        goto done;
+    }
+
+    text = append_newline(text, strlen(text));
+
+    augorig_canon = canonicalize_file_name(augorig);
+    augorig_exists = 1;
+    if (augorig_canon == NULL) {
+        if (errno == ENOENT) {
+            augorig_canon = augorig;
+            augorig_exists = 0;
+        } else {
+            err_status = "canon_augorig";
+            goto done;
+        }
+    }
+
+    /* Figure out where to put the .augnew file. If we need to rename it
+       later on, put it next to augorig_canon */
+    if (aug->flags & AUG_SAVE_NEWFILE) {
+        if (xasprintf(&augnew, "%s" EXT_AUGNEW, augorig) < 0) {
+            err_status = "augnew_oom";
+            goto done;
+        }
+    } else {
+        if (xasprintf(&augnew, "%s" EXT_AUGNEW, augorig_canon) < 0) {
+            err_status = "augnew_oom";
+            goto done;
+        }
+    }
+
+    // FIXME: We might have to create intermediate directories
+    // to be able to write augnew, but we have no idea what permissions
+    // etc. they should get. Just the process default ?
+    fp = fopen(augnew, "w");
+    if (fp == NULL) {
+        err_status = "open_augnew";
+        goto done;
+    }
+
+    if (augorig_exists) {
+        if (transfer_file_attrs(augorig_canon, augnew, &err_status) != 0) {
+            err_status = "xfer_attrs";
+            goto done;
+        }
+    }
+
+    if (tree != NULL)
+        lns_put(fp, lens, tree->children, text, &err);
+
+    if (ferror(fp)) {
+        err_status = "error_augnew";
+        goto done;
+    }
+
+    if (fflush(fp) != 0) {
+        err_status = "flush_augnew";
+        goto done;
+    }
+
+    if (fsync(fileno(fp)) < 0) {
+        err_status = "sync_augnew";
+        goto done;
+    }
+
+    if (fclose(fp) != 0) {
+        err_status = "close_augnew";
+        goto done;
+    }
+
+    fp = NULL;
+
+    if (err != NULL) {
+        err_status = "put_failed";
+        unlink(augnew);
+        goto done;
+    }
+
+    {
+        char *new_text = xread_file(augnew);
+        int same = 0;
+        if (new_text == NULL) {
+            err_status = "read_augnew";
+            goto done;
+        }
+        same = STREQ(text, new_text);
+        FREE(new_text);
+        if (same) {
+            result = 0;
+            unlink(augnew);
+            goto done;
+        } else if (aug->flags & AUG_SAVE_NOOP) {
+            result = 1;
+            unlink(augnew);
+            goto done;
+        }
+    }
+
+    if (!(aug->flags & AUG_SAVE_NEWFILE)) {
+        if (augorig_exists && (aug->flags & AUG_SAVE_BACKUP)) {
+            r = asprintf(&augsave, "%s%s" EXT_AUGSAVE, aug->root, filename);
+            if (r == -1) {
+                augsave = NULL;
+                goto done;
+            }
+
+            r = clone_file(augorig_canon, augsave, &err_status, 1);
+            if (r != 0) {
+                dyn_err_status = strappend(err_status, "_augsave");
+                goto done;
+            }
+        }
+        r = clone_file(augnew, augorig_canon, &err_status,
+                       copy_if_rename_fails);
+        if (r != 0) {
+            dyn_err_status = strappend(err_status, "_augnew");
+            goto done;
+        }
+    }
+    result = 1;
+
+ done:
+    r = add_file_info(aug, path, lens, lens_name, augorig);
+    if (r < 0) {
+        err_status = "file_info";
+        result = -1;
+    }
+    if (result > 0) {
+        r = file_saved_event(aug, path);
+        if (r < 0) {
+            err_status = "saved_event";
+            result = -1;
+        }
+    }
+    {
+        const char *emsg =
+            dyn_err_status == NULL ? err_status : dyn_err_status;
+        store_error(aug, filename, path, emsg, errno, err, NULL);
+    }
+    free(dyn_err_status);
+    lens_release(lens);
+    free(text);
+    free(augnew);
+    if (augorig_canon != augorig)
+        free(augorig_canon);
+    free(augorig);
+    free(augsave);
+    free_lns_error(err);
+
+    if (fp != NULL)
+        fclose(fp);
+    return result;
+}
+
+int remove_file(struct augeas *aug, struct tree *tree) {
+    char *path = NULL;
+    const char *filename = NULL;
+    const char *err_status = NULL;
+    char *dyn_err_status = NULL;
+    char *augsave = NULL, *augorig = NULL, *augorig_canon = NULL;
+    int r;
+
+    path = path_of_tree(tree);
+    if (path == NULL) {
+        err_status = "path_of_tree";
+        goto error;
+    }
+    filename = path + strlen(AUGEAS_META_FILES);
+
+    if ((augorig = strappend(aug->root, filename + 1)) == NULL) {
+        err_status = "root_file";
+        goto error;
+    }
+
+    augorig_canon = canonicalize_file_name(augorig);
+    if (augorig_canon == NULL) {
+        if (errno == ENOENT) {
+            goto done;
+        } else {
+            err_status = "canon_augorig";
+            goto error;
+        }
+    }
+
+    r = file_saved_event(aug, path + strlen(AUGEAS_META_TREE));
+    if (r < 0) {
+        err_status = "saved_event";
+        goto error;
+    }
+
+    if (aug->flags & AUG_SAVE_NOOP)
+        goto done;
+
+    if (aug->flags & AUG_SAVE_BACKUP) {
+        /* Move file to one with extension .augsave */
+        r = asprintf(&augsave, "%s" EXT_AUGSAVE, augorig_canon);
+        if (r == -1) {
+            augsave = NULL;
+                goto error;
+        }
+
+        r = clone_file(augorig_canon, augsave, &err_status, 1);
+        if (r != 0) {
+            dyn_err_status = strappend(err_status, "_augsave");
+            goto error;
+        }
+    } else {
+        /* Unlink file */
+        r = unlink(augorig_canon);
+        if (r < 0) {
+            err_status = "unlink_orig";
+            goto error;
+        }
+    }
+    tree_unlink(tree);
+ done:
+    free(path);
+    free(augorig);
+    free(augorig_canon);
+    free(augsave);
+    return 0;
+ error:
+    {
+        const char *emsg =
+            dyn_err_status == NULL ? err_status : dyn_err_status;
+        store_error(aug, filename, path, emsg, errno, NULL, NULL);
+    }
+    free(path);
+    free(augorig);
+    free(augorig_canon);
+    free(augsave);
+    free(dyn_err_status);
+    return -1;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/transform.h b/src/transform.h
new file mode 100644 (file)
index 0000000..c8b2788
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009-2010 David Lutterkort
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#ifndef TRANSFORM_H_
+#define TRANSFORM_H_
+
+/*
+ * Transformers for going from file globs to path names in the tree
+ * functions are in transform.c
+ */
+
+/* Filters for globbing files */
+struct filter {
+    unsigned int   ref;
+    struct filter *next;
+    struct string *glob;
+    unsigned int   include : 1;
+};
+
+struct filter *make_filter(struct string *glb, unsigned int include);
+void free_filter(struct filter *filter);
+
+/* Transformers that actually run lenses on contents of files */
+struct transform {
+    unsigned int      ref;
+    struct lens      *lens;
+    struct filter    *filter;
+};
+
+struct transform *make_transform(struct lens *lens, struct filter *filter);
+void free_transform(struct transform *xform);
+
+/*
+ * When we pass a tree for a transform, the tree must have exactly one
+ * child with label "lens" whose value is the qualified name of the lens to
+ * use, and any number of children labelled "incl" or "excl" whose values
+ * are glob patterns used to filter which files to transform.
+ */
+
+/* Verify that the tree XFM represents a valid transform. If it does not,
+ * add an 'error' child to it.
+ *
+ * Return 0 if XFM is a valid transform, -1 otherwise.
+ */
+int transform_validate(struct augeas *aug, struct tree *xfm);
+
+/* Load all files matching the TRANSFORM's filter into the tree in AUG by
+ * applying the TRANSFORM's lens to their contents and putting the
+ * resulting tree under "/files" + filename. Also stores some information
+ * about filename underneath "/augeas/files" + filename
+ */
+int transform_load(struct augeas *aug, struct tree *xfm);
+
+/* Return 1 if TRANSFORM applies to PATH, 0 otherwise. The TRANSFORM
+ * applies to PATH if (1) PATH starts with "/files/" and (2) the rest of
+ * PATH matches the transform's filter
+*/
+int transform_applies(struct tree *xfm, const char *path);
+
+/* Save TREE into the file corresponding to PATH. It is assumed that the
+ * TRANSFORM applies to that PATH
+ */
+int transform_save(struct augeas *aug, struct tree *xfm,
+                   const char *path, struct tree *tree);
+
+/* Remove the file for TREE, either by moving it to a .augsave file or by
+ * unlinking it, depending on aug->flags. TREE must be the node underneath
+ * /augeas/files corresponding to the file to be removed.
+ *
+ * Return 0 on success, -1 on failure
+ */
+int remove_file(struct augeas *aug, struct tree *tree);
+
+/* Return a printable name for the transform XFM. Never returns NULL. */
+const char *xfm_lens_name(struct tree *xfm);
+
+/* Store a file-specific transformation error in /augeas/files/PATH/error */
+ATTRIBUTE_FORMAT(printf, 4, 5)
+void transform_file_error(struct augeas *aug, const char *status,
+                          const char *filename, const char *format, ...);
+#endif
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/src/try b/src/try
new file mode 100755 (executable)
index 0000000..12ffb62
--- /dev/null
+++ b/src/try
@@ -0,0 +1,42 @@
+#! /bin/bash
+
+topdir=$(cd $(dirname $0)/.. && pwd)
+export AUGEAS_LENS_LIB=${topdir}/lenses
+export AUGEAS_ROOT=${topdir}/build/try
+
+AUGCMDS=${topdir}/build/augcmds.txt
+GDBCMDS=${topdir}/build/gdbcmds.txt
+
+rm -rf $AUGEAS_ROOT
+cp -pr ${topdir}/tests/root $AUGEAS_ROOT
+find $AUGEAS_ROOT -name \*.augnew\* | xargs -r rm
+
+if [[ ! -f $AUGCMDS ]] ; then
+    cat > $AUGCMDS <<EOF
+match /augeas/version
+EOF
+fi
+
+cat > $GDBCMDS <<EOF
+set annotate 3
+run --nostdinc -I $AUGEAS_LENS_LIB -r $AUGEAS_ROOT < $AUGCMDS
+EOF
+
+cd $topdir/src
+if [[ "x$1" == "xgdb" ]] ; then
+    libtool --mode=execute gdb -x $GDBCMDS ./augtool
+elif [[ "x$1" == "xstrace" ]] ; then
+    libtool --mode=execute /usr/bin/strace ./augtool --nostdinc < $AUGCMDS
+elif [[ "x$1" == "xvalgrind" ]] ; then
+    libtool --mode=execute valgrind --leak-check=full ./augtool --nostdinc < $AUGCMDS
+elif [[ "x$1" == "xcli" ]] ; then
+    shift
+    ./augtool --nostdinc "$@"
+else
+    ./augtool --nostdinc "$@" < $AUGCMDS
+    echo
+    for f in $(find $AUGEAS_ROOT -name \*.augnew); do
+        echo "File $f"
+        diff -u ${f%.augnew} $f
+    done
+fi
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..e6ebb4b
--- /dev/null
@@ -0,0 +1,174 @@
+GNULIB= ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
+
+AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS) $(GNULIB_CFLAGS) \
+       -I $(top_builddir)/src
+
+valgrind: fatest
+       libtool --mode=execute valgrind --quiet --leak-check=full ./fatest
+
+lens_tests =                   \
+  lens-sudoers.sh              \
+  lens-access.sh               \
+  lens-aliases.sh              \
+  lens-approx.sh               \
+  lens-aptpreferences.sh       \
+  lens-aptsource.sh            \
+  lens-bbhosts.sh              \
+  lens-cgconfig.sh             \
+  lens-cgrules.sh              \
+  lens-cobblersettings.sh      \
+  lens-cobblermodules.sh       \
+  lens-cron.sh                 \
+  lens-crypttab.sh             \
+  lens-darkice.sh              \
+  lens-debctrl.sh              \
+  lens-device_map.sh    \
+  lens-dhclient.sh             \
+  lens-dhcpd.sh                \
+  lens-dnsmasq.sh              \
+  lens-dpkg.sh                 \
+  lens-dput.sh                 \
+  lens-ethers.sh               \
+  lens-exports.sh              \
+  lens-fstab.sh                        \
+  lens-gdm.sh                  \
+  lens-group.sh                        \
+  lens-json.sh          \
+  lens-hosts.sh                        \
+  lens-httpd.sh         \
+  lens-inetd.sh         \
+  lens-inifile.sh              \
+  lens-inittab.sh              \
+  lens-interfaces.sh           \
+  lens-iptables.sh             \
+  lens-keepalived.sh   \
+  lens-krb5.sh                 \
+  lens-ldap.sh                 \
+  lens-limits.sh               \
+  lens-login_defs.sh   \
+  lens-logrotate.sh            \
+  lens-lokkit.sh               \
+  lens-mke2fs.sh               \
+  lens-modprobe.sh             \
+  lens-modules_conf.sh \
+  lens-monit.sh                        \
+  lens-multipath.sh     \
+  lens-mysql.sh                        \
+  lens-nagioscfg.sh     \
+  lens-nagiosobjects.sh     \
+  lens-ntp.sh                  \
+  lens-nrpe.sh          \
+  lens-nsswitch.sh             \
+  lens-odbc.sh          \
+  lens-openvpn.sh              \
+  lens-pam.sh                  \
+  lens-passwd.sh               \
+  lens-pbuilder.sh             \
+  lens-pg_hba.sh               \
+  lens-php.sh                  \
+  lens-phpvars.sh              \
+  lens-postfix_access.sh \
+  lens-postfix_main.sh         \
+  lens-postfix_master.sh       \
+  lens-puppet.sh               \
+  lens-puppetfileserver.sh             \
+  lens-resolv.sh               \
+  lens-rsyncd.sh               \
+  lens-rx.sh                   \
+  lens-samba.sh                        \
+  lens-securetty.sh     \
+  lens-services.sh             \
+  lens-shells.sh               \
+  lens-shellvars.sh            \
+  lens-shellvars_list.sh       \
+  lens-slapd.sh                        \
+  lens-solaris_system.sh               \
+  lens-soma.sh                 \
+  lens-spacevars.sh            \
+  lens-squid.sh                        \
+  lens-sshd.sh                 \
+  lens-sysconfig.sh            \
+  lens-syslog.sh               \
+  lens-sysctl.sh               \
+  lens-vsftpd.sh               \
+  lens-webmin.sh               \
+  lens-wine.sh                 \
+  lens-xinetd.sh               \
+  lens-xml.sh                  \
+  lens-xorg.sh                 \
+  lens-grub.sh                 \
+  lens-yum.sh
+
+ME = tests/Makefile.am
+
+# Ensure that the above list stays up to date:
+# Construct two lists: list of lens-*.sh from lens_tests = ... above,
+# and the list of ../lenses/tests/test_*.aug names.
+# If they're not the same, print the new or removed names and fail.
+check: check-lens-tests
+.PHONY: check-lens-tests
+_v = lens_tests
+check-lens-tests:
+       @u=$$({ sed -n '/^$(_v) =[       ]*\\$$/,/[^\]$$/p'             \
+               $(srcdir)/Makefile.am                                   \
+           | sed 's/^  *//;/^\$$.*/d;/^$(_v) =/d'                      \
+           | sed 's,\.sh.*\\,.sh,';                                    \
+         ls -1 $(srcdir)/../lenses/tests/test_*.aug                    \
+           | sed 's,.*/test_\([^./]*\)\.aug$$,lens-\1.sh,';            \
+       } | LC_ALL=C sort | uniq -u);                                   \
+       test "x$$u" = x && :                                            \
+         || { printf '%s\n' "$$u" >&2;                                 \
+              echo '$(ME): new test(s)?  update lens_tests' >&2; exit 1; }
+
+DISTCLEANFILES = $(lens_tests)
+$(lens_tests): lens-test-1
+       $(LN_S) $< $@
+
+check_SCRIPTS = \
+  test-interpreter.sh \
+  $(lens_tests) \
+  test-get.sh test-augtool.sh \
+  test-put-symlink.sh test-save-empty.sh test-mv.sh \
+  test-bug-1.sh test-idempotent.sh test-preserve.sh \
+  test-events-saved.sh test-save-mode.sh test-unlink-error.sh \
+  test-augtool-empty-line.sh test-augtool-modify-root.sh
+
+EXTRA_DIST = \
+  test-augtool root lens-test-1 \
+  $(check_SCRIPTS) $(wildcard modules/*.aug) xpath.tests
+
+noinst_SCRIPTS = $(check_SCRIPTS)
+
+check_PROGRAMS = fatest test-xpath test-load test-save test-api
+
+TESTS_ENVIRONMENT = \
+  PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
+  abs_top_builddir='$(abs_top_builddir)' \
+  abs_top_srcdir='$(abs_top_srcdir)' \
+  LANG=en_US
+
+TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
+
+INCLUDES = -I$(top_srcdir)/src
+
+fatest_SOURCES = fatest.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+fatest_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+test_xpath_SOURCES = test-xpath.c $(top_srcdir)/src/memory.c
+test_xpath_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+test_load_SOURCES = test-load.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_load_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+test_save_SOURCES = test-save.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_save_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+test_api_SOURCES = test-api.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_api_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./fatest
+
+include $(top_srcdir)/Makefile.inc
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644 (file)
index 0000000..ad8c18c
--- /dev/null
@@ -0,0 +1,1935 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# -*- Makefile-automake -*-
+#
+# Support for running programs with failmalloc preloaded. Include in other
+# automake files and make sure the following variables are set:
+#
+# FAILMALLOC_START - number of first FAILMALLOC_INTERVAL
+# FAILMALLOC_REP   - how often to repeat with increasing FAILMALLOC_INTERVAL
+# FAILMALLOC_PROG  - the program to run with linfailmalloc preloaded
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+check_PROGRAMS = fatest$(EXEEXT) test-xpath$(EXEEXT) \
+       test-load$(EXEEXT) test-save$(EXEEXT) test-api$(EXEEXT)
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(top_srcdir)/Makefile.inc
+subdir = tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/00gnulib.m4 \
+       $(top_srcdir)/gnulib/m4/alloca.m4 \
+       $(top_srcdir)/gnulib/m4/argz.m4 \
+       $(top_srcdir)/gnulib/m4/btowc.m4 \
+       $(top_srcdir)/gnulib/m4/canonicalize.m4 \
+       $(top_srcdir)/gnulib/m4/codeset.m4 \
+       $(top_srcdir)/gnulib/m4/configmake.m4 \
+       $(top_srcdir)/gnulib/m4/ctype.m4 \
+       $(top_srcdir)/gnulib/m4/double-slash-root.m4 \
+       $(top_srcdir)/gnulib/m4/dup2.m4 \
+       $(top_srcdir)/gnulib/m4/eealloc.m4 \
+       $(top_srcdir)/gnulib/m4/environ.m4 \
+       $(top_srcdir)/gnulib/m4/errno_h.m4 \
+       $(top_srcdir)/gnulib/m4/extensions.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl-o.m4 \
+       $(top_srcdir)/gnulib/m4/fcntl_h.m4 \
+       $(top_srcdir)/gnulib/m4/float_h.m4 \
+       $(top_srcdir)/gnulib/m4/fnmatch.m4 \
+       $(top_srcdir)/gnulib/m4/getdelim.m4 \
+       $(top_srcdir)/gnulib/m4/getline.m4 \
+       $(top_srcdir)/gnulib/m4/getopt.m4 \
+       $(top_srcdir)/gnulib/m4/getpagesize.m4 \
+       $(top_srcdir)/gnulib/m4/glibc21.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-common.m4 \
+       $(top_srcdir)/gnulib/m4/gnulib-comp.m4 \
+       $(top_srcdir)/gnulib/m4/include_next.m4 \
+       $(top_srcdir)/gnulib/m4/intlmacosx.m4 \
+       $(top_srcdir)/gnulib/m4/intmax_t.m4 \
+       $(top_srcdir)/gnulib/m4/inttypes_h.m4 \
+       $(top_srcdir)/gnulib/m4/isblank.m4 \
+       $(top_srcdir)/gnulib/m4/langinfo_h.m4 \
+       $(top_srcdir)/gnulib/m4/lcmessage.m4 \
+       $(top_srcdir)/gnulib/m4/lib-ld.m4 \
+       $(top_srcdir)/gnulib/m4/lib-link.m4 \
+       $(top_srcdir)/gnulib/m4/lib-prefix.m4 \
+       $(top_srcdir)/gnulib/m4/libtool.m4 \
+       $(top_srcdir)/gnulib/m4/localcharset.m4 \
+       $(top_srcdir)/gnulib/m4/locale-fr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-ja.m4 \
+       $(top_srcdir)/gnulib/m4/locale-tr.m4 \
+       $(top_srcdir)/gnulib/m4/locale-zh.m4 \
+       $(top_srcdir)/gnulib/m4/locale_h.m4 \
+       $(top_srcdir)/gnulib/m4/localename.m4 \
+       $(top_srcdir)/gnulib/m4/lock.m4 \
+       $(top_srcdir)/gnulib/m4/longlong.m4 \
+       $(top_srcdir)/gnulib/m4/lstat.m4 \
+       $(top_srcdir)/gnulib/m4/ltoptions.m4 \
+       $(top_srcdir)/gnulib/m4/ltsugar.m4 \
+       $(top_srcdir)/gnulib/m4/ltversion.m4 \
+       $(top_srcdir)/gnulib/m4/lt~obsolete.m4 \
+       $(top_srcdir)/gnulib/m4/malloc.m4 \
+       $(top_srcdir)/gnulib/m4/malloca.m4 \
+       $(top_srcdir)/gnulib/m4/mbrtowc.m4 \
+       $(top_srcdir)/gnulib/m4/mbsinit.m4 \
+       $(top_srcdir)/gnulib/m4/mbsrtowcs.m4 \
+       $(top_srcdir)/gnulib/m4/mbstate_t.m4 \
+       $(top_srcdir)/gnulib/m4/mbtowc.m4 \
+       $(top_srcdir)/gnulib/m4/memchr.m4 \
+       $(top_srcdir)/gnulib/m4/mempcpy.m4 \
+       $(top_srcdir)/gnulib/m4/mmap-anon.m4 \
+       $(top_srcdir)/gnulib/m4/mode_t.m4 \
+       $(top_srcdir)/gnulib/m4/multiarch.m4 \
+       $(top_srcdir)/gnulib/m4/nl_langinfo.m4 \
+       $(top_srcdir)/gnulib/m4/onceonly.m4 \
+       $(top_srcdir)/gnulib/m4/open.m4 \
+       $(top_srcdir)/gnulib/m4/pathmax.m4 \
+       $(top_srcdir)/gnulib/m4/printf.m4 \
+       $(top_srcdir)/gnulib/m4/putenv.m4 \
+       $(top_srcdir)/gnulib/m4/readlink.m4 \
+       $(top_srcdir)/gnulib/m4/realloc.m4 \
+       $(top_srcdir)/gnulib/m4/regex.m4 \
+       $(top_srcdir)/gnulib/m4/safe-alloc.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-context-h.m4 \
+       $(top_srcdir)/gnulib/m4/selinux-selinux-h.m4 \
+       $(top_srcdir)/gnulib/m4/setenv.m4 \
+       $(top_srcdir)/gnulib/m4/setlocale.m4 \
+       $(top_srcdir)/gnulib/m4/size_max.m4 \
+       $(top_srcdir)/gnulib/m4/ssize_t.m4 \
+       $(top_srcdir)/gnulib/m4/stat.m4 \
+       $(top_srcdir)/gnulib/m4/stdbool.m4 \
+       $(top_srcdir)/gnulib/m4/stddef_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdint.m4 \
+       $(top_srcdir)/gnulib/m4/stdint_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdio_h.m4 \
+       $(top_srcdir)/gnulib/m4/stdlib_h.m4 \
+       $(top_srcdir)/gnulib/m4/stpcpy.m4 \
+       $(top_srcdir)/gnulib/m4/stpncpy.m4 \
+       $(top_srcdir)/gnulib/m4/string_h.m4 \
+       $(top_srcdir)/gnulib/m4/strndup.m4 \
+       $(top_srcdir)/gnulib/m4/strnlen.m4 \
+       $(top_srcdir)/gnulib/m4/strstr.m4 \
+       $(top_srcdir)/gnulib/m4/symlink.m4 \
+       $(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
+       $(top_srcdir)/gnulib/m4/sys_wait_h.m4 \
+       $(top_srcdir)/gnulib/m4/thread.m4 \
+       $(top_srcdir)/gnulib/m4/threadlib.m4 \
+       $(top_srcdir)/gnulib/m4/time_h.m4 \
+       $(top_srcdir)/gnulib/m4/unistd_h.m4 \
+       $(top_srcdir)/gnulib/m4/vasnprintf.m4 \
+       $(top_srcdir)/gnulib/m4/vasprintf.m4 \
+       $(top_srcdir)/gnulib/m4/warn-on-use.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_h.m4 \
+       $(top_srcdir)/gnulib/m4/wchar_t.m4 \
+       $(top_srcdir)/gnulib/m4/wcrtomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctob.m4 \
+       $(top_srcdir)/gnulib/m4/wctomb.m4 \
+       $(top_srcdir)/gnulib/m4/wctype_h.m4 \
+       $(top_srcdir)/gnulib/m4/wint_t.m4 \
+       $(top_srcdir)/gnulib/m4/xsize.m4 \
+       $(top_srcdir)/gnulib/m4/yield.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am_fatest_OBJECTS = fatest.$(OBJEXT) cutest.$(OBJEXT) memory.$(OBJEXT)
+fatest_OBJECTS = $(am_fatest_OBJECTS)
+fatest_DEPENDENCIES = $(top_builddir)/src/libaugeas.la $(GNULIB)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am_test_api_OBJECTS = test-api.$(OBJEXT) cutest.$(OBJEXT) \
+       memory.$(OBJEXT)
+test_api_OBJECTS = $(am_test_api_OBJECTS)
+test_api_DEPENDENCIES = $(top_builddir)/src/libaugeas.la $(GNULIB)
+am_test_load_OBJECTS = test-load.$(OBJEXT) cutest.$(OBJEXT) \
+       memory.$(OBJEXT)
+test_load_OBJECTS = $(am_test_load_OBJECTS)
+test_load_DEPENDENCIES = $(top_builddir)/src/libaugeas.la $(GNULIB)
+am_test_save_OBJECTS = test-save.$(OBJEXT) cutest.$(OBJEXT) \
+       memory.$(OBJEXT)
+test_save_OBJECTS = $(am_test_save_OBJECTS)
+test_save_DEPENDENCIES = $(top_builddir)/src/libaugeas.la $(GNULIB)
+am_test_xpath_OBJECTS = test-xpath.$(OBJEXT) memory.$(OBJEXT)
+test_xpath_OBJECTS = $(am_test_xpath_OBJECTS)
+test_xpath_DEPENDENCIES = $(top_builddir)/src/libaugeas.la $(GNULIB)
+SCRIPTS = $(noinst_SCRIPTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build/aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(fatest_SOURCES) $(test_api_SOURCES) $(test_load_SOURCES) \
+       $(test_save_SOURCES) $(test_xpath_SOURCES)
+DIST_SOURCES = $(fatest_SOURCES) $(test_api_SOURCES) \
+       $(test_load_SOURCES) $(test_save_SOURCES) \
+       $(test_xpath_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+# If stdout is a non-dumb tty, use colors.  If test -t is not supported,
+# then this fails; a conservative approach.  Of course do not redirect
+# stdout here, just stderr.
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=; \
+test "X$(AM_COLOR_TESTS)" != Xno \
+&& test "X$$TERM" != Xdumb \
+&& { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \
+&& { \
+  red='\e[0;31m'; \
+  grn='\e[0;32m'; \
+  lgn='\e[1;32m'; \
+  blu='\e[1;34m'; \
+  std='\e[m'; \
+}
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+# Restructured Text title and section.
+am__rst_title = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
+am__rst_section = sed 'p;s/./=/g;p;g'
+# Put stdin (possibly several lines separated by ".  ") in a box.
+am__text_box = $(AWK) '{                               \
+  n = split($$0, lines, "\\.  "); max = 0;             \
+  for (i = 1; i <= n; ++i)                             \
+    if (max < length(lines[i]))                                \
+      max = length(lines[i]);                          \
+  for (i = 0; i < max; ++i) line = line "=";           \
+  print line;                                          \
+  for (i = 1; i <= n; ++i) if (lines[i]) print lines[i];\
+  print line;                                          \
+}'
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL).  This contradicts POSIX.  Work around the problem
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# To be inserted before the command running the test.  Creates the
+# directory for the log if needed.  Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log, and passes
+# TESTS_ENVIRONMENT.  Save and restore TERM around use of
+# TESTS_ENVIRONMENT, in case that unsets it.
+am__check_pre = \
+$(am__sh_e_setup);                                     \
+$(am__vpath_adj_setup) $(am__vpath_adj)                        \
+srcdir=$(srcdir); export srcdir;                       \
+rm -f $@-t;                                            \
+trap 'st=$$?; rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st' \
+  1 2 13 15;                                           \
+am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;           \
+test "x$$am__odir" = x. || $(MKDIR_P) "$$am__odir" || exit $$?;        \
+if test -f "./$$f"; then dir=./;                       \
+elif test -f "$$f"; then dir=;                         \
+else dir="$(srcdir)/"; fi;                             \
+tst=$$dir$$f; log='$@'; __SAVED_TERM=$$TERM;           \
+$(TESTS_ENVIRONMENT)
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check check-html recheck recheck-html
+TEST_SUITE_LOG = test-suite.log
+TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+       $(TEST_LOG_FLAGS)
+TEST_LOGS_TMP = $(TEST_LOGS:.log=.log-t)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+pkglibexecdir = @pkglibexecdir@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALLOCA_H = @ALLOCA_H@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
+AR = @AR@
+ARGZ_H = @ARGZ_H@
+AUGEAS_CFLAGS = @AUGEAS_CFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
+ENOLINK_VALUE = @ENOLINK_VALUE@
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
+ERRNO_H = @ERRNO_H@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FLOAT_H = @FLOAT_H@
+FNMATCH_H = @FNMATCH_H@
+GETOPT_H = @GETOPT_H@
+GLIBC21 = @GLIBC21@
+GNULIB_ATOLL = @GNULIB_ATOLL@
+GNULIB_BTOWC = @GNULIB_BTOWC@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_CLOSE = @GNULIB_CLOSE@
+GNULIB_DPRINTF = @GNULIB_DPRINTF@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_DUP3 = @GNULIB_DUP3@
+GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@
+GNULIB_ENVIRON = @GNULIB_ENVIRON@
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
+GNULIB_FCLOSE = @GNULIB_FCLOSE@
+GNULIB_FCNTL = @GNULIB_FCNTL@
+GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FOPEN = @GNULIB_FOPEN@
+GNULIB_FPRINTF = @GNULIB_FPRINTF@
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@
+GNULIB_FPURGE = @GNULIB_FPURGE@
+GNULIB_FPUTC = @GNULIB_FPUTC@
+GNULIB_FPUTS = @GNULIB_FPUTS@
+GNULIB_FREOPEN = @GNULIB_FREOPEN@
+GNULIB_FSEEK = @GNULIB_FSEEK@
+GNULIB_FSEEKO = @GNULIB_FSEEKO@
+GNULIB_FSTATAT = @GNULIB_FSTATAT@
+GNULIB_FSYNC = @GNULIB_FSYNC@
+GNULIB_FTELL = @GNULIB_FTELL@
+GNULIB_FTELLO = @GNULIB_FTELLO@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@
+GNULIB_FWRITE = @GNULIB_FWRITE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETDELIM = @GNULIB_GETDELIM@
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
+GNULIB_GETLINE = @GNULIB_GETLINE@
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
+GNULIB_GRANTPT = @GNULIB_GRANTPT@
+GNULIB_ISBLANK = @GNULIB_ISBLANK@
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@
+GNULIB_LCHMOD = @GNULIB_LCHMOD@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LINK = @GNULIB_LINK@
+GNULIB_LINKAT = @GNULIB_LINKAT@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_LSTAT = @GNULIB_LSTAT@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBRLEN = @GNULIB_MBRLEN@
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSINIT = @GNULIB_MBSINIT@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MBTOWC = @GNULIB_MBTOWC@
+GNULIB_MEMCHR = @GNULIB_MEMCHR@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKFIFO = @GNULIB_MKFIFO@
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
+GNULIB_MKNOD = @GNULIB_MKNOD@
+GNULIB_MKNODAT = @GNULIB_MKNODAT@
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
+GNULIB_MKTIME = @GNULIB_MKTIME@
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
+GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_OPENAT = @GNULIB_OPENAT@
+GNULIB_PERROR = @GNULIB_PERROR@
+GNULIB_PIPE = @GNULIB_PIPE@
+GNULIB_PIPE2 = @GNULIB_PIPE2@
+GNULIB_POPEN = @GNULIB_POPEN@
+GNULIB_PREAD = @GNULIB_PREAD@
+GNULIB_PRINTF = @GNULIB_PRINTF@
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
+GNULIB_PTSNAME = @GNULIB_PTSNAME@
+GNULIB_PUTC = @GNULIB_PUTC@
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_PUTS = @GNULIB_PUTS@
+GNULIB_PWRITE = @GNULIB_PWRITE@
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_READLINKAT = @GNULIB_READLINKAT@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_REALPATH = @GNULIB_REALPATH@
+GNULIB_REMOVE = @GNULIB_REMOVE@
+GNULIB_RENAME = @GNULIB_RENAME@
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@
+GNULIB_RMDIR = @GNULIB_RMDIR@
+GNULIB_RPMATCH = @GNULIB_RPMATCH@
+GNULIB_SETENV = @GNULIB_SETENV@
+GNULIB_SETLOCALE = @GNULIB_SETLOCALE@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
+GNULIB_STAT = @GNULIB_STAT@
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
+GNULIB_STRNCAT = @GNULIB_STRNCAT@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRPTIME = @GNULIB_STRPTIME@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@
+GNULIB_STRSTR = @GNULIB_STRSTR@
+GNULIB_STRTOD = @GNULIB_STRTOD@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLL = @GNULIB_STRTOLL@
+GNULIB_STRTOULL = @GNULIB_STRTOULL@
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
+GNULIB_SYMLINK = @GNULIB_SYMLINK@
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
+GNULIB_TIMEGM = @GNULIB_TIMEGM@
+GNULIB_TIME_R = @GNULIB_TIME_R@
+GNULIB_TMPFILE = @GNULIB_TMPFILE@
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
+GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@
+GNULIB_UNLINK = @GNULIB_UNLINK@
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@
+GNULIB_UNSETENV = @GNULIB_UNSETENV@
+GNULIB_USLEEP = @GNULIB_USLEEP@
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@
+GNULIB_VPRINTF = @GNULIB_VPRINTF@
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
+GNULIB_WAITPID = @GNULIB_WAITPID@
+GNULIB_WCPCPY = @GNULIB_WCPCPY@
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@
+GNULIB_WCSCAT = @GNULIB_WCSCAT@
+GNULIB_WCSCHR = @GNULIB_WCSCHR@
+GNULIB_WCSCMP = @GNULIB_WCSCMP@
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@
+GNULIB_WCSCPY = @GNULIB_WCSCPY@
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@
+GNULIB_WCSDUP = @GNULIB_WCSDUP@
+GNULIB_WCSLEN = @GNULIB_WCSLEN@
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
+GNULIB_WCSSPN = @GNULIB_WCSSPN@
+GNULIB_WCSSTR = @GNULIB_WCSSTR@
+GNULIB_WCSTOK = @GNULIB_WCSTOK@
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@
+GNULIB_WCTOB = @GNULIB_WCTOB@
+GNULIB_WCTOMB = @GNULIB_WCTOMB@
+GNULIB_WCTRANS = @GNULIB_WCTRANS@
+GNULIB_WCTYPE = @GNULIB_WCTYPE@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@
+GNULIB_WMEMSET = @GNULIB_WMEMSET@
+GNULIB_WRITE = @GNULIB_WRITE@
+GNULIB__EXIT = @GNULIB__EXIT@
+GREP = @GREP@
+HAVE_ATOLL = @HAVE_ATOLL@
+HAVE_BTOWC = @HAVE_BTOWC@
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
+HAVE_CHOWN = @HAVE_CHOWN@
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DPRINTF = @HAVE_DPRINTF@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_DUP3 = @HAVE_DUP3@
+HAVE_DUPLOCALE = @HAVE_DUPLOCALE@
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
+HAVE_FACCESSAT = @HAVE_FACCESSAT@
+HAVE_FCHDIR = @HAVE_FCHDIR@
+HAVE_FCHMODAT = @HAVE_FCHMODAT@
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
+HAVE_FCNTL = @HAVE_FCNTL@
+HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FSEEKO = @HAVE_FSEEKO@
+HAVE_FSTATAT = @HAVE_FSTATAT@
+HAVE_FSYNC = @HAVE_FSYNC@
+HAVE_FTELLO = @HAVE_FTELLO@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_FUTIMENS = @HAVE_FUTIMENS@
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
+HAVE_GETGROUPS = @HAVE_GETGROUPS@
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
+HAVE_GETLOGIN = @HAVE_GETLOGIN@
+HAVE_GETOPT_H = @HAVE_GETOPT_H@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
+HAVE_GRANTPT = @HAVE_GRANTPT@
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_ISBLANK = @HAVE_ISBLANK@
+HAVE_ISWBLANK = @HAVE_ISWBLANK@
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
+HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@
+HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@
+HAVE_LANGINFO_H = @HAVE_LANGINFO_H@
+HAVE_LANGINFO_T_FMT_AMPM = @HAVE_LANGINFO_T_FMT_AMPM@
+HAVE_LANGINFO_YESEXPR = @HAVE_LANGINFO_YESEXPR@
+HAVE_LCHMOD = @HAVE_LCHMOD@
+HAVE_LCHOWN = @HAVE_LCHOWN@
+HAVE_LINK = @HAVE_LINK@
+HAVE_LINKAT = @HAVE_LINKAT@
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MBRLEN = @HAVE_MBRLEN@
+HAVE_MBRTOWC = @HAVE_MBRTOWC@
+HAVE_MBSINIT = @HAVE_MBSINIT@
+HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
+HAVE_MEMCHR = @HAVE_MEMCHR@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDIRAT = @HAVE_MKDIRAT@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_MKFIFO = @HAVE_MKFIFO@
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
+HAVE_MKNOD = @HAVE_MKNOD@
+HAVE_MKNODAT = @HAVE_MKNODAT@
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
+HAVE_MKSTEMP = @HAVE_MKSTEMP@
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
+HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
+HAVE_OPENAT = @HAVE_OPENAT@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_PIPE = @HAVE_PIPE@
+HAVE_PIPE2 = @HAVE_PIPE2@
+HAVE_PREAD = @HAVE_PREAD@
+HAVE_PTSNAME = @HAVE_PTSNAME@
+HAVE_PWRITE = @HAVE_PWRITE@
+HAVE_RANDOM_H = @HAVE_RANDOM_H@
+HAVE_RANDOM_R = @HAVE_RANDOM_R@
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_READLINKAT = @HAVE_READLINKAT@
+HAVE_REALPATH = @HAVE_REALPATH@
+HAVE_RENAMEAT = @HAVE_RENAMEAT@
+HAVE_RPMATCH = @HAVE_RPMATCH@
+HAVE_SETENV = @HAVE_SETENV@
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
+HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRPTIME = @HAVE_STRPTIME@
+HAVE_STRSEP = @HAVE_STRSEP@
+HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLL = @HAVE_STRTOLL@
+HAVE_STRTOULL = @HAVE_STRTOULL@
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
+HAVE_SYMLINK = @HAVE_SYMLINK@
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNLINKAT = @HAVE_UNLINKAT@
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
+HAVE_USLEEP = @HAVE_USLEEP@
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
+HAVE_VASPRINTF = @HAVE_VASPRINTF@
+HAVE_VDPRINTF = @HAVE_VDPRINTF@
+HAVE_WCHAR_H = @HAVE_WCHAR_H@
+HAVE_WCHAR_T = @HAVE_WCHAR_T@
+HAVE_WCPCPY = @HAVE_WCPCPY@
+HAVE_WCPNCPY = @HAVE_WCPNCPY@
+HAVE_WCRTOMB = @HAVE_WCRTOMB@
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@
+HAVE_WCSCAT = @HAVE_WCSCAT@
+HAVE_WCSCHR = @HAVE_WCSCHR@
+HAVE_WCSCMP = @HAVE_WCSCMP@
+HAVE_WCSCOLL = @HAVE_WCSCOLL@
+HAVE_WCSCPY = @HAVE_WCSCPY@
+HAVE_WCSCSPN = @HAVE_WCSCSPN@
+HAVE_WCSDUP = @HAVE_WCSDUP@
+HAVE_WCSLEN = @HAVE_WCSLEN@
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@
+HAVE_WCSNCAT = @HAVE_WCSNCAT@
+HAVE_WCSNCMP = @HAVE_WCSNCMP@
+HAVE_WCSNCPY = @HAVE_WCSNCPY@
+HAVE_WCSNLEN = @HAVE_WCSNLEN@
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@
+HAVE_WCSPBRK = @HAVE_WCSPBRK@
+HAVE_WCSRCHR = @HAVE_WCSRCHR@
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@
+HAVE_WCSSPN = @HAVE_WCSSPN@
+HAVE_WCSSTR = @HAVE_WCSSTR@
+HAVE_WCSTOK = @HAVE_WCSTOK@
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@
+HAVE_WCSXFRM = @HAVE_WCSXFRM@
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@
+HAVE_WINT_T = @HAVE_WINT_T@
+HAVE_WMEMCHR = @HAVE_WMEMCHR@
+HAVE_WMEMCMP = @HAVE_WMEMCMP@
+HAVE_WMEMCPY = @HAVE_WMEMCPY@
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@
+HAVE_WMEMSET = @HAVE_WMEMSET@
+HAVE_XLOCALE_H = @HAVE_XLOCALE_H@
+HAVE__BOOL = @HAVE__BOOL@
+HAVE__EXIT = @HAVE__EXIT@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUGEAS_VERSION_INFO = @LIBAUGEAS_VERSION_INFO@
+LIBFAILMALLOC = @LIBFAILMALLOC@
+LIBFA_VERSION_INFO = @LIBFA_VERSION_INFO@
+LIBINTL = @LIBINTL@
+LIBMULTITHREAD = @LIBMULTITHREAD@
+LIBOBJS = @LIBOBJS@
+LIBPTH = @LIBPTH@
+LIBPTH_PREFIX = @LIBPTH_PREFIX@
+LIBS = @LIBS@
+LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@
+LIBTHREAD = @LIBTHREAD@
+LIBTOOL = @LIBTOOL@
+LIB_SELINUX = @LIB_SELINUX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
+LOCALE_FR = @LOCALE_FR@
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
+LOCALE_JA = @LOCALE_JA@
+LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@
+LOCALE_ZH_CN = @LOCALE_ZH_CN@
+LTALLOCA = @LTALLOCA@
+LTLIBINTL = @LTLIBINTL@
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBOBJS = @LTLIBOBJS@
+LTLIBPTH = @LTLIBPTH@
+LTLIBTHREAD = @LTLIBTHREAD@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+ND_FORMAT = @ND_FORMAT@
+ND_PROG = @ND_PROG@
+NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
+NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@
+NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@
+NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
+NEXT_CTYPE_H = @NEXT_CTYPE_H@
+NEXT_ERRNO_H = @NEXT_ERRNO_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_FLOAT_H = @NEXT_FLOAT_H@
+NEXT_GETOPT_H = @NEXT_GETOPT_H@
+NEXT_LANGINFO_H = @NEXT_LANGINFO_H@
+NEXT_LOCALE_H = @NEXT_LOCALE_H@
+NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@
+NEXT_STDDEF_H = @NEXT_STDDEF_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDIO_H = @NEXT_STDIO_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@
+NEXT_TIME_H = @NEXT_TIME_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFDOCS = @PDFDOCS@
+PDFLATEX = @PDFLATEX@
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+REPLACE_BTOWC = @REPLACE_BTOWC@
+REPLACE_CALLOC = @REPLACE_CALLOC@
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_CLOSE = @REPLACE_CLOSE@
+REPLACE_DPRINTF = @REPLACE_DPRINTF@
+REPLACE_DUP = @REPLACE_DUP@
+REPLACE_DUP2 = @REPLACE_DUP2@
+REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
+REPLACE_FCLOSE = @REPLACE_FCLOSE@
+REPLACE_FCNTL = @REPLACE_FCNTL@
+REPLACE_FFLUSH = @REPLACE_FFLUSH@
+REPLACE_FOPEN = @REPLACE_FOPEN@
+REPLACE_FPRINTF = @REPLACE_FPRINTF@
+REPLACE_FPURGE = @REPLACE_FPURGE@
+REPLACE_FREOPEN = @REPLACE_FREOPEN@
+REPLACE_FSEEK = @REPLACE_FSEEK@
+REPLACE_FSEEKO = @REPLACE_FSEEKO@
+REPLACE_FSTAT = @REPLACE_FSTAT@
+REPLACE_FSTATAT = @REPLACE_FSTATAT@
+REPLACE_FTELL = @REPLACE_FTELL@
+REPLACE_FTELLO = @REPLACE_FTELLO@
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_GETDELIM = @REPLACE_GETDELIM@
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
+REPLACE_GETLINE = @REPLACE_GETLINE@
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LINK = @REPLACE_LINK@
+REPLACE_LINKAT = @REPLACE_LINKAT@
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_LSTAT = @REPLACE_LSTAT@
+REPLACE_MALLOC = @REPLACE_MALLOC@
+REPLACE_MBRLEN = @REPLACE_MBRLEN@
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@
+REPLACE_MBSINIT = @REPLACE_MBSINIT@
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@
+REPLACE_MBTOWC = @REPLACE_MBTOWC@
+REPLACE_MEMCHR = @REPLACE_MEMCHR@
+REPLACE_MEMMEM = @REPLACE_MEMMEM@
+REPLACE_MKDIR = @REPLACE_MKDIR@
+REPLACE_MKFIFO = @REPLACE_MKFIFO@
+REPLACE_MKNOD = @REPLACE_MKNOD@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_MKTIME = @REPLACE_MKTIME@
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
+REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@
+REPLACE_NULL = @REPLACE_NULL@
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_OPENAT = @REPLACE_OPENAT@
+REPLACE_PERROR = @REPLACE_PERROR@
+REPLACE_POPEN = @REPLACE_POPEN@
+REPLACE_PREAD = @REPLACE_PREAD@
+REPLACE_PRINTF = @REPLACE_PRINTF@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_PWRITE = @REPLACE_PWRITE@
+REPLACE_READLINK = @REPLACE_READLINK@
+REPLACE_REALLOC = @REPLACE_REALLOC@
+REPLACE_REALPATH = @REPLACE_REALPATH@
+REPLACE_REMOVE = @REPLACE_REMOVE@
+REPLACE_RENAME = @REPLACE_RENAME@
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
+REPLACE_RMDIR = @REPLACE_RMDIR@
+REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETLOCALE = @REPLACE_SETLOCALE@
+REPLACE_SLEEP = @REPLACE_SLEEP@
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
+REPLACE_SPRINTF = @REPLACE_SPRINTF@
+REPLACE_STAT = @REPLACE_STAT@
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
+REPLACE_STPNCPY = @REPLACE_STPNCPY@
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
+REPLACE_STRDUP = @REPLACE_STRDUP@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
+REPLACE_STRNCAT = @REPLACE_STRNCAT@
+REPLACE_STRNDUP = @REPLACE_STRNDUP@
+REPLACE_STRNLEN = @REPLACE_STRNLEN@
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@
+REPLACE_STRSTR = @REPLACE_STRSTR@
+REPLACE_STRTOD = @REPLACE_STRTOD@
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_SYMLINK = @REPLACE_SYMLINK@
+REPLACE_TIMEGM = @REPLACE_TIMEGM@
+REPLACE_TMPFILE = @REPLACE_TMPFILE@
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
+REPLACE_UNLINK = @REPLACE_UNLINK@
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
+REPLACE_UNSETENV = @REPLACE_UNSETENV@
+REPLACE_USLEEP = @REPLACE_USLEEP@
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@
+REPLACE_VPRINTF = @REPLACE_VPRINTF@
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@
+REPLACE_WCTOB = @REPLACE_WCTOB@
+REPLACE_WCTOMB = @REPLACE_WCTOMB@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
+REPLACE_WRITE = @REPLACE_WRITE@
+SED = @SED@
+SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+STDBOOL_H = @STDBOOL_H@
+STDDEF_H = @STDDEF_H@
+STDINT_H = @STDINT_H@
+STRIP = @STRIP@
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
+VERSION = @VERSION@
+VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
+WINT_T_SUFFIX = @WINT_T_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+YIELD_LIB = @YIELD_LIB@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
+gltests_WITNESS = @gltests_WITNESS@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+GNULIB = ../gnulib/lib/libgnu.la
+GNULIB_CFLAGS = -I $(top_srcdir)/gnulib/lib
+AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS) $(GNULIB_CFLAGS) \
+       -I $(top_builddir)/src
+
+lens_tests = \
+  lens-sudoers.sh              \
+  lens-access.sh               \
+  lens-aliases.sh              \
+  lens-approx.sh               \
+  lens-aptpreferences.sh       \
+  lens-aptsource.sh            \
+  lens-bbhosts.sh              \
+  lens-cgconfig.sh             \
+  lens-cgrules.sh              \
+  lens-cobblersettings.sh      \
+  lens-cobblermodules.sh       \
+  lens-cron.sh                 \
+  lens-crypttab.sh             \
+  lens-darkice.sh              \
+  lens-debctrl.sh              \
+  lens-device_map.sh    \
+  lens-dhclient.sh             \
+  lens-dhcpd.sh                \
+  lens-dnsmasq.sh              \
+  lens-dpkg.sh                 \
+  lens-dput.sh                 \
+  lens-ethers.sh               \
+  lens-exports.sh              \
+  lens-fstab.sh                        \
+  lens-gdm.sh                  \
+  lens-group.sh                        \
+  lens-json.sh          \
+  lens-hosts.sh                        \
+  lens-httpd.sh         \
+  lens-inetd.sh         \
+  lens-inifile.sh              \
+  lens-inittab.sh              \
+  lens-interfaces.sh           \
+  lens-iptables.sh             \
+  lens-keepalived.sh   \
+  lens-krb5.sh                 \
+  lens-ldap.sh                 \
+  lens-limits.sh               \
+  lens-login_defs.sh   \
+  lens-logrotate.sh            \
+  lens-lokkit.sh               \
+  lens-mke2fs.sh               \
+  lens-modprobe.sh             \
+  lens-modules_conf.sh \
+  lens-monit.sh                        \
+  lens-multipath.sh     \
+  lens-mysql.sh                        \
+  lens-nagioscfg.sh     \
+  lens-nagiosobjects.sh     \
+  lens-ntp.sh                  \
+  lens-nrpe.sh          \
+  lens-nsswitch.sh             \
+  lens-odbc.sh          \
+  lens-openvpn.sh              \
+  lens-pam.sh                  \
+  lens-passwd.sh               \
+  lens-pbuilder.sh             \
+  lens-pg_hba.sh               \
+  lens-php.sh                  \
+  lens-phpvars.sh              \
+  lens-postfix_access.sh \
+  lens-postfix_main.sh         \
+  lens-postfix_master.sh       \
+  lens-puppet.sh               \
+  lens-puppetfileserver.sh             \
+  lens-resolv.sh               \
+  lens-rsyncd.sh               \
+  lens-rx.sh                   \
+  lens-samba.sh                        \
+  lens-securetty.sh     \
+  lens-services.sh             \
+  lens-shells.sh               \
+  lens-shellvars.sh            \
+  lens-shellvars_list.sh       \
+  lens-slapd.sh                        \
+  lens-solaris_system.sh               \
+  lens-soma.sh                 \
+  lens-spacevars.sh            \
+  lens-squid.sh                        \
+  lens-sshd.sh                 \
+  lens-sysconfig.sh            \
+  lens-syslog.sh               \
+  lens-sysctl.sh               \
+  lens-vsftpd.sh               \
+  lens-webmin.sh               \
+  lens-wine.sh                 \
+  lens-xinetd.sh               \
+  lens-xml.sh                  \
+  lens-xorg.sh                 \
+  lens-grub.sh                 \
+  lens-yum.sh
+
+ME = tests/Makefile.am
+_v = lens_tests
+DISTCLEANFILES = $(lens_tests)
+check_SCRIPTS = \
+  test-interpreter.sh \
+  $(lens_tests) \
+  test-get.sh test-augtool.sh \
+  test-put-symlink.sh test-save-empty.sh test-mv.sh \
+  test-bug-1.sh test-idempotent.sh test-preserve.sh \
+  test-events-saved.sh test-save-mode.sh test-unlink-error.sh \
+  test-augtool-empty-line.sh test-augtool-modify-root.sh
+
+EXTRA_DIST = \
+  test-augtool root lens-test-1 \
+  $(check_SCRIPTS) $(wildcard modules/*.aug) xpath.tests
+
+noinst_SCRIPTS = $(check_SCRIPTS)
+TESTS_ENVIRONMENT = \
+  PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
+  abs_top_builddir='$(abs_top_builddir)' \
+  abs_top_srcdir='$(abs_top_srcdir)' \
+  LANG=en_US
+
+TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
+INCLUDES = -I$(top_srcdir)/src
+fatest_SOURCES = fatest.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+fatest_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+test_xpath_SOURCES = test-xpath.c $(top_srcdir)/src/memory.c
+test_xpath_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+test_load_SOURCES = test-load.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_load_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+test_save_SOURCES = test-save.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_save_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+test_api_SOURCES = test-api.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
+test_api_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .html .lo .log .o .obj .test .test$(EXEEXT)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/Makefile.inc $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+       @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+fatest$(EXEEXT): $(fatest_OBJECTS) $(fatest_DEPENDENCIES) 
+       @rm -f fatest$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(fatest_OBJECTS) $(fatest_LDADD) $(LIBS)
+test-api$(EXEEXT): $(test_api_OBJECTS) $(test_api_DEPENDENCIES) 
+       @rm -f test-api$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_api_OBJECTS) $(test_api_LDADD) $(LIBS)
+test-load$(EXEEXT): $(test_load_OBJECTS) $(test_load_DEPENDENCIES) 
+       @rm -f test-load$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_load_OBJECTS) $(test_load_LDADD) $(LIBS)
+test-save$(EXEEXT): $(test_save_OBJECTS) $(test_save_DEPENDENCIES) 
+       @rm -f test-save$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_save_OBJECTS) $(test_save_LDADD) $(LIBS)
+test-xpath$(EXEEXT): $(test_xpath_OBJECTS) $(test_xpath_DEPENDENCIES) 
+       @rm -f test-xpath$(EXEEXT)
+       $(AM_V_CCLD)$(LINK) $(test_xpath_OBJECTS) $(test_xpath_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cutest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-api.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-load.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-save.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xpath.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+memory.o: $(top_srcdir)/src/memory.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT memory.o -MD -MP -MF $(DEPDIR)/memory.Tpo -c -o memory.o `test -f '$(top_srcdir)/src/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/src/memory.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/memory.Tpo $(DEPDIR)/memory.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(top_srcdir)/src/memory.c' object='memory.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.o `test -f '$(top_srcdir)/src/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/src/memory.c
+
+memory.obj: $(top_srcdir)/src/memory.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT memory.obj -MD -MP -MF $(DEPDIR)/memory.Tpo -c -o memory.obj `if test -f '$(top_srcdir)/src/memory.c'; then $(CYGPATH_W) '$(top_srcdir)/src/memory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/memory.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/memory.Tpo $(DEPDIR)/memory.Po
+@am__fastdepCC_FALSE@  $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$(top_srcdir)/src/memory.c' object='memory.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.obj `if test -f '$(top_srcdir)/src/memory.c'; then $(CYGPATH_W) '$(top_srcdir)/src/memory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/src/memory.c'; fi`
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+# To be appended to the command running the test.  Handle the stdout
+# and stderr redirection, and catch the exit status.
+am__check_post =                                       \
+>$@-t 2>&1;                                            \
+estatus=$$?;                                           \
+if test -n '$(DISABLE_HARD_ERRORS)'                    \
+   && test $$estatus -eq 99; then                      \
+  estatus=1;                                           \
+fi;                                                    \
+TERM=$$__SAVED_TERM; export TERM;                      \
+$(am__tty_colors);                                     \
+xfailed=PASS;                                          \
+case " $(XFAIL_TESTS) " in                             \
+  *[\ \        ]$$f[\ \        ]* | *[\ \      ]$$dir$$f[\ \   ]*) \
+    xfailed=XFAIL;;                                    \
+esac;                                                  \
+case $$estatus:$$xfailed in                            \
+    0:XFAIL) col=$$red; res=XPASS;;                    \
+    0:*)     col=$$grn; res=PASS ;;                    \
+    77:*)    col=$$blu; res=SKIP ;;                    \
+    99:*)    col=$$red; res=FAIL ;;                    \
+    *:XFAIL) col=$$lgn; res=XFAIL;;                    \
+    *:*)     col=$$red; res=FAIL ;;                    \
+esac;                                                  \
+echo "$${col}$$res$${std}: $$f";                       \
+echo "$$res: $$f (exit: $$estatus)" |                  \
+  $(am__rst_section) >$@;                              \
+cat $@-t >>$@;                                         \
+rm -f $@-t
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+       @$(am__sh_e_setup);                                             \
+       list='$(TEST_LOGS)';                                            \
+       results=`for f in $$list; do                                    \
+                  read line < $$f && echo "$$line" || echo FAIL;       \
+                done`;                                                 \
+       all=`echo "$$results" | sed '/^$$/d' | wc -l | sed -e 's/^[      ]*//'`; \
+       fail=`echo "$$results" | grep -c '^FAIL'`;                      \
+       pass=`echo "$$results" | grep -c '^PASS'`;                      \
+       skip=`echo "$$results" | grep -c '^SKIP'`;                      \
+       xfail=`echo "$$results" | grep -c '^XFAIL'`;                    \
+       xpass=`echo "$$results" | grep -c '^XPASS'`;                    \
+       failures=`expr $$fail + $$xpass`;                               \
+       all=`expr $$all - $$skip`;                                      \
+       if test "$$all" -eq 1; then tests=test; All=;                   \
+       else tests=tests; All="All "; fi;                               \
+       case fail=$$fail:xpass=$$xpass:xfail=$$xfail in                 \
+         fail=0:xpass=0:xfail=0)                                       \
+           msg="$$All$$all $$tests passed.  ";                         \
+           exit=true;;                                                 \
+         fail=0:xpass=0:xfail=*)                                       \
+           msg="$$All$$all $$tests behaved as expected";               \
+           if test "$$xfail" -eq 1; then xfailures=failure;            \
+           else xfailures=failures; fi;                                \
+           msg="$$msg ($$xfail expected $$xfailures).  ";              \
+           exit=true;;                                                 \
+         fail=*:xpass=0:xfail=*)                                       \
+           msg="$$fail of $$all $$tests failed.  ";                    \
+           exit=false;;                                                \
+         fail=*:xpass=*:xfail=*)                                       \
+           msg="$$failures of $$all $$tests did not behave as expected"; \
+           if test "$$xpass" -eq 1; then xpasses=pass;                 \
+           else xpasses=passes; fi;                                    \
+           msg="$$msg ($$xpass unexpected $$xpasses).  ";              \
+           exit=false;;                                                \
+         *)                                                            \
+           echo >&2 "incorrect case"; exit 4;;                         \
+       esac;                                                           \
+       if test "$$skip" -ne 0; then                                    \
+         if test "$$skip" -eq 1; then                                  \
+           msg="$$msg($$skip test was not run).  ";                    \
+         else                                                          \
+           msg="$$msg($$skip tests were not run).  ";                  \
+         fi;                                                           \
+       fi;                                                             \
+       {                                                               \
+         echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |       \
+           $(am__rst_title);                                           \
+         echo "$$msg";                                                 \
+         echo;                                                         \
+         echo ".. contents:: :depth: 2";                               \
+         echo;                                                         \
+         for f in $$list; do                                           \
+           read line < $$f;                                            \
+           case $$line in                                              \
+             PASS:*|XFAIL:*);;                                         \
+             *) echo; cat $$f;;                                        \
+           esac;                                                       \
+         done;                                                         \
+       } >$(TEST_SUITE_LOG).tmp;                                       \
+       mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                     \
+       if test "$$failures" -ne 0; then                                \
+         msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";              \
+         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
+           msg="$${msg}Please report to $(PACKAGE_BUGREPORT).  ";      \
+         fi;                                                           \
+       fi;                                                             \
+       test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);       \
+       $(am__tty_colors);                                              \
+       if $$exit; then                                                 \
+         echo $(ECHO_N) "$$grn$(ECHO_C)";                              \
+        else                                                           \
+         echo $(ECHO_N) "$$red$(ECHO_C)";                              \
+       fi;                                                             \
+       echo "$$msg" | $(am__text_box);                                 \
+       echo $(ECHO_N) "$$std$(ECHO_C)";                                \
+       $$exit
+
+# Run all the tests.
+check-TESTS:
+       @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+       @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+       @list='$(TEST_LOGS)';                                           \
+       list=`for f in $$list; do                                       \
+         test .log = $$f || echo $$f;                                  \
+       done | tr '\012\015' '  '`;                                     \
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
+
+.log.html:
+       @list='$(RST2HTML) $$RST2HTML rst2html rst2html.py';            \
+       for r2h in $$list; do                                           \
+         if ($$r2h --version) >/dev/null 2>&1; then                    \
+           R2H=$$r2h;                                                  \
+         fi;                                                           \
+       done;                                                           \
+       if test -z "$$R2H"; then                                        \
+         echo >&2 "cannot find rst2html, cannot create $@";            \
+         exit 2;                                                       \
+       fi;                                                             \
+       $$R2H $< >$@.tmp
+       @mv $@.tmp $@
+
+# Be sure to run check first, and then to convert the result.
+# Beware of concurrent executions.  Run "check" not "check-TESTS", as
+# check-SCRIPTS and other dependencies are rebuilt by the former only.
+# And expect check to fail.
+check-html:
+       @if $(MAKE) $(AM_MAKEFLAGS) check; then                 \
+         rv=0; else rv=$$?;                                    \
+       fi;                                                     \
+       $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML) || exit 4;   \
+       exit $$rv
+recheck recheck-html:
+       @target=`echo $@ | sed 's,^re,,'`;                              \
+       list='$(TEST_LOGS)';                                            \
+       list=`for f in $$list; do                                       \
+               test -f $$f || continue;                                \
+               if read line < $$f; then                                \
+                 case $$line in FAIL*|XPASS*) echo $$f;; esac;         \
+               else echo $$f; fi;                                      \
+             done | tr '\012\015' '  '`;                               \
+       $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
+test-interpreter.sh.log: test-interpreter.sh
+       @p='test-interpreter.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-sudoers.sh.log: lens-sudoers.sh
+       @p='lens-sudoers.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-access.sh.log: lens-access.sh
+       @p='lens-access.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-aliases.sh.log: lens-aliases.sh
+       @p='lens-aliases.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-approx.sh.log: lens-approx.sh
+       @p='lens-approx.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-aptpreferences.sh.log: lens-aptpreferences.sh
+       @p='lens-aptpreferences.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-aptsource.sh.log: lens-aptsource.sh
+       @p='lens-aptsource.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-bbhosts.sh.log: lens-bbhosts.sh
+       @p='lens-bbhosts.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-cgconfig.sh.log: lens-cgconfig.sh
+       @p='lens-cgconfig.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-cgrules.sh.log: lens-cgrules.sh
+       @p='lens-cgrules.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-cobblersettings.sh.log: lens-cobblersettings.sh
+       @p='lens-cobblersettings.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-cobblermodules.sh.log: lens-cobblermodules.sh
+       @p='lens-cobblermodules.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-cron.sh.log: lens-cron.sh
+       @p='lens-cron.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-crypttab.sh.log: lens-crypttab.sh
+       @p='lens-crypttab.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-darkice.sh.log: lens-darkice.sh
+       @p='lens-darkice.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-debctrl.sh.log: lens-debctrl.sh
+       @p='lens-debctrl.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-device_map.sh.log: lens-device_map.sh
+       @p='lens-device_map.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-dhclient.sh.log: lens-dhclient.sh
+       @p='lens-dhclient.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-dhcpd.sh.log: lens-dhcpd.sh
+       @p='lens-dhcpd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-dnsmasq.sh.log: lens-dnsmasq.sh
+       @p='lens-dnsmasq.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-dpkg.sh.log: lens-dpkg.sh
+       @p='lens-dpkg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-dput.sh.log: lens-dput.sh
+       @p='lens-dput.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-ethers.sh.log: lens-ethers.sh
+       @p='lens-ethers.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-exports.sh.log: lens-exports.sh
+       @p='lens-exports.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-fstab.sh.log: lens-fstab.sh
+       @p='lens-fstab.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-gdm.sh.log: lens-gdm.sh
+       @p='lens-gdm.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-group.sh.log: lens-group.sh
+       @p='lens-group.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-json.sh.log: lens-json.sh
+       @p='lens-json.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-hosts.sh.log: lens-hosts.sh
+       @p='lens-hosts.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-httpd.sh.log: lens-httpd.sh
+       @p='lens-httpd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-inetd.sh.log: lens-inetd.sh
+       @p='lens-inetd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-inifile.sh.log: lens-inifile.sh
+       @p='lens-inifile.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-inittab.sh.log: lens-inittab.sh
+       @p='lens-inittab.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-interfaces.sh.log: lens-interfaces.sh
+       @p='lens-interfaces.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-iptables.sh.log: lens-iptables.sh
+       @p='lens-iptables.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-keepalived.sh.log: lens-keepalived.sh
+       @p='lens-keepalived.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-krb5.sh.log: lens-krb5.sh
+       @p='lens-krb5.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-ldap.sh.log: lens-ldap.sh
+       @p='lens-ldap.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-limits.sh.log: lens-limits.sh
+       @p='lens-limits.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-login_defs.sh.log: lens-login_defs.sh
+       @p='lens-login_defs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-logrotate.sh.log: lens-logrotate.sh
+       @p='lens-logrotate.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-lokkit.sh.log: lens-lokkit.sh
+       @p='lens-lokkit.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-mke2fs.sh.log: lens-mke2fs.sh
+       @p='lens-mke2fs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-modprobe.sh.log: lens-modprobe.sh
+       @p='lens-modprobe.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-modules_conf.sh.log: lens-modules_conf.sh
+       @p='lens-modules_conf.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-monit.sh.log: lens-monit.sh
+       @p='lens-monit.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-multipath.sh.log: lens-multipath.sh
+       @p='lens-multipath.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-mysql.sh.log: lens-mysql.sh
+       @p='lens-mysql.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-nagioscfg.sh.log: lens-nagioscfg.sh
+       @p='lens-nagioscfg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-nagiosobjects.sh.log: lens-nagiosobjects.sh
+       @p='lens-nagiosobjects.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-ntp.sh.log: lens-ntp.sh
+       @p='lens-ntp.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-nrpe.sh.log: lens-nrpe.sh
+       @p='lens-nrpe.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-nsswitch.sh.log: lens-nsswitch.sh
+       @p='lens-nsswitch.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-odbc.sh.log: lens-odbc.sh
+       @p='lens-odbc.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-openvpn.sh.log: lens-openvpn.sh
+       @p='lens-openvpn.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-pam.sh.log: lens-pam.sh
+       @p='lens-pam.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-passwd.sh.log: lens-passwd.sh
+       @p='lens-passwd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-pbuilder.sh.log: lens-pbuilder.sh
+       @p='lens-pbuilder.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-pg_hba.sh.log: lens-pg_hba.sh
+       @p='lens-pg_hba.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-php.sh.log: lens-php.sh
+       @p='lens-php.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-phpvars.sh.log: lens-phpvars.sh
+       @p='lens-phpvars.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-postfix_access.sh.log: lens-postfix_access.sh
+       @p='lens-postfix_access.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-postfix_main.sh.log: lens-postfix_main.sh
+       @p='lens-postfix_main.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-postfix_master.sh.log: lens-postfix_master.sh
+       @p='lens-postfix_master.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-puppet.sh.log: lens-puppet.sh
+       @p='lens-puppet.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-puppetfileserver.sh.log: lens-puppetfileserver.sh
+       @p='lens-puppetfileserver.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-resolv.sh.log: lens-resolv.sh
+       @p='lens-resolv.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-rsyncd.sh.log: lens-rsyncd.sh
+       @p='lens-rsyncd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-rx.sh.log: lens-rx.sh
+       @p='lens-rx.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-samba.sh.log: lens-samba.sh
+       @p='lens-samba.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-securetty.sh.log: lens-securetty.sh
+       @p='lens-securetty.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-services.sh.log: lens-services.sh
+       @p='lens-services.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-shells.sh.log: lens-shells.sh
+       @p='lens-shells.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-shellvars.sh.log: lens-shellvars.sh
+       @p='lens-shellvars.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-shellvars_list.sh.log: lens-shellvars_list.sh
+       @p='lens-shellvars_list.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-slapd.sh.log: lens-slapd.sh
+       @p='lens-slapd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-solaris_system.sh.log: lens-solaris_system.sh
+       @p='lens-solaris_system.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-soma.sh.log: lens-soma.sh
+       @p='lens-soma.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-spacevars.sh.log: lens-spacevars.sh
+       @p='lens-spacevars.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-squid.sh.log: lens-squid.sh
+       @p='lens-squid.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-sshd.sh.log: lens-sshd.sh
+       @p='lens-sshd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-sysconfig.sh.log: lens-sysconfig.sh
+       @p='lens-sysconfig.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-syslog.sh.log: lens-syslog.sh
+       @p='lens-syslog.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-sysctl.sh.log: lens-sysctl.sh
+       @p='lens-sysctl.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-vsftpd.sh.log: lens-vsftpd.sh
+       @p='lens-vsftpd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-webmin.sh.log: lens-webmin.sh
+       @p='lens-webmin.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-wine.sh.log: lens-wine.sh
+       @p='lens-wine.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-xinetd.sh.log: lens-xinetd.sh
+       @p='lens-xinetd.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-xml.sh.log: lens-xml.sh
+       @p='lens-xml.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-xorg.sh.log: lens-xorg.sh
+       @p='lens-xorg.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-grub.sh.log: lens-grub.sh
+       @p='lens-grub.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+lens-yum.sh.log: lens-yum.sh
+       @p='lens-yum.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-get.sh.log: test-get.sh
+       @p='test-get.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-augtool.sh.log: test-augtool.sh
+       @p='test-augtool.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-put-symlink.sh.log: test-put-symlink.sh
+       @p='test-put-symlink.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-save-empty.sh.log: test-save-empty.sh
+       @p='test-save-empty.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-mv.sh.log: test-mv.sh
+       @p='test-mv.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-bug-1.sh.log: test-bug-1.sh
+       @p='test-bug-1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-idempotent.sh.log: test-idempotent.sh
+       @p='test-idempotent.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-preserve.sh.log: test-preserve.sh
+       @p='test-preserve.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-events-saved.sh.log: test-events-saved.sh
+       @p='test-events-saved.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-save-mode.sh.log: test-save-mode.sh
+       @p='test-save-mode.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-unlink-error.sh.log: test-unlink-error.sh
+       @p='test-unlink-error.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-augtool-empty-line.sh.log: test-augtool-empty-line.sh
+       @p='test-augtool-empty-line.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-augtool-modify-root.sh.log: test-augtool-modify-root.sh
+       @p='test-augtool-modify-root.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+fatest.log: fatest$(EXEEXT)
+       @p='fatest$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-xpath.log: test-xpath$(EXEEXT)
+       @p='test-xpath$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-load.log: test-load$(EXEEXT)
+       @p='test-load$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-save.log: test-save$(EXEEXT)
+       @p='test-save$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+test-api.log: test-api$(EXEEXT)
+       @p='test-api$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+.test.log:
+       @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@      @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS)
+       $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+       -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+       -test -z "$(TEST_LOGS_TMP)" || rm -f $(TEST_LOGS_TMP)
+       -test -z "$(TEST_SUITE_HTML)" || rm -f $(TEST_SUITE_HTML)
+       -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am check-html install-am install-strip recheck \
+       recheck-html
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am check-html \
+       clean clean-checkPROGRAMS clean-generic clean-libtool ctags \
+       distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-html install-html-am install-info \
+       install-info-am install-man install-pdf install-pdf-am \
+       install-ps install-ps-am install-strip installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       recheck recheck-html tags uninstall uninstall-am
+
+
+valgrind: fatest
+       libtool --mode=execute valgrind --quiet --leak-check=full ./fatest
+
+# Ensure that the above list stays up to date:
+# Construct two lists: list of lens-*.sh from lens_tests = ... above,
+# and the list of ../lenses/tests/test_*.aug names.
+# If they're not the same, print the new or removed names and fail.
+check: check-lens-tests
+.PHONY: check-lens-tests
+check-lens-tests:
+       @u=$$({ sed -n '/^$(_v) =[       ]*\\$$/,/[^\]$$/p'             \
+               $(srcdir)/Makefile.am                                   \
+           | sed 's/^  *//;/^\$$.*/d;/^$(_v) =/d'                      \
+           | sed 's,\.sh.*\\,.sh,';                                    \
+         ls -1 $(srcdir)/../lenses/tests/test_*.aug                    \
+           | sed 's,.*/test_\([^./]*\)\.aug$$,lens-\1.sh,';            \
+       } | LC_ALL=C sort | uniq -u);                                   \
+       test "x$$u" = x && :                                            \
+         || { printf '%s\n' "$$u" >&2;                                 \
+              echo '$(ME): new test(s)?  update lens_tests' >&2; exit 1; }
+$(lens_tests): lens-test-1
+       $(LN_S) $< $@
+
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./fatest
+
+@WITH_FAILMALLOC_TRUE@failmalloc: failmalloc-run
+@WITH_FAILMALLOC_FALSE@failmalloc: failmalloc-error
+
+failmalloc-run: $(FAILMALLOC_PROG)
+       @(echo "Running $(FAILMALLOC_PROG) with failmalloc";    \
+      for i in $$(seq $(FAILMALLOC_START) $$(expr $(FAILMALLOC_START) + $(FAILMALLOC_REP) - 1)) ; do \
+         resp=$$(libtool --mode=execute env LD_PRELOAD=$(LIBFAILMALLOC) FAILMALLOC_INTERVAL=$$i $(FAILMALLOC_PROG));        \
+         status=$$?;                                          \
+         if [ $$status -ne 0 -a $$status -ne 2 ] ;     then       \
+           printf "%5d FAIL %3d %s\n" $$i $$status "$$resp" ; \
+         elif [ x$(V) = x1 -o $$(( $$i % 100 )) -eq 0 ] ; then \
+           printf "%5d PASS %s\n" $$i "$$resp" ;              \
+         fi                                                   \
+       done)
+
+failmalloc-error:
+       @(echo "You need to turn on failmalloc support with --with-failmalloc"; \
+         exit 1)
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/cutest.c b/tests/cutest.c
new file mode 100644 (file)
index 0000000..08dbfd7
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * This code is based on CuTest by Asim Jalis
+ * http://sourceforge.net/projects/cutest/
+ *
+ * The license for the original code is
+ * LICENSE
+ *
+ * Copyright (c) 2003 Asim Jalis
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software in
+ * a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+#include <config.h>
+
+#include <assert.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "cutest.h"
+#include "memory.h"
+
+#define HUGE_STRING_LEN        8192
+#define STRING_MAX             256
+
+#define asprintf_or_die(strp, fmt, args ...)                            \
+    if (asprintf(strp, fmt, ## args) == -1) {                           \
+        fprintf(stderr, "Fatal error (probably out of memory)\n");      \
+        abort();                                                        \
+    }
+
+void die_oom(void) {
+    printf("Ran out of memory. Send more\n");
+    exit(2);
+}
+
+/*-------------------------------------------------------------------------*
+ * CuTest
+ *-------------------------------------------------------------------------*/
+
+void CuTestInit(CuTest* t, const char* name, TestFunction function) {
+       t->name = strdup(name);
+       t->failed = 0;
+       t->ran = 0;
+       t->message = NULL;
+       t->function = function;
+       t->jumpBuf = NULL;
+}
+
+CuTest* CuTestNew(const char* name, TestFunction function) {
+       CuTest* tc = NULL;
+    if (ALLOC(tc) < 0)
+        die_oom();
+       CuTestInit(tc, name, function);
+       return tc;
+}
+
+void CuTestRun(CuTest* tc, TestFunction setup, TestFunction teardown) {
+       jmp_buf buf;
+       tc->jumpBuf = &buf;
+       if (setjmp(buf) == 0) {
+        if (setup)
+            (setup)(tc);
+               tc->ran = 1;
+               (tc->function)(tc);
+       }
+    if (teardown && setjmp(buf) == 0) {
+        (teardown)(tc);
+    }
+       tc->jumpBuf = 0;
+}
+
+static void CuFailInternal(CuTest* tc, const char* file, int line,
+                           const char *string) {
+       char *buf = NULL;
+
+       asprintf_or_die(&buf, "%s:%d: %s", file, line, string);
+
+       tc->failed = 1;
+       tc->message = buf;
+       if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
+}
+
+void CuFail_Line(CuTest* tc, const char* file, int line,
+                 const char* message2, const char* message) {
+    char *string = NULL;
+
+       if (message2 != NULL) {
+               asprintf_or_die(&string, "%s:%s", message2, message);
+       } else {
+        string = strdup(message);
+    }
+       CuFailInternal(tc, file, line, string);
+}
+
+void CuAssert_Line(CuTest* tc, const char* file, int line,
+                   const char* message, int condition) {
+       if (condition) return;
+       CuFail_Line(tc, file, line, NULL, message);
+}
+
+void CuAssertStrEquals_LineMsg(CuTest* tc, const char* file, int line,
+                               const char* message,
+                               const char* expected, const char* actual) {
+       char *string = NULL;
+
+       if ((expected == NULL && actual == NULL) ||
+           (expected != NULL && actual != NULL &&
+            strcmp(expected, actual) == 0))
+        {
+            return;
+        }
+
+       if (message != NULL) {
+        asprintf_or_die(&string, "%s: expected <%s> but was <%s>", message,
+                        expected, actual);
+       } else {
+        asprintf_or_die(&string, "expected <%s> but was <%s>", expected, actual);
+    }
+       CuFailInternal(tc, file, line, string);
+}
+
+void CuAssertStrNotEqual_LineMsg(CuTest* tc, const char* file, int line,
+                                 const char* message,
+                                 const char* expected, const char* actual) {
+       char *string = NULL;
+
+    if (expected != NULL && actual != NULL && strcmp(expected, actual) != 0)
+        return;
+
+       if (message != NULL) {
+        asprintf_or_die(&string, "%s: expected <%s> but was <%s>", message,
+                        expected, actual);
+       } else {
+        asprintf_or_die(&string, "expected <%s> but was <%s>", expected, actual);
+    }
+       CuFailInternal(tc, file, line, string);
+}
+
+void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line,
+                               const char* message,
+                               int expected, int actual) {
+       char buf[STRING_MAX];
+       if (expected == actual) return;
+       sprintf(buf, "expected <%d> but was <%d>", expected, actual);
+       CuFail_Line(tc, file, line, message, buf);
+}
+
+void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line,
+                               const char* message,
+                               double expected, double actual, double delta) {
+       char buf[STRING_MAX];
+       if (fabs(expected - actual) <= delta) return;
+       sprintf(buf, "expected <%lf> but was <%lf>", expected, actual);
+       CuFail_Line(tc, file, line, message, buf);
+}
+
+void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line,
+                               const char* message,
+                               const void* expected, const void* actual) {
+       char buf[STRING_MAX];
+       if (expected == actual) return;
+       sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
+       CuFail_Line(tc, file, line, message, buf);
+}
+
+void CuAssertPtrNotEqual_LineMsg(CuTest* tc, const char* file, int line,
+                                 const char* message,
+                                 const void* expected, const void* actual) {
+       char buf[STRING_MAX];
+       if (expected != actual) return;
+       sprintf(buf, "expected pointer <0x%p> to be different from <0x%p>",
+            expected, actual);
+       CuFail_Line(tc, file, line, message, buf);
+}
+
+
+/*-------------------------------------------------------------------------*
+ * CuSuite
+ *-------------------------------------------------------------------------*/
+
+void CuSuiteInit(CuSuite* testSuite) {
+       testSuite->count = 0;
+       testSuite->failCount = 0;
+}
+
+CuSuite* CuSuiteNew(void) {
+       CuSuite* testSuite = NULL;
+    if (ALLOC(testSuite) < 0)
+        die_oom();
+       CuSuiteInit(testSuite);
+       return testSuite;
+}
+
+void CuSuiteSetup(CuSuite *testSuite,
+                  TestFunction setup, TestFunction teardown) {
+    testSuite->setup = setup;
+    testSuite->teardown = teardown;
+}
+
+void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase) {
+       assert(testSuite->count < MAX_TEST_CASES);
+       testSuite->list[testSuite->count] = testCase;
+       testSuite->count++;
+}
+
+void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2) {
+       int i;
+       for (i = 0 ; i < testSuite2->count ; ++i)
+        {
+            CuTest* testCase = testSuite2->list[i];
+            CuSuiteAdd(testSuite, testCase);
+        }
+}
+
+void CuSuiteRun(CuSuite* testSuite) {
+       int i;
+       for (i = 0 ; i < testSuite->count ; ++i)
+        {
+            CuTest* testCase = testSuite->list[i];
+            CuTestRun(testCase, testSuite->setup, testSuite->teardown);
+            if (testCase->failed) { testSuite->failCount += 1; }
+        }
+}
+
+static void string_append(char **s, const char *p) {
+    if (*s == NULL) {
+        *s = strdup(p);
+    } else {
+        int len = strlen(*s) + strlen(p) + 1;
+        *s = realloc(*s, len);
+        if (*s == NULL)
+            die_oom();
+        strcat(*s, p);
+    }
+}
+
+void CuSuiteSummary(CuSuite* testSuite, char **summary) {
+       int i;
+
+       for (i = 0 ; i < testSuite->count ; ++i)
+        {
+            CuTest* testCase = testSuite->list[i];
+            string_append(summary, testCase->failed ? "F" : ".");
+        }
+       string_append(summary, "\n\n");
+}
+
+void CuSuiteDetails(CuSuite* testSuite, char **details) {
+       int i;
+       int failCount = 0;
+    char *s = NULL;
+
+       if (testSuite->failCount == 0)
+        {
+            int passCount = testSuite->count - testSuite->failCount;
+            const char* testWord = passCount == 1 ? "test" : "tests";
+            asprintf_or_die(&s, "OK (%d %s)\n", passCount, testWord);
+            string_append(details, s);
+            free(s);
+        } else {
+               if (testSuite->failCount == 1)
+                       string_append(details, "There was 1 failure:\n");
+               else {
+            asprintf_or_die(&s, "There were %d failures:\n",
+                            testSuite->failCount);
+            string_append(details, s);
+            free(s);
+        }
+               for (i = 0 ; i < testSuite->count ; ++i) {
+                       CuTest* testCase = testSuite->list[i];
+                       if (testCase->failed) {
+                               failCount++;
+                               asprintf_or_die(&s, "%d) %s:\n%s\n",
+                         failCount, testCase->name, testCase->message);
+                string_append(details, s);
+                free(s);
+                       }
+               }
+               string_append(details, "\n!!!FAILURES!!!\n");
+
+               asprintf_or_die(&s, "Runs: %d ",   testSuite->count);
+        string_append(details, s);
+        free(s);
+
+        asprintf_or_die(&s, "Passes: %d ",
+                        testSuite->count - testSuite->failCount);
+        string_append(details, s);
+        free(s);
+
+               asprintf_or_die(&s, "Fails: %d\n",  testSuite->failCount);
+        string_append(details, s);
+        free(s);
+       }
+}
+
+/*
+ * Test utilities
+ */
+void run(CuTest *tc, const char *format, ...) {
+    char *command;
+    va_list args;
+    int r;
+
+    va_start(args, format);
+    r = vasprintf(&command, format, args);
+    va_end (args);
+    if (r < 0)
+        CuFail(tc, "Failed to format command (out of memory)");
+    r = system(command);
+    if (r < 0 || (WIFEXITED(r) && WEXITSTATUS(r) != 0)) {
+        char *msg;
+        r = asprintf(&msg, "Command %s failed with status %d\n",
+                     command, WEXITSTATUS(r));
+        CuFail(tc, msg);
+        free(msg);
+    }
+    free(command);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/cutest.h b/tests/cutest.h
new file mode 100644 (file)
index 0000000..99e2d34
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * This code is based on CuTest by Asim Jalis
+ * http://sourceforge.net/projects/cutest/
+ *
+ * The license for the original code is
+ * LICENSE
+ *
+ * Copyright (c) 2003 Asim Jalis
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software in
+ * a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+
+#ifndef CU_TEST_H
+#define CU_TEST_H
+
+#include <setjmp.h>
+#include <stdarg.h>
+
+void die_oom(void);
+
+/* CuTest */
+
+#define CuAssertPositive(tc, n) CuAssertTrue(tc, (n) > 0)
+#define CuAssertZero(tc, n) CuAssertIntEquals(tc, 0, (n))
+#define CuAssertRetSuccess(tc, n) CuAssertIntEquals(tc, 0, (n))
+
+typedef struct CuTest CuTest;
+
+typedef void (*TestFunction)(CuTest *);
+
+struct CuTest
+{
+       const char* name;
+       TestFunction function;
+       int failed;
+       int ran;
+       const char* message;
+       jmp_buf *jumpBuf;
+};
+
+void CuTestInit(CuTest* t, const char* name, TestFunction function);
+CuTest* CuTestNew(const char* name, TestFunction function);
+void CuTestRun(CuTest* tc, TestFunction setup, TestFunction teardown);
+
+/* Internal versions of assert functions -- use the public versions */
+void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message);
+void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition);
+void CuAssertStrEquals_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       const char* expected, const char* actual);
+void CuAssertStrNotEqual_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       const char* expected, const char* actual);
+void CuAssertIntEquals_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       int expected, int actual);
+void CuAssertDblEquals_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       double expected, double actual, double delta);
+void CuAssertPtrEquals_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       const void* expected, const void* actual);
+void CuAssertPtrNotEqual_LineMsg(CuTest* tc,
+       const char* file, int line, const char* message,
+       const void* expected, const void* actual);
+
+/* public assert functions */
+
+#define CuFail(tc, ms)                        CuFail_Line(  (tc), __FILE__, __LINE__, NULL, (ms))
+#define CuAssert(tc, ms, cond)                CuAssert_Line((tc), __FILE__, __LINE__, (ms), (cond))
+#define CuAssertTrue(tc, cond)                CuAssert_Line((tc), __FILE__, __LINE__, "assert failed", (cond))
+
+#define CuAssertStrEquals(tc,ex,ac)           CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
+#define CuAssertStrEquals_Msg(tc,ms,ex,ac)    CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
+#define CuAssertStrNotEqual(tc,ex,ac)         CuAssertStrNotEqual_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
+#define CuAssertIntEquals(tc,ex,ac)           CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
+#define CuAssertIntEquals_Msg(tc,ms,ex,ac)    CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
+#define CuAssertDblEquals(tc,ex,ac,dl)        CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac),(dl))
+#define CuAssertDblEquals_Msg(tc,ms,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac),(dl))
+#define CuAssertPtrEquals(tc,ex,ac)           CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
+#define CuAssertPtrEquals_Msg(tc,ms,ex,ac)    CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
+#define CuAssertPtrNotEqual(tc,ex,ac)           CuAssertPtrNotEqual_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
+#define CuAssertPtrNotEqual_Msg(tc,ms,ex,ac)    CuAssertPtrNotEqual_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
+
+#define CuAssertPtrNotNull(tc,p)        CuAssert_Line((tc),__FILE__,__LINE__,"null pointer unexpected",(p != NULL))
+#define CuAssertPtrNotNullMsg(tc,msg,p) CuAssert_Line((tc),__FILE__,__LINE__,(msg),(p != NULL))
+
+/* CuSuite */
+
+#define MAX_TEST_CASES 1024
+
+#define SUITE_ADD_TEST(SUITE,TEST)     CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
+
+typedef struct
+{
+       int count;
+       CuTest* list[MAX_TEST_CASES];
+       int failCount;
+    TestFunction setup;
+    TestFunction teardown;
+} CuSuite;
+
+
+void CuSuiteInit(CuSuite* testSuite);
+CuSuite* CuSuiteNew(void);
+void CuSuiteSetup(CuSuite *testSuite,
+                  TestFunction setup, TestFunction teardown);
+void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase);
+void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2);
+void CuSuiteRun(CuSuite* testSuite);
+void CuSuiteSummary(CuSuite* testSuite, char **summary);
+void CuSuiteDetails(CuSuite* testSuite, char **details);
+
+/* Run a command */
+void run(CuTest *tc, const char *format, ...);
+#endif /* CU_TEST_H */
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/fatest.c b/tests/fatest.c
new file mode 100644 (file)
index 0000000..be4460b
--- /dev/null
@@ -0,0 +1,653 @@
+/*
+ * fatest.c:
+ *
+ * Copyright (C) 2007 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "fa.h"
+#include "cutest.h"
+#include "internal.h"
+#include "memory.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#define FA_DOT_DIR "FA_DOT_DIR"
+
+struct fa_list {
+    struct fa_list *next;
+    struct fa *fa;
+};
+
+static struct fa_list *fa_list;
+
+static void print_regerror(int err, const char *regexp) {
+    size_t size;
+    char *errbuf;
+    size = regerror(err, NULL, NULL, 0);
+    if (ALLOC_N(errbuf, size) < 0)
+        die_oom();
+    regerror(err, NULL, errbuf, size);
+    if (strlen(regexp) > 40) {
+        char *s = strndup(regexp, 40);
+        fprintf(stderr, "Error building fa from %s...:\n", s);
+        free(s);
+    } else {
+        fprintf(stderr, "Error building fa from %s:\n", regexp);
+    }
+    fprintf(stderr, "  %s\n", errbuf);
+    free(errbuf);
+}
+
+static void setup(ATTRIBUTE_UNUSED CuTest *tc) {
+    fa_list = NULL;
+}
+
+static void teardown(ATTRIBUTE_UNUSED CuTest *tc) {
+    list_for_each(fl, fa_list) {
+        fa_free(fl->fa);
+    }
+    list_free(fa_list);
+}
+
+static struct fa *mark(struct fa *fa) {
+    struct fa_list *fl;
+
+    if (fa != NULL) {
+        if (ALLOC(fl) < 0)
+            die_oom();
+        fl->fa = fa;
+        list_cons(fa_list, fl);
+    }
+    return fa;
+}
+
+static void assertAsRegexp(CuTest *tc, struct fa *fa) {
+    char *re;
+    size_t re_len;
+    struct fa *fa1, *fa2;
+    struct fa *empty = mark(fa_make_basic(FA_EPSILON));
+    int r;
+
+    /* Jump through some hoops to make FA1 a copy of FA */
+    fa1 = mark(fa_concat(fa, empty));
+    /* Minimize FA1, otherwise the regexp returned is enormous for the */
+    /* monster (~ 2MB) and fa_compile becomes incredibly slow          */
+    r = fa_minimize(fa1);
+    if (r < 0)
+        die_oom();
+
+    r = fa_as_regexp(fa1, &re, &re_len);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = fa_compile(re, re_len, &fa2);
+    if (r != REG_NOERROR) {
+        print_regerror(r, re);
+    }
+    CuAssertIntEquals(tc, REG_NOERROR, r);
+    CuAssertTrue(tc, fa_equals(fa, fa2));
+
+    fa_free(fa2);
+    free(re);
+}
+
+static struct fa *make_fa(CuTest *tc,
+                          const char *regexp, size_t reglen,
+                          int exp_err) {
+    struct fa *fa;
+    int r;
+
+    r = fa_compile(regexp, reglen, &fa);
+    if (r == REG_ESPACE)
+        die_oom();
+    if (exp_err == REG_NOERROR) {
+        if (r != REG_NOERROR)
+            print_regerror(r, regexp);
+        CuAssertIntEquals(tc, REG_NOERROR, r);
+        CuAssertPtrNotNull(tc, fa);
+        mark(fa);
+        assertAsRegexp(tc, fa);
+    } else {
+        CuAssertIntEquals(tc, exp_err, r);
+        CuAssertPtrEquals(tc, NULL, fa);
+    }
+    return fa;
+}
+
+static struct fa *make_good_fa(CuTest *tc, const char *regexp) {
+    return make_fa(tc, regexp, strlen(regexp), REG_NOERROR);
+}
+
+static void dot(struct fa *fa) {
+    static int count = 0;
+    FILE *fp;
+    const char *dot_dir;
+    char *fname;
+    int r;
+
+    if ((dot_dir = getenv(FA_DOT_DIR)) == NULL)
+        return;
+
+    r = asprintf(&fname, "%s/fa_test_%02d.dot", dot_dir, count++);
+    if (r == -1)
+        return;
+
+    if ((fp = fopen(fname, "w")) == NULL) {
+        free(fname);
+        return;
+    }
+
+    fa_dot(fp, fa);
+    fclose(fp);
+
+    free(fname);
+}
+
+static void testBadRegexps(CuTest *tc) {
+    const char *const re1 = "(x";
+    const char *const re2 = "a{5,3}";
+    make_fa(tc, re1, strlen(re1), REG_EPAREN);
+    make_fa(tc, re2, strlen(re2), REG_BADBR);
+}
+
+/* Stress test, mostly good to check that allocation is clean */
+static void testMonster(CuTest *tc) {
+#define WORD "[a-zA-Z_0-9]+"
+#define CWS  "([ \\n\\t]+|\\/\\*([^\\*]|\\*[^\\/])*\\*\\/)*"
+#define QUOTED "\"[^\"]*\""
+#define ELT    "\\(" WORD "(," CWS WORD "){3}\\)"
+
+    static const char *const monster =
+        "(" WORD "|" QUOTED "|" "\\(" CWS ELT  "(," CWS ELT ")*" CWS "\\))";
+
+#undef ELT
+#undef QUOTED
+#undef CWS
+#undef WORD
+
+    struct fa *fa, *fas;
+    char *upv, *pv, *v;
+    size_t upv_len;
+
+    fa = make_good_fa(tc, monster);
+
+    fa_ambig_example(fa, fa, &upv, &upv_len, &pv, &v);
+
+    /* Monster can't be concatenated with itself */
+    CuAssertStrEquals(tc, "AAA", upv);
+    CuAssertStrEquals(tc, "AA", pv);
+    CuAssertStrEquals(tc, "A", v);
+    free(upv);
+
+    /* Monster can also not be starred */
+    fas = mark(fa_iter(fa, 0, -1));
+    /* Minimize FAS, otherwise the example returned is nondeterministic,
+       since example generation depends on the structure of the FA.
+       FIXME: Explain why UPV with the unminimized FAS changes to a much
+       longer string simply when allocation patterns change (e.g., by
+       running the test under valgrind vs. plain glibc malloc. Fishy ?
+       FA_EXAMPLE should depend on the structure of the FA, but not
+       incidental details like sorting of transitions.
+     */
+    fa_minimize(fas);
+    fa_ambig_example(fas, fa, &upv, &upv_len, &pv, &v);
+
+    CuAssertStrEquals(tc, "AA", upv);
+    CuAssertStrEquals(tc, "AA", pv);
+    CuAssertStrEquals(tc, "A", v);
+    free(upv);
+}
+
+static void testChars(CuTest *tc) {
+    struct fa *fa1, *fa2, *fa3;
+
+    fa1 = make_good_fa(tc, ".");
+    fa2 = make_good_fa(tc, "[a-z]");
+    CuAssertTrue(tc, fa_contains(fa2, fa1));
+
+    fa1 = make_good_fa(tc, "(.|\n)");
+    CuAssertTrue(tc, fa_contains(fa2, fa1));
+
+    fa1 = mark(fa_intersect(fa1, fa2));
+    CuAssertTrue(tc, fa_equals(fa1, fa2));
+
+    fa1 = make_good_fa(tc, "[^b-dxyz]");
+    fa2 = make_good_fa(tc, "[a-z]");
+    fa3 = mark(fa_intersect(fa1, fa2));
+    fa2 = make_good_fa(tc, "[ae-w]");
+    CuAssertTrue(tc, fa_equals(fa2, fa3));
+}
+
+static void testManualAmbig(CuTest *tc) {
+    /* The point of this test is mostly to teach me how Anders Moeller's
+       algorithm for finding ambiguous strings works.
+
+       For the two languages a1 = a|ab and a2 = a|ba, a1.a2 has one
+       ambiguous word aba, which can be split as a.ba and ab.a.
+
+       This uses X and Y as the markers*/
+
+    struct fa *a1f = make_good_fa(tc, "Xa|XaXb");
+    struct fa *a1t = make_good_fa(tc, "(YX)*Xa|(YX)*Xa(YX)*Xb");
+    struct fa *a2f = make_good_fa(tc, "Xa|XbXa");
+    struct fa *a2t = make_good_fa(tc, "(YX)*Xa|((YX)*Xb(YX)*Xa)");
+    struct fa *mp = make_good_fa(tc, "YX(X(.|\n))+");
+    struct fa *ms = make_good_fa(tc, "YX(X(.|\n))*");
+    struct fa *sp = make_good_fa(tc, "(X(.|\n))+YX");
+    struct fa *ss = make_good_fa(tc, "(X(.|\n))*YX");
+
+    struct fa *a1f_mp = mark(fa_concat(a1f, mp));
+    struct fa *a1f_mp_a1t = mark(fa_intersect(a1f_mp, a1t));
+    struct fa *b1 = mark(fa_concat(a1f_mp_a1t, ms));
+
+    struct fa *sp_a2f = mark(fa_concat(sp, a2f));
+    struct fa *sp_a2f_a2t = mark(fa_intersect(sp_a2f, a2t));
+    struct fa *b2 = mark(fa_concat(ss, sp_a2f_a2t));
+
+    struct fa *amb = mark(fa_intersect(b1, b2));
+    struct fa *exp = make_good_fa(tc, "XaYXXbYXXa");
+    CuAssertTrue(tc, fa_equals(exp, amb));
+}
+
+static void testContains(CuTest *tc) {
+    struct fa *fa1, *fa2, *fa3;
+
+    fa1 = make_good_fa(tc, "ab*");
+    fa2 = make_good_fa(tc, "ab+");
+    fa3 = make_good_fa(tc, "ab+c*|acc");
+
+    CuAssertTrue(tc, fa_contains(fa1, fa1));
+    CuAssertTrue(tc, fa_contains(fa2, fa2));
+    CuAssertTrue(tc, fa_contains(fa3, fa3));
+
+    CuAssertTrue(tc, ! fa_contains(fa1, fa2));
+    CuAssertTrue(tc, fa_contains(fa2, fa1));
+    CuAssertTrue(tc, fa_contains(fa2, fa3));
+    CuAssertTrue(tc, ! fa_contains(fa3, fa2));
+    CuAssertTrue(tc, ! fa_contains(fa1, fa3));
+    CuAssertTrue(tc, ! fa_contains(fa3, fa1));
+}
+
+static void testIntersect(CuTest *tc) {
+    struct fa *fa1, *fa2, *fa;
+
+    fa1 = make_good_fa(tc, "[a-zA-Z]*[.:=]([0-9]|[^A-Z])*");
+    fa2 = make_good_fa(tc, "[a-z][:=][0-9a-z]+");
+    fa = mark(fa_intersect(fa1, fa2));
+    CuAssertPtrNotNull(tc, fa);
+    CuAssertTrue(tc, fa_equals(fa, fa2));
+    CuAssertTrue(tc, ! fa_equals(fa, fa1));
+}
+
+static void testComplement(CuTest *tc) {
+    struct fa *fa1 = make_good_fa(tc, "[b-y]+");
+    struct fa *fa2 = mark(fa_complement(fa1));
+    /* We use '()' to match the empty word explicitly */
+    struct fa *fa3 = make_good_fa(tc, "(()|[b-y]*[^b-y](.|\n)*)");
+
+    CuAssertTrue(tc, fa_equals(fa2, fa3));
+
+    fa2 = mark(fa_complement(fa2));
+    CuAssertTrue(tc, fa_equals(fa1, fa2));
+}
+
+static void testOverlap(CuTest *tc) {
+    struct fa *fa1 = make_good_fa(tc, "a|ab");
+    struct fa *fa2 = make_good_fa(tc, "a|ba");
+    struct fa *p   = mark(fa_overlap(fa1, fa2));
+    struct fa *exp = make_good_fa(tc, "b");
+
+    CuAssertTrue(tc, fa_equals(exp, p));
+
+    fa1 = make_good_fa(tc, "a|b|c|abc");
+    fa2 = mark(fa_iter(fa1, 0, -1));
+    exp = make_good_fa(tc, "bc");
+    p = mark(fa_overlap(fa1, fa2));
+
+    CuAssertTrue(tc, fa_equals(exp, p));
+}
+
+static void assertExample(CuTest *tc, const char *regexp, const char *exp) {
+    struct fa *fa = make_good_fa(tc, regexp);
+    size_t xmpl_len;
+    char *xmpl;
+    fa_example(fa, &xmpl, &xmpl_len);
+    CuAssertStrEquals(tc, exp, xmpl);
+    free(xmpl);
+
+    fa_nocase(fa);
+    char *s = strdup(exp);
+    for (int i = 0; i < strlen(s); i++) s[i] = tolower(s[i]);
+
+    fa_example(fa, &xmpl, &xmpl_len);
+    CuAssertStrEquals(tc, s, xmpl);
+    free(xmpl);
+    free(s);
+}
+
+static void testExample(CuTest *tc) {
+    assertExample(tc, "(.|\n)", "A");
+    assertExample(tc, "(\n|\t|x)", "x");
+    assertExample(tc, "[^b-y]", "A");
+    assertExample(tc, "x*", "x");
+    assertExample(tc, "yx*", "y");
+    assertExample(tc, "ab+cx*", "abc");
+    assertExample(tc, "ab+cx*|y*", "y");
+    assertExample(tc, "u*|[0-9]", "u");
+    assertExample(tc, "u+|[0-9]", "u");
+    assertExample(tc, "vu+|[0-9]", "0");
+    assertExample(tc, "vu{2}|[0-9]", "0");
+    assertExample(tc, "\\[", "[");
+    assertExample(tc, "[\\]", "\\");
+    assertExample(tc, "a{3}", "aaa");
+    assertExample(tc, "a{3,}", "aaa");
+
+    assertExample(tc, "\001((\002.)*\001)+\002", "\001\001\002");
+    assertExample(tc, "\001((\001.)*\002)+\002", "\001\002\002");
+
+    assertExample(tc, "a[^\001-\004]+b", "aAb");
+
+    /* A strange way to write a? - allowed by POSIX */
+    assertExample(tc, "(a|)", "a");
+    assertExample(tc, "(|a)", "a");
+
+    struct fa *fa1 = mark(fa_make_basic(FA_EMPTY));
+    size_t xmpl_len;
+    char *xmpl;
+    fa_example(fa1, &xmpl, &xmpl_len);
+    CuAssertPtrEquals(tc, NULL, xmpl);
+
+    fa1 = mark(fa_make_basic(FA_EPSILON));
+    fa_example(fa1, &xmpl, &xmpl_len);
+    CuAssertStrEquals(tc, "", xmpl);
+    free(xmpl);
+}
+
+static void assertAmbig(CuTest *tc, const char *regexp1, const char *regexp2,
+                        const char *exp_upv,
+                        const char *exp_pv, const char *exp_v) {
+
+    struct fa *fa1 = make_good_fa(tc, regexp1);
+    struct fa *fa2 = make_good_fa(tc, regexp2);
+    char *upv, *pv, *v;
+    size_t upv_len;
+    fa_ambig_example(fa1, fa2, &upv, &upv_len, &pv, &v);
+    CuAssertPtrNotNull(tc, upv);
+    CuAssertPtrNotNull(tc, pv);
+    CuAssertPtrNotNull(tc, v);
+
+    CuAssertStrEquals(tc, exp_upv, upv);
+    CuAssertStrEquals(tc, exp_pv, pv);
+    CuAssertStrEquals(tc, exp_v, v);
+    free(upv);
+}
+
+static void assertNotAmbig(CuTest *tc, const char *regexp1,
+                           const char *regexp2) {
+    struct fa *fa1 = make_good_fa(tc, regexp1);
+    struct fa *fa2 = make_good_fa(tc, regexp2);
+    char *upv;
+    size_t upv_len;
+    fa_ambig_example(fa1, fa2, &upv, &upv_len, NULL, NULL);
+    CuAssertPtrEquals(tc, NULL, upv);
+}
+
+static void testAmbig(CuTest *tc) {
+    assertAmbig(tc, "a|ab", "a|ba", "aba", "ba", "a");
+    assertAmbig(tc, "(a|ab)*", "a|ba", "aba", "ba", "a");
+    assertAmbig(tc, "(a|b|c|d|abcd)", "(a|b|c|d|abcd)*",
+                "abcd", "bcd", "");
+    assertAmbig(tc, "(a*)*", "a*", "a", "a", "");
+    assertAmbig(tc, "(a+)*", "a+", "aa", "aa", "a");
+
+    assertNotAmbig(tc, "a*", "a");
+    assertNotAmbig(tc, "(a*b)*", "a*b");
+    assertNotAmbig(tc, "(a|b|c|d|abcd)", "(a|b|c|d|abcd)");
+}
+
+static void assertFaAsRegexp(CuTest *tc, const char *regexp) {
+    char *re;
+    size_t re_len;
+    struct fa *fa1 = make_good_fa(tc, regexp);
+    struct fa *fa2;
+    int r;
+
+    r = fa_as_regexp(fa1, &re, &re_len);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = fa_compile(re, strlen(re), &fa2);
+    CuAssertIntEquals(tc, REG_NOERROR, r);
+
+    CuAssert(tc, regexp, fa_equals(fa1, fa2));
+
+    fa_free(fa2);
+    free(re);
+}
+
+static void testAsRegexp(CuTest *tc) {
+    assertFaAsRegexp(tc, "a*");
+    assertFaAsRegexp(tc, "abcd");
+    assertFaAsRegexp(tc, "ab|cd");
+    assertFaAsRegexp(tc, "[a-z]+");
+    assertFaAsRegexp(tc, "[]a-]+");
+    assertFaAsRegexp(tc, "[^0-9A-Z]");
+    assertFaAsRegexp(tc, "ab|(xy[A-Z0-9])*(uv[^0-9]?)");
+    assertFaAsRegexp(tc, "[A-CE-GI-LN-QS-Z]");
+}
+
+static void testAsRegexpMinus(CuTest *tc) {
+    struct fa *fa1 = make_good_fa(tc, "[A-Za-z]+");
+    struct fa *fa2 = make_good_fa(tc, "Deny(Users|Groups|Other)");
+    struct fa *fa = mark(fa_minus(fa1, fa2));
+    char *re;
+    size_t re_len;
+    int r;
+
+    r = fa_as_regexp(fa, &re, &re_len);
+    CuAssertIntEquals(tc, 0, r);
+
+    struct fa *far = make_good_fa(tc, re);
+    CuAssertTrue(tc, fa_equals(fa, far));
+
+    free(re);
+}
+
+static void testRangeEnd(CuTest *tc) {
+    const char *const re = "[1-0]";
+    make_fa(tc, re, strlen(re), REG_ERANGE);
+}
+
+static void testNul(CuTest *tc) {
+    static const char *const re0 = "a\0b";
+    int re0_len = 3;
+
+    struct fa *fa1 = make_fa(tc, "a\0b", re0_len, REG_NOERROR);
+    struct fa *fa2 = make_good_fa(tc, "a.b");
+    char *re;
+    size_t re_len;
+    int r;
+
+    CuAssertTrue(tc, fa_contains(fa1, fa2));
+
+    r = fa_as_regexp(fa1, &re, &re_len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertIntEquals(tc, re0_len, re_len);
+    CuAssertIntEquals(tc, 0, memcmp(re0, re, re0_len));
+}
+
+static void testRestrictAlphabet(CuTest *tc) {
+    const char *re = "ab|(xy[B-Z0-9])*(uv[^0-9]?)";
+    struct fa *fa_exp = make_good_fa(tc, "((xy[0-9])*)uv[^0-9A-Z]?|ab");
+    struct fa *fa_act = NULL;
+    size_t nre_len;
+    char *nre;
+    int r;
+
+    r = fa_restrict_alphabet(re, strlen(re), &nre, &nre_len, 'A', 'Z');
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertIntEquals(tc, nre_len, strlen(nre));
+    fa_act = make_good_fa(tc, nre);
+    CuAssertTrue(tc, fa_equals(fa_exp, fa_act));
+    free(nre);
+
+    r = fa_restrict_alphabet("HELLO", strlen("HELLO"),
+                             &nre, &nre_len, 'A', 'Z');
+    CuAssertIntEquals(tc, -2, r);
+    CuAssertPtrEquals(tc, NULL, nre);
+
+    r = fa_restrict_alphabet("a{2,", strlen("a{2"), &nre, &nre_len, 'A', 'Z');
+    CuAssertIntEquals(tc, REG_EBRACE, r);
+}
+
+static void testExpandCharRanges(CuTest *tc) {
+    const char *re = "[1-3]*|[a-b]([^\nU-X][^\n])*";
+    const char *re2 = "a\\|b";
+
+    char *nre;
+    size_t nre_len;
+    int r;
+
+    r = fa_expand_char_ranges(re, strlen(re), &nre, &nre_len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, "[123]*|[ab]([^\nUVWX].)*", nre);
+    CuAssertIntEquals(tc, strlen(nre), nre_len);
+    free(nre);
+
+    r = fa_expand_char_ranges(re2, strlen(re2), &nre, &nre_len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, re2, nre);
+    free(nre);
+}
+
+static void testNoCase(CuTest *tc) {
+    struct fa *fa1 = make_good_fa(tc, "[a-z0-9]");
+    struct fa *fa2 = make_good_fa(tc, "B");
+    struct fa *fa, *exp;
+    int r;
+
+    fa_nocase(fa1);
+    fa = fa_intersect(fa1, fa2);
+    CuAssertPtrNotNull(tc, fa);
+    r = fa_equals(fa, fa2);
+    fa_free(fa);
+    CuAssertIntEquals(tc, 1, r);
+
+    fa = fa_concat(fa1, fa2);
+    exp = make_good_fa(tc, "[a-zA-Z0-9]B");
+    r = fa_equals(fa, exp);
+    fa_free(fa);
+    CuAssertIntEquals(tc, 1, r);
+}
+
+static void testExpandNoCase(CuTest *tc) {
+    const char *p1 = "aB";
+    const char *p2 = "[a-cUV]";
+    const char *p3 = "[^a-z]";
+    char *s;
+    size_t len;
+    int r;
+
+    r = fa_expand_nocase(p1, strlen(p1), &s, &len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, "[Aa][Bb]", s);
+    free(s);
+
+    r = fa_expand_nocase(p2, strlen(p2), &s, &len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, "[A-CUVa-cuv]", s);
+    free(s);
+
+    r = fa_expand_nocase(p3, strlen(p3), &s, &len);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, "[^A-Za-z]", s);
+    free(s);
+}
+
+int main(int argc, char **argv) {
+    if (argc == 1) {
+        char *output = NULL;
+        CuSuite* suite = CuSuiteNew();
+        CuSuiteSetup(suite, setup, teardown);
+
+        SUITE_ADD_TEST(suite, testBadRegexps);
+        SUITE_ADD_TEST(suite, testMonster);
+        SUITE_ADD_TEST(suite, testChars);
+        SUITE_ADD_TEST(suite, testManualAmbig);
+        SUITE_ADD_TEST(suite, testContains);
+        SUITE_ADD_TEST(suite, testIntersect);
+        SUITE_ADD_TEST(suite, testComplement);
+        SUITE_ADD_TEST(suite, testOverlap);
+        SUITE_ADD_TEST(suite, testExample);
+        SUITE_ADD_TEST(suite, testAmbig);
+        SUITE_ADD_TEST(suite, testAsRegexp);
+        SUITE_ADD_TEST(suite, testAsRegexpMinus);
+        SUITE_ADD_TEST(suite, testRangeEnd);
+        SUITE_ADD_TEST(suite, testNul);
+        SUITE_ADD_TEST(suite, testRestrictAlphabet);
+        SUITE_ADD_TEST(suite, testExpandCharRanges);
+        SUITE_ADD_TEST(suite, testNoCase);
+        SUITE_ADD_TEST(suite, testExpandNoCase);
+
+        CuSuiteRun(suite);
+        CuSuiteSummary(suite, &output);
+        CuSuiteDetails(suite, &output);
+        printf("%s\n", output);
+        free(output);
+        if (getenv("FAILMALLOC_INTERVAL") != NULL)
+            return EXIT_SUCCESS;
+        else
+            return suite->failCount;
+    }
+
+    for (int i=1; i<argc; i++) {
+        struct fa *fa;
+        int r;
+        if ((r = fa_compile(argv[i], strlen(argv[i]), &fa)) != REG_NOERROR) {
+            print_regerror(r, argv[i]);
+        } else {
+            dot(fa);
+            size_t s_len;
+            char *s;
+            fa_example(fa, &s, &s_len);
+            printf("Example for %s: %s\n", argv[i], s);
+            free(s);
+            char *re;
+            size_t re_len;
+            r = fa_as_regexp(fa, &re, &re_len);
+            if (r == 0) {
+                printf("/%s/ = /%s/\n", argv[i], re);
+                free(re);
+            } else {
+                printf("/%s/ = ***\n", argv[i]);
+            }
+            fa_free(fa);
+        }
+    }
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/lens-access.sh b/tests/lens-access.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-aliases.sh b/tests/lens-aliases.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-approx.sh b/tests/lens-approx.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-aptpreferences.sh b/tests/lens-aptpreferences.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-aptsource.sh b/tests/lens-aptsource.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-bbhosts.sh b/tests/lens-bbhosts.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-cgconfig.sh b/tests/lens-cgconfig.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-cgrules.sh b/tests/lens-cgrules.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-cobblermodules.sh b/tests/lens-cobblermodules.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-cobblersettings.sh b/tests/lens-cobblersettings.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-cron.sh b/tests/lens-cron.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-crypttab.sh b/tests/lens-crypttab.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-darkice.sh b/tests/lens-darkice.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-debctrl.sh b/tests/lens-debctrl.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-device_map.sh b/tests/lens-device_map.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-dhclient.sh b/tests/lens-dhclient.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-dhcpd.sh b/tests/lens-dhcpd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-dnsmasq.sh b/tests/lens-dnsmasq.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-dpkg.sh b/tests/lens-dpkg.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-dput.sh b/tests/lens-dput.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-ethers.sh b/tests/lens-ethers.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-exports.sh b/tests/lens-exports.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-fstab.sh b/tests/lens-fstab.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-gdm.sh b/tests/lens-gdm.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-group.sh b/tests/lens-group.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-grub.sh b/tests/lens-grub.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-hosts.sh b/tests/lens-hosts.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-httpd.sh b/tests/lens-httpd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-inetd.sh b/tests/lens-inetd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-inifile.sh b/tests/lens-inifile.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-inittab.sh b/tests/lens-inittab.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-interfaces.sh b/tests/lens-interfaces.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-iptables.sh b/tests/lens-iptables.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-json.sh b/tests/lens-json.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-keepalived.sh b/tests/lens-keepalived.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-krb5.sh b/tests/lens-krb5.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-ldap.sh b/tests/lens-ldap.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-limits.sh b/tests/lens-limits.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-login_defs.sh b/tests/lens-login_defs.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-logrotate.sh b/tests/lens-logrotate.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-lokkit.sh b/tests/lens-lokkit.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-mke2fs.sh b/tests/lens-mke2fs.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-modprobe.sh b/tests/lens-modprobe.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-modules_conf.sh b/tests/lens-modules_conf.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-monit.sh b/tests/lens-monit.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-multipath.sh b/tests/lens-multipath.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-mysql.sh b/tests/lens-mysql.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-nagioscfg.sh b/tests/lens-nagioscfg.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-nagiosobjects.sh b/tests/lens-nagiosobjects.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-nrpe.sh b/tests/lens-nrpe.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-nsswitch.sh b/tests/lens-nsswitch.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-ntp.sh b/tests/lens-ntp.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-odbc.sh b/tests/lens-odbc.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-openvpn.sh b/tests/lens-openvpn.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-pam.sh b/tests/lens-pam.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-passwd.sh b/tests/lens-passwd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-pbuilder.sh b/tests/lens-pbuilder.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-pg_hba.sh b/tests/lens-pg_hba.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-php.sh b/tests/lens-php.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-phpvars.sh b/tests/lens-phpvars.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-postfix_access.sh b/tests/lens-postfix_access.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-postfix_main.sh b/tests/lens-postfix_main.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-postfix_master.sh b/tests/lens-postfix_master.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-puppet.sh b/tests/lens-puppet.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-puppetfileserver.sh b/tests/lens-puppetfileserver.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-resolv.sh b/tests/lens-resolv.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-rsyncd.sh b/tests/lens-rsyncd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-rx.sh b/tests/lens-rx.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-samba.sh b/tests/lens-samba.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-securetty.sh b/tests/lens-securetty.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-services.sh b/tests/lens-services.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-shells.sh b/tests/lens-shells.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-shellvars.sh b/tests/lens-shellvars.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-shellvars_list.sh b/tests/lens-shellvars_list.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-slapd.sh b/tests/lens-slapd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-solaris_system.sh b/tests/lens-solaris_system.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-soma.sh b/tests/lens-soma.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-spacevars.sh b/tests/lens-spacevars.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-squid.sh b/tests/lens-squid.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-sshd.sh b/tests/lens-sshd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-sudoers.sh b/tests/lens-sudoers.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-sysconfig.sh b/tests/lens-sysconfig.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-sysctl.sh b/tests/lens-sysctl.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-syslog.sh b/tests/lens-syslog.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-test-1 b/tests/lens-test-1
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-vsftpd.sh b/tests/lens-vsftpd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-webmin.sh b/tests/lens-webmin.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-wine.sh b/tests/lens-wine.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-xinetd.sh b/tests/lens-xinetd.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-xml.sh b/tests/lens-xml.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-xorg.sh b/tests/lens-xorg.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/lens-yum.sh b/tests/lens-yum.sh
new file mode 100755 (executable)
index 0000000..1352907
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+# Run one lens test.
+# Derive names of inputs from the name of this script.
+
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+LENS_DIR=$abs_top_srcdir/lenses
+
+me=`echo "$0"|sed 's,.*/lens-\(.*\)\.sh$,\1,'`
+
+t=$LENS_DIR/tests/test_$me.aug
+exec augparse --nostdinc -I "$LENS_DIR" "$t"
diff --git a/tests/modules/fail_cf_two_nullable.aug b/tests/modules/fail_cf_two_nullable.aug
new file mode 100644 (file)
index 0000000..3376803
--- /dev/null
@@ -0,0 +1,4 @@
+module Fail_cf_two_nullable =
+
+(* Both branches of the union are nullable, making SPC ambiguous *)
+let rec spc = [ spc . label "x" ] | del /s*/ "s"
diff --git a/tests/modules/fail_concat_ctype.aug b/tests/modules/fail_concat_ctype.aug
new file mode 100644 (file)
index 0000000..a1fa2fe
--- /dev/null
@@ -0,0 +1,8 @@
+module Fail_concat_ctype =
+
+  (* Concatenation of /a|ab/ and /a|ba/ is ambiguous *)
+  let lns = store /a|ab/ . (del /a/ "x" | del /ba/ "y")
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_del_default_check.aug b/tests/modules/fail_del_default_check.aug
new file mode 100644 (file)
index 0000000..a76764d
--- /dev/null
@@ -0,0 +1,4 @@
+module Fail_del_default_check =
+
+  (* Not valid since the default value "NO" does not match /[a-z]+/ *)
+  let lns = del /[a-z]+/ "NO"
diff --git a/tests/modules/fail_del_maybe.aug b/tests/modules/fail_del_maybe.aug
new file mode 100644 (file)
index 0000000..d6b3e70
--- /dev/null
@@ -0,0 +1,7 @@
+(* The construct (del RE STR)? must raise an error from the typechecker *)
+(* since there's no way for the put of '?' to determine whether the del *)
+(* should be used or not - that decision is made by looking at the tree *)
+(* alone.                                                               *)
+module Fail_del_maybe =
+
+let indent = (del /[ \t]+/ " ")?
diff --git a/tests/modules/fail_double_maybe.aug b/tests/modules/fail_double_maybe.aug
new file mode 100644 (file)
index 0000000..99fef33
--- /dev/null
@@ -0,0 +1,8 @@
+module Fail_double_maybe =
+
+  (* We can not allow this: for a string " = " we have no way to know  *)
+  (* during put whether to use any of the lenses within the '?' or not *)
+  (* since we key that decision off either a tree label (there is none *)
+  (* here) or the presence of a value (which in this case may or may   *)
+  (* not be there)                                                     *)
+  let lns = (del /[ \t]*=/ "=" . (del /[ \t]*/ "" . store /[a-z]+/)? )?
diff --git a/tests/modules/fail_empty_module.aug b/tests/modules/fail_empty_module.aug
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/modules/fail_key_slash.aug b/tests/modules/fail_key_slash.aug
new file mode 100644 (file)
index 0000000..b774b64
--- /dev/null
@@ -0,0 +1,6 @@
+module Fail_key_slash =
+  let lns = key /[^]]+/
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_label_slash.aug b/tests/modules/fail_label_slash.aug
new file mode 100644 (file)
index 0000000..0f6a419
--- /dev/null
@@ -0,0 +1,6 @@
+module Fail_label_slash =
+  let lns = label "a/b"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_let_no_exp.aug b/tests/modules/fail_let_no_exp.aug
new file mode 100644 (file)
index 0000000..cfb3f70
--- /dev/null
@@ -0,0 +1,4 @@
+module Fail_let_no_exp =
+
+  (* This used to be accepted because of a grammar bug *)
+  let x =
diff --git a/tests/modules/fail_multi_key_concat.aug b/tests/modules/fail_multi_key_concat.aug
new file mode 100644 (file)
index 0000000..7a3b147
--- /dev/null
@@ -0,0 +1,3 @@
+module Fail_multi_key_concat =
+
+  let lns = key /a/ . key /b/
diff --git a/tests/modules/fail_multi_key_iter.aug b/tests/modules/fail_multi_key_iter.aug
new file mode 100644 (file)
index 0000000..c333626
--- /dev/null
@@ -0,0 +1,4 @@
+module Fail_multi_key_iter =
+
+  let lns = ( key /a/ ) *
+
diff --git a/tests/modules/fail_multi_store_concat.aug b/tests/modules/fail_multi_store_concat.aug
new file mode 100644 (file)
index 0000000..b1e4c70
--- /dev/null
@@ -0,0 +1,7 @@
+module Fail_multi_store_concat =
+
+  let lns = store /a/ . store /b/
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_multi_store_iter.aug b/tests/modules/fail_multi_store_iter.aug
new file mode 100644 (file)
index 0000000..d933ac9
--- /dev/null
@@ -0,0 +1,7 @@
+module Fail_multi_store_iter =
+
+  let lns = (store /a/)*
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_nocase_union.aug b/tests/modules/fail_nocase_union.aug
new file mode 100644 (file)
index 0000000..6b69fae
--- /dev/null
@@ -0,0 +1,3 @@
+module Fail_Nocase_Union =
+
+let lns = [ key /[a-z]+/i ] | [ key "UPPER" ]
diff --git a/tests/modules/fail_put_bad_value.aug b/tests/modules/fail_put_bad_value.aug
new file mode 100644 (file)
index 0000000..688c99c
--- /dev/null
@@ -0,0 +1,5 @@
+module Fail_put_bad_value =
+  
+  let lns = [ key /a/ . del /=/ "=" . store /[0-9]+/ ]
+
+  test lns put "a=20" after set "a" "foo" = ?
diff --git a/tests/modules/fail_recursion_multi_keys.aug b/tests/modules/fail_recursion_multi_keys.aug
new file mode 100644 (file)
index 0000000..f6d0c3c
--- /dev/null
@@ -0,0 +1,4 @@
+module Fail_recursion_multi_keys =
+
+(* This is the same as (key "a")* . store "x" *)
+let rec l = key "a" . l | store "x"
diff --git a/tests/modules/fail_regexp_minus_empty.aug b/tests/modules/fail_regexp_minus_empty.aug
new file mode 100644 (file)
index 0000000..28b51f9
--- /dev/null
@@ -0,0 +1,9 @@
+module Fail_regexp_minus_empty =
+
+  (* This fails since the result of the subtraction is the empty set *)
+  (* which we can not represent as a regular expression.             *)
+  let re = "a" - /[a-z]/
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_regexp_range_end.aug b/tests/modules/fail_regexp_range_end.aug
new file mode 100644 (file)
index 0000000..67ea404
--- /dev/null
@@ -0,0 +1,3 @@
+module Fail_regexp_range_end =
+
+  let lns = [ key /[1-0]/ ]
diff --git a/tests/modules/fail_self_ref_module.aug b/tests/modules/fail_self_ref_module.aug
new file mode 100644 (file)
index 0000000..57cbe28
--- /dev/null
@@ -0,0 +1,8 @@
+module Fail_self_ref_module =
+
+  let b = Fail_self_ref_module.a
+  let a = "a"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_shadow_union.aug b/tests/modules/fail_shadow_union.aug
new file mode 100644 (file)
index 0000000..aa63690
--- /dev/null
@@ -0,0 +1,6 @@
+module Fail_shadow_union =
+  let lns = store /[a-z]+/ | del /(abc|xyz)/ "never used"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/fail_xform_orphan_value.aug b/tests/modules/fail_xform_orphan_value.aug
new file mode 100644 (file)
index 0000000..f164d22
--- /dev/null
@@ -0,0 +1,10 @@
+module Fail_xform_orphan_value =
+
+  let lns = store /a/
+
+  let xfm = transform lns (incl "/dev/null")
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_array.aug b/tests/modules/pass_array.aug
new file mode 100644 (file)
index 0000000..7a4da4c
--- /dev/null
@@ -0,0 +1,17 @@
+(* Check that we properly discard skeletons when we shift subtrees   *)
+(* across lenses. The test shifts a subtree parsed with SND to one   *)
+(* that is put with FST. Since the two have different skeleton types *)
+(* we need to ignore the skeleton that comes with it.                *)
+module Pass_array =
+
+  let array = 
+    let array_value = store /[a-z0-9]+/ in
+    let fst = seq "values" . array_value . del /[ \t]+/ "\t" in
+    let snd = seq "values" . array_value in
+    del "(" "(" . counter "values" .
+    [ fst ] * . [ snd ] . del ")" ")"
+
+  let lns = [ key /[a-z]+/ . del "=" "=" . array ]
+
+  test lns put "var=(v1 v2)" after
+    set "var/3" "v3" = "var=(v1 v2\tv3)"
diff --git a/tests/modules/pass_bad_tests.aug b/tests/modules/pass_bad_tests.aug
new file mode 100644 (file)
index 0000000..563402e
--- /dev/null
@@ -0,0 +1,17 @@
+(* Make sure that nonsensical tests fail properly instead of *)
+(* causing a segfault (see bug #129)                         *)
+module Pass_bad_tests =
+
+ let k = [ key "a" ]*
+
+ test k put "aaa" after insb "a" "/a[4]" = *
+ test k put "aaa" after insa "a" "/a[4]" = *
+
+ test k put "aa" after set "x[func()]" "foo" = *
+
+ (* Make sure we reset internal error flags after the above *)
+ test k get "aa" = { "a" } { "a" }
+
+ test k put "aa" after rm "/a[func()]" = *
+
+ test k put "aa" after clear "/a[func()]" = *
diff --git a/tests/modules/pass_concat_atype.aug b/tests/modules/pass_concat_atype.aug
new file mode 100644 (file)
index 0000000..04301ae
--- /dev/null
@@ -0,0 +1,18 @@
+module Pass_concat_atype =
+
+  (* This passes both the ctype and atype check for unambiguous  *)
+  (* concatenation because the STORE's keep everything copacetic.*)
+  (* If we would only look at tree labels, we'd get a type error *)
+  (* in the PUT direction, because we couldn't tell how to split *)
+  (* the tree                                                    *)
+  (*    { "a" = .. } { "b" = .. } { "a" = .. }                   *)
+  (* solely by looking at tree labels.                           *)
+
+  let ab = [ key /a/ . store /1/ ] . ([ key /b/ . store /2/ ]?)
+  let ba = ([ key /b/ . store /3/ ])? . [ key /a/ . store /4/ ]
+  let lns = ab . ba
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_cont_line.aug b/tests/modules/pass_cont_line.aug
new file mode 100644 (file)
index 0000000..a914cc9
--- /dev/null
@@ -0,0 +1,19 @@
+module Pass_cont_line =
+
+(* Parse a list of words where the list can stretch over multiple lines.
+   Mostly there to demonstrate how to deal with continuation lines. *)
+
+let list_elt = [ label "element" . store /[a-z]+/ ]
+
+let ws_cont = /([ \t]+|[ \t]*\\\\\n[ \t]*)/ 
+
+let sep = del ws_cont " "
+let eol = del /[ \t]*\n/ "\n"
+
+let list = list_elt . ( sep . list_elt )* . eol
+
+let exp_tree = { "element" = "a" } { "element" = "b" }
+
+test list get "a  b\n"      = exp_tree
+test list get "a  \\\n b\n" = exp_tree
+test list get "a\\\nb\n"    = exp_tree
diff --git a/tests/modules/pass_empty_put.aug b/tests/modules/pass_empty_put.aug
new file mode 100644 (file)
index 0000000..866f8d6
--- /dev/null
@@ -0,0 +1,8 @@
+module Pass_empty_put =
+
+  let eol = del "\n" "\n"
+  let lns = [ key /[a-z]+/ . del /[ \t]+/ " " . store /[a-z]+/ . eol ]*
+
+  test lns put "" after
+    set "entry" "value"
+  = "entry value\n"
diff --git a/tests/modules/pass_empty_regexp.aug b/tests/modules/pass_empty_regexp.aug
new file mode 100644 (file)
index 0000000..45dce0b
--- /dev/null
@@ -0,0 +1,5 @@
+module Pass_empty_regexp =
+
+let l = [ del // "" . key /[a-z]+/ ]
+
+test l get "abc" = { "abc" }
diff --git a/tests/modules/pass_ins_test.aug b/tests/modules/pass_ins_test.aug
new file mode 100644 (file)
index 0000000..a173e7d
--- /dev/null
@@ -0,0 +1,48 @@
+module Pass_ins_test =
+
+  let eol = del "\n" "\n"
+  let word = /[a-z0-9]+/
+  let sep = del /[ \t]+/ " "
+  let lns = [ key word . sep . store word . eol ]*
+
+  let s = "key value1\nkey value2\n"
+  let t = "key value1\nnewkey newvalue\nkey value2\n"
+
+  test lns put s after
+    insa "newkey" "key[1]";
+    set "newkey" "newvalue"
+  = t
+
+  test lns put s after
+    insb "newkey" "key[2]";
+    set "newkey" "newvalue"
+  = t
+
+  test lns put s after
+    insb "newkey" "key[1]";
+    set "newkey" "newvalue"
+  = "newkey newvalue\n" . s
+
+  (* Now test insertion inside the tree *)
+
+  let lns2 = [ key word . eol . lns ]
+
+  let s2 = "outer\n" . s
+  let t2 = "outer\n" . t
+
+  test lns2 put s2 after
+    insa "newkey" "outer/key[1]";
+    set "outer/newkey" "newvalue"
+  = t2
+
+  test lns2 put s2 after
+    insb "newkey" "outer/key[2]";
+    set "outer/newkey" "newvalue"
+  = t2
+
+
+  test lns2 put s2 after
+    insb "newkey" "outer/key[1]";
+    set "outer/newkey" "newvalue"
+  = "outer\nnewkey newvalue\n" . s
+
diff --git a/tests/modules/pass_iter_atype.aug b/tests/modules/pass_iter_atype.aug
new file mode 100644 (file)
index 0000000..afaeaed
--- /dev/null
@@ -0,0 +1,14 @@
+module Pass_iter_atype =
+
+  (* Similar to the Pass_concat_atype check; verify that the          *)
+  (* typechecker takes tree values into account in the PUT direction, *)
+  (* and not just tree labels.                                        *)
+
+  let a (r:regexp) = [ key /a/ . store r ]
+  let aa = (a /1/) . (a /2/)
+  let lns = ((a /3/) | aa)*
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_iter_key_union.aug b/tests/modules/pass_iter_key_union.aug
new file mode 100644 (file)
index 0000000..10c7921
--- /dev/null
@@ -0,0 +1,13 @@
+module Pass_iter_key_union =
+
+  (* We used to typecheck the atype of this as (a|b/)*               *)
+  (* which is wrong and leads to spurious ambiguous iteration errors *)
+  (* The right atype is ((a|b)/)*                                    *)
+  let l1 = [ key /a|b/ . store /x/ ]
+  let l2 = [ key /ab/ . store /y/ ]
+
+  let lns = (l1 | l2)*
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_label_value.aug b/tests/modules/pass_label_value.aug
new file mode 100644 (file)
index 0000000..4df5832
--- /dev/null
@@ -0,0 +1,27 @@
+module Pass_label_value =
+
+let l = [ label "label" . value "value" ]
+
+test l get "" = { "label" = "value" }
+
+test l put "" after rm "/foo" = ""
+
+let word = /[^ \t\n]+/
+let ws = del /[ \t]+/ " "
+let chain = [ key "RewriteCond" . ws .
+              [ label "eq" . store word ] . ws . store word .
+              ([ label "chain_as" . ws . del "[OR]" "[OR]" . value "or"]
+              |[ label "chain_as" . value "and" ]) ]
+
+test chain get "RewriteCond %{var} val [OR]" =
+  { "RewriteCond" = "val"
+    { "eq" = "%{var}" }
+    { "chain_as" = "or" } }
+
+test chain get "RewriteCond %{var} lue" =
+  { "RewriteCond" = "lue"
+    { "eq" = "%{var}" }
+    { "chain_as" = "and" } }
+
+test chain put "RewriteCond %{var} val [OR]" after
+  set "/RewriteCond/chain_as" "and" = "RewriteCond %{var} val"
diff --git a/tests/modules/pass_lens_plus.aug b/tests/modules/pass_lens_plus.aug
new file mode 100644 (file)
index 0000000..75fdf25
--- /dev/null
@@ -0,0 +1,11 @@
+module Pass_lens_plus =
+
+  let a = [ key /a/ ]
+  let lns = a+
+
+  test lns put "a" after rm "x" = "a"
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_let_exp.aug b/tests/modules/pass_let_exp.aug
new file mode 100644 (file)
index 0000000..ca3f671
--- /dev/null
@@ -0,0 +1,21 @@
+(* Test let expressions *)
+module Pass_let_exp =
+
+  (* This definition is insanely roundabout; it's written that way *)
+  (* since we want to exercise LET expressions                     *)
+  let lns =
+    let lbl = "a" in
+    let spc = " " in
+    let del_spaces (s:string) = del spc+ s in
+    let del_str (s:string) = del s s in
+    let store_delim (ldelim:string)
+                    (rdelim:string) (val:regexp) =
+      del_str ldelim . store val . del_str rdelim in
+    [ label lbl . del_spaces " " . store_delim "(" ")" /[a-z]+/ ]
+
+  test lns get "  (abc)" = { "a" = "abc" }
+
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_mixed_recursion.aug b/tests/modules/pass_mixed_recursion.aug
new file mode 100644 (file)
index 0000000..c49ac48
--- /dev/null
@@ -0,0 +1,30 @@
+module Pass_Mixed_Recursion =
+
+(* Test that using a recursive lens as part of another lens works *)
+
+let rec r = [ key "a" . r ] | [ key "a" . store "x" ]
+
+(* Star a recursive lens *)
+let star = r*
+
+test star get "aax" = { "a" { "a" = "x" } }
+test star put "aax" after rm "/nothing" = "aax"
+
+test star get "axax" = { "a" = "x" } { "a" = "x" }
+test star put "axaaxax" after rm "/a[2]" = "axax"
+
+(* Use a starred recursive lens in a more complicated construct *)
+let top = [ label "top" . r* . value "high" ]
+
+test top get "axaax" = { "top" = "high" { "a" = "x" } { "a" { "a" = "x" } } }
+test top put "axaax" after rm "/top/a[1]" = "aax"
+
+(* Use a recursive lens in a union *)
+let union = (r | [ key "b" . store /[a-z]/ ])*
+
+test union get "aaxbyax" =
+  { "a" { "a" = "x" } } { "b" = "y" } { "a" = "x" }
+test union put "aaxbyax" after
+  set "/b[2]" "z" = "aaxbyaxbz"
+test union put "aaxbyax" after
+  set "/b[2]" "z"; rm "/b[1]" = "aaxaxbz"
diff --git a/tests/modules/pass_nested_sections.aug b/tests/modules/pass_nested_sections.aug
new file mode 100644 (file)
index 0000000..7b51bc2
--- /dev/null
@@ -0,0 +1,54 @@
+module Pass_nested_sections =
+
+let word = /[a-zA-Z0-9]+/
+let ws = /[ \t]*/
+let nl = /\n/
+
+let eol = del (ws . nl) "\n"
+let eq = del (ws . "=" . ws) "="
+let lbr = del (ws . "{" . ws . nl) " {\n"
+let rbr = del (ws . "}" . ws . nl) "}\n"
+let indent = del ws ""
+
+let entry = [ indent . key word . eq . store word . eol ]
+
+let rec lns =
+  let sec = [ indent . key word . lbr . lns . rbr ] in
+  (sec | entry)+
+
+
+test lns get "key = value\n" = { "key" = "value" }
+
+test lns get "section {
+  key1 = v1
+  key2 = v2
+  section {
+    section {
+      key4 = v4
+    }
+  }
+  section {
+    key5 = v5
+  }
+}\n" =
+  { "section"
+    { "key1" = "v1" }
+    { "key2" = "v2" }
+    { "section" { "section" { "key4" = "v4" } } }
+    { "section" { "key5" = "v5" } } }
+
+
+test lns get "section {
+  section {
+    key2 = v2
+  }
+}
+section {
+  key3 = v3
+}
+" =
+  { "section"
+    { "section"
+      { "key2" = "v2" } } }
+  { "section"
+    { "key3" = "v3" } }
diff --git a/tests/modules/pass_nocase.aug b/tests/modules/pass_nocase.aug
new file mode 100644 (file)
index 0000000..6d254a3
--- /dev/null
@@ -0,0 +1,19 @@
+module Pass_nocase =
+
+let lns1 =
+  let re = /[a-z]+/i - "Key" in
+  [ label "1" . store re ] | [ label "2" . store "Key" ]
+
+test lns1 get "Key" = { "2" = "Key" }
+test lns1 get "key" = { "1" = "key" }
+test lns1 get "KEY" = { "1" = "KEY" }
+test lns1 get "KeY" = { "1" = "KeY" }
+
+let lns2 =
+  let re = /[a-z]/i - /Key/i in
+  [ label "1" . store re ] | [ label "2" . store /Key/i ]
+
+test lns2 get "Key" = { "2" = "Key" }
+test lns2 get "key" = { "2" = "key" }
+test lns2 get "KEY" = { "2" = "KEY" }
+test lns2 get "KeY" = { "2" = "KeY" }
diff --git a/tests/modules/pass_prefix_union.aug b/tests/modules/pass_prefix_union.aug
new file mode 100644 (file)
index 0000000..d9c2473
--- /dev/null
@@ -0,0 +1,8 @@
+module Pass_prefix_union =
+
+let eol = del "\n" "\n"
+let pair (k:regexp) (v:regexp) = [ key k . del "=" "=" . store v . eol ]
+
+let lns = pair "a" "a" | pair "a" "a" . pair "b" "b"
+
+test lns get "a=a\nb=b\n" = { "a" = "a" } { "b" = "b" }
diff --git a/tests/modules/pass_put_bad_label.aug b/tests/modules/pass_put_bad_label.aug
new file mode 100644 (file)
index 0000000..7150588
--- /dev/null
@@ -0,0 +1,9 @@
+module Pass_put_bad_label =
+
+  let entry = [ key /[a-z]+/ . del /=/ "=" . store /[0-9]+/ . del "\n" "\n" ]
+
+  let lns = [ key /[A-Z]+/ . del "\n" "\n" . entry* ]
+              
+  test lns put "SECTION\na=1\nz=26\n" after 
+    insa "B" "/SECTION/a";
+    set "/SECTION/B" "2" = *
diff --git a/tests/modules/pass_put_invalid_star.aug b/tests/modules/pass_put_invalid_star.aug
new file mode 100644 (file)
index 0000000..f3eaf72
--- /dev/null
@@ -0,0 +1,15 @@
+module Pass_put_invalid_star =
+
+  let lns = [ key /[a-z]+/ . del "=" "=" . store /[0-9]+/ . del "\n" "\n" ]*
+
+  test lns put "a=1\nb=2\n" after
+    set "c2" "3"
+  = *
+
+  test lns put "a=1\n" after
+    insb "x1" "a" ;
+    set "x1" "1"
+  = *
+
+
+
diff --git a/tests/modules/pass_quote_quote.aug b/tests/modules/pass_quote_quote.aug
new file mode 100644 (file)
index 0000000..98ce3df
--- /dev/null
@@ -0,0 +1,13 @@
+module Pass_quote_quote =
+
+  let str = "\"A quote\""
+
+  let delq = del /"/ "\""
+
+  let lns = [ delq . key /[a-zA-Z ]+/ . delq ] (* " Make emacs relax *)
+
+  test lns get str = { "A quote" }
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_read_file.aug b/tests/modules/pass_read_file.aug
new file mode 100644 (file)
index 0000000..f07250d
--- /dev/null
@@ -0,0 +1,15 @@
+module Pass_read_file =
+
+(* This is a roundabout way to test that Sys.getenv and Sys.read_file *)
+(* work. Since we don't have a generic unit testing facility, we need *)
+(* to phrase things in terms of a lens test.                          *)
+
+let fname = (Sys.getenv "abs_top_srcdir") . "/tests/root/pairs.txt"
+let str = (Sys.read_file fname)
+let lns = [ key /[a-z0-9]*/ . del /[ \t]*=[ \t]*/ "="
+    . store /[^ \t\n]*/ . del /\n/ "\n" ] *
+
+test lns get str =
+  { "key1" = "value1" }
+  { "key2" = "value2" }
+  { "key3" = "value3" }
diff --git a/tests/modules/pass_regexp_minus.aug b/tests/modules/pass_regexp_minus.aug
new file mode 100644 (file)
index 0000000..bf9fe93
--- /dev/null
@@ -0,0 +1,22 @@
+module Pass_regexp_minus =
+
+  let word = /[a-z]+/
+  let no_baseurl = word - "baseurl"
+
+  let eq = del "=" "="
+
+  let l1 = [ key no_baseurl . eq . store /[a-z]+/ ]
+  let l2 = [ key "baseurl" . eq . store /[0-9]+/ ]
+
+  let lns = ((l1 | l2) . del "\n" "\n")*
+
+  test lns get "foo=abc\nbaseurl=123\n" = 
+    { "foo" = "abc" }
+    { "baseurl" = "123" }
+
+  test lns get "baseurl=abc\n" = *      
+  
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_self_ref_module.aug b/tests/modules/pass_self_ref_module.aug
new file mode 100644 (file)
index 0000000..7792c30
--- /dev/null
@@ -0,0 +1,8 @@
+module Pass_self_ref_module =
+
+  let b = "b"
+  let a = Pass_self_ref_module.b
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_simple_recursion.aug b/tests/modules/pass_simple_recursion.aug
new file mode 100644 (file)
index 0000000..664ed3e
--- /dev/null
@@ -0,0 +1,97 @@
+module Pass_simple_recursion =
+
+let rec lns =
+  let lbr = del "<" "<" in
+  let rbr = del ">" ">" in
+  let k   = [ key /[a-z]+/ ] in
+  let node = [ label "S" . lbr . lns . rbr ] in
+  let b = node | k in
+  b*
+
+(* let rec lns = [ key "a" . lns ] | [ key "a" ] *)
+test lns get "<x>" = { "S" { "x" } }
+
+test lns put "<x>" after rm "nothing" = "<x>"
+
+test lns put "<<x>>" after rm "nothing" = "<<x>>"
+
+test lns put "<x><x>" after rm "/S[2]" = "<x>"
+
+test lns put "<x>" after clear "/S/S/S/x" = "<x<<x>>>"
+
+
+(* Start with { "S" { "x" } } and modify to { "S" { "S" { "x" } } } *)
+test lns put "<x>" after
+  insa "S" "/S";
+  clear "/S[2]/S/x";
+  rm "/S[1]" = "<<x>>"
+
+test lns get "<<<x><x>><x>><x>" =
+  { "S"
+    { "S"
+      { "S" { "x" } }
+      { "S" { "x" } } }
+    { "S" { "x" } } }
+  { "S" { "x" } }
+
+test lns put "<<<x><x>><x>><x>" after rm "/S[1]/S[1]/S[1]" =
+  "<<<x>><x>><x>"
+
+
+test lns get "<<yo>><zulu>" =
+  { "S" { "S" { "yo" } } }
+  { "S" { "zulu" } }
+
+(* Some pathological tests for nullable lenses *)
+
+let rec prim_nullable = [ prim_nullable . key /x/ ] | del /s*/ ""
+test prim_nullable get "sx" = { "x" }
+test prim_nullable get "x" = { "x" }
+
+let rec ambig = [ ambig . label "x" ] | del /s+/ "s"
+test ambig get "" = *
+test ambig get "s" = *
+
+(* Test link filtering. These tests cause seemingly ambiguous parses, which
+ * need to be disambiguated by filtering links in the Earley graph. See
+ * section 5.3 in the paper *)
+let rec unamb1 = [ label "x" . unamb1 . store /y/ ] | [ key "z" ]
+test unamb1 get "zyy" = { "x" = "y" { "x" = "y" { "z" } } }
+
+
+let rec unamb2 = del /u*/ "" . [ unamb2 . key /x/ ] | del /s*/ ""
+test unamb2 get "sx" = { "x" }
+test unamb2 get "x" = { "x" }
+
+(* Test proper handling of '?'; bug #119 *)
+let rec maybe = [ del "a" "a" . maybe . del "b" "b" ]?
+test maybe get "aabb" = { { } }
+
+(* Test proper handling of '?'; bug #180 *)
+let rec maybe2 = [ del "a" "a" . maybe2 ]?
+test maybe2 get "aa" = { { } }
+
+let rec maybe3 = [ maybe3 . del "a" "a" ]?
+test maybe3 get "aa" = { { } }
+
+let rec maybe4 = [ del "a" "a" ] . maybe4?
+test maybe4 get "aa" = { } { }
+
+let rec maybe5 = maybe5? . [ del "a" "a" ]
+test maybe5 get "aa" = { } { }
+
+(* Test that parses ending with a SCAN are accepted; bug #126 *)
+let dels (s:string) = del s s
+let d2 = del /b*/ ""
+let sec (body:lens) = [ key /a*/ . dels "{" . body . dels "}"]*
+let rec sec_complete = sec sec_complete
+let lns2 = sec_complete . d2
+test lns2 get "a{}b" = { "a" }
+
+(* Test stack handling with both parsing direction; bug #136 *)
+let idr = [ key /[0-9]+/ . del /z+/ "z" . store /[0-9]+/ . del /a+/ "a" ]
+let rec idr_left = idr_left? . idr
+let rec idr_right = idr . idr_right?
+let input = "1zz2aa33zzz44aaa555zzzz666aaaa"
+test idr_left get input = { "1" = "2" }{ "33" = "44" }{ "555" = "666" }
+test idr_right get input = { "1" = "2" }{ "33" = "44" }{ "555" = "666" }
diff --git a/tests/modules/pass_square.aug b/tests/modules/pass_square.aug
new file mode 100644 (file)
index 0000000..0185031
--- /dev/null
@@ -0,0 +1,114 @@
+module Pass_square =
+
+(*  Utilities lens *)
+let dels (s:string) = del s s
+
+(************************************************************************
+ *                           Regular square lens
+ *************************************************************************)
+
+(* Simplest square lens *)
+let s = store /[yz]/
+let sqr0 = [ square "x" s ] *
+test sqr0 get "xyxxyxxyx" = { "x" = "y" }{ "x" = "y" }{ "x" = "y" }
+test sqr0 put "xyx" after set "/x[3]" "z" = "xyxxzx"
+
+(* test mismatch tag *)
+test sqr0 get "xya" = *
+
+(* Test regular expression matching with multiple groups *)
+let body = del /([f]+)([f]+)/ "ff" . del /([g]+)([g]+)/ "gg"
+let sqr1 = [ square /([a-b]*)([a-b]*)([a-b]*)/ body . del /([x]+)([x]+)/ "xx" ] *
+
+test sqr1 get "aaffggaaxxbbffggbbxx" = { "aa" }{ "bb" }
+test sqr1 get "affggaxx" = { "a" }
+test sqr1 put "affggaxx" after clear "/b" = "affggaxxbffggbxx"
+
+(* Test XML like elements up to depth 2 *)
+let b = del ">" ">" . del /[a-z ]*/ "" . del "</" "</"
+let xml = [ del "<" "<" . square /[a-z]+/ b . del ">" ">" ] *
+
+let b2 = del ">" ">" . xml . del "</" "</"
+let xml2 = [ del "<" "<" . square /[a-z]+/ b2 . del ">" ">" ] *
+
+test xml get "<a></a><b></b>" = { "a" }{ "b" }
+
+(* test error on mismatch tag *)
+test xml get "<a></a><b></c>" = *
+
+(* test get nested tags of depth 2 *)
+test xml2 get "<a><b></b><c></c></a>" =
+  { "a"
+    { "b" }
+    { "c" }
+  }
+
+(* test nested put of depth 2 *)
+test xml2 put "<a></a>" after clear "/x/y" = "<a></a><x><y></y></x>"
+
+(* test nested put of depth 3 : should fail *)
+test xml2 put "<a></a>" after clear "/x/y/z" = *
+
+(************************************************************************
+ *                        Recursive square lens
+ *************************************************************************)
+
+(* Basic element *)
+let xml_element (body:lens) =
+    let g = del ">" ">" . body . del "</" "</" in
+        [ del "<" "<" . square /[a-z]+/ g . del ">" ">" ] *
+
+let rec xml_rec = xml_element xml_rec
+
+test xml_rec get "<a><b><c><d><e></e></d></c></b></a>" =
+  { "a"
+    { "b"
+      { "c"
+        { "d"
+          { "e" }
+        }
+      }
+    }
+  }
+
+test xml_rec get "<a><b></b><c></c><d></d><e></e></a>" =
+  { "a"
+    { "b" }
+    { "c" }
+    { "d" }
+    { "e" }
+  }
+
+test xml_rec put "<a></a><b><c></c></b>" after clear "/x/y/z" = "<a></a><b><c></c></b><x><y><z></z></y></x>"
+
+(* mismatch tag *)
+test xml_rec get "<a></c>" = *
+test xml_rec get "<a><b></b></c>" = *
+test xml_rec get "<a><b></c></a>" = *
+
+(* test ctype_nullable and typecheck *)
+let rec z = [ square "ab" z? ]
+test z get "abab" = { "ab" }
+
+(* test tip handling when using store inside body *)
+let c (body:lens) =
+    let sto = store "c" . body* in
+        [ square "ab" sto ]
+
+let rec cc = c cc
+
+test cc get "abcabcabab" =
+  { "ab" = "c"
+    { "ab" = "c" }
+  }
+
+(* test correct put behavior *)
+let input3 = "aaxyxbbaaaxyxbb"
+let b3 = dels "y"
+let sqr3 = [ del /[a]*/ "a" . square /[x]/ b3 . del /[b]*/ "b" ]*
+test sqr3 get input3 = { "x" }{ "x" }
+test sqr3 put input3 after clear "/x[1]" = input3
+
+let b4 = del "x" "x"
+let rec sqr4 = [ del /[a]+/ "a" . square /[b]|[c]/ (b4|sqr4) ]
+test sqr4 put "aabaaacxcb" after rm "x" = "aabaaacxcb"
diff --git a/tests/modules/pass_store_maybe.aug b/tests/modules/pass_store_maybe.aug
new file mode 100644 (file)
index 0000000..6ad5aec
--- /dev/null
@@ -0,0 +1,19 @@
+(* Test that the '?' operator behaves properly when it contains only   *)
+(* a store. For this to work, the put for '?' has to take into account *)
+(* whether the current tree node has a value associated with it or not *)
+module Pass_store_maybe =
+
+  let lns = [ key /[a-z]+/ . del / +/ " " . (store /[0-9]+/) ? ]
+
+  test lns put "key " after rm "noop" = "key "
+  test lns put "key " after set "key" "42" = "key 42"
+  test lns put "key 42" after set "key" "13" = "key 13"
+
+  (* Convoluted way to make the value for "key" NULL *)
+  test lns put "key 42" after insa "key" "key"; rm "key[1]" = "key "
+
+  (* Check that we correctly restore the DEL if we choose to go into the *)
+  (* '?' operator instead of doing a create and using the "--" default   *)
+  let ds = [ key /[a-z]+/ . (del /[ -]*/ "--" . store /[0-9]+/) ? ]
+
+  test ds put "key 0" after rm "noop" = "key 0"
diff --git a/tests/modules/pass_strip_quotes.aug b/tests/modules/pass_strip_quotes.aug
new file mode 100644 (file)
index 0000000..7e24b31
--- /dev/null
@@ -0,0 +1,26 @@
+(* Demonstrate how quotes can be stripped from values.            *)
+(* Values can be enclosed in single or double quotes, if they     *)
+(* contain spaces they _have_ to be enclosed in quotes. Since     *)
+(* everything's regular, we can't actually match a closing quote  *)
+(* to the opening quote, so "hello' will be accepted, too.        *)
+
+module Pass_strip_quotes =
+
+  let nuttin = del /(""|'')?/ "''"
+  let bare = del /["']?/ "" . store /[a-zA-Z0-9]+/ . del /["']?/ ""
+  let quoted = del /["']/ "'" . store /.*[ \t].*/ . del /["']/ "'"
+
+  let lns = [ label "foo" . bare ]
+    | [ label "foo" . quoted ]
+    | [ label "foo" . nuttin ]
+
+  test lns get "'hello'" = { "foo" = "hello" }
+  test lns get "'hello world'" = { "foo" = "hello world" }
+
+  let hw = "'hello world'"
+  let set_hw = set "/foo" "hello world"
+  test lns put "hello" after set_hw = hw
+  test lns put "'hello world'" after set "/foo" "hello" = "'hello'"
+
+  test lns put "" after set_hw = hw
+  test lns put "\"\"" after set_hw = hw
diff --git a/tests/modules/pass_subtree_growth.aug b/tests/modules/pass_subtree_growth.aug
new file mode 100644 (file)
index 0000000..efbf3a2
--- /dev/null
@@ -0,0 +1,20 @@
+module Pass_subtree_growth =
+
+  (* Make sure that a subtree that is not the lowest one does indeed *)
+  (* grow the tree, instead of just setting the label of an enclosed *)
+  (* subtree. This is only a problem if the enclosed subtree does    *)
+  (* not have a label                                                *)
+
+  let lns = [ label "outer" . [ store /a/ ] ]
+
+  (* The improper result is { "outer" = "a" } *)
+  test lns get "a" = { "outer" { = "a" } }
+
+  (* This produces a tree { "outer" = "b" { = "a" } }         *)
+  (* but the value for "outer" is never used in put           *)
+  (* (That should probably be flagged as an error separately) *)
+  test lns put "a" after set "outer" "b" = "a"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_switch_value_regexp.aug b/tests/modules/pass_switch_value_regexp.aug
new file mode 100644 (file)
index 0000000..b2726c0
--- /dev/null
@@ -0,0 +1,9 @@
+module Pass_switch_value_regexp =
+
+  let lns =  ([ key /u/ ] . [ key /b/ . store /[0-9]+/ ])
+           | ([ key /v/ ] . [ key /b/ . store /[a-z]+/ ])
+
+  test lns get "ub42" = { "u" } { "b" = "42" }
+  test lns get "vbxy" = { "v" } { "b" = "xy" }
+  test lns get "ubxy" = *
+  test lns get "vb42" = *
diff --git a/tests/modules/pass_union_atype.aug b/tests/modules/pass_union_atype.aug
new file mode 100644 (file)
index 0000000..ea87709
--- /dev/null
@@ -0,0 +1,13 @@
+(* Test that we take the right branch in a union based solely on *)
+(* differing values associated with a tree node                  *)
+module Pass_union_atype =
+  let del_str (s:string) = del s s
+
+  let lns = [ key /a/ . store /b/ . del_str " (l)" ]
+          | [ key /a/ . store /c/ . del_str " (r)" ]
+
+  test lns put "ac (r)" after set "a" "b" = "ab (l)"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_union_atype_298.aug b/tests/modules/pass_union_atype_298.aug
new file mode 100644 (file)
index 0000000..36d8cc3
--- /dev/null
@@ -0,0 +1,12 @@
+module Pass_union_atype_298 =
+  (* The key calculation in union would cause the outer subtree to have  *)
+  (* an atype of %r{a/(/|/)}, which is wrong since the two subtrees in   *)
+  (* the union do not contribute to the key of the outer subtree         *)
+  (* The tree produced by this lens has schema                           *)
+  (*   { /a/ ({ = /b/ }|{}) }                                            *)
+  (* which is prefectly legal                                            *)
+  let lns = [ key /a/ . ([ store /b/] | del /c/ "c") ]
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_union_nokey.aug b/tests/modules/pass_union_nokey.aug
new file mode 100644 (file)
index 0000000..084cf8c
--- /dev/null
@@ -0,0 +1,4 @@
+module Pass_union_nokey =
+
+let lns = [ key /[a-z]+/ . store /[0-9]+/
+          | [ key /[a-z]+/ ] . del /[ ]+/ " " ]
diff --git a/tests/modules/pass_union_select_star.aug b/tests/modules/pass_union_select_star.aug
new file mode 100644 (file)
index 0000000..f5267c2
--- /dev/null
@@ -0,0 +1,16 @@
+module Pass_union_select_star =
+
+  (* Check that in unions the right branch is selected, even if the *)
+  (* first branch matches nothing.                                  *)
+  let a = [ key /a/ ]
+  let b = [ key /b/ ]
+
+  let lns = (a* | b+)
+
+  (* The 'rm "x"' is a noop; the grammar won't let us do a put test *)
+  (* without any commands                                           *)
+  test lns put "b" after rm "x" = "b"
+
+(* Local Variables: *)
+(* mode: caml       *)
+(* End:             *)
diff --git a/tests/modules/pass_unit.aug b/tests/modules/pass_unit.aug
new file mode 100644 (file)
index 0000000..ea865bb
--- /dev/null
@@ -0,0 +1,6 @@
+module Pass_Unit =
+
+(* The unit literal *)
+let _ = ()
+(* Check that composition allows units on the left *)
+let _ = () ; () ; (); "something"
diff --git a/tests/root/boot/grub/grub.conf b/tests/root/boot/grub/grub.conf
new file mode 100644 (file)
index 0000000..adb02f5
--- /dev/null
@@ -0,0 +1,31 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE:  You have a /boot partition.  This means that
+#          all kernel and initrd paths are relative to /boot/, eg.
+#          root (hd0,0)
+#          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+#          initrd /initrd-version.img
+#boot=/dev/sda
+default=0
+timeout=5
+splashimage=(hd0,0)/grub/splash.xpm.gz
+hiddenmenu
+title Fedora (2.6.24.4-64.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.4-64.fc8.img
+title Fedora (2.6.24.3-50.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-50.fc8.img
+title Fedora (2.6.21.7-3.fc8xen)
+       root (hd0,0)
+       kernel /xen.gz-2.6.21.7-3.fc8
+       module /vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00
+       module /initrd-2.6.21.7-3.fc8xen.img
+title Fedora (2.6.24.3-34.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-34.fc8.img
+        savedefault
diff --git a/tests/root/boot/grub/menu.lst b/tests/root/boot/grub/menu.lst
new file mode 100644 (file)
index 0000000..adb02f5
--- /dev/null
@@ -0,0 +1,31 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE:  You have a /boot partition.  This means that
+#          all kernel and initrd paths are relative to /boot/, eg.
+#          root (hd0,0)
+#          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+#          initrd /initrd-version.img
+#boot=/dev/sda
+default=0
+timeout=5
+splashimage=(hd0,0)/grub/splash.xpm.gz
+hiddenmenu
+title Fedora (2.6.24.4-64.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.4-64.fc8.img
+title Fedora (2.6.24.3-50.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-50.fc8.img
+title Fedora (2.6.21.7-3.fc8xen)
+       root (hd0,0)
+       kernel /xen.gz-2.6.21.7-3.fc8
+       module /vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00
+       module /initrd-2.6.21.7-3.fc8xen.img
+title Fedora (2.6.24.3-34.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-34.fc8.img
+        savedefault
diff --git a/tests/root/etc/aliases b/tests/root/etc/aliases
new file mode 100644 (file)
index 0000000..7bdb9ba
--- /dev/null
@@ -0,0 +1,29 @@
+#
+#  Aliases in this file will NOT be expanded in the header from
+#  Mail, but WILL be visible over networks or from /bin/mail.
+#
+#      >>>>>>>>>>      The program "newaliases" must be run after
+#      >> NOTE >>      this file is updated for any changes to
+#      >>>>>>>>>>      show through to sendmail.
+#
+
+# Basic system aliases -- these MUST be present.
+mailer-daemon: postmaster
+postmaster:    root
+
+# General redirections for pseudo accounts.
+bin:           root, adm
+daemon:                root
+adm:           root
+
+# mailman aliases
+mailman:       postmaster
+mailman-owner: mailman
+
+# Person who should get root's mail
+mrepo:          root
+root:          realroot@example.com
+root+special:   realroot+other@example.com
+
+include:        :include:/etc/morealiases
+command:        |/usr/local/bin/procmail
diff --git a/tests/root/etc/apt/sources.list b/tests/root/etc/apt/sources.list
new file mode 100644 (file)
index 0000000..e6391f5
--- /dev/null
@@ -0,0 +1,6 @@
+#deb http://www.backports.org/debian/ sarge postfix
+# deb http://people.debian.org/~adconrad sarge subversion
+
+deb ftp://mirror.bytemark.co.uk/debian/ etch main non-free contrib
+deb http://security.debian.org/ etch/updates main contrib non-free # security line
+deb-src http://mirror.bytemark.co.uk/debian etch main contrib non-free
diff --git a/tests/root/etc/dput.cf b/tests/root/etc/dput.cf
new file mode 100644 (file)
index 0000000..ba56316
--- /dev/null
@@ -0,0 +1,46 @@
+# Example dput.cf that defines the host that can be used
+# with dput for uploading.
+
+[DEFAULT]
+login = username
+method = ftp
+hash = md5
+allow_unsigned_uploads = 0
+run_lintian = 0
+run_dinstall = 0
+check_version = 0
+scp_compress = 0
+post_upload_command =
+pre_upload_command =
+passive_ftp = 1
+default_host_non-us =
+default_host_main = hebex
+
+[hebex]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/hebex
+passive_ftp = 0
+
+[dop/desktop]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/dop/desktop
+passive_ftp = 0
+
+[dop/experimental]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/dop/experimental
+passive_ftp = 0
+
+[dop/test]
+fqdn = condor.infra.s1.p.fti.net
+login = anonymous
+method = ftp
+incoming = /incoming/dop/test
+passive_ftp = 0
+
diff --git a/tests/root/etc/exports b/tests/root/etc/exports
new file mode 100644 (file)
index 0000000..129645a
--- /dev/null
@@ -0,0 +1,4 @@
+/local 207.46.0.0/16(rw,sync)
+/home 207.46.0.0/16(rw,root_squash,sync) 192.168.50.2/32(rw,root_squash,sync)
+/tmp 207.46.0.0/16(rw,root_squash,sync)
+/pub            *(ro,insecure,all_squash)
diff --git a/tests/root/etc/fstab b/tests/root/etc/fstab
new file mode 100644 (file)
index 0000000..ddbd8ff
--- /dev/null
@@ -0,0 +1,10 @@
+/dev/vg00/lv00          /                       ext3    defaults        1 1
+LABEL=/boot             /boot                   ext3    defaults        1 2
+devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
+tmpfs                   /dev/shm                tmpfs   defaults        0 0
+/dev/vg00/home          /home                   ext3    defaults        1 2
+proc                    /proc                   proc    defaults        0 0
+sysfs                   /sys                    sysfs   defaults        0 0
+/dev/vg00/local         /local                  ext3    defaults        1 2
+/dev/vg00/images        /var/lib/xen/images     ext3    defaults        1 2
+/dev/vg00/swap          swap                    swap    defaults        0 0
diff --git a/tests/root/etc/group b/tests/root/etc/group
new file mode 100644 (file)
index 0000000..500b1d7
--- /dev/null
@@ -0,0 +1,26 @@
+root:x:0:root
+bin:x:1:root,bin,daemon
+daemon:x:2:root,bin,daemon
+sys:x:3:root,bin,adm
+adm:x:4:root,adm,daemon
+tty:x:5:
+disk:x:6:root
+lp:x:7:daemon,lp
+mem:x:8:
+kmem:x:9:
+wheel:x:10:root
+mail:x:12:mail,postfix
+uucp:x:14:uucp
+man:x:15:
+games:x:20:
+gopher:x:30:
+dip:x:40:
+ftp:x:50:
+lock:x:54:
+nobody:x:99:
+users:x:100:
+floppy:x:19:
+vcsa:x:69:
+rpc:x:32:
+rpcuser:x:29:
+nfsnobody:x:499:
\ No newline at end of file
diff --git a/tests/root/etc/grub.conf b/tests/root/etc/grub.conf
new file mode 100644 (file)
index 0000000..adb02f5
--- /dev/null
@@ -0,0 +1,31 @@
+# grub.conf generated by anaconda
+#
+# Note that you do not have to rerun grub after making changes to this file
+# NOTICE:  You have a /boot partition.  This means that
+#          all kernel and initrd paths are relative to /boot/, eg.
+#          root (hd0,0)
+#          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+#          initrd /initrd-version.img
+#boot=/dev/sda
+default=0
+timeout=5
+splashimage=(hd0,0)/grub/splash.xpm.gz
+hiddenmenu
+title Fedora (2.6.24.4-64.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.4-64.fc8.img
+title Fedora (2.6.24.3-50.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-50.fc8.img
+title Fedora (2.6.21.7-3.fc8xen)
+       root (hd0,0)
+       kernel /xen.gz-2.6.21.7-3.fc8
+       module /vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00
+       module /initrd-2.6.21.7-3.fc8xen.img
+title Fedora (2.6.24.3-34.fc8)
+       root (hd0,0)
+       kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+       initrd /initrd-2.6.24.3-34.fc8.img
+        savedefault
diff --git a/tests/root/etc/hosts b/tests/root/etc/hosts
new file mode 100644 (file)
index 0000000..44cd9da
--- /dev/null
@@ -0,0 +1,6 @@
+# Do not remove the following line, or various programs
+# that require network functionality will fail.
+127.0.0.1      localhost.localdomain   localhost galia.watzmann.net galia
+#172.31.122.254   granny.watzmann.net granny puppet
+#172.31.122.1     galia.watzmann.net galia
+172.31.122.14   orange.watzmann.net orange
diff --git a/tests/root/etc/inittab b/tests/root/etc/inittab
new file mode 100644 (file)
index 0000000..049d298
--- /dev/null
@@ -0,0 +1,53 @@
+#
+# inittab       This file describes how the INIT process should set up
+#               the system in a certain run-level.
+#
+# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
+#
+
+# Default runlevel. The runlevels used by RHS are:
+#   0 - halt (Do NOT set initdefault to this)
+#   1 - Single user mode
+#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
+#   3 - Full multiuser mode
+#   4 - unused
+#   5 - X11
+#   6 - reboot (Do NOT set initdefault to this)
+#
+id:5:initdefault:
+
+# System initialization.
+si::sysinit:/etc/rc.d/rc.sysinit
+
+l0:0:wait:/etc/rc.d/rc 0
+l1:1:wait:/etc/rc.d/rc 1
+l2:2:wait:/etc/rc.d/rc 2
+l3:3:wait:/etc/rc.d/rc 3
+l4:4:wait:/etc/rc.d/rc 4
+l5:5:wait:/etc/rc.d/rc 5
+l6:6:wait:/etc/rc.d/rc 6
+
+# Trap CTRL-ALT-DELETE
+ca::ctrlaltdel:/sbin/shutdown -t3 -r now
+
+# When our UPS tells us power has failed, assume we have a few minutes
+# of power left.  Schedule a shutdown for 2 minutes from now.
+# This does, of course, assume you have powerd installed and your
+# UPS connected and working correctly.
+pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
+
+# If power was restored before the shutdown kicked in, cancel it.
+pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
+
+
+# Run gettys in standard runlevels
+1:2345:respawn:/sbin/mingetty tty1
+2:2345:respawn:/sbin/mingetty tty2
+3:2345:respawn:/sbin/mingetty tty3
+4:2345:respawn:/sbin/mingetty tty4
+5:2345:respawn:/sbin/mingetty tty5
+6:2345:respawn:/sbin/mingetty tty6
+
+# Run xdm in runlevel 5
+x:5:respawn:/etc/X11/prefdm -nodaemon
diff --git a/tests/root/etc/krb5.conf b/tests/root/etc/krb5.conf
new file mode 100644 (file)
index 0000000..e57cf45
--- /dev/null
@@ -0,0 +1,31 @@
+[logging]
+ default = FILE:/var/log/krb5libs.log
+ kdc = FILE:/var/log/krb5kdc.log
+ admin_server = FILE:/var/log/kadmind.log
+
+[libdefaults]
+ default_realm = EXAMPLE.COM
+ dns_lookup_realm = false
+ dns_lookup_kdc = false
+ ticket_lifetime = 24h
+ forwardable = yes
+
+[realms]
+ EXAMPLE.COM = {
+  kdc = kerberos.example.com:88
+  admin_server = kerberos.example.com:749
+  default_domain = example.com
+ }
+
+[domain_realm]
+ .example.com = EXAMPLE.COM
+ example.com = EXAMPLE.COM
+
+[appdefaults]
+ pam = {
+   debug = false
+   ticket_lifetime = 36000
+   renew_lifetime = 36000
+   forwardable = true
+   krb4_convert = false
+ }
diff --git a/tests/root/etc/logrotate.d/acpid b/tests/root/etc/logrotate.d/acpid
new file mode 100644 (file)
index 0000000..cc44813
--- /dev/null
@@ -0,0 +1,8 @@
+/var/log/acpid {
+     missingok
+     notifempty
+     size=64k
+     postrotate
+         /etc/init.d/acpid condrestart >/dev/null || :
+     endscript
+ }
diff --git a/tests/root/etc/logrotate.d/rpm b/tests/root/etc/logrotate.d/rpm
new file mode 100644 (file)
index 0000000..ba3b29d
--- /dev/null
@@ -0,0 +1,6 @@
+/var/log/rpmpkgs {
+    weekly
+    notifempty
+    missingok
+       create 0640 root root
+}
diff --git a/tests/root/etc/modules.conf b/tests/root/etc/modules.conf
new file mode 100644 (file)
index 0000000..f435b47
--- /dev/null
@@ -0,0 +1,353 @@
+### This file is automatically generated by update-modules"
+#
+# Please do not edit this file directly. If you want to change or add
+# anything please take a look at the files in /etc/modutils and read
+# the manpage for update-modules.
+#
+### update-modules: start processing /etc/modutils/0keep
+# DO NOT MODIFY THIS FILE!
+# This file is not marked as conffile to make sure if you upgrade modutils
+# it will be restored in case some modifications have been made.
+#
+# The keep command is necessary to prevent insmod and friends from ignoring
+# the builtin defaults of a path-statement is encountered. Until all other
+# packages use the new `add path'-statement this keep-statement is essential
+# to keep your system working
+keep
+
+### update-modules: end processing /etc/modutils/0keep
+
+### update-modules: start processing /etc/modutils/1devfsd
+# /etc/modules.devfs
+# Richard Gooch  <rgooch@atnf.csiro.au>                24-MAR-2002
+#
+# THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT!!!
+# THIS FILE WILL BE OVERWRITTEN EACH TIME YOU INSTALL DEVFSD!!!
+# Modify /etc/modules.conf instead.
+# This file comes with devfsd-vDEVFSD-VERSION which is available from:
+# http://www.atnf.csiro.au/~rgooch/linux/
+# or directly from:
+# ftp://ftp.atnf.csiro.au/pub/people/rgooch/linux/daemons/devfsd-vDEVFSD-VERSION.tar.gz
+
+###############################################################################
+#   Sample configurations that you may want to place in /etc/modules.conf
+#
+#alias         sound-slot-0            sb
+#alias         /dev/v4l                bttv
+#alias         /dev/misc/watchdog      pcwd
+#alias         gen-md                  raid0
+#alias         /dev/joysticks          joystick
+#probeall      scsi_hostadapter        sym53c8xx
+
+###############################################################################
+#                   Generic section: do not change or copy
+#
+# All HDDs
+probeall  /dev/discs           scsi_hostadapter sd_mod ide-probe-mod ide-disk ide-floppy DAC960
+alias     /dev/discs/*         /dev/discs
+
+# All CD-ROMs
+probeall  /dev/cdroms          scsi_hostadapter sr_mod ide-probe-mod ide-cd cdrom
+alias     /dev/cdroms/*                /dev/cdroms
+alias     /dev/cdrom           /dev/cdroms
+
+# All tapes
+probeall  /dev/tapes           scsi_hostadapter st ide-probe-mod ide-tape
+alias     /dev/tapes/*         /dev/tapes
+
+# All SCSI devices
+probeall  /dev/scsi            scsi_hostadapter sd_mod sr_mod st sg
+
+# All IDE devices
+alias /dev/hd*                  /dev/ide
+alias /dev/ide/host*/bus*/target*/lun*/*        /dev/ide
+probeall  /dev/ide             ide-probe-mod ide-disk ide-cd ide-tape ide-floppy
+
+# IDE CD-ROMs
+alias     /dev/ide/*/cd                ide-cd
+
+# SCSI HDDs
+probeall  /dev/sd              scsi_hostadapter sd_mod
+alias     /dev/sd*             /dev/sd
+
+# SCSI CD-ROMs
+probeall  /dev/sr              scsi_hostadapter sr_mod
+alias     /dev/sr*             /dev/sr
+alias     /dev/scsi/*/cd       sr_mod
+
+# SCSI tapes
+probeall  /dev/st              scsi_hostadapter st
+alias     /dev/st*             /dev/st
+alias     /dev/nst*            /dev/st
+
+# SCSI generic
+probeall  /dev/sg              scsi_hostadapter sg
+alias     /dev/sg*             /dev/sg
+alias     /dev/scsi/*/generic  /dev/sg
+alias     /dev/pg              /dev/sg
+alias     /dev/pg*             /dev/sg
+
+# Floppies
+alias     /dev/floppy          floppy
+alias     /dev/fd*             floppy
+
+# RAMDISCs
+alias     /dev/rd              rd
+alias     /dev/ram*            rd
+
+# Loop devices
+alias     /dev/loop*           loop
+
+# Meta devices
+alias     /dev/md*             gen-md
+
+# Parallel port printers
+alias     /dev/printers*       lp
+alias     /dev/lp*             /dev/printers
+
+# Soundcard
+alias     /dev/sound           sound-slot-0
+alias     /dev/audio           /dev/sound
+alias     /dev/mixer           /dev/sound
+alias     /dev/dsp             /dev/sound
+alias     /dev/dspW            /dev/sound
+alias     /dev/midi            /dev/sound
+
+# Joysticks
+alias     /dev/js*             /dev/joysticks
+
+# Serial ports
+alias     /dev/tts*            serial
+alias     /dev/ttyS*           /dev/tts
+alias     /dev/cua*            /dev/tts
+
+# Input devices
+alias     /dev/input/mouse*    mousedev
+
+# Miscellaneous devices
+alias     /dev/misc/atibm      atixlmouse
+alias     /dev/misc/inportbm   msbusmouse
+alias     /dev/misc/logibm     busmouse
+alias     /dev/misc/rtc                rtc
+alias     /dev/misc/agpgart    agpgart
+alias     /dev/rtc             /dev/misc/rtc
+
+# PPP devices
+alias     /dev/ppp*            ppp_generic
+
+# Video capture devices
+alias     /dev/video*          /dev/v4l
+alias     /dev/vbi*            /dev/v4l
+
+# agpgart
+alias     /dev/agpgart         agpgart
+alias     /dev/dri*            agpgart
+
+# Irda devices
+alias     /dev/ircomm          ircomm-tty
+alias     /dev/ircomm*         /dev/ircomm
+
+# Raw I/O devices
+alias  /dev/rawctl             /dev/raw
+
+
+# Pull in the configuration file. Do this last because modprobe(8) processes in
+# per^H^H^Hreverse order and the sysadmin may want to over-ride what is in the
+# generic file
+#include /etc/modules.conf
+
+### update-modules: end processing /etc/modutils/1devfsd
+
+### update-modules: start processing /etc/modutils/actions
+# Special actions that are needed for some modules
+
+# The BTTV module does not load the tuner module automatically,
+# so do that in here
+post-install bttv insmod tuner
+post-remove bttv rmmod tuner
+
+
+### update-modules: end processing /etc/modutils/actions
+
+### update-modules: start processing /etc/modutils/aliases
+# Aliases to tell insmod/modprobe which modules to use 
+
+# Uncomment the network protocols you don't want loaded:
+# alias net-pf-1 off           # Unix
+# alias net-pf-2 off           # IPv4
+# alias net-pf-3 off           # Amateur Radio AX.25
+# alias net-pf-4 off           # IPX
+# alias net-pf-5 off           # DDP / appletalk
+# alias net-pf-6 off           # Amateur Radio NET/ROM
+# alias net-pf-9 off           # X.25
+# alias net-pf-10 off          # IPv6
+# alias net-pf-11 off          # ROSE / Amateur Radio X.25 PLP
+# alias net-pf-19 off          # Acorn Econet
+
+alias char-major-10-175        agpgart
+alias char-major-10-200        tun
+alias char-major-81    bttv
+alias char-major-108   ppp_generic
+alias /dev/ppp         ppp_generic
+alias tty-ldisc-3      ppp_async
+alias tty-ldisc-14     ppp_synctty
+alias ppp-compress-21  bsd_comp
+alias ppp-compress-24  ppp_deflate
+alias ppp-compress-26  ppp_deflate
+
+# Crypto modules (see http://www.kerneli.org/)
+alias loop-xfer-gen-0  loop_gen
+alias loop-xfer-3      loop_fish2
+alias loop-xfer-gen-10 loop_gen
+alias cipher-2         des
+alias cipher-3         fish2
+alias cipher-4         blowfish
+alias cipher-6         idea
+alias cipher-7         serp6f
+alias cipher-8         mars6
+alias cipher-11                rc62
+alias cipher-15                dfc2
+alias cipher-16                rijndael
+alias cipher-17                rc5
+
+alias char-major-195 NVdriver
+
+### update-modules: end processing /etc/modutils/aliases
+
+### update-modules: start processing /etc/modutils/alsa-path
+# Debian ALSA modules path
+# Do not edit this unless you understand what you're doing.
+path=/lib/modules/`uname -r`/alsa
+
+### update-modules: end processing /etc/modutils/alsa-path
+
+### update-modules: start processing /etc/modutils/apm
+alias char-major-10-134        apm
+alias /dev/apm_bios            /dev/misc/apm_bios
+alias /dev/misc/apm_bios       apm
+
+### update-modules: end processing /etc/modutils/apm
+
+### update-modules: start processing /etc/modutils/cdrw
+options ide-cd ignore=hdc            # tell the ide-cd module to ignore hdb
+alias scd0 sr_mod                    # load sr_mod upon access of scd0
+#pre-install ide-scsi modprobe imm    # uncomment for some ZIP drives only
+pre-install sg     modprobe ide-scsi # load ide-scsi before sg
+pre-install sr_mod modprobe ide-scsi # load ide-scsi before sr_mod
+pre-install ide-scsi modprobe ide-cd # load ide-cd   before ide-scsi
+
+### update-modules: end processing /etc/modutils/cdrw
+
+### update-modules: start processing /etc/modutils/irda
+alias tty-ldisc-11 irtty
+alias char-major-161 ircomm-tty
+alias char-major-60 ircomm_tty
+
+# for dongle
+alias irda-dongle-0 tekram
+alias irda-dongle-1 esi
+alias irda-dongle-2 actisys
+alias irda-dongle-3 actisys
+alias irda-dongle-4 girbil
+alias irda-dongle-5 litelink
+alias irda-dongle-6 airport
+alias irda-dongle-7 old_belkin
+
+# for FIR device
+alias irda0 smc-ircc 
+#dongle_id=0x09
+pre-install smc-ircc /usr/local/sbin/tosh5100-smcinit
+
+### update-modules: end processing /etc/modutils/irda
+
+### update-modules: start processing /etc/modutils/paths
+# This file contains a list of paths that modprobe should scan,
+# beside the once that are compiled into the modutils tools
+# themselves.
+
+
+### update-modules: end processing /etc/modutils/paths
+
+### update-modules: start processing /etc/modutils/pcmcia
+pre-install ide-cs /etc/init.d/irda stop
+post-remove ide-cs /etc/init.d/irda start
+
+
+
+### update-modules: end processing /etc/modutils/pcmcia
+
+### update-modules: start processing /etc/modutils/ppp
+alias /dev/ppp          ppp_generic
+alias char-major-108    ppp_generic
+alias tty-ldisc-3       ppp_async  
+alias tty-ldisc-14      ppp_synctty
+alias ppp-compress-21   bsd_comp   
+alias ppp-compress-24   ppp_deflate
+alias ppp-compress-26   ppp_deflate
+
+### update-modules: end processing /etc/modutils/ppp
+
+### update-modules: start processing /etc/modutils/setserial
+#
+# This is what I wanted to do, but logger is in /usr/bin, which isn't loaded
+# when the module is first loaded into the kernel at boot time!
+#
+#post-install serial /etc/init.d/setserial start | logger -p daemon.info -t "setserial-module reload"
+#pre-remove serial /etc/init.d/setserial stop | logger -p daemon.info -t "setserial-module uload"
+#
+alias /dev/tts          serial
+alias /dev/tts/0        serial
+alias /dev/tts/1        serial
+alias /dev/tts/2        serial
+alias /dev/tts/3        serial
+post-install serial /etc/init.d/setserial modload > /dev/null 2> /dev/null
+pre-remove serial /etc/init.d/setserial modsave  > /dev/null 2> /dev/null
+
+### update-modules: end processing /etc/modutils/setserial
+
+### update-modules: start processing /etc/modutils/sound
+# ALSA portion
+alias char-major-116 snd
+# OSS/Free portion
+alias char-major-14 soundcore
+alias snd-card-0 snd-intel8x0
+alias sound-slot-0 snd-card-0
+# OSS/Free portion - card #1
+alias sound-service-0-0 snd-mixer-oss
+alias sound-service-0-1 snd-seq-oss
+alias sound-service-0-3 snd-pcm-oss
+alias sound-service-0-8 snd-seq-oss
+alias sound-service-0-12 snd-pcm-oss
+alias sound-service-1-0 off
+alias sound-slot-1 off
+#gentoo suggestion
+alias /dev/dsp  snd-pcm-oss
+alias /dev/mixer snd-mixer-oss
+alias /dev/midi  snd-seq-oss
+
+
+### update-modules: end processing /etc/modutils/sound
+
+### update-modules: start processing /etc/modutils/toshutils
+alias char-major-10-181 toshiba
+options toshiba tosh_fn=0x62
+### update-modules: end processing /etc/modutils/toshutils
+
+### update-modules: start processing /etc/modutils/usb
+options usb-uhci debug 3
+post-install belkin_sa /usr/local/sbin/belkin-usb-serial
+
+
+### update-modules: end processing /etc/modutils/usb
+
+### update-modules: start processing /etc/modutils/arch/i386
+#alias parport_lowlevel parport_pc
+alias char-major-10-144 nvram
+alias binfmt-0064 binfmt_aout
+alias char-major-10-135 rtc
+
+alias parport_lowlevel off
+alias char-major-6 off
+
+### update-modules: end processing /etc/modutils/arch/i386
+
diff --git a/tests/root/etc/multipath.conf b/tests/root/etc/multipath.conf
new file mode 100644 (file)
index 0000000..fa2017b
--- /dev/null
@@ -0,0 +1,97 @@
+# This is a basic configuration file with some examples, for device mapper
+# multipath.
+# For a complete list of the default configuration values, see
+# /usr/share/doc/device-mapper-multipath-0.4.8/multipath.conf.defaults
+# For a list of configuration options with descriptions, see
+# /usr/share/doc/device-mapper-multipath-0.4.8/multipath.conf.annotated
+
+
+# Blacklist all devices by default. Remove this to enable multipathing
+# on the default devices.
+blacklist {
+        devnode "*"
+}
+
+# By default, devices with vendor = "IBM" and product = "S/390.*" are
+# blacklisted. To enable mulitpathing on these devies, uncomment the
+# following lines.
+blacklist_exceptions {
+       device {
+               vendor  "IBM"
+               product "S/390.*"
+       }
+}
+
+## Use user friendly names, instead of using WWIDs as names.
+defaults {
+       user_friendly_names yes
+}
+#
+# Here is an example of how to configure some standard options.
+#
+
+defaults {
+       udev_dir                /dev
+       polling_interval        10
+       selector                "round-robin 0"
+       path_grouping_policy    multibus
+       getuid_callout          "/sbin/scsi_id --whitelisted /dev/%n"
+       prio                    alua
+       path_checker            readsector0
+       rr_min_io               100
+       max_fds                 8192
+       rr_weight               priorities
+       failback                immediate
+       no_path_retry           fail
+       user_friendly_names     yes
+}
+#
+# The wwid line in the following blacklist section is shown as an example
+# of how to blacklist devices by wwid.  The 2 devnode lines are the
+# compiled in default blacklist. If you want to blacklist entire types
+# of devices, such as all scsi devices, you should use a devnode line.
+# However, if you want to blacklist specific devices, you should use
+# a wwid line.  Since there is no guarantee that a specific device will
+# not change names on reboot (from /dev/sda to /dev/sdb for example)
+# devnode lines are not recommended for blacklisting specific devices.
+#
+blacklist {
+       wwid 26353900f02796769
+       devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
+       devnode "^hd[a-z]"
+}
+multipaths {
+       multipath {
+               wwid                    3600508b4000156d700012000000b0000
+               alias                   yellow
+               path_grouping_policy    multibus
+               path_checker            readsector0
+               path_selector           "round-robin 0"
+               failback                manual
+               rr_weight               priorities
+               no_path_retry           5
+       }
+       multipath {
+               wwid                    1DEC_____321816758474
+               alias                   red
+       }
+}
+devices {
+       device {
+               vendor                  "COMPAQ  "
+               product                 "HSV110 (C)COMPAQ"
+               path_grouping_policy    multibus
+               getuid_callout          "/sbin/scsi_id --whitelisted /dev/%n"
+               path_checker            readsector0
+               path_selector           "round-robin 0"
+               hardware_handler        "0"
+               failback                15
+               rr_weight               priorities
+               no_path_retry           queue
+       }
+       device {
+               vendor                  "COMPAQ  "
+               product                 "MSA1000         "
+               path_grouping_policy    multibus
+       }
+}
diff --git a/tests/root/etc/network/interfaces b/tests/root/etc/network/interfaces
new file mode 100644 (file)
index 0000000..bac131f
--- /dev/null
@@ -0,0 +1,40 @@
+# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
+
+# The loopback interface
+auto lo
+iface lo inet loopback
+
+# The first network card - this entry was created during the Debian installation
+## auto eth0
+iface eth0 inet dhcp
+  pre-up /etc/init.d/ntp-server stop || true
+  up /etc/init.d/ntpdate restart || true
+  up /etc/init.d/ntp-server start || true
+
+iface eth0-0 inet static
+  address 134.158.129.99
+  netmask 255.255.254.0
+  network 134.158.128.0
+  broadcast 134.158.129.255
+  gateway 134.158.128.1
+
+iface eth0-2 inet static
+       address 192.168.1.160
+  netmask 255.255.255.0
+  network 192.168.1.0
+  broadcast 192.168.1.255
+  gateway 192.168.1.1
+
+iface eth0-3 inet static
+  address 192.168.1.7
+  netmask 255.255.255.0
+  network 192.168.1.0
+  broadcast 192.168.1.255
+
+iface adsl0 inet dhcp
+  pre-up /sbin/modprobe adiusbadsl
+  pre-up /usr/sbin/adictrl -i
+  pre-up /usr/sbin/adictrl -f
+  pre-up /usr/sbin/adictrl -d
+  pre-up /usr/sbin/adictrl -s
+
diff --git a/tests/root/etc/nrpe.cfg b/tests/root/etc/nrpe.cfg
new file mode 100644 (file)
index 0000000..792d600
--- /dev/null
@@ -0,0 +1 @@
+#
diff --git a/tests/root/etc/ntp.conf b/tests/root/etc/ntp.conf
new file mode 100644 (file)
index 0000000..8a375db
--- /dev/null
@@ -0,0 +1,50 @@
+# Permit time synchronization with our time source, but do not
+# permit the source to query or modify the service on this system.
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+# Permit all access over the loopback interface.  This could
+# be tightened as well, but to do so would effect some of
+# the administrative functions.
+restrict 127.0.0.1
+restrict -6 ::1
+
+# Hosts on local network are less restricted.
+restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
+
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+server 0.centos.pool.ntp.org
+server 1.centos.pool.ntp.org
+server 2.centos.pool.ntp.org
+
+broadcast 192.168.1.255 key 42         # broadcast server
+broadcastclient                        # broadcast client
+broadcast 224.0.1.1 key 42             # multicast server
+multicastclient 224.0.1.1              # multicast client
+manycastserver 239.255.254.254         # manycast server
+manycastclient 239.255.254.254 key 42  # manycast client
+
+# Undisciplined Local Clock. This is a fake driver intended for backup
+# and when no outside source of synchronized time is available.
+server 127.127.1.0     # local clock
+fudge  127.127.1.0 stratum 10
+
+# Drift file.  Put this in a directory which the daemon can write to.
+# No symbolic links allowed, either, since the daemon updates the file
+# by creating a temporary in the same directory and then rename()'ing
+# it to the file.
+driftfile /var/lib/ntp/drift
+
+# Key file containing the keys and key identifiers used when operating
+# with symmetric key cryptography.
+keys /etc/ntp/keys
+
+# Specify the key identifiers which are trusted.
+trustedkey 4 8 42
+
+# Specify the key identifier to use with the ntpdc utility.
+requestkey 8
+
+# Specify the key identifier to use with the ntpq utility.
+controlkey 8
diff --git a/tests/root/etc/pam.d/login b/tests/root/etc/pam.d/login
new file mode 100644 (file)
index 0000000..9e8ca3b
--- /dev/null
@@ -0,0 +1,15 @@
+#%PAM-1.0
+auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
+auth       include      system-auth
+account    required     pam_nologin.so
+account    include      system-auth
+password   include      system-auth
+# pam_selinux.so close should be the first session rule
+session    required     pam_selinux.so close
+session    optional     pam_keyinit.so force revoke
+session    include      system-auth
+session    required     pam_loginuid.so
+session    optional     pam_console.so
+# pam_selinux.so open should only be followed by sessions to be executed in the user context
+session    required     pam_selinux.so open
+session    optional     pam_ck_connector.so
diff --git a/tests/root/etc/pam.d/newrole b/tests/root/etc/pam.d/newrole
new file mode 100644 (file)
index 0000000..836b689
--- /dev/null
@@ -0,0 +1,5 @@
+#%PAM-1.0
+auth       include     system-auth
+account    include     system-auth
+password   include     system-auth
+session    required    pam_namespace.so unmnt_remnt no_unmount_on_close
diff --git a/tests/root/etc/pam.d/postgresql b/tests/root/etc/pam.d/postgresql
new file mode 100644 (file)
index 0000000..40bfa6f
--- /dev/null
@@ -0,0 +1,3 @@
+#%PAM-1.0
+auth           include         system-auth
+account                include         system-auth
diff --git a/tests/root/etc/pam.d/sshd~ b/tests/root/etc/pam.d/sshd~
new file mode 100644 (file)
index 0000000..dc64f9b
--- /dev/null
@@ -0,0 +1,13 @@
+#%PAM-1.0
+auth       include      system-auth
+account    required     pam_nologin.so
+account    include      system-auth
+password   include      system-auth
+# pam_selinux.so close should be the first session rule
+session    required     pam_selinux.so close
+session    include      system-auth
+session    required     pam_loginuid.so
+# pam_selinux.so open should only be followed by sessions to be
+executed in the user context
+session    required     pam_selinux.so open env_params
+session    optional     pam_keyinit.so force revoke
diff --git a/tests/root/etc/passwd b/tests/root/etc/passwd
new file mode 100644 (file)
index 0000000..9cefbfe
--- /dev/null
@@ -0,0 +1,19 @@
+root:x:0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/bin:/sbin/nologin
+daemon:x:2:2:daemon:/sbin:/sbin/nologin
+adm:x:3:4:adm:/var/adm:/sbin/nologin
+lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
+sync:x:5:0:sync:/sbin:/bin/sync
+shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
+halt:x:7:0:halt:/sbin:/sbin/halt
+mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
+uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
+operator:x:11:0:operator:/root:/sbin/nologin
+games:x:12:100:games:/usr/games:/sbin/nologin
+gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
+ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
+nobody:x:99:99:Nobody:/:/sbin/nologin
+vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
+rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
+rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
+nfsnobody:x:4294967294:499:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
diff --git a/tests/root/etc/php.ini b/tests/root/etc/php.ini
new file mode 100644 (file)
index 0000000..0135141
--- /dev/null
@@ -0,0 +1,1221 @@
+[PHP]
+
+;;;;;;;;;;;;;;;;;;;
+; About php.ini   ;
+;;;;;;;;;;;;;;;;;;;
+; This file controls many aspects of PHP's behavior.  In order for PHP to
+; read it, it must be named 'php.ini'.  PHP looks for it in the current
+; working directory, in the path designated by the environment variable
+; PHPRC, and in the path that was defined in compile time (in that order).
+; Under Windows, the compile-time path is the Windows directory.  The
+; path in which the php.ini file is looked for can be overridden using
+; the -c argument in command line mode.
+;
+; The syntax of the file is extremely simple.  Whitespace and Lines
+; beginning with a semicolon are silently ignored (as you probably guessed).
+; Section headers (e.g. [Foo]) are also silently ignored, even though
+; they might mean something in the future.
+;
+; Directives are specified using the following syntax:
+; directive = value
+; Directive names are *case sensitive* - foo=bar is different from FOO=bar.
+;
+; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one
+; of the INI constants (On, Off, True, False, Yes, No and None) or an expression
+; (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo").
+;
+; Expressions in the INI file are limited to bitwise operators and parentheses:
+; |        bitwise OR
+; &        bitwise AND
+; ~        bitwise NOT
+; !        boolean NOT
+;
+; Boolean flags can be turned on using the values 1, On, True or Yes.
+; They can be turned off using the values 0, Off, False or No.
+;
+; An empty string can be denoted by simply not writing anything after the equal
+; sign, or by using the None keyword:
+;
+;  foo =         ; sets foo to an empty string
+;  foo = none    ; sets foo to an empty string
+;  foo = "none"  ; sets foo to the string 'none'
+;
+; If you use constants in your value, and these constants belong to a
+; dynamically loaded extension (either a PHP extension or a Zend extension),
+; you may only use these constants *after* the line that loads the extension.
+; 
+;
+;;;;;;;;;;;;;;;;;;;
+; About this file ;
+;;;;;;;;;;;;;;;;;;;
+; This is the recommended, PHP 5-style version of the php.ini-dist file.  It
+; sets some non standard settings, that make PHP more efficient, more secure,
+; and encourage cleaner coding.
+;
+; The price is that with these settings, PHP may be incompatible with some
+; applications, and sometimes, more difficult to develop with.  Using this
+; file is warmly recommended for production sites.  As all of the changes from
+; the standard settings are thoroughly documented, you can go over each one,
+; and decide whether you want to use it or not.
+;
+; For general information about the php.ini file, please consult the php.ini-dist
+; file, included in your PHP distribution.
+;
+; This file is different from the php.ini-dist file in the fact that it features
+; different values for several directives, in order to improve performance, while
+; possibly breaking compatibility with the standard out-of-the-box behavior of
+; PHP.  Please make sure you read what's different, and modify your scripts
+; accordingly, if you decide to use this file instead.
+;
+; - register_globals = Off         [Security, Performance]
+;     Global variables are no longer registered for input data (POST, GET, cookies,
+;     environment and other server variables).  Instead of using $foo, you must use
+;     you can use $_REQUEST["foo"] (includes any variable that arrives through the
+;     request, namely, POST, GET and cookie variables), or use one of the specific
+;     $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending
+;     on where the input originates.  Also, you can look at the
+;     import_request_variables() function.
+;     Note that register_globals is going to be depracated (i.e., turned off by
+;     default) in the next version of PHP, because it often leads to security bugs.
+;     Read http://php.net/manual/en/security.registerglobals.php for further
+;     information.
+; - register_long_arrays = Off     [Performance]
+;     Disables registration of the older (and deprecated) long predefined array
+;     variables ($HTTP_*_VARS).  Instead, use the superglobals that were
+;     introduced in PHP 4.1.0
+; - display_errors = Off           [Security]
+;     With this directive set to off, errors that occur during the execution of
+;     scripts will no longer be displayed as a part of the script output, and thus,
+;     will no longer be exposed to remote users.  With some errors, the error message
+;     content may expose information about your script, web server, or database
+;     server that may be exploitable for hacking.  Production sites should have this
+;     directive set to off.
+; - log_errors = On                [Security]
+;     This directive complements the above one.  Any errors that occur during the
+;     execution of your script will be logged (typically, to your server's error log,
+;     but can be configured in several ways).  Along with setting display_errors to off,
+;     this setup gives you the ability to fully understand what may have gone wrong,
+;     without exposing any sensitive information to remote users.
+; - output_buffering = 4096        [Performance]
+;     Set a 4KB output buffer.  Enabling output buffering typically results in less
+;     writes, and sometimes less packets sent on the wire, which can often lead to
+;     better performance.  The gain this directive actually yields greatly depends
+;     on which Web server you're working with, and what kind of scripts you're using.
+; - register_argc_argv = Off       [Performance]
+;     Disables registration of the somewhat redundant $argv and $argc global
+;     variables.
+; - magic_quotes_gpc = Off         [Performance]
+;     Input data is no longer escaped with slashes so that it can be sent into
+;     SQL databases without further manipulation.  Instead, you should use the
+;     function addslashes() on each input element you wish to send to a database.
+; - variables_order = "GPCS"       [Performance]
+;     The environment variables are not hashed into the $_ENV.  To access
+;     environment variables, you can use getenv() instead.
+; - error_reporting = E_ALL        [Code Cleanliness, Security(?)]
+;     By default, PHP surpresses errors of type E_NOTICE.  These error messages
+;     are emitted for non-critical errors, but that could be a symptom of a bigger
+;     problem.  Most notably, this will cause error messages about the use
+;     of uninitialized variables to be displayed.
+; - allow_call_time_pass_reference = Off     [Code cleanliness]
+;     It's not possible to decide to force a variable to be passed by reference
+;     when calling a function.  The PHP 4 style to do this is by making the
+;     function require the relevant argument by reference.
+
+
+;;;;;;;;;;;;;;;;;;;;
+; Language Options ;
+;;;;;;;;;;;;;;;;;;;;
+
+; Enable the PHP scripting language engine under Apache.
+engine = On
+
+; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
+zend.ze1_compatibility_mode = Off
+
+; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
+; NOTE: Using short tags should be avoided when developing applications or
+; libraries that are meant for redistribution, or deployment on PHP
+; servers which are not under your control, because short tags may not
+; be supported on the target server. For portable, redistributable code,
+; be sure not to use short tags.
+short_open_tag = On
+
+; Allow ASP-style <% %> tags.
+asp_tags = Off
+
+; The number of significant digits displayed in floating point numbers.
+precision    =  14
+
+; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
+y2k_compliance = On
+
+; Output buffering allows you to send header lines (including cookies) even
+; after you send body content, at the price of slowing PHP's output layer a
+; bit.  You can enable output buffering during runtime by calling the output
+; buffering functions.  You can also enable output buffering for all files by
+; setting this directive to On.  If you wish to limit the size of the buffer
+; to a certain size - you can use a maximum number of bytes instead of 'On', as
+; a value for this directive (e.g., output_buffering=4096).
+output_buffering = 4096
+
+; You can redirect all of the output of your scripts to a function.  For
+; example, if you set output_handler to "mb_output_handler", character
+; encoding will be transparently converted to the specified encoding.
+; Setting any output handler automatically turns on output buffering.
+; Note: People who wrote portable scripts should not depend on this ini
+;       directive. Instead, explicitly set the output handler using ob_start().
+;       Using this ini directive may cause problems unless you know what script
+;       is doing.
+; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler"
+;       and you cannot use both "ob_gzhandler" and "zlib.output_compression".
+; Note: output_handler must be empty if this is set 'On' !!!!
+;       Instead you must use zlib.output_handler.
+;output_handler =
+
+; Transparent output compression using the zlib library
+; Valid values for this option are 'off', 'on', or a specific buffer size
+; to be used for compression (default is 4KB)
+; Note: Resulting chunk size may vary due to nature of compression. PHP
+;       outputs chunks that are few hundreds bytes each as a result of
+;       compression. If you prefer a larger chunk size for better
+;       performance, enable output_buffering in addition.
+; Note: You need to use zlib.output_handler instead of the standard
+;       output_handler, or otherwise the output will be corrupted.
+zlib.output_compression = Off
+
+; You cannot specify additional output handlers if zlib.output_compression
+; is activated here. This setting does the same as output_handler but in
+; a different order.
+;zlib.output_handler =
+
+; Implicit flush tells PHP to tell the output layer to flush itself
+; automatically after every output block.  This is equivalent to calling the
+; PHP function flush() after each and every call to print() or echo() and each
+; and every HTML block.  Turning this option on has serious performance
+; implications and is generally recommended for debugging purposes only.
+implicit_flush = Off
+
+; The unserialize callback function will be called (with the undefined class'
+; name as parameter), if the unserializer finds an undefined class
+; which should be instantiated.
+; A warning appears if the specified function is not defined, or if the
+; function doesn't include/implement the missing class.
+; So only set this entry, if you really want to implement such a
+; callback-function.
+unserialize_callback_func=
+
+; When floats & doubles are serialized store serialize_precision significant
+; digits after the floating point. The default value ensures that when floats
+; are decoded with unserialize, the data will remain the same.
+serialize_precision = 100
+
+; Whether to enable the ability to force arguments to be passed by reference
+; at function call time.  This method is deprecated and is likely to be
+; unsupported in future versions of PHP/Zend.  The encouraged method of
+; specifying which arguments should be passed by reference is in the function
+; declaration.  You're encouraged to try and turn this option Off and make
+; sure your scripts work properly with it in order to ensure they will work
+; with future versions of the language (you will receive a warning each time
+; you use this feature, and the argument will be passed by value instead of by
+; reference).
+allow_call_time_pass_reference = Off
+
+;
+; Safe Mode
+;
+safe_mode = Off
+
+; By default, Safe Mode does a UID compare check when
+; opening files. If you want to relax this to a GID compare,
+; then turn on safe_mode_gid.
+safe_mode_gid = Off
+
+; When safe_mode is on, UID/GID checks are bypassed when
+; including files from this directory and its subdirectories.
+; (directory must also be in include_path or full path must
+; be used when including)
+safe_mode_include_dir =
+
+; When safe_mode is on, only executables located in the safe_mode_exec_dir
+; will be allowed to be executed via the exec family of functions.
+safe_mode_exec_dir =
+
+; Setting certain environment variables may be a potential security breach.
+; This directive contains a comma-delimited list of prefixes.  In Safe Mode,
+; the user may only alter environment variables whose names begin with the
+; prefixes supplied here.  By default, users will only be able to set
+; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR).
+;
+; Note:  If this directive is empty, PHP will let the user modify ANY
+; environment variable!
+safe_mode_allowed_env_vars = PHP_
+
+; This directive contains a comma-delimited list of environment variables that
+; the end user won't be able to change using putenv().  These variables will be
+; protected even if safe_mode_allowed_env_vars is set to allow to change them.
+safe_mode_protected_env_vars = LD_LIBRARY_PATH
+
+; open_basedir, if set, limits all file operations to the defined directory
+; and below.  This directive makes most sense if used in a per-directory
+; or per-virtualhost web server configuration file. This directive is
+; *NOT* affected by whether Safe Mode is turned On or Off.
+;open_basedir =
+
+; This directive allows you to disable certain functions for security reasons.
+; It receives a comma-delimited list of function names. This directive is
+; *NOT* affected by whether Safe Mode is turned On or Off.
+disable_functions =
+
+; This directive allows you to disable certain classes for security reasons.
+; It receives a comma-delimited list of class names. This directive is
+; *NOT* affected by whether Safe Mode is turned On or Off.
+disable_classes =
+
+; Colors for Syntax Highlighting mode.  Anything that's acceptable in
+; <span style="color: ???????"> would work.
+;highlight.string  = #DD0000
+;highlight.comment = #FF9900
+;highlight.keyword = #007700
+;highlight.bg      = #FFFFFF
+;highlight.default = #0000BB
+;highlight.html    = #000000
+
+; If enabled, the request will be allowed to complete even if the user aborts
+; the request. Consider enabling it if executing long request, which may end up
+; being interrupted by the user or a browser timing out.
+; ignore_user_abort = On
+
+; Determines the size of the realpath cache to be used by PHP. This value should
+; be increased on systems where PHP opens many files to reflect the quantity of
+; the file operations performed.
+; realpath_cache_size=16k
+
+; Duration of time, in seconds for which to cache realpath information for a given
+; file or directory. For systems with rarely changing files, consider increasing this
+; value.
+; realpath_cache_ttl=120
+
+;
+; Misc
+;
+; Decides whether PHP may expose the fact that it is installed on the server
+; (e.g. by adding its signature to the Web server header).  It is no security
+; threat in any way, but it makes it possible to determine whether you use PHP
+; on your server or not.
+expose_php = On
+
+
+;;;;;;;;;;;;;;;;;;;
+; Resource Limits ;
+;;;;;;;;;;;;;;;;;;;
+
+max_execution_time = 30     ; Maximum execution time of each script, in seconds
+max_input_time = 60    ; Maximum amount of time each script may spend parsing request data
+memory_limit = 16M      ; Maximum amount of memory a script may consume
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Error handling and logging ;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; error_reporting is a bit-field.  Or each number up to get desired error
+; reporting level
+; E_ALL             - All errors and warnings (doesn't include E_STRICT)
+; E_ERROR           - fatal run-time errors
+; E_WARNING         - run-time warnings (non-fatal errors)
+; E_PARSE           - compile-time parse errors
+; E_NOTICE          - run-time notices (these are warnings which often result
+;                     from a bug in your code, but it's possible that it was
+;                     intentional (e.g., using an uninitialized variable and
+;                     relying on the fact it's automatically initialized to an
+;                     empty string)
+; E_STRICT          - run-time notices, enable to have PHP suggest changes
+;                     to your code which will ensure the best interoperability
+;                     and forward compatibility of your code
+; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
+; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
+;                     initial startup
+; E_COMPILE_ERROR   - fatal compile-time errors
+; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
+; E_USER_ERROR      - user-generated error message
+; E_USER_WARNING    - user-generated warning message
+; E_USER_NOTICE     - user-generated notice message
+;
+; Examples:
+;
+;   - Show all errors, except for notices and coding standards warnings
+;
+;error_reporting = E_ALL & ~E_NOTICE
+;
+;   - Show all errors, except for notices
+;
+;error_reporting = E_ALL & ~E_NOTICE | E_STRICT
+;
+;   - Show only errors
+;
+;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
+;
+;   - Show all errors, except coding standards warnings
+;
+error_reporting  =  E_ALL
+
+; Print out errors (as a part of the output).  For production web sites,
+; you're strongly encouraged to turn this feature off, and use error logging
+; instead (see below).  Keeping display_errors enabled on a production web site
+; may reveal security information to end users, such as file paths on your Web
+; server, your database schema or other information.
+display_errors = Off
+
+; Even when display_errors is on, errors that occur during PHP's startup
+; sequence are not displayed.  It's strongly recommended to keep
+; display_startup_errors off, except for when debugging.
+display_startup_errors = Off
+
+; Log errors into a log file (server-specific log, stderr, or error_log (below))
+; As stated above, you're strongly advised to use error logging in place of
+; error displaying on production web sites.
+log_errors = On
+
+; Set maximum length of log_errors. In error_log information about the source is
+; added. The default is 1024 and 0 allows to not apply any maximum length at all.
+log_errors_max_len = 1024
+
+; Do not log repeated messages. Repeated errors must occur in same file on same
+; line until ignore_repeated_source is set true.
+ignore_repeated_errors = Off
+
+; Ignore source of message when ignoring repeated messages. When this setting
+; is On you will not log errors with repeated messages from different files or
+; sourcelines.
+ignore_repeated_source = Off
+
+; If this parameter is set to Off, then memory leaks will not be shown (on
+; stdout or in the log). This has only effect in a debug compile, and if
+; error reporting includes E_WARNING in the allowed list
+report_memleaks = On
+
+; Store the last error/warning message in $php_errormsg (boolean).
+track_errors = Off
+
+; Disable the inclusion of HTML tags in error messages.
+; Note: Never use this feature for production boxes.
+;html_errors = Off
+
+; If html_errors is set On PHP produces clickable error messages that direct
+; to a page describing the error or function causing the error in detail.
+; You can download a copy of the PHP manual from http://www.php.net/docs.php
+; and change docref_root to the base URL of your local copy including the
+; leading '/'. You must also specify the file extension being used including
+; the dot.
+; Note: Never use this feature for production boxes.
+;docref_root = "/phpmanual/"
+;docref_ext = .html
+
+; String to output before an error message.
+;error_prepend_string = "<font color=ff0000>"
+
+; String to output after an error message.
+;error_append_string = "</font>"
+
+; Log errors to specified file.
+;error_log = filename
+
+; Log errors to syslog (Event Log on NT, not valid in Windows 95).
+;error_log = syslog
+
+
+;;;;;;;;;;;;;;;;;
+; Data Handling ;
+;;;;;;;;;;;;;;;;;
+;
+; Note - track_vars is ALWAYS enabled as of PHP 4.0.3
+
+; The separator used in PHP generated URLs to separate arguments.
+; Default is "&".
+;arg_separator.output = "&amp;"
+
+; List of separator(s) used by PHP to parse input URLs into variables.
+; Default is "&".
+; NOTE: Every character in this directive is considered as separator!
+;arg_separator.input = ";&"
+
+; This directive describes the order in which PHP registers GET, POST, Cookie,
+; Environment and Built-in variables (G, P, C, E & S respectively, often
+; referred to as EGPCS or GPC).  Registration is done from left to right, newer
+; values override older values.
+variables_order = "EGPCS"
+
+; Whether or not to register the EGPCS variables as global variables.  You may
+; want to turn this off if you don't want to clutter your scripts' global scope
+; with user data.  This makes most sense when coupled with track_vars - in which
+; case you can access all of the GPC variables through the $HTTP_*_VARS[],
+; variables.
+;
+; You should do your best to write your scripts so that they do not require
+; register_globals to be on;  Using form variables as globals can easily lead
+; to possible security problems, if the code is not very well thought of.
+register_globals = Off
+
+; Whether or not to register the old-style input arrays, HTTP_GET_VARS
+; and friends.  If you're not using them, it's recommended to turn them off,
+; for performance reasons.
+register_long_arrays = Off
+
+; This directive tells PHP whether to declare the argv&argc variables (that
+; would contain the GET information).  If you don't use these variables, you
+; should turn it off for increased performance.
+register_argc_argv = Off
+
+; When enabled, the SERVER and ENV variables are created when they're first
+; used (Just In Time) instead of when the script starts. If these variables
+; are not used within a script, having this directive on will result in a
+; performance gain. The PHP directives register_globals, register_long_arrays,
+; and register_argc_argv must be disabled for this directive to have any affect.
+auto_globals_jit = On
+
+; Maximum size of POST data that PHP will accept.
+post_max_size = 8M
+
+; Magic quotes
+;
+
+; Magic quotes for incoming GET/POST/Cookie data.
+magic_quotes_gpc = Off
+
+; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
+magic_quotes_runtime = Off
+
+; Use Sybase-style magic quotes (escape ' with '' instead of \').
+magic_quotes_sybase = Off
+
+; Automatically add files before or after any PHP document.
+auto_prepend_file =
+auto_append_file =
+
+; As of 4.0b4, PHP always outputs a character encoding by default in
+; the Content-type: header.  To disable sending of the charset, simply
+; set it to be empty.
+;
+; PHP's built-in default is text/html
+default_mimetype = "text/html"
+;default_charset = "iso-8859-1"
+
+; Always populate the $HTTP_RAW_POST_DATA variable.
+;always_populate_raw_post_data = On
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;
+; Paths and Directories ;
+;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; UNIX: "/path1:/path2"
+;include_path = ".:/php/includes"
+;
+; Windows: "\path1;\path2"
+;include_path = ".;c:\php\includes"
+
+; The root of the PHP pages, used only if nonempty.
+; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
+; if you are running php as a CGI under any web server (other than IIS)
+; see documentation for security issues.  The alternate is to use the
+; cgi.force_redirect configuration below
+doc_root =
+
+; The directory under which PHP opens the script using /~username used only
+; if nonempty.
+user_dir =
+
+; Directory in which the loadable extensions (modules) reside.
+extension_dir = "/usr/lib/php/modules"
+
+; Whether or not to enable the dl() function.  The dl() function does NOT work
+; properly in multithreaded servers, such as IIS or Zeus, and is automatically
+; disabled on them.
+enable_dl = On
+
+; cgi.force_redirect is necessary to provide security running PHP as a CGI under
+; most web servers.  Left undefined, PHP turns this on by default.  You can
+; turn it off here AT YOUR OWN RISK
+; **You CAN safely turn this off for IIS, in fact, you MUST.**
+; cgi.force_redirect = 1
+
+; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
+; every request.
+; cgi.nph = 1
+
+; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
+; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
+; will look for to know it is OK to continue execution.  Setting this variable MAY
+; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
+; cgi.redirect_status_env = ;
+
+; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
+; security tokens of the calling client.  This allows IIS to define the
+; security context that the request runs under.  mod_fastcgi under Apache
+; does not currently support this feature (03/17/2002)
+; Set to 1 if running under IIS.  Default is zero.
+; fastcgi.impersonate = 1;
+
+; Disable logging through FastCGI connection
+; fastcgi.log = 0
+
+; cgi.rfc2616_headers configuration option tells PHP what type of headers to
+; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
+; is supported by Apache. When this option is set to 1 PHP will send
+; RFC2616 compliant header.
+; Default is zero.
+;cgi.rfc2616_headers = 0
+
+
+;;;;;;;;;;;;;;;;
+; File Uploads ;
+;;;;;;;;;;;;;;;;
+
+; Whether to allow HTTP file uploads.
+file_uploads = On
+
+; Temporary directory for HTTP uploaded files (will use system default if not
+; specified).
+;upload_tmp_dir =
+
+; Maximum allowed size for uploaded files.
+upload_max_filesize = 2M
+
+
+;;;;;;;;;;;;;;;;;;
+; Fopen wrappers ;
+;;;;;;;;;;;;;;;;;;
+
+; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
+allow_url_fopen = On
+
+; Define the anonymous ftp password (your email address)
+;from="john@doe.com"
+
+; Define the User-Agent string
+; user_agent="PHP"
+
+; Default timeout for socket based streams (seconds)
+default_socket_timeout = 60
+
+; If your scripts have to deal with files from Macintosh systems,
+; or you are running on a Mac and need to deal with files from
+; unix or win32 systems, setting this flag will cause PHP to
+; automatically detect the EOL character in those files so that
+; fgets() and file() will work regardless of the source of the file.
+; auto_detect_line_endings = Off
+
+
+;;;;;;;;;;;;;;;;;;;;;;
+; Dynamic Extensions ;
+;;;;;;;;;;;;;;;;;;;;;;
+;
+; If you wish to have an extension loaded automatically, use the following
+; syntax:
+;
+;   extension=modulename.extension
+;
+; For example:
+;
+;   extension=msql.so
+;
+; Note that it should be the name of the module only; no directory information
+; needs to go here.  Specify the location of the extension with the
+; extension_dir directive above.
+
+  
+;;;;
+; Note: packaged extension modules are now loaded via the .ini files
+; found in the directory /etc/php.d; these are loaded by default.
+;;;;
+
+
+;;;;;;;;;;;;;;;;;;;
+; Module Settings ;
+;;;;;;;;;;;;;;;;;;;
+
+[Date]
+; Defines the default timezone used by the date functions
+;date.timezone =
+
+[Syslog]
+; Whether or not to define the various syslog variables (e.g. $LOG_PID,
+; $LOG_CRON, etc.).  Turning it off is a good idea performance-wise.  In
+; runtime, you can define these variables by calling define_syslog_variables().
+define_syslog_variables  = Off
+
+[mail function]
+; For Win32 only.
+SMTP = localhost
+smtp_port = 25
+
+; For Win32 only.
+;sendmail_from = me@example.com
+
+; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
+sendmail_path = /usr/sbin/sendmail -t -i
+
+; Force the addition of the specified parameters to be passed as extra parameters
+; to the sendmail binary. These parameters will always replace the value of
+; the 5th parameter to mail(), even in safe mode.
+;mail.force_extra_parameters =
+
+[SQL]
+sql.safe_mode = Off
+
+[ODBC]
+;odbc.default_db    =  Not yet implemented
+;odbc.default_user  =  Not yet implemented
+;odbc.default_pw    =  Not yet implemented
+
+; Allow or prevent persistent links.
+odbc.allow_persistent = On
+
+; Check that a connection is still valid before reuse.
+odbc.check_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+odbc.max_persistent = -1
+
+; Maximum number of links (persistent + non-persistent).  -1 means no limit.
+odbc.max_links = -1
+
+; Handling of LONG fields.  Returns number of bytes to variables.  0 means
+; passthru.
+odbc.defaultlrl = 4096
+
+; Handling of binary data.  0 means passthru, 1 return as is, 2 convert to char.
+; See the documentation on odbc_binmode and odbc_longreadlen for an explanation
+; of uodbc.defaultlrl and uodbc.defaultbinmode
+odbc.defaultbinmode = 1
+
+[MySQL]
+; Allow or prevent persistent links.
+mysql.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+mysql.max_persistent = -1
+
+; Maximum number of links (persistent + non-persistent).  -1 means no limit.
+mysql.max_links = -1
+
+; Default port number for mysql_connect().  If unset, mysql_connect() will use
+; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
+; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
+; at MYSQL_PORT.
+mysql.default_port =
+
+; Default socket name for local MySQL connects.  If empty, uses the built-in
+; MySQL defaults.
+mysql.default_socket =
+
+; Default host for mysql_connect() (doesn't apply in safe mode).
+mysql.default_host =
+
+; Default user for mysql_connect() (doesn't apply in safe mode).
+mysql.default_user =
+
+; Default password for mysql_connect() (doesn't apply in safe mode).
+; Note that this is generally a *bad* idea to store passwords in this file.
+; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
+; and reveal this password!  And of course, any users with read access to this
+; file will be able to reveal the password as well.
+mysql.default_password =
+
+; Maximum time (in secondes) for connect timeout. -1 means no limit
+mysql.connect_timeout = 60
+
+; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
+; SQL-Errors will be displayed.
+mysql.trace_mode = Off
+
+[MySQLi]
+
+; Maximum number of links.  -1 means no limit.
+mysqli.max_links = -1
+
+; Default port number for mysqli_connect().  If unset, mysqli_connect() will use
+; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
+; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
+; at MYSQL_PORT.
+mysqli.default_port = 3306
+
+; Default socket name for local MySQL connects.  If empty, uses the built-in
+; MySQL defaults.
+mysqli.default_socket =
+
+; Default host for mysql_connect() (doesn't apply in safe mode).
+mysqli.default_host =
+
+; Default user for mysql_connect() (doesn't apply in safe mode).
+mysqli.default_user =
+
+; Default password for mysqli_connect() (doesn't apply in safe mode).
+; Note that this is generally a *bad* idea to store passwords in this file.
+; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
+; and reveal this password!  And of course, any users with read access to this
+; file will be able to reveal the password as well.
+mysqli.default_pw =
+
+; Allow or prevent reconnect
+mysqli.reconnect = Off
+
+[mSQL]
+; Allow or prevent persistent links.
+msql.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+msql.max_persistent = -1
+
+; Maximum number of links (persistent+non persistent).  -1 means no limit.
+msql.max_links = -1
+
+[PostgresSQL]
+; Allow or prevent persistent links.
+pgsql.allow_persistent = On
+
+; Detect broken persistent links always with pg_pconnect().
+; Auto reset feature requires a little overheads.
+pgsql.auto_reset_persistent = Off
+
+; Maximum number of persistent links.  -1 means no limit.
+pgsql.max_persistent = -1
+
+; Maximum number of links (persistent+non persistent).  -1 means no limit.
+pgsql.max_links = -1
+
+; Ignore PostgreSQL backends Notice message or not.
+; Notice message logging require a little overheads.
+pgsql.ignore_notice = 0
+
+; Log PostgreSQL backends Noitce message or not.
+; Unless pgsql.ignore_notice=0, module cannot log notice message.
+pgsql.log_notice = 0
+
+[Sybase]
+; Allow or prevent persistent links.
+sybase.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+sybase.max_persistent = -1
+
+; Maximum number of links (persistent + non-persistent).  -1 means no limit.
+sybase.max_links = -1
+
+;sybase.interface_file = "/usr/sybase/interfaces"
+
+; Minimum error severity to display.
+sybase.min_error_severity = 10
+
+; Minimum message severity to display.
+sybase.min_message_severity = 10
+
+; Compatability mode with old versions of PHP 3.0.
+; If on, this will cause PHP to automatically assign types to results according
+; to their Sybase type, instead of treating them all as strings.  This
+; compatability mode will probably not stay around forever, so try applying
+; whatever necessary changes to your code, and turn it off.
+sybase.compatability_mode = Off
+
+[Sybase-CT]
+; Allow or prevent persistent links.
+sybct.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+sybct.max_persistent = -1
+
+; Maximum number of links (persistent + non-persistent).  -1 means no limit.
+sybct.max_links = -1
+
+; Minimum server message severity to display.
+sybct.min_server_severity = 10
+
+; Minimum client message severity to display.
+sybct.min_client_severity = 10
+
+[bcmath]
+; Number of decimal digits for all bcmath functions.
+bcmath.scale = 0
+
+[browscap]
+;browscap = extra/browscap.ini
+
+[Informix]
+; Default host for ifx_connect() (doesn't apply in safe mode).
+ifx.default_host =
+
+; Default user for ifx_connect() (doesn't apply in safe mode).
+ifx.default_user =
+
+; Default password for ifx_connect() (doesn't apply in safe mode).
+ifx.default_password =
+
+; Allow or prevent persistent links.
+ifx.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+ifx.max_persistent = -1
+
+; Maximum number of links (persistent + non-persistent).  -1 means no limit.
+ifx.max_links = -1
+
+; If on, select statements return the contents of a text blob instead of its id.
+ifx.textasvarchar = 0
+
+; If on, select statements return the contents of a byte blob instead of its id.
+ifx.byteasvarchar = 0
+
+; Trailing blanks are stripped from fixed-length char columns.  May help the
+; life of Informix SE users.
+ifx.charasvarchar = 0
+
+; If on, the contents of text and byte blobs are dumped to a file instead of
+; keeping them in memory.
+ifx.blobinfile = 0
+
+; NULL's are returned as empty strings, unless this is set to 1.  In that case,
+; NULL's are returned as string 'NULL'.
+ifx.nullformat = 0
+
+[Session]
+; Handler used to store/retrieve data.
+session.save_handler = files
+
+; Argument passed to save_handler.  In the case of files, this is the path
+; where data files are stored. Note: Windows users have to change this
+; variable in order to use PHP's session functions.
+;
+; As of PHP 4.0.1, you can define the path as:
+;
+;     session.save_path = "N;/path"
+;
+; where N is an integer.  Instead of storing all the session files in
+; /path, what this will do is use subdirectories N-levels deep, and
+; store the session data in those directories.  This is useful if you
+; or your OS have problems with lots of files in one directory, and is
+; a more efficient layout for servers that handle lots of sessions.
+;
+; NOTE 1: PHP will not create this directory structure automatically.
+;         You can use the script in the ext/session dir for that purpose.
+; NOTE 2: See the section on garbage collection below if you choose to
+;         use subdirectories for session storage
+;
+; The file storage module creates files using mode 600 by default.
+; You can change that by using
+;
+;     session.save_path = "N;MODE;/path"
+;
+; where MODE is the octal representation of the mode. Note that this
+; does not overwrite the process's umask.
+session.save_path = "/var/lib/php/session"
+
+; Whether to use cookies.
+session.use_cookies = 1
+
+; This option enables administrators to make their users invulnerable to
+; attacks which involve passing session ids in URLs; defaults to 0.
+; session.use_only_cookies = 1
+
+; Name of the session (used as cookie name).
+session.name = PHPSESSID
+
+; Initialize session on request startup.
+session.auto_start = 0
+
+; Lifetime in seconds of cookie or, if 0, until browser is restarted.
+session.cookie_lifetime = 0
+
+; The path for which the cookie is valid.
+session.cookie_path = /
+
+; The domain for which the cookie is valid.
+session.cookie_domain =
+
+; Handler used to serialize data.  php is the standard serializer of PHP.
+session.serialize_handler = php
+
+; Define the probability that the 'garbage collection' process is started
+; on every session initialization.
+; The probability is calculated by using gc_probability/gc_divisor,
+; e.g. 1/100 means there is a 1% chance that the GC process starts
+; on each request.
+
+session.gc_probability = 1
+session.gc_divisor     = 1000
+
+; After this number of seconds, stored data will be seen as 'garbage' and
+; cleaned up by the garbage collection process.
+session.gc_maxlifetime = 1440
+
+; NOTE: If you are using the subdirectory option for storing session files
+;       (see session.save_path above), then garbage collection does *not*
+;       happen automatically.  You will need to do your own garbage
+;       collection through a shell script, cron entry, or some other method.
+;       For example, the following script would is the equivalent of
+;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
+;          cd /path/to/sessions; find -cmin +24 | xargs rm
+
+; PHP 4.2 and less have an undocumented feature/bug that allows you to
+; to initialize a session variable in the global scope, albeit register_globals
+; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
+; You can disable the feature and the warning separately. At this time,
+; the warning is only displayed, if bug_compat_42 is enabled.
+
+session.bug_compat_42 = 0
+session.bug_compat_warn = 1
+
+; Check HTTP Referer to invalidate externally stored URLs containing ids.
+; HTTP_REFERER has to contain this substring for the session to be
+; considered as valid.
+session.referer_check =
+
+; How many bytes to read from the file.
+session.entropy_length = 0
+
+; Specified here to create the session id.
+session.entropy_file =
+
+;session.entropy_length = 16
+
+;session.entropy_file = /dev/urandom
+
+; Set to {nocache,private,public,} to determine HTTP caching aspects
+; or leave this empty to avoid sending anti-caching headers.
+session.cache_limiter = nocache
+
+; Document expires after n minutes.
+session.cache_expire = 180
+
+; trans sid support is disabled by default.
+; Use of trans sid may risk your users security.
+; Use this option with caution.
+; - User may send URL contains active session ID
+;   to other person via. email/irc/etc.
+; - URL that contains active session ID may be stored
+;   in publically accessible computer.
+; - User may access your site with the same session ID
+;   always using URL stored in browser's history or bookmarks.
+session.use_trans_sid = 0
+
+; Select a hash function
+; 0: MD5   (128 bits)
+; 1: SHA-1 (160 bits)
+session.hash_function = 0
+
+; Define how many bits are stored in each character when converting
+; the binary hash data to something readable.
+;
+; 4 bits: 0-9, a-f
+; 5 bits: 0-9, a-v
+; 6 bits: 0-9, a-z, A-Z, "-", ","
+session.hash_bits_per_character = 5
+
+; The URL rewriter will look for URLs in a defined set of HTML tags.
+; form/fieldset are special; if you include them here, the rewriter will
+; add a hidden <input> field with the info which is otherwise appended
+; to URLs.  If you want XHTML conformity, remove the form entry.
+; Note that all valid entries require a "=", even if no value follows.
+url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
+
+[MSSQL]
+; Allow or prevent persistent links.
+mssql.allow_persistent = On
+
+; Maximum number of persistent links.  -1 means no limit.
+mssql.max_persistent = -1
+
+; Maximum number of links (persistent+non persistent).  -1 means no limit.
+mssql.max_links = -1
+
+; Minimum error severity to display.
+mssql.min_error_severity = 10
+
+; Minimum message severity to display.
+mssql.min_message_severity = 10
+
+; Compatability mode with old versions of PHP 3.0.
+mssql.compatability_mode = Off
+
+; Connect timeout
+;mssql.connect_timeout = 5
+
+; Query timeout
+;mssql.timeout = 60
+
+; Valid range 0 - 2147483647.  Default = 4096.
+;mssql.textlimit = 4096
+
+; Valid range 0 - 2147483647.  Default = 4096.
+;mssql.textsize = 4096
+
+; Limits the number of records in each batch.  0 = all records in one batch.
+;mssql.batchsize = 0
+
+; Specify how datetime and datetim4 columns are returned
+; On => Returns data converted to SQL server settings
+; Off => Returns values as YYYY-MM-DD hh:mm:ss
+;mssql.datetimeconvert = On
+
+; Use NT authentication when connecting to the server
+mssql.secure_connection = Off
+
+; Specify max number of processes. -1 = library default
+; msdlib defaults to 25
+; FreeTDS defaults to 4096
+;mssql.max_procs = -1
+
+; Specify client character set. 
+; If empty or not set the client charset from freetds.comf is used
+; This is only used when compiled with FreeTDS
+;mssql.charset = "ISO-8859-1"
+
+[Assertion]
+; Assert(expr); active by default.
+;assert.active = On
+
+; Issue a PHP warning for each failed assertion.
+;assert.warning = On
+
+; Don't bail out by default.
+;assert.bail = Off
+
+; User-function to be called if an assertion fails.
+;assert.callback = 0
+
+; Eval the expression with current error_reporting().  Set to true if you want
+; error_reporting(0) around the eval().
+;assert.quiet_eval = 0
+
+[Verisign Payflow Pro]
+; Default Payflow Pro server.
+pfpro.defaulthost = "test-payflow.verisign.com"
+
+; Default port to connect to.
+pfpro.defaultport = 443
+
+; Default timeout in seconds.
+pfpro.defaulttimeout = 30
+
+; Default proxy IP address (if required).
+;pfpro.proxyaddress =
+
+; Default proxy port.
+;pfpro.proxyport =
+
+; Default proxy logon.
+;pfpro.proxylogon =
+
+; Default proxy password.
+;pfpro.proxypassword =
+
+[COM]
+; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
+;com.typelib_file =
+; allow Distributed-COM calls
+;com.allow_dcom = true
+; autoregister constants of a components typlib on com_load()
+;com.autoregister_typelib = true
+; register constants casesensitive
+;com.autoregister_casesensitive = false
+; show warnings on duplicate constat registrations
+;com.autoregister_verbose = true
+
+[mbstring]
+; language for internal character representation.
+;mbstring.language = Japanese
+
+; internal/script encoding.
+; Some encoding cannot work as internal encoding.
+; (e.g. SJIS, BIG5, ISO-2022-*)
+;mbstring.internal_encoding = EUC-JP
+
+; http input encoding.
+;mbstring.http_input = auto
+
+; http output encoding. mb_output_handler must be
+; registered as output buffer to function
+;mbstring.http_output = SJIS
+
+; enable automatic encoding translation according to
+; mbstring.internal_encoding setting. Input chars are
+; converted to internal encoding by setting this to On.
+; Note: Do _not_ use automatic encoding translation for
+;       portable libs/applications.
+;mbstring.encoding_translation = Off
+
+; automatic encoding detection order.
+; auto means
+;mbstring.detect_order = auto
+
+; substitute_character used when character cannot be converted
+; one from another
+;mbstring.substitute_character = none;
+
+; overload(replace) single byte functions by mbstring functions.
+; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
+; etc. Possible values are 0,1,2,4 or combination of them.
+; For example, 7 for overload everything.
+; 0: No overload
+; 1: Overload mail() function
+; 2: Overload str*() functions
+; 4: Overload ereg*() functions
+;mbstring.func_overload = 0
+
+; enable strict encoding detection.
+;mbstring.strict_encoding = Off
+
+[FrontBase]
+;fbsql.allow_persistent = On
+;fbsql.autocommit = On
+;fbsql.default_database =
+;fbsql.default_database_password =
+;fbsql.default_host =
+;fbsql.default_password =
+;fbsql.default_user = "_SYSTEM"
+;fbsql.generate_warnings = Off
+;fbsql.max_connections = 128
+;fbsql.max_links = 128
+;fbsql.max_persistent = -1
+;fbsql.max_results = 128
+;fbsql.batchSize = 1000
+
+[gd]
+; Tell the jpeg decode to libjpeg warnings and try to create
+; a gd image. The warning will then be displayed as notices
+; disabled by default
+;gd.jpeg_ignore_warning = 0
+
+[exif]
+; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS.
+; With mbstring support this will automatically be converted into the encoding
+; given by corresponding encode setting. When empty mbstring.internal_encoding
+; is used. For the decode settings you can distinguish between motorola and
+; intel byte order. A decode setting cannot be empty.
+;exif.encode_unicode = ISO-8859-15
+;exif.decode_unicode_motorola = UCS-2BE
+;exif.decode_unicode_intel    = UCS-2LE
+;exif.encode_jis =
+;exif.decode_jis_motorola = JIS
+;exif.decode_jis_intel    = JIS
+
+[Tidy]
+; The path to a default tidy configuration file to use when using tidy
+;tidy.default_config = /usr/local/lib/php/default.tcfg
+
+; Should tidy clean and repair output automatically?
+; WARNING: Do not use this option if you are generating non-html content
+; such as dynamic images
+tidy.clean_output = Off
+
+[soap]
+; Enables or disables WSDL caching feature.
+soap.wsdl_cache_enabled=1
+; Sets the directory name where SOAP extension will put cache files.
+soap.wsdl_cache_dir="/tmp"
+; (time to live) Sets the number of second while cached file will be used 
+; instead of original one.
+soap.wsdl_cache_ttl=86400
+
+; Local Variables:
+; tab-width: 4
+; End:
diff --git a/tests/root/etc/puppet/puppet.conf b/tests/root/etc/puppet/puppet.conf
new file mode 100644 (file)
index 0000000..70dcb02
--- /dev/null
@@ -0,0 +1,29 @@
+[main]
+    # Where Puppet stores dynamic and growing data.
+    # The default value is '/var/puppet'.
+    vardir = /var/lib/puppet
+
+    # The Puppet log directory.
+    # The default value is '$vardir/log'.
+    logdir = /var/log/puppet
+
+    # Where Puppet PID files are kept.
+    # The default value is '$vardir/run'.
+    rundir = /var/run/puppet
+
+    # Where SSL certificates are kept.
+    # The default value is '$confdir/ssl'.
+    ssldir = $vardir/ssl
+
+[puppetd]
+    # The file in which puppetd stores a list of the classes
+    # associated with the retrieved configuratiion.  Can be loaded in
+    # the separate ``puppet`` executable using the ``--loadclasses``
+    # option.
+    # The default value is '$confdir/classes.txt'.
+    classfile = $vardir/classes.txt
+
+    # Where puppetd caches the local configuration.  An
+    # extension indicating the cache format is added automatically.
+    # The default value is '$confdir/localconfig'.
+    localconfig = $vardir/localconfig
diff --git a/tests/root/etc/samba/smb.conf b/tests/root/etc/samba/smb.conf
new file mode 100644 (file)
index 0000000..5be6fa0
--- /dev/null
@@ -0,0 +1,288 @@
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options (perhaps too
+# many!) most of which are not shown in this example
+#
+# For a step to step guide on installing, configuring and using samba, 
+# read the Samba-HOWTO-Collection. This may be obtained from:
+#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
+#
+# Many working examples of smb.conf files can be found in the 
+# Samba-Guide which is generated daily and can be downloaded from: 
+#  http://www.samba.org/samba/docs/Samba-Guide.pdf
+#
+# Any line which starts with a ; (semi-colon) or a # (hash) 
+# is a comment and is ignored. In this example we will use a #
+# for commentry and a ; for parts of the config file that you
+# may wish to enable
+#
+# NOTE: Whenever you modify this file you should run the command "testparm"
+# to check that you have not made any basic syntactic errors. 
+#
+#---------------
+# SELINUX NOTES:
+#
+# If you want to use the useradd/groupadd family of binaries please run:
+# setsebool -P samba_domain_controller on
+#
+# If you want to share home directories via samba please run:
+# setsebool -P samba_enable_home_dirs on
+#
+# If you create a new directory you want to share you should mark it as
+# "samba-share_t" so that selinux will let you write into it.
+# Make sure not to do that on system directories as they may already have
+# been marked with othe SELinux labels.
+#
+# Use ls -ldZ /path to see which context a directory has
+#
+# Set labels only on directories you created!
+# To set a label use the following: chcon -t samba_share_t /path
+#
+# If you need to share a system created directory you can use one of the
+# following (read-only/read-write):
+# setsebool -P samba_export_all_ro on
+# or
+# setsebool -P samba_export_all_rw on
+#
+# If you want to run scripts (preexec/root prexec/print command/...) please
+# put them into the /var/lib/samba/scripts directory so that smbd will be
+# allowed to run them.
+# Make sure you COPY them and not MOVE them so that the right SELinux context
+# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
+#
+#--------------
+#
+#======================= Global Settings =====================================
+       
+[global]
+       
+# ----------------------- Netwrok Related Options -------------------------
+#
+# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
+#
+# server string is the equivalent of the NT Description field
+#
+# netbios name can be used to specify a server name not tied to the hostname
+#
+# Interfaces lets you configure Samba to use multiple interfaces
+# If you have multiple network interfaces then you can list the ones
+# you want to listen on (never omit localhost)
+#
+# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
+# specifiy it as a per share option as well
+#
+       workgroup = MYGROUP
+       server string = Samba Server Version %v
+       
+;      netbios name = MYSERVER
+       
+;      interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 
+;      hosts allow = 127. 192.168.12. 192.168.13.
+       
+# --------------------------- Logging Options -----------------------------
+#
+# Log File let you specify where to put logs and how to split them up.
+#
+# Max Log Size let you specify the max size log files should reach
+       
+       # logs split per machine
+       log file = /var/log/samba/log.%m
+       # max 50KB per log file, then rotate
+       max log size = 50
+       
+# ----------------------- Standalone Server Options ------------------------
+#
+# Scurity can be set to user, share(deprecated) or server(deprecated)
+#
+# Backend to store user information in. New installations should 
+# use either tdbsam or ldapsam. smbpasswd is available for backwards 
+# compatibility. tdbsam requires no further configuration.
+
+       security = user
+       passdb backend = tdbsam
+
+
+# ----------------------- Domain Members Options ------------------------
+#
+# Security must be set to domain or ads
+#
+# Use the realm option only with security = ads
+# Specifies the Active Directory realm the host is part of
+#
+# Backend to store user information in. New installations should 
+# use either tdbsam or ldapsam. smbpasswd is available for backwards 
+# compatibility. tdbsam requires no further configuration.
+#
+# Use password server option only with security = server or if you can't
+# use the DNS to locate Domain Controllers
+# The argument list may include:
+#   password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
+# or to auto-locate the domain controller/s
+#   password server = *
+       
+       
+;      security = domain
+;      passdb backend = tdbsam
+;      realm = MY_REALM
+
+;      password server = <NT-Server-Name>
+
+# ----------------------- Domain Controller Options ------------------------
+#
+# Security must be set to user for domain controllers
+#
+# Backend to store user information in. New installations should 
+# use either tdbsam or ldapsam. smbpasswd is available for backwards 
+# compatibility. tdbsam requires no further configuration.
+#
+# Domain Master specifies Samba to be the Domain Master Browser. This
+# allows Samba to collate browse lists between subnets. Don't use this
+# if you already have a Windows NT domain controller doing this job
+#
+# Domain Logons let Samba be a domain logon server for Windows workstations. 
+#
+# Logon Scrpit let yuou specify a script to be run at login time on the client
+# You need to provide it in a share called NETLOGON
+#
+# Logon Path let you specify where user profiles are stored (UNC path)
+#
+# Various scripts can be used on a domain controller or stand-alone
+# machine to add or delete corresponding unix accounts
+#
+;      security = user
+;      passdb backend = tdbsam
+       
+;      domain master = yes 
+;      domain logons = yes
+       
+       # the login script name depends on the machine name
+;      logon script = %m.bat
+       # the login script name depends on the unix user used
+;      logon script = %u.bat
+;      logon path = \\%L\Profiles\%u
+       # disables profiles support by specifing an empty path
+;      logon path =          
+       
+;      add user script = /usr/sbin/useradd "%u" -n -g users
+;      add group script = /usr/sbin/groupadd "%g"
+;      add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u"
+;      delete user script = /usr/sbin/userdel "%u"
+;      delete user from group script = /usr/sbin/userdel "%u" "%g"
+;      delete group script = /usr/sbin/groupdel "%g"
+       
+       
+# ----------------------- Browser Control Options ----------------------------
+#
+# set local master to no if you don't want Samba to become a master
+# browser on your network. Otherwise the normal election rules apply
+#
+# OS Level determines the precedence of this server in master browser
+# elections. The default value should be reasonable
+#
+# Preferred Master causes Samba to force a local browser election on startup
+# and gives it a slightly higher chance of winning the election
+;      local master = no
+;      os level = 33
+;      preferred master = yes
+       
+#----------------------------- Name Resolution -------------------------------
+# Windows Internet Name Serving Support Section:
+# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
+#
+# - WINS Support: Tells the NMBD component of Samba to enable it's WINS Server
+#
+# - WINS Server: Tells the NMBD components of Samba to be a WINS Client
+#
+# - WINS Proxy: Tells Samba to answer name resolution queries on
+#   behalf of a non WINS capable client, for this to work there must be
+#   at least one       WINS Server on the network. The default is NO.
+#
+# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
+# via DNS nslookups.
+       
+;      wins support = yes
+;      wins server = w.x.y.z
+;      wins proxy = yes
+       
+;      dns proxy = yes
+       
+# --------------------------- Printing Options -----------------------------
+#
+# Load Printers let you load automatically the list of printers rather
+# than setting them up individually
+#
+# Cups Options let you pass the cups libs custom options, setting it to raw
+# for example will let you use drivers on your Windows clients
+#
+# Printcap Name let you specify an alternative printcap file
+#
+# You can choose a non default printing system using the Printing option
+       
+       load printers = yes
+       cups options = raw
+
+;      printcap name = /etc/printcap
+       #obtain list of printers automatically on SystemV
+;      printcap name = lpstat
+;      printing = cups
+
+# --------------------------- Filesystem Options ---------------------------
+#
+# The following options can be uncommented if the filesystem supports
+# Extended Attributes and they are enabled (usually by the mount option
+# user_xattr). Thess options will let the admin store the DOS attributes
+# in an EA and make samba not mess with the permission bits.
+#
+# Note: these options can also be set just per share, setting them in global
+# makes them the default for all shares
+
+;      map archive = no
+;      map hidden = no
+;      map read only = no
+;      map system = no
+;      store dos attributes = yes
+
+
+#============================ Share Definitions ==============================
+       
+[homes]
+       comment = Home Directories
+       browseable = no
+       writable = yes
+;      valid users = %S
+;      valid users = MYDOMAIN\%S
+       
+[printers]
+       comment = All Printers
+       path = /var/spool/samba
+       browseable = no
+       guest ok = no
+       writable = no
+       printable = yes
+       
+# Un-comment the following and create the netlogon directory for Domain Logons
+;      [netlogon]
+;      comment = Network Logon Service
+;      path = /var/lib/samba/netlogon
+;      guest ok = yes
+;      writable = no
+;      share modes = no
+       
+       
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
+;      [Profiles]
+;      path = /var/lib/samba/profiles
+;      browseable = no
+;      guest ok = yes
+       
+       
+# A publicly accessible directory, but read only, except for people in
+# the "staff" group
+;      [public]
+;      comment = Public Stuff
+;      path = /home/samba
+;      public = yes
+;      writable = yes
+;      printable = no
+;      write list = +staff
diff --git a/tests/root/etc/security/limits.conf b/tests/root/etc/security/limits.conf
new file mode 100644 (file)
index 0000000..740c77e
--- /dev/null
@@ -0,0 +1,58 @@
+# /etc/security/limits.conf
+#
+#Each line describes a limit for a user in the form:
+#
+#<domain>        <type>  <item>  <value>
+#
+#Where:
+#<domain> can be:
+#        - an user name
+#        - a group name, with @group syntax
+#        - the wildcard *, for default entry
+#        - the wildcard %, can be also used with %group syntax,
+#                 for maxlogin limit
+#
+#<type> can have the two values:
+#        - "soft" for enforcing the soft limits
+#        - "hard" for enforcing hard limits
+#
+#<item> can be one of the following:
+#        - core - limits the core file size (KB)
+#        - data - max data size (KB)
+#        - fsize - maximum filesize (KB)
+#        - memlock - max locked-in-memory address space (KB)
+#        - nofile - max number of open files
+#        - rss - max resident set size (KB)
+#        - stack - max stack size (KB)
+#        - cpu - max CPU time (MIN)
+#        - nproc - max number of processes
+#        - as - address space limit
+#        - maxlogins - max number of logins for this user
+#        - maxsyslogins - max number of logins on the system
+#        - priority - the priority to run user process with
+#        - locks - max number of file locks the user can hold
+#        - sigpending - max number of pending signals
+#        - msgqueue - max memory used by POSIX message queues (bytes)
+#        - nice - max nice priority allowed to raise to
+#        - rtprio - max realtime priority
+#
+#<domain>      <type>  <item>         <value>
+#
+
+#*               soft    core            0
+#*               hard    rss             10000
+#@student        hard    nproc           20
+#@faculty        soft    nproc           20
+#@faculty        hard    nproc           50
+#ftp             hard    nproc           0
+#@student        -       maxlogins       4
+
+# End of file
+
+## Automatically appended by jack-audio-connection-kit
+@jackuser - rtprio 20
+@jackuser - memlock 4194304
+
+## Automatically appended by jack-audio-connection-kit
+@pulse-rt - rtprio 20
+@pulse-rt - nice -20
diff --git a/tests/root/etc/services b/tests/root/etc/services
new file mode 100644 (file)
index 0000000..0f57519
--- /dev/null
@@ -0,0 +1,387 @@
+# /etc/services:
+# $Id: services,v 1.44 2008/04/07 21:30:33 pknirsch Exp $
+#
+#
+# Truncated version of Fedora's /etc/services, the original is gigantic
+#
+# Network services, Internet style
+#
+# Note that it is presently the policy of IANA to assign a single well-known
+# port number for both TCP and UDP; hence, most entries here have two entries
+# even if the protocol doesn't support UDP operations.
+# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
+# are included, only the more common ones.
+#
+# The latest IANA port assignments can be gotten from
+#      http://www.iana.org/assignments/port-numbers
+# The Well Known Ports are those from 0 through 1023.
+# The Registered Ports are those from 1024 through 49151
+# The Dynamic and/or Private Ports are those from 49152 through 65535
+#
+# Each line describes one service, and is of the form:
+#
+# service-name  port/protocol  [aliases ...]   [# comment]
+
+tcpmux         1/tcp                           # TCP port service multiplexer
+tcpmux         1/udp                           # TCP port service multiplexer
+rje            5/tcp                           # Remote Job Entry
+rje            5/udp                           # Remote Job Entry
+echo           7/tcp
+echo           7/udp
+discard                9/tcp           sink null
+discard                9/udp           sink null
+systat         11/tcp          users
+systat         11/udp          users
+daytime                13/tcp
+daytime                13/udp
+qotd           17/tcp          quote
+qotd           17/udp          quote
+msp            18/tcp                          # message send protocol
+msp            18/udp                          # message send protocol
+chargen                19/tcp          ttytst source
+chargen                19/udp          ttytst source
+ftp-data       20/tcp
+ftp-data       20/udp
+# 21 is registered to ftp, but also used by fsp
+ftp            21/tcp
+ftp            21/udp          fsp fspd
+ssh            22/tcp                          # SSH Remote Login Protocol
+ssh            22/udp                          # SSH Remote Login Protocol
+telnet         23/tcp
+telnet         23/udp
+# 24 - private mail system
+lmtp           24/tcp                          # LMTP Mail Delivery
+lmtp           24/udp                          # LMTP Mail Delivery
+smtp           25/tcp          mail
+smtp           25/udp          mail
+time           37/tcp          timserver
+time           37/udp          timserver
+rlp            39/tcp          resource        # resource location
+rlp            39/udp          resource        # resource location
+nameserver     42/tcp          name            # IEN 116
+nameserver     42/udp          name            # IEN 116
+nicname                43/tcp          whois
+nicname                43/udp          whois
+tacacs         49/tcp                          # Login Host Protocol (TACACS)
+tacacs         49/udp                          # Login Host Protocol (TACACS)
+re-mail-ck     50/tcp                          # Remote Mail Checking Protocol
+re-mail-ck     50/udp                          # Remote Mail Checking Protocol
+domain         53/tcp                          # name-domain server
+domain         53/udp
+whois++                63/tcp
+whois++                63/udp
+bootps         67/tcp                          # BOOTP server
+bootps         67/udp
+bootpc         68/tcp          dhcpc           # BOOTP client
+bootpc         68/udp          dhcpc
+tftp           69/tcp
+tftp           69/udp
+gopher         70/tcp                          # Internet Gopher
+gopher         70/udp
+netrjs-1       71/tcp                          # Remote Job Service
+netrjs-1       71/udp                          # Remote Job Service
+netrjs-2       72/tcp                          # Remote Job Service
+netrjs-2       72/udp                          # Remote Job Service
+netrjs-3       73/tcp                          # Remote Job Service
+netrjs-3       73/udp                          # Remote Job Service
+netrjs-4       74/tcp                          # Remote Job Service
+netrjs-4       74/udp                          # Remote Job Service
+finger         79/tcp
+finger         79/udp
+http           80/tcp          www www-http    # WorldWideWeb HTTP
+http           80/udp          www www-http    # HyperText Transfer Protocol
+kerberos       88/tcp          kerberos5 krb5  # Kerberos v5
+kerberos       88/udp          kerberos5 krb5  # Kerberos v5
+supdup         95/tcp
+supdup         95/udp
+hostname       101/tcp         hostnames       # usually from sri-nic
+hostname       101/udp         hostnames       # usually from sri-nic
+iso-tsap       102/tcp         tsap            # part of ISODE.
+csnet-ns       105/tcp         cso             # also used by CSO name server
+csnet-ns       105/udp         cso
+# unfortunately the poppassd (Eudora) uses a port which has already
+# been assigned to a different service. We list the poppassd as an
+# alias here. This should work for programs asking for this service.
+# (due to a bug in inetd the 3com-tsmux line is disabled)
+#3com-tsmux    106/tcp         poppassd
+#3com-tsmux    106/udp         poppassd
+rtelnet                107/tcp                         # Remote Telnet
+rtelnet                107/udp
+pop2           109/tcp         pop-2   postoffice      # POP version 2
+pop2           109/udp         pop-2
+pop3           110/tcp         pop-3           # POP version 3
+pop3           110/udp         pop-3
+sunrpc         111/tcp         portmapper rpcbind      # RPC 4.0 portmapper TCP
+sunrpc         111/udp         portmapper rpcbind      # RPC 4.0 portmapper UDP
+auth           113/tcp         authentication tap ident
+auth           113/udp         authentication tap ident
+sftp           115/tcp
+sftp           115/udp
+uucp-path      117/tcp
+uucp-path      117/udp
+nntp           119/tcp         readnews untp   # USENET News Transfer Protocol
+nntp           119/udp         readnews untp   # USENET News Transfer Protocol
+ntp            123/tcp
+ntp            123/udp                         # Network Time Protocol
+netbios-ns     137/tcp                         # NETBIOS Name Service
+netbios-ns     137/udp
+netbios-dgm    138/tcp                         # NETBIOS Datagram Service
+netbios-dgm    138/udp
+netbios-ssn    139/tcp                         # NETBIOS session service
+netbios-ssn    139/udp
+imap           143/tcp         imap2           # Interim Mail Access Proto v2
+imap           143/udp         imap2
+snmp           161/tcp                         # Simple Net Mgmt Proto
+snmp           161/udp                         # Simple Net Mgmt Proto
+snmptrap       162/tcp                         # SNMPTRAP
+snmptrap       162/udp         snmp-trap       # Traps for SNMP
+cmip-man       163/tcp                         # ISO mgmt over IP (CMOT)
+cmip-man       163/udp
+cmip-agent     164/tcp
+cmip-agent     164/udp
+mailq          174/tcp                         # MAILQ
+mailq          174/udp                         # MAILQ
+xdmcp          177/tcp                         # X Display Mgr. Control Proto
+xdmcp          177/udp
+nextstep       178/tcp         NeXTStep NextStep       # NeXTStep window
+nextstep       178/udp         NeXTStep NextStep       # server
+bgp            179/tcp                         # Border Gateway Proto.
+bgp            179/udp
+prospero       191/tcp                         # Cliff Neuman's Prospero
+prospero       191/udp
+irc            194/tcp                         # Internet Relay Chat
+irc            194/udp
+smux           199/tcp                         # SNMP Unix Multiplexer
+smux           199/udp
+at-rtmp                201/tcp                         # AppleTalk routing
+at-rtmp                201/udp
+at-nbp         202/tcp                         # AppleTalk name binding
+at-nbp         202/udp
+at-echo                204/tcp                         # AppleTalk echo
+at-echo                204/udp
+at-zis         206/tcp                         # AppleTalk zone information
+at-zis         206/udp
+qmtp           209/tcp                         # Quick Mail Transfer Protocol
+qmtp           209/udp                         # Quick Mail Transfer Protocol
+z39.50         210/tcp         z3950 wais      # NISO Z39.50 database
+z39.50         210/udp         z3950 wais
+ipx            213/tcp                         # IPX
+ipx            213/udp
+imap3          220/tcp                         # Interactive Mail Access
+imap3          220/udp                         # Protocol v3
+link           245/tcp         ttylink
+link           245/udp         ttylink
+fatserv                347/tcp                         # Fatmen Server
+fatserv                347/udp                         # Fatmen Server
+rsvp_tunnel    363/tcp
+rsvp_tunnel    363/udp
+odmr           366/tcp                         # odmr required by fetchmail
+odmr           366/udp                         # odmr required by fetchmail
+rpc2portmap    369/tcp
+rpc2portmap    369/udp                         # Coda portmapper
+codaauth2      370/tcp
+codaauth2      370/udp                         # Coda authentication server
+ulistproc      372/tcp         ulistserv       # UNIX Listserv
+ulistproc      372/udp         ulistserv
+ldap           389/tcp
+ldap           389/udp
+svrloc          427/tcp                                # Server Location Protocl
+svrloc          427/udp                                # Server Location Protocl
+mobileip-agent 434/tcp
+mobileip-agent 434/udp
+mobilip-mn     435/tcp
+mobilip-mn     435/udp
+https          443/tcp                         # MCom
+https          443/udp                         # MCom
+snpp           444/tcp                         # Simple Network Paging Protocol
+snpp           444/udp                         # Simple Network Paging Protocol
+microsoft-ds   445/tcp
+microsoft-ds   445/udp
+kpasswd                464/tcp         kpwd            # Kerberos "passwd"
+kpasswd                464/udp         kpwd            # Kerberos "passwd"
+photuris       468/tcp
+photuris       468/udp
+saft           487/tcp                         # Simple Asynchronous File Transfer
+saft           487/udp                         # Simple Asynchronous File Transfer
+gss-http       488/tcp
+gss-http       488/udp
+pim-rp-disc    496/tcp
+pim-rp-disc    496/udp
+isakmp         500/tcp
+isakmp         500/udp
+gdomap         538/tcp                         # GNUstep distributed objects
+gdomap         538/udp                         # GNUstep distributed objects
+iiop           535/tcp
+iiop           535/udp
+dhcpv6-client  546/tcp
+dhcpv6-client  546/udp
+dhcpv6-server  547/tcp
+dhcpv6-server  547/udp
+rtsp           554/tcp                         # Real Time Stream Control Protocol
+rtsp           554/udp                         # Real Time Stream Control Protocol
+nntps          563/tcp                         # NNTP over SSL
+nntps          563/udp                         # NNTP over SSL
+whoami         565/tcp
+whoami         565/udp
+submission     587/tcp         msa             # mail message submission
+submission     587/udp         msa             # mail message submission
+npmp-local     610/tcp         dqs313_qmaster  # npmp-local / DQS
+npmp-local     610/udp         dqs313_qmaster  # npmp-local / DQS
+npmp-gui       611/tcp         dqs313_execd    # npmp-gui / DQS
+npmp-gui       611/udp         dqs313_execd    # npmp-gui / DQS
+hmmp-ind       612/tcp         dqs313_intercell # HMMP Indication / DQS
+hmmp-ind       612/udp         dqs313_intercell # HMMP Indication / DQS
+ipp            631/tcp                         # Internet Printing Protocol
+ipp            631/udp                         # Internet Printing Protocol
+ldaps          636/tcp                         # LDAP over SSL
+ldaps          636/udp                         # LDAP over SSL
+acap           674/tcp
+acap           674/udp
+ha-cluster     694/tcp                         # Heartbeat HA-cluster
+ha-cluster     694/udp                         # Heartbeat HA-cluster
+kerberos-adm   749/tcp                         # Kerberos `kadmin' (v5)
+kerberos-adm   749/udp                         # kerberos administration
+kerberos-iv    750/udp         kerberos4 kerberos-sec kdc loadav
+kerberos-iv    750/tcp         kerberos4 kerberos-sec kdc rfile
+webster                765/tcp                         # Network dictionary
+webster                765/udp
+phonebook      767/tcp                         # Network phonebook
+phonebook      767/udp
+rsync          873/tcp                         # rsync
+rsync          873/udp                         # rsync
+rquotad  875/tcp      # rquota daemon
+rquotad  875/udp      # rquota daemon
+telnets                992/tcp
+telnets                992/udp
+imaps          993/tcp                         # IMAP over SSL
+imaps          993/udp                         # IMAP over SSL
+ircs           994/tcp
+ircs           994/udp
+pop3s          995/tcp                         # POP-3 over SSL
+pop3s          995/udp                         # POP-3 over SSL
+
+#
+# UNIX specific services
+#
+exec           512/tcp
+biff           512/udp         comsat
+login          513/tcp
+who            513/udp         whod
+shell          514/tcp         cmd             # no passwords used
+syslog         514/udp
+printer                515/tcp         spooler         # line printer spooler
+printer                515/udp         spooler         # line printer spooler
+talk           517/udp
+ntalk          518/udp
+utime          519/tcp         unixtime
+utime          519/udp         unixtime
+efs            520/tcp
+router         520/udp         route routed    # RIP
+ripng          521/tcp
+ripng          521/udp
+timed          525/tcp         timeserver
+timed          525/udp         timeserver
+tempo          526/tcp         newdate
+courier                530/tcp         rpc
+conference     531/tcp         chat
+netnews                532/tcp
+netwall                533/udp                         # -for emergency broadcasts
+uucp           540/tcp         uucpd           # uucp daemon
+klogin         543/tcp                         # Kerberized `rlogin' (v5)
+kshell         544/tcp         krcmd           # Kerberized `rsh' (v5)
+afpovertcp     548/tcp                         # AFP over TCP
+afpovertcp     548/udp                         # AFP over TCP
+remotefs       556/tcp         rfs_server rfs  # Brunhoff remote filesystem
+
+#
+# From ``PORT NUMBERS'':
+#
+#>REGISTERED PORT NUMBERS
+#>
+#>The Registered Ports are listed by the IANA and on most systems can be
+#>used by ordinary user processes or programs executed by ordinary
+#>users.
+#>
+#>Ports are used in the TCP [RFC793] to name the ends of logical
+#>connections which carry long term conversations.  For the purpose of
+#>providing services to unknown callers, a service contact port is
+#>defined.  This list specifies the port used by the server process as
+#>its contact port.
+#>
+#>The IANA registers uses of these ports as a convienence to the
+#>community.
+#
+socks          1080/tcp                        # socks proxy server
+socks          1080/udp                        # socks proxy server
+
+# Port 1236 is registered as `bvcontrol', but is also used by the
+# Gracilis Packeten remote config server.  The official name is listed as
+# the primary name, with the unregistered name as an alias.
+bvcontrol      1236/tcp        rmtcfg          # Daniel J. Walsh, Gracilis Packeten remote config server
+bvcontrol      1236/udp                        # Daniel J. Walsh
+
+h323hostcallsc 1300/tcp                        # H323 Host Call Secure
+h323hostcallsc 1300/udp                        # H323 Host Call Secure
+ms-sql-s       1433/tcp                        # Microsoft-SQL-Server 
+ms-sql-s       1433/udp                        # Microsoft-SQL-Server 
+ms-sql-m       1434/tcp                        # Microsoft-SQL-Monitor
+ms-sql-m       1434/udp                        # Microsoft-SQL-Monitor          
+ica            1494/tcp                        # Citrix ICA Client
+ica            1494/udp                        # Citrix ICA Client
+wins           1512/tcp                        # Microsoft's Windows Internet Name Service
+wins           1512/udp                        # Microsoft's Windows Internet Name Service
+ingreslock     1524/tcp
+ingreslock     1524/udp
+prospero-np    1525/tcp        orasrv          # Prospero non-privileged/oracle
+prospero-np    1525/udp        orasrv
+datametrics    1645/tcp        old-radius sightline    # datametrics / old radius entry
+datametrics    1645/udp        old-radius sightline    # datametrics / old radius entry
+sa-msg-port    1646/tcp        old-radacct     # sa-msg-port / old radacct entry
+sa-msg-port    1646/udp        old-radacct     # sa-msg-port / old radacct entry
+kermit         1649/tcp
+kermit         1649/udp
+l2tp           1701/tcp        l2f
+l2tp           1701/udp        l2f
+h323gatedisc   1718/tcp
+h323gatedisc   1718/udp
+h323gatestat   1719/tcp
+h323gatestat   1719/udp
+h323hostcall   1720/tcp
+h323hostcall   1720/udp
+tftp-mcast     1758/tcp
+tftp-mcast     1758/udp
+mtftp          1759/udp        spss-lm
+hello          1789/tcp
+hello          1789/udp
+radius         1812/tcp                        # Radius
+radius         1812/udp                        # Radius
+radius-acct    1813/tcp        radacct         # Radius Accounting
+radius-acct    1813/udp        radacct         # Radius Accounting
+mtp            1911/tcp                        #
+mtp            1911/udp                        #
+hsrp           1985/tcp                        # Cisco Hot Standby Router Protocol
+hsrp           1985/udp                        # Cisco Hot Standby Router Protocol
+licensedaemon  1986/tcp
+licensedaemon  1986/udp
+gdp-port       1997/tcp                        # Cisco Gateway Discovery Protocol
+gdp-port       1997/udp                        # Cisco Gateway Discovery Protocol
+sieve          2000/tcp        cisco-sccp      # Sieve Mail Filter Daemon
+sieve          2000/udp        cisco-sccp      # Sieve Mail Filter Daemon
+nfs            2049/tcp        nfsd shilp
+nfs            2049/udp        nfsd shilp
+zephyr-srv     2102/tcp                        # Zephyr server
+zephyr-srv     2102/udp                        # Zephyr server
+zephyr-clt     2103/tcp                        # Zephyr serv-hm connection
+zephyr-clt     2103/udp                        # Zephyr serv-hm connection
+zephyr-hm      2104/tcp                        # Zephyr hostmanager
+zephyr-hm      2104/udp                        # Zephyr hostmanager
+cvspserver     2401/tcp                        # CVS client/server operations
+cvspserver     2401/udp                        # CVS client/server operations
+venus          2430/tcp                        # codacon port
+venus          2430/udp                        # Venus callback/wbc interface
+venus-se       2431/tcp                        # tcp side effects
+venus-se       2431/udp                        # udp sftp side effect
+codasrv                2432/tcp                        # not used
+codasrv                2432/udp                        # server port
+codasrv-se     2433/tcp                        # tcp side effects
+codasrv-se     2433/udp                        # udp sftp side effectQ
diff --git a/tests/root/etc/squid/squid.conf b/tests/root/etc/squid/squid.conf
new file mode 100644 (file)
index 0000000..208625c
--- /dev/null
@@ -0,0 +1,4725 @@
+
+#      WELCOME TO SQUID 3.0.STABLE13
+#      ----------------------------
+#
+#      This is the default Squid configuration file. You may wish
+#      to look at the Squid home page (http://www.squid-cache.org/)
+#      for the FAQ and other documentation.
+#
+#      The default Squid config file shows what the defaults for
+#      various options happen to be.  If you don't need to change the
+#      default, you shouldn't uncomment the line.  Doing so may cause
+#      run-time problems.  In some cases "none" refers to no default
+#      setting at all, while in other cases it refers to a valid
+#      option - the comments for that keyword indicate if this is the
+#      case.
+#
+
+
+#  Configuration options can be included using the "include" directive.
+#  Include takes a list of files to include. Quoting and wildcards is
+#  supported.
+#
+#  For example,
+#
+#  include /path/to/included/file/squid.acl.config
+#
+#  Includes can be nested up to a hard-coded depth of 16 levels.
+#  This arbitrary restriction is to prevent recursive include references
+#  from causing Squid entering an infinite loop whilst trying to load
+#  configuration files.
+
+
+# OPTIONS FOR AUTHENTICATION
+# -----------------------------------------------------------------------------
+
+#  TAG: auth_param
+#      This is used to define parameters for the various authentication
+#      schemes supported by Squid.
+#
+#      format: auth_param scheme parameter [setting]
+#
+#      The order in which authentication schemes are presented to the client is
+#      dependent on the order the scheme first appears in config file. IE
+#      has a bug (it's not RFC 2617 compliant) in that it will use the basic
+#      scheme if basic is the first entry presented, even if more secure
+#      schemes are presented. For now use the order in the recommended
+#      settings section below. If other browsers have difficulties (don't
+#      recognize the schemes offered even if you are using basic) either
+#      put basic first, or disable the other schemes (by commenting out their
+#      program entry).
+#
+#      Once an authentication scheme is fully configured, it can only be
+#      shutdown by shutting squid down and restarting. Changes can be made on
+#      the fly and activated with a reconfigure. I.E. You can change to a
+#      different helper, but not unconfigure the helper completely.
+#
+#      Please note that while this directive defines how Squid processes
+#      authentication it does not automatically activate authentication.
+#      To use authentication you must in addition make use of ACLs based
+#      on login name in http_access (proxy_auth, proxy_auth_regex or
+#      external with %LOGIN used in the format tag). The browser will be
+#      challenged for authentication on the first such acl encountered
+#      in http_access processing and will also be re-challenged for new
+#      login credentials if the request is being denied by a proxy_auth
+#      type acl.
+#
+#      WARNING: authentication can't be used in a transparently intercepting
+#      proxy as the client then thinks it is talking to an origin server and
+#      not the proxy. This is a limitation of bending the TCP/IP protocol to
+#      transparently intercepting port 80, not a limitation in Squid.
+#      Ports flagged 'transparent' or 'tproxy' have authentication disabled.
+#
+#      === Parameters for the basic scheme follow. ===
+#
+#      "program" cmdline
+#      Specify the command for the external authenticator.  Such a program
+#      reads a line containing "username password" and replies "OK" or
+#      "ERR" in an endless loop. "ERR" responses may optionally be followed
+#      by a error description available as %m in the returned error page.
+#      If you use an authenticator, make sure you have 1 acl of type proxy_auth.
+#
+#      By default, the basic authentication scheme is not used unless a
+#      program is specified.
+#
+#      If you want to use the traditional NCSA proxy authentication, set
+#      this line to something like
+#
+#      auth_param basic program /usr/libexec/ncsa_auth /usr/etc/passwd
+#
+#      "children" numberofchildren
+#      The number of authenticator processes to spawn. If you start too few
+#      Squid will have to wait for them to process a backlog of credential
+#      verifications, slowing it down. When password verifications are
+#      done via a (slow) network you are likely to need lots of
+#      authenticator processes.
+#      auth_param basic children 5
+#
+#      "concurrency" concurrency
+#      The number of concurrent requests the helper can process.
+#      The default of 0 is used for helpers who only supports
+#      one request at a time. Setting this changes the protocol used to
+#      include a channel number first on the request/response line, allowing
+#      multiple requests to be sent to the same helper in parallell without
+#      wating for the response.
+#      Must not be set unless it's known the helper supports this.
+#      auth_param basic concurrency 0
+#
+#      "realm" realmstring
+#      Specifies the realm name which is to be reported to the
+#      client for the basic proxy authentication scheme (part of
+#      the text the user will see when prompted their username and
+#      password). There is no default.
+#      auth_param basic realm Squid proxy-caching web server
+#
+#      "credentialsttl" timetolive
+#      Specifies how long squid assumes an externally validated
+#      username:password pair is valid for - in other words how
+#      often the helper program is called for that user. Set this
+#      low to force revalidation with short lived passwords.  Note
+#      setting this high does not impact your susceptibility
+#      to replay attacks unless you are using an one-time password
+#      system (such as SecureID).  If you are using such a system,
+#      you will be vulnerable to replay attacks unless you also
+#      use the max_user_ip ACL in an http_access rule.
+#
+#      "casesensitive" on|off
+#      Specifies if usernames are case sensitive. Most user databases are
+#      case insensitive allowing the same username to be spelled using both
+#      lower and upper case letters, but some are case sensitive. This
+#      makes a big difference for user_max_ip ACL processing and similar.
+#      auth_param basic casesensitive off
+#
+#      === Parameters for the digest scheme follow ===
+#
+#      "program" cmdline
+#      Specify the command for the external authenticator.  Such
+#      a program reads a line containing "username":"realm" and
+#      replies with the appropriate H(A1) value hex encoded or
+#      ERR if the user (or his H(A1) hash) does not exists.
+#      See rfc 2616 for the definition of H(A1).
+#      "ERR" responses may optionally be followed by a error description
+#      available as %m in the returned error page.
+#
+#      By default, the digest authentication scheme is not used unless a
+#      program is specified.
+#
+#      If you want to use a digest authenticator, set this line to
+#      something like
+#
+#      auth_param digest program /usr/bin/digest_auth_pw /usr/etc/digpass
+#
+#      "children" numberofchildren
+#      The number of authenticator processes to spawn (no default).
+#      If you start too few Squid will have to wait for them to
+#      process a backlog of H(A1) calculations, slowing it down.
+#      When the H(A1) calculations are done via a (slow) network
+#      you are likely to need lots of authenticator processes.
+#      auth_param digest children 5
+#
+#      "realm" realmstring
+#      Specifies the realm name which is to be reported to the
+#      client for the digest proxy authentication scheme (part of
+#      the text the user will see when prompted their username and
+#      password). There is no default.
+#      auth_param digest realm Squid proxy-caching web server
+#
+#      "nonce_garbage_interval" timeinterval
+#      Specifies the interval that nonces that have been issued
+#      to client_agent's are checked for validity.
+#
+#      "nonce_max_duration" timeinterval
+#      Specifies the maximum length of time a given nonce will be
+#      valid for.
+#
+#      "nonce_max_count" number
+#      Specifies the maximum number of times a given nonce can be
+#      used.
+#
+#      "nonce_strictness" on|off
+#      Determines if squid requires strict increment-by-1 behavior
+#      for nonce counts, or just incrementing (off - for use when
+#      useragents generate nonce counts that occasionally miss 1
+#      (ie, 1,2,4,6)). Default off.
+#
+#      "check_nonce_count" on|off
+#      This directive if set to off can disable the nonce count check
+#      completely to work around buggy digest qop implementations in
+#      certain mainstream browser versions. Default on to check the
+#      nonce count to protect from authentication replay attacks.
+#
+#      "post_workaround" on|off
+#      This is a workaround to certain buggy browsers who sends
+#      an incorrect request digest in POST requests when reusing
+#      the same nonce as acquired earlier on a GET request.
+#
+#      === NTLM scheme options follow ===
+#
+#      "program" cmdline
+#      Specify the command for the external NTLM authenticator.
+#      Such a program reads exchanged NTLMSSP packets with
+#      the browser via Squid until authentication is completed.
+#      If you use an NTLM authenticator, make sure you have 1 acl
+#      of type proxy_auth.  By default, the NTLM authenticator_program
+#      is not used.
+#
+#      auth_param ntlm program /usr/bin/ntlm_auth
+#
+#      "children" numberofchildren
+#      The number of authenticator processes to spawn (no default).
+#      If you start too few Squid will have to wait for them to
+#      process a backlog of credential verifications, slowing it
+#      down. When credential verifications are done via a (slow)
+#      network you are likely to need lots of authenticator
+#      processes.
+#
+#      auth_param ntlm children 5
+#
+#      "keep_alive" on|off
+#      If you experience problems with PUT/POST requests when using the
+#      Negotiate authentication scheme then you can try setting this to
+#      off. This will cause Squid to forcibly close the connection on
+#      the initial requests where the browser asks which schemes are
+#      supported by the proxy.
+#
+#      auth_param ntlm keep_alive on
+#
+#      === Options for configuring the NEGOTIATE auth-scheme follow ===
+#
+#      "program" cmdline
+#      Specify the command for the external Negotiate authenticator.
+#      This protocol is used in Microsoft Active-Directory enabled setups with
+#      the Microsoft Internet Explorer or Mozilla Firefox browsers.
+#      Its main purpose is to exchange credentials with the Squid proxy
+#      using the Kerberos mechanisms.
+#      If you use a Negotiate authenticator, make sure you have at least one acl
+#      of type proxy_auth active.  By default, the negotiate authenticator_program
+#      is not used.
+#      The only supported program for this role is the ntlm_auth
+#      program distributed as part of Samba, version 4 or later.
+#
+#      auth_param negotiate program /usr/bin/ntlm_auth --helper-protocol=gss-spnego
+#
+#      "children" numberofchildren
+#      The number of authenticator processes to spawn (no default).
+#      If you start too few Squid will have to wait for them to
+#      process a backlog of credential verifications, slowing it
+#      down. When crendential verifications are done via a (slow)
+#      network you are likely to need lots of authenticator
+#      processes.
+#      auth_param negotiate children 5
+#
+#      "keep_alive" on|off
+#      If you experience problems with PUT/POST requests when using the
+#      Negotiate authentication scheme then you can try setting this to
+#      off. This will cause Squid to forcibly close the connection on
+#      the initial requests where the browser asks which schemes are
+#      supported by the proxy.
+#
+#      auth_param negotiate keep_alive on
+#
+#Recommended minimum configuration per scheme:
+#auth_param negotiate program <uncomment and complete this line to activate>
+#auth_param negotiate children 5
+#auth_param negotiate keep_alive on
+#auth_param ntlm program <uncomment and complete this line to activate>
+#auth_param ntlm children 5
+#auth_param ntlm keep_alive on
+#auth_param digest program <uncomment and complete this line>
+#auth_param digest children 5
+#auth_param digest realm Squid proxy-caching web server
+#auth_param digest nonce_garbage_interval 5 minutes
+#auth_param digest nonce_max_duration 30 minutes
+#auth_param digest nonce_max_count 50
+#auth_param basic program <uncomment and complete this line>
+#auth_param basic children 5
+#auth_param basic realm Squid proxy-caching web server
+#auth_param basic credentialsttl 2 hours
+
+#  TAG: authenticate_cache_garbage_interval
+#      The time period between garbage collection across the username cache.
+#      This is a tradeoff between memory utilization (long intervals - say
+#      2 days) and CPU (short intervals - say 1 minute). Only change if you
+#      have good reason to.
+#
+#Default:
+# authenticate_cache_garbage_interval 1 hour
+
+#  TAG: authenticate_ttl
+#      The time a user & their credentials stay in the logged in
+#      user cache since their last request. When the garbage
+#      interval passes, all user credentials that have passed their
+#      TTL are removed from memory.
+#
+#Default:
+# authenticate_ttl 1 hour
+
+#  TAG: authenticate_ip_ttl
+#      If you use proxy authentication and the 'max_user_ip' ACL,
+#      this directive controls how long Squid remembers the IP
+#      addresses associated with each user.  Use a small value
+#      (e.g., 60 seconds) if your users might change addresses
+#      quickly, as is the case with dialups.   You might be safe
+#      using a larger value (e.g., 2 hours) in a corporate LAN
+#      environment with relatively static address assignments.
+#
+#Default:
+# authenticate_ip_ttl 0 seconds
+
+
+# ACCESS CONTROLS
+# -----------------------------------------------------------------------------
+
+#  TAG: external_acl_type
+#      This option defines external acl classes using a helper program
+#      to look up the status
+#
+#        external_acl_type name [options] FORMAT.. /path/to/helper [helper arguments..]
+#
+#      Options:
+#
+#        ttl=n         TTL in seconds for cached results (defaults to 3600
+#                      for 1 hour)
+#        negative_ttl=n
+#                      TTL for cached negative lookups (default same
+#                      as ttl)
+#        children=n    Number of acl helper processes spawn to service
+#                      external acl lookups of this type. (default 5)
+#        concurrency=n concurrency level per process. Only used with helpers
+#                      capable of processing more than one query at a time.
+#        cache=n       result cache size, 0 is unbounded (default)
+#        grace=n       Percentage remaining of TTL where a refresh of a
+#                      cached entry should be initiated without needing to
+#                      wait for a new reply. (default 0 for no grace period)
+#        protocol=2.5  Compatibility mode for Squid-2.5 external acl helpers
+#
+#      FORMAT specifications
+#
+#        %LOGIN        Authenticated user login name
+#        %EXT_USER     Username from external acl
+#        %IDENT        Ident user name
+#        %SRC          Client IP
+#        %SRCPORT      Client source port
+#        %URI          Requested URI
+#        %DST          Requested host
+#        %PROTO        Requested protocol
+#        %PORT         Requested port
+#        %PATH         Requested URL path
+#        %METHOD       Request method
+#        %MYADDR       Squid interface address
+#        %MYPORT       Squid http_port number
+#        %PATH         Requested URL-path (including query-string if any)
+#        %USER_CERT    SSL User certificate in PEM format
+#        %USER_CERTCHAIN SSL User certificate chain in PEM format
+#        %USER_CERT_xx SSL User certificate subject attribute xx
+#        %USER_CA_xx   SSL User certificate issuer attribute xx
+#        %{Header}     HTTP request header
+#        %{Hdr:member} HTTP request header list member
+#        %{Hdr:;member}
+#                      HTTP request header list member using ; as
+#                      list separator. ; can be any non-alphanumeric
+#                      character.
+#
+#      In addition to the above, any string specified in the referencing
+#      acl will also be included in the helper request line, after the
+#      specified formats (see the "acl external" directive)
+#
+#      The helper receives lines per the above format specification,
+#      and returns lines starting with OK or ERR indicating the validity
+#      of the request and optionally followed by additional keywords with
+#      more details.
+#
+#      General result syntax:
+#
+#        OK/ERR keyword=value ...
+#
+#      Defined keywords:
+#
+#        user=         The users name (login)
+#        password=     The users password (for login= cache_peer option)
+#        message=      Message describing the reason. Available as %o
+#                      in error pages
+#        tag=          Apply a tag to a request (for both ERR and OK results)
+#                      Only sets a tag, does not alter existing tags.
+#        log=          String to be logged in access.log. Available as
+#                      %ea in logformat specifications
+#
+#      If protocol=3.0 (the default) then URL escaping is used to protect
+#      each value in both requests and responses.
+#
+#      If using protocol=2.5 then all values need to be enclosed in quotes
+#      if they may contain whitespace, or the whitespace escaped using \.
+#      And quotes or \ characters within the keyword value must be \ escaped.
+#
+#      When using the concurrency= option the protocol is changed by
+#      introducing a query channel tag infront of the request/response.
+#      The query channel tag is a number between 0 and concurrency-1.
+#
+#Default:
+# none
+
+#  TAG: acl
+#      Defining an Access List
+#
+#      Every access list definition must begin with an aclname and acltype, 
+#      followed by either type-specific arguments or a quoted filename that
+#      they are read from.
+#
+#         acl aclname acltype argument ...
+#         acl aclname acltype "file" ...
+#
+#      When using "file", the file should contain one item per line.
+#
+#      By default, regular expressions are CASE-SENSITIVE.  To make
+#      them case-insensitive, use the -i option.
+#
+#
+#      ***** ACL TYPES AVAILABLE *****
+#
+#      acl aclname src ip-address/netmask ...          # clients IP address
+#      acl aclname src addr1-addr2/netmask ...         # range of addresses
+#      acl aclname dst ip-address/netmask ...          # URL host's IP address
+#      acl aclname myip ip-address/netmask ...         # local socket IP address
+#
+#      acl aclname arp      mac-address ... (xx:xx:xx:xx:xx:xx notation)
+#        # The arp ACL requires the special configure option --enable-arp-acl.
+#        # Furthermore, the ARP ACL code is not portable to all operating systems.
+#        # It works on Linux, Solaris, Windows, FreeBSD, and some other *BSD variants.
+#        #
+#        # NOTE: Squid can only determine the MAC address for clients that are on
+#        # the same subnet. If the client is on a different subnet, then Squid cannot
+#        # find out its MAC address.
+#
+#      acl aclname srcdomain   .foo.com ...            # reverse lookup, from client IP
+#      acl aclname dstdomain   .foo.com ...            # Destination server from URL
+#      acl aclname srcdom_regex [-i] \.foo\.com ...    # regex matching client name
+#      acl aclname dstdom_regex [-i] \.foo\.com ...    # regex matching server
+#        # For dstdomain and dstdom_regex a reverse lookup is tried if a IP
+#        # based URL is used and no match is found. The name "none" is used
+#        # if the reverse lookup fails.
+#
+#      acl aclname src_as number ...
+#      acl aclname dst_as number ...
+#        # Except for access control, AS numbers can be used for
+#        # routing of requests to specific caches. Here's an
+#        # example for routing all requests for AS#1241 and only
+#        # those to mycache.mydomain.net:
+#        # acl asexample dst_as 1241
+#        # cache_peer_access mycache.mydomain.net allow asexample
+#        # cache_peer_access mycache_mydomain.net deny all
+#
+#      acl aclname time [day-abbrevs] [h1:m1-h2:m2]
+#        #  day-abbrevs:
+#        #     S - Sunday
+#        #     M - Monday
+#        #     T - Tuesday
+#        #     W - Wednesday
+#        #     H - Thursday
+#        #     F - Friday
+#        #     A - Saturday
+#        #  h1:m1 must be less than h2:m2
+#
+#      acl aclname url_regex [-i] ^http:// ...         # regex matching on whole URL
+#      acl aclname urlpath_regex [-i] \.gif$ ...       # regex matching on URL path
+#
+#      acl aclname port 80 70 21 ...
+#      acl aclname port 0-1024 ...             # ranges allowed
+#      acl aclname myport 3128 ...             # (local socket TCP port)
+#      acl aclname myportname 3128 ...         # http(s)_port name
+#
+#      acl aclname proto HTTP FTP ...
+#
+#      acl aclname method GET POST ...
+#
+#      acl aclname http_status 200 301 500- 400-403 ...     # status code in reply
+#
+#      acl aclname browser [-i] regexp ...
+#        # pattern match on User-Agent header (see also req_header below)
+#
+#      acl aclname referer_regex [-i] regexp ...
+#        # pattern match on Referer header
+#        # Referer is highly unreliable, so use with care
+#
+#      acl aclname ident username ...
+#      acl aclname ident_regex [-i] pattern ...
+#        # string match on ident output.
+#        # use REQUIRED to accept any non-null ident.
+#
+#      acl aclname proxy_auth [-i] username ...
+#      acl aclname proxy_auth_regex [-i] pattern ...
+#        # list of valid usernames
+#        # use REQUIRED to accept any valid username.
+#        #
+#        # NOTE: when a Proxy-Authentication header is sent but it is not
+#        # needed during ACL checking the username is NOT logged
+#        # in access.log.
+#        #
+#        # NOTE: proxy_auth requires a EXTERNAL authentication program
+#        # to check username/password combinations (see
+#        # auth_param directive).
+#        #
+#        # NOTE: proxy_auth can't be used in a transparent/intercepting proxy
+#        # as the browser needs to be configured for using a proxy in order
+#        # to respond to proxy authentication.
+#
+#      acl aclname snmp_community string ...
+#        # A community string to limit access to your SNMP Agent
+#        # Example:
+#        #
+#        #     acl snmppublic snmp_community public
+#
+#      acl aclname maxconn number
+#        # This will be matched when the client's IP address has
+#        # more than <number> HTTP connections established.
+#
+#      acl aclname max_user_ip [-s] number
+#        # This will be matched when the user attempts to log in from more
+#        # than <number> different ip addresses. The authenticate_ip_ttl
+#        # parameter controls the timeout on the ip entries.
+#        # If -s is specified the limit is strict, denying browsing
+#        # from any further IP addresses until the ttl has expired. Without
+#        # -s Squid will just annoy the user by "randomly" denying requests.
+#        # (the counter is reset each time the limit is reached and a
+#        # request is denied)
+#        # NOTE: in acceleration mode or where there is mesh of child proxies,
+#        # clients may appear to come from multiple addresses if they are
+#        # going through proxy farms, so a limit of 1 may cause user problems.
+#
+#      acl aclname req_mime_type [-i] mime-type ...
+#        # regex match against the mime type of the request generated
+#        # by the client. Can be used to detect file upload or some
+#        # types HTTP tunneling requests.
+#        # NOTE: This does NOT match the reply. You cannot use this
+#        # to match the returned file type.
+#
+#      acl aclname req_header header-name [-i] any\.regex\.here
+#        # regex match against any of the known request headers.  May be
+#        # thought of as a superset of "browser", "referer" and "mime-type"
+#        # ACLs.
+#
+#      acl aclname rep_mime_type [-i] mime-type ...
+#        # regex match against the mime type of the reply received by
+#        # squid. Can be used to detect file download or some
+#        # types HTTP tunneling requests.
+#        # NOTE: This has no effect in http_access rules. It only has
+#        # effect in rules that affect the reply data stream such as
+#        # http_reply_access.
+#
+#      acl aclname rep_header header-name [-i] any\.regex\.here
+#        # regex match against any of the known reply headers. May be
+#        # thought of as a superset of "browser", "referer" and "mime-type"
+#        # ACLs.
+#
+#      acl aclname external class_name [arguments...]
+#        # external ACL lookup via a helper class defined by the
+#        # external_acl_type directive.
+#
+#      acl aclname user_cert attribute values...
+#        # match against attributes in a user SSL certificate
+#        # attribute is one of DN/C/O/CN/L/ST
+#
+#      acl aclname ca_cert attribute values...
+#        # match against attributes a users issuing CA SSL certificate
+#        # attribute is one of DN/C/O/CN/L/ST
+#
+#      acl aclname ext_user username ...
+#      acl aclname ext_user_regex [-i] pattern ...
+#        # string match on username returned by external acl helper
+#        # use REQUIRED to accept any non-null user name.
+#
+#Examples:
+#acl macaddress arp 09:00:2b:23:45:67
+#acl myexample dst_as 1241
+#acl password proxy_auth REQUIRED
+#acl fileupload req_mime_type -i ^multipart/form-data$
+#acl javascript rep_mime_type -i ^application/x-javascript$
+#
+#Default:
+# acl all src all
+#
+#Recommended minimum configuration:
+acl manager proto cache_object
+acl localhost src 127.0.0.1/32
+acl to_localhost dst 127.0.0.0/8
+#
+# Example rule allowing access from your local networks.
+# Adapt to list your (internal) IP networks from where browsing
+# should be allowed
+acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
+acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
+acl localnet src 192.168.0.0/16        # RFC1918 possible internal network
+#
+acl SSL_ports port 443
+acl Safe_ports port 80         # http
+acl Safe_ports port 21         # ftp
+acl Safe_ports port 443                # https
+acl Safe_ports port 70         # gopher
+acl Safe_ports port 210                # wais
+acl Safe_ports port 1025-65535 # unregistered ports
+acl Safe_ports port 280                # http-mgmt
+acl Safe_ports port 488                # gss-http
+acl Safe_ports port 591                # filemaker
+acl Safe_ports port 777                # multiling http
+acl CONNECT method CONNECT
+
+#  TAG: http_access
+#      Allowing or Denying access based on defined access lists
+#
+#      Access to the HTTP port:
+#      http_access allow|deny [!]aclname ...
+#
+#      NOTE on default values:
+#
+#      If there are no "access" lines present, the default is to deny
+#      the request.
+#
+#      If none of the "access" lines cause a match, the default is the
+#      opposite of the last line in the list.  If the last line was
+#      deny, the default is allow.  Conversely, if the last line
+#      is allow, the default will be deny.  For these reasons, it is a
+#      good idea to have an "deny all" or "allow all" entry at the end
+#      of your access lists to avoid potential confusion.
+#
+#Default:
+# http_access deny all
+#
+#Recommended minimum configuration:
+#
+# Only allow cachemgr access from localhost
+http_access allow manager localhost
+http_access deny manager
+# Deny requests to unknown ports
+http_access deny !Safe_ports
+# Deny CONNECT to other than SSL ports
+http_access deny CONNECT !SSL_ports
+#
+# We strongly recommend the following be uncommented to protect innocent
+# web applications running on the proxy server who think the only
+# one who can access services on "localhost" is a local user
+#http_access deny to_localhost
+#
+# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
+
+# Example rule allowing access from your local networks.
+# Adapt localnet in the ACL section to list your (internal) IP networks
+# from where browsing should be allowed
+http_access allow localnet
+
+# And finally deny all other access to this proxy
+http_access allow localhost
+http_access deny all
+
+#  TAG: http_reply_access
+#      Allow replies to client requests. This is complementary to http_access.
+#
+#      http_reply_access allow|deny [!] aclname ...
+#
+#      NOTE: if there are no access lines present, the default is to allow
+#      all replies
+#
+#      If none of the access lines cause a match the opposite of the
+#      last line will apply. Thus it is good practice to end the rules
+#      with an "allow all" or "deny all" entry.
+#
+#Default:
+# none
+
+#  TAG: icp_access
+#      Allowing or Denying access to the ICP port based on defined
+#      access lists
+#
+#      icp_access  allow|deny [!]aclname ...
+#
+#      See http_access for details
+#
+#Default:
+# icp_access deny all
+#
+#Allow ICP queries from local networks only
+icp_access allow localnet
+icp_access deny all
+
+#  TAG: htcp_access
+#      Allowing or Denying access to the HTCP port based on defined
+#      access lists
+#
+#      htcp_access  allow|deny [!]aclname ...
+#
+#      See http_access for details
+#
+#      NOTE: The default if no htcp_access lines are present is to
+#      deny all traffic. This default may cause problems with peers
+#      using the htcp or htcp-oldsquid options.
+#
+#Default:
+# htcp_access deny all
+#
+#Allow HTCP queries from local networks only
+htcp_access allow localnet
+htcp_access deny all
+
+#  TAG: htcp_clr_access
+#      Allowing or Denying access to purge content using HTCP based
+#      on defined access lists
+#
+#      htcp_clr_access  allow|deny [!]aclname ...
+#
+#      See http_access for details
+#
+##Allow HTCP CLR requests from trusted peers
+#acl htcp_clr_peer src 172.16.1.2
+#htcp_clr_access allow htcp_clr_peer
+#
+#Default:
+# htcp_clr_access deny all
+
+#  TAG: miss_access
+#      Use to force your neighbors to use you as a sibling instead of
+#      a parent.  For example:
+#
+#              acl localclients src 172.16.0.0/16
+#              miss_access allow localclients
+#              miss_access deny  !localclients
+#
+#      This means only your local clients are allowed to fetch
+#      MISSES and all other clients can only fetch HITS.
+#
+#      By default, allow all clients who passed the http_access rules
+#      to fetch MISSES from us.
+#
+#Default setting:
+# miss_access allow all
+
+#  TAG: ident_lookup_access
+#      A list of ACL elements which, if matched, cause an ident
+#      (RFC 931) lookup to be performed for this request.  For
+#      example, you might choose to always perform ident lookups
+#      for your main multi-user Unix boxes, but not for your Macs
+#      and PCs.  By default, ident lookups are not performed for
+#      any requests.
+#
+#      To enable ident lookups for specific client addresses, you
+#      can follow this example:
+#
+#      acl ident_aware_hosts src 198.168.1.0/255.255.255.0
+#      ident_lookup_access allow ident_aware_hosts
+#      ident_lookup_access deny all
+#
+#      Only src type ACL checks are fully supported.  A src_domain
+#      ACL might work at times, but it will not always provide
+#      the correct result.
+#
+#Default:
+# ident_lookup_access deny all
+
+#  TAG: reply_body_max_size    size [acl acl...]
+#      This option specifies the maximum size of a reply body. It can be
+#      used to prevent users from downloading very large files, such as
+#      MP3's and movies. When the reply headers are received, the
+#      reply_body_max_size lines are processed, and the first line where
+#      all (if any) listed ACLs are true is used as the maximum body size
+#      for this reply.
+#
+#      This size is checked twice. First when we get the reply headers,
+#      we check the content-length value.  If the content length value exists
+#      and is larger than the allowed size, the request is denied and the
+#      user receives an error message that says "the request or reply
+#      is too large." If there is no content-length, and the reply
+#      size exceeds this limit, the client's connection is just closed
+#      and they will receive a partial reply.
+#
+#      WARNING: downstream caches probably can not detect a partial reply
+#      if there is no content-length header, so they will cache
+#      partial responses and give them out as hits.  You should NOT
+#      use this option if you have downstream caches.
+#
+#      WARNING: A maximum size smaller than the size of squid's error messages
+#      will cause an infinite loop and crash squid. Ensure that the smallest
+#      non-zero value you use is greater that the maximum header size plus
+#      the size of your largest error page.
+#
+#      If you set this parameter none (the default), there will be
+#      no limit imposed.
+#
+#      Configuration Format is:
+#              reply_body_max_size SIZE UNITS [acl ...]
+#      ie.
+#              reply_body_max_size 10 MB
+#
+#
+#Default:
+# none
+
+
+# NETWORK OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: http_port
+#      Usage:  port [options]
+#              hostname:port [options]
+#              1.2.3.4:port [options]
+#
+#      The socket addresses where Squid will listen for HTTP client
+#      requests.  You may specify multiple socket addresses.
+#      There are three forms: port alone, hostname with port, and
+#      IP address with port.  If you specify a hostname or IP
+#      address, Squid binds the socket to that specific
+#      address.  This replaces the old 'tcp_incoming_address'
+#      option.  Most likely, you do not need to bind to a specific
+#      address, so you can use the port number alone.
+#
+#      If you are running Squid in accelerator mode, you
+#      probably want to listen on port 80 also, or instead.
+#
+#      The -a command line option may be used to specify additional
+#      port(s) where Squid listens for proxy request. Such ports will
+#      be plain proxy ports with no options.
+#
+#      You may specify multiple socket addresses on multiple lines.
+#
+#      Options:
+#
+#         transparent  Support for transparent interception of
+#                      outgoing requests without browser settings.
+#                      NP: disables authentication on the port.
+#
+#         tproxy       Support Linux TPROXY for spoofing outgoing
+#                      connections using the client IP address.
+#                      NP: disables authentication on the port.
+#
+#         accel        Accelerator mode. Also needs at least one of
+#                      vhost / vport / defaultsite.
+#
+#         defaultsite=domainname
+#                      What to use for the Host: header if it is not present
+#                      in a request. Determines what site (not origin server)
+#                      accelerators should consider the default.
+#                      Implies accel.
+#
+#         vhost        Accelerator mode using Host header for virtual
+#                      domain support. Implies accel.
+#
+#         vport        Accelerator with IP based virtual host support.
+#                      Implies accel.
+#
+#         vport=NN     As above, but uses specified port number rather
+#                      than the http_port number. Implies accel.
+#
+#         protocol=    Protocol to reconstruct accelerated requests with.
+#                      Defaults to http.
+#
+#         disable-pmtu-discovery=
+#                      Control Path-MTU discovery usage:
+#                          off         lets OS decide on what to do (default).
+#                          transparent disable PMTU discovery when transparent
+#                                      support is enabled.
+#                          always      disable always PMTU discovery.
+#
+#                      In many setups of transparently intercepting proxies
+#                      Path-MTU discovery can not work on traffic towards the
+#                      clients. This is the case when the intercepting device
+#                      does not fully track connections and fails to forward
+#                      ICMP must fragment messages to the cache server. If you
+#                      have such setup and experience that certain clients
+#                      sporadically hang or never complete requests set
+#                      disable-pmtu-discovery option to 'transparent'.
+#
+#         name=        Specifies a internal name for the port. Defaults to
+#                      the port specification (port or addr:port)
+#
+#      If you run Squid on a dual-homed machine with an internal
+#      and an external interface we recommend you to specify the
+#      internal address:port in http_port. This way Squid will only be
+#      visible on the internal address.
+#
+# Squid normally listens to port 3128
+http_port 3128
+
+#  TAG: https_port
+#      Usage:  [ip:]port cert=certificate.pem [key=key.pem] [options...]
+#
+#      The socket address where Squid will listen for HTTPS client
+#      requests.
+#
+#      This is really only useful for situations where you are running
+#      squid in accelerator mode and you want to do the SSL work at the
+#      accelerator level.
+#
+#      You may specify multiple socket addresses on multiple lines,
+#      each with their own SSL certificate and/or options.
+#
+#      Options:
+#
+#         accel        Accelerator mode. Also needs at least one of
+#                      defaultsite or vhost.
+#
+#         defaultsite= The name of the https site presented on
+#                      this port. Implies accel.
+#
+#         vhost        Accelerator mode using Host header for virtual
+#                      domain support. Requires a wildcard certificate
+#                      or other certificate valid for more than one domain.
+#                      Implies accel.
+#
+#         protocol=    Protocol to reconstruct accelerated requests with.
+#                      Defaults to https.
+#
+#         cert=        Path to SSL certificate (PEM format).
+#
+#         key=         Path to SSL private key file (PEM format)
+#                      if not specified, the certificate file is
+#                      assumed to be a combined certificate and
+#                      key file.
+#
+#         version=     The version of SSL/TLS supported
+#                          1   automatic (default)
+#                          2   SSLv2 only
+#                          3   SSLv3 only
+#                          4   TLSv1 only
+#
+#         cipher=      Colon separated list of supported ciphers.
+#
+#         options=     Various SSL engine options. The most important
+#                      being:
+#                          NO_SSLv2  Disallow the use of SSLv2
+#                          NO_SSLv3  Disallow the use of SSLv3
+#                          NO_TLSv1  Disallow the use of TLSv1
+#                          SINGLE_DH_USE Always create a new key when using
+#                                    temporary/ephemeral DH key exchanges
+#                      See src/ssl_support.c or OpenSSL SSL_CTX_set_options
+#                      documentation for a complete list of options.
+#
+#         clientca=    File containing the list of CAs to use when
+#                      requesting a client certificate.
+#
+#         cafile=      File containing additional CA certificates to
+#                      use when verifying client certificates. If unset
+#                      clientca will be used.
+#
+#         capath=      Directory containing additional CA certificates
+#                      and CRL lists to use when verifying client certificates.
+#
+#         crlfile=     File of additional CRL lists to use when verifying
+#                      the client certificate, in addition to CRLs stored in
+#                      the capath. Implies VERIFY_CRL flag below.
+#
+#         dhparams=    File containing DH parameters for temporary/ephemeral
+#                      DH key exchanges.
+#
+#         sslflags=    Various flags modifying the use of SSL:
+#                          DELAYED_AUTH
+#                              Don't request client certificates
+#                              immediately, but wait until acl processing
+#                              requires a certificate (not yet implemented).
+#                          NO_DEFAULT_CA
+#                              Don't use the default CA lists built in
+#                              to OpenSSL.
+#                          NO_SESSION_REUSE
+#                              Don't allow for session reuse. Each connection
+#                              will result in a new SSL session.
+#                          VERIFY_CRL
+#                              Verify CRL lists when accepting client
+#                              certificates.
+#                          VERIFY_CRL_ALL
+#                              Verify CRL lists for all certificates in the
+#                              client certificate chain.
+#
+#         sslcontext=  SSL session ID context identifier.
+#
+#         vport        Accelerator with IP based virtual host support.
+#
+#         vport=NN     As above, but uses specified port number rather
+#                      than the https_port number. Implies accel.
+#
+#         name=        Specifies a internal name for the port. Defaults to
+#                      the port specification (port or addr:port)
+#
+#
+#Default:
+# none
+
+#  TAG: tcp_outgoing_tos
+#      Allows you to select a TOS/Diffserv value to mark outgoing
+#      connections with, based on the username or source address
+#      making the request.
+#
+#      tcp_outgoing_tos ds-field [!]aclname ...
+#
+#      Example where normal_service_net uses the TOS value 0x00
+#      and normal_service_net uses 0x20
+#
+#      acl normal_service_net src 10.0.0.0/255.255.255.0
+#      acl good_service_net src 10.0.1.0/255.255.255.0
+#      tcp_outgoing_tos 0x00 normal_service_net
+#      tcp_outgoing_tos 0x20 good_service_net
+#
+#      TOS/DSCP values really only have local significance - so you should
+#      know what you're specifying. For more information, see RFC2474 and
+#      RFC3260.
+#
+#      The TOS/DSCP byte must be exactly that - a octet value  0 - 255, or
+#      "default" to use whatever default your host has. Note that in
+#      practice often only values 0 - 63 is usable as the two highest bits
+#      have been redefined for use by ECN (RFC3168).
+#
+#      Processing proceeds in the order specified, and stops at first fully
+#      matching line.
+#
+#      Note: The use of this directive using client dependent ACLs is
+#      incompatible with the use of server side persistent connections. To
+#      ensure correct results it is best to set server_persisten_connections
+#      to off when using this directive in such configurations.
+#
+#Default:
+# none
+
+#  TAG: clientside_tos
+#      Allows you to select a TOS/Diffserv value to mark client-side
+#      connections with, based on the username or source address
+#      making the request.
+#
+#Default:
+# none
+
+#  TAG: tcp_outgoing_address
+#      Allows you to map requests to different outgoing IP addresses
+#      based on the username or source address of the user making
+#      the request.
+#
+#      tcp_outgoing_address ipaddr [[!]aclname] ...
+#
+#      Example where requests from 10.0.0.0/24 will be forwarded
+#      with source address 10.1.0.1, 10.0.2.0/24 forwarded with
+#      source address 10.1.0.2 and the rest will be forwarded with
+#      source address 10.1.0.3.
+#
+#      acl normal_service_net src 10.0.0.0/24
+#      acl good_service_net src 10.0.2.0/24
+#      tcp_outgoing_address 10.1.0.1 normal_service_net
+#      tcp_outgoing_address 10.1.0.2 good_service_net
+#      tcp_outgoing_address 10.1.0.3
+#
+#      Processing proceeds in the order specified, and stops at first fully
+#      matching line.
+#
+#      Note: The use of this directive using client dependent ACLs is
+#      incompatible with the use of server side persistent connections. To
+#      ensure correct results it is best to set server_persistent_connections
+#      to off when using this directive in such configurations.
+#
+#Default:
+# none
+
+
+# SSL OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: ssl_unclean_shutdown
+#      Some browsers (especially MSIE) bugs out on SSL shutdown
+#      messages.
+#
+#Default:
+# ssl_unclean_shutdown off
+
+#  TAG: ssl_engine
+#      The OpenSSL engine to use. You will need to set this if you
+#      would like to use hardware SSL acceleration for example.
+#
+#Default:
+# none
+
+#  TAG: sslproxy_client_certificate
+#      Client SSL Certificate to use when proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_client_key
+#      Client SSL Key to use when proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_version
+#      SSL version level to use when proxying https:// URLs
+#
+#Default:
+# sslproxy_version 1
+
+#  TAG: sslproxy_options
+#      SSL engine options to use when proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_cipher
+#      SSL cipher list to use when proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_cafile
+#      file containing CA certificates to use when verifying server
+#      certificates while proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_capath
+#      directory containing CA certificates to use when verifying
+#      server certificates while proxying https:// URLs
+#
+#Default:
+# none
+
+#  TAG: sslproxy_flags
+#      Various flags modifying the use of SSL while proxying https:// URLs:
+#          DONT_VERIFY_PEER    Accept certificates even if they fail to
+#                              verify.
+#          NO_DEFAULT_CA       Don't use the default CA list built in
+#                              to OpenSSL.
+#
+#Default:
+# none
+
+#  TAG: sslpassword_program
+#      Specify a program used for entering SSL key passphrases
+#      when using encrypted SSL certificate keys. If not specified
+#      keys must either be unencrypted, or Squid started with the -N
+#      option to allow it to query interactively for the passphrase.
+#
+#Default:
+# none
+
+
+# OPTIONS WHICH AFFECT THE NEIGHBOR SELECTION ALGORITHM
+# -----------------------------------------------------------------------------
+
+#  TAG: cache_peer
+#      To specify other caches in a hierarchy, use the format:
+#
+#              cache_peer hostname type http-port icp-port [options]
+#
+#      For example,
+#
+#      #                                        proxy  icp
+#      #          hostname             type     port   port  options
+#      #          -------------------- -------- ----- -----  -----------
+#      cache_peer parent.foo.net       parent    3128  3130  proxy-only default
+#      cache_peer sib1.foo.net         sibling   3128  3130  proxy-only
+#      cache_peer sib2.foo.net         sibling   3128  3130  proxy-only
+#
+#            type:  either 'parent', 'sibling', or 'multicast'.
+#
+#      proxy-port:  The port number where the cache listens for proxy
+#                   requests.
+#
+#        icp-port:  Used for querying neighbor caches about
+#                   objects.  To have a non-ICP neighbor
+#                   specify '7' for the ICP port and make sure the
+#                   neighbor machine has the UDP echo port
+#                   enabled in its /etc/inetd.conf file.
+#              NOTE: Also requires icp_port option enabled to send/receive
+#                    requests via this method.
+#
+#          options: proxy-only
+#                   weight=n
+#                   basetime=n
+#                   ttl=n
+#                   no-query
+#                   background-ping
+#                   default
+#                   round-robin
+#                   weighted-round-robin
+#                   carp
+#                   userhash
+#                   sourcehash
+#                   multicast-responder
+#                   closest-only
+#                   no-digest
+#                   no-netdb-exchange
+#                   no-delay
+#                   login=user:password | PASS | *:password
+#                   connect-timeout=nn
+#                   digest-url=url
+#                   allow-miss
+#                   max-conn=n
+#                   htcp
+#                   htcp-oldsquid
+#                   originserver
+#                   name=xxx
+#                   forceddomain=name
+#                   ssl
+#                   sslcert=/path/to/ssl/certificate
+#                   sslkey=/path/to/ssl/key
+#                   sslversion=1|2|3|4
+#                   sslcipher=...
+#                   ssloptions=...
+#                   front-end-https[=on|auto]
+#
+#                   use 'proxy-only' to specify objects fetched
+#                   from this cache should not be saved locally.
+#
+#                   use 'weight=n' to affect the selection of a peer
+#                   during any weighted peer-selection mechanisms.
+#                   The weight must be an integer; default is 1,
+#                   larger weights are favored more.
+#                   This option does not affect parent selection if a peering
+#                   protocol is not in use.
+#
+#                   use 'basetime=n' to specify a base amount to
+#                   be subtracted from round trip times of parents.
+#                   It is subtracted before division by weight in calculating
+#                   which parent to fectch from. If the rtt is less than the
+#                   base time the rtt is set to a minimal value.
+#
+#                   use 'ttl=n' to specify a IP multicast TTL to use
+#                   when sending an ICP queries to this address.
+#                   Only useful when sending to a multicast group.
+#                   Because we don't accept ICP replies from random
+#                   hosts, you must configure other group members as
+#                   peers with the 'multicast-responder' option below.
+#
+#                   use 'no-query' to NOT send ICP queries to this
+#                   neighbor.
+#
+#                   use 'background-ping' to only send ICP queries to this
+#                   neighbor infrequently. This is used to keep the neighbor
+#                   round trip time updated and is usually used in
+#                   conjunction with weighted-round-robin.
+#
+#                   use 'default' if this is a parent cache which can
+#                   be used as a "last-resort" if a peer cannot be located
+#                   by any of the peer-selection mechanisms.
+#                   If specified more than once, only the first is used.
+#
+#                   use 'round-robin' to define a set of parents which
+#                   should be used in a round-robin fashion in the
+#                   absence of any ICP queries.
+#
+#                   use 'weighted-round-robin' to define a set of parents
+#                   which should be used in a round-robin fashion with the
+#                   frequency of each parent being based on the round trip
+#                   time. Closer parents are used more often.
+#                   Usually used for background-ping parents.
+#
+#                   use 'carp' to define a set of parents which should
+#                   be used as a CARP array. The requests will be
+#                   distributed among the parents based on the CARP load
+#                   balancing hash function based on their weight.
+#
+#                   use 'userhash' to load-balance amongst a set of parents
+#                   based on the client proxy_auth or ident username.
+#
+#                   use 'sourcehash' to load-balance amongst a set of parents
+#                   based on the client source ip.
+#
+#                   'multicast-responder' indicates the named peer
+#                   is a member of a multicast group.  ICP queries will
+#                   not be sent directly to the peer, but ICP replies
+#                   will be accepted from it.
+#
+#                   'closest-only' indicates that, for ICP_OP_MISS
+#                   replies, we'll only forward CLOSEST_PARENT_MISSes
+#                   and never FIRST_PARENT_MISSes.
+#
+#                   use 'no-digest' to NOT request cache digests from
+#                   this neighbor.
+#
+#                   'no-netdb-exchange' disables requesting ICMP
+#                   RTT database (NetDB) from the neighbor.
+#
+#                   use 'no-delay' to prevent access to this neighbor
+#                   from influencing the delay pools.
+#
+#                   use 'login=user:password' if this is a personal/workgroup
+#                   proxy and your parent requires proxy authentication.
+#                   Note: The string can include URL escapes (i.e. %20 for
+#                   spaces). This also means % must be written as %%.
+#
+#                   use 'login=PASS' if users must authenticate against
+#                   the upstream proxy or in the case of a reverse proxy
+#                   configuration, the origin web server.  This will pass
+#                   the users credentials as they are to the peer.
+#                   This only works for the Basic HTTP authentication scheme.
+#                   Note: To combine this with proxy_auth both proxies must
+#                   share the same user database as HTTP only allows for
+#                   a single login (one for proxy, one for origin server).
+#                   Also be warned this will expose your users proxy
+#                   password to the peer. USE WITH CAUTION
+#
+#                   use 'login=*:password' to pass the username to the
+#                   upstream cache, but with a fixed password. This is meant
+#                   to be used when the peer is in another administrative
+#                   domain, but it is still needed to identify each user.
+#                   The star can optionally be followed by some extra
+#                   information which is added to the username. This can
+#                   be used to identify this proxy to the peer, similar to
+#                   the login=username:password option above.
+#
+#                   use 'connect-timeout=nn' to specify a peer
+#                   specific connect timeout (also see the
+#                   peer_connect_timeout directive)
+#
+#                   use 'digest-url=url' to tell Squid to fetch the cache
+#                   digest (if digests are enabled) for this host from
+#                   the specified URL rather than the Squid default
+#                   location.
+#
+#                   use 'allow-miss' to disable Squid's use of only-if-cached
+#                   when forwarding requests to siblings. This is primarily
+#                   useful when icp_hit_stale is used by the sibling. To
+#                   extensive use of this option may result in forwarding
+#                   loops, and you should avoid having two-way peerings
+#                   with this option. (for example to deny peer usage on
+#                   requests from peer by denying cache_peer_access if the
+#                   source is a peer)
+#
+#                   use 'max-conn=n' to limit the amount of connections Squid
+#                   may open to this peer.
+#
+#                   use 'htcp' to send HTCP, instead of ICP, queries
+#                   to the neighbor.  You probably also want to
+#                   set the "icp port" to 4827 instead of 3130.
+#                   You MUST also set htcp_access expicitly. The default of
+#                   deny all will prevent peer traffic.
+#
+#                   use 'htcp-oldsquid' to send HTCP to old Squid versions
+#                   You MUST also set htcp_access expicitly. The default of
+#                   deny all will prevent peer traffic.                     
+#
+#                   'originserver' causes this parent peer to be contacted as
+#                   a origin server. Meant to be used in accelerator setups.
+#
+#                   use 'name=xxx' if you have multiple peers on the same
+#                   host but different ports. This name can be used to
+#                   differentiate the peers in cache_peer_access and similar
+#                   directives.
+#
+#                   use 'forceddomain=name' to forcibly set the Host header
+#                   of requests forwarded to this peer. Useful in accelerator
+#                   setups where the server (peer) expects a certain domain
+#                   name and using redirectors to feed this domain name
+#                   is not feasible.
+#
+#                   use 'ssl' to indicate connections to this peer should
+#                   be SSL/TLS encrypted.
+#
+#                   use 'sslcert=/path/to/ssl/certificate' to specify a client
+#                   SSL certificate to use when connecting to this peer.
+#
+#                   use 'sslkey=/path/to/ssl/key' to specify the private SSL
+#                   key corresponding to sslcert above. If 'sslkey' is not
+#                   specified 'sslcert' is assumed to reference a
+#                   combined file containing both the certificate and the key.
+#
+#                   use sslversion=1|2|3|4 to specify the SSL version to use
+#                   when connecting to this peer
+#                      1 = automatic (default)
+#                      2 = SSL v2 only
+#                      3 = SSL v3 only
+#                      4 = TLS v1 only
+#
+#                   use sslcipher=... to specify the list of valid SSL ciphers
+#                   to use when connecting to this peer.
+#
+#                   use ssloptions=... to specify various SSL engine options:
+#                      NO_SSLv2  Disallow the use of SSLv2
+#                      NO_SSLv3  Disallow the use of SSLv3
+#                      NO_TLSv1  Disallow the use of TLSv1
+#                   See src/ssl_support.c or the OpenSSL documentation for
+#                   a more complete list.
+#
+#                   use sslcafile=... to specify a file containing
+#                   additional CA certificates to use when verifying the
+#                   peer certificate.
+#
+#                   use sslcapath=... to specify a directory containing
+#                   additional CA certificates to use when verifying the
+#                   peer certificate.
+#
+#                   use sslcrlfile=... to specify a certificate revocation
+#                   list file to use when verifying the peer certificate.
+#                   
+#                   use sslflags=... to specify various flags modifying the
+#                   SSL implementation:
+#                      DONT_VERIFY_PEER
+#                              Accept certificates even if they fail to
+#                              verify.
+#                      NO_DEFAULT_CA
+#                              Don't use the default CA list built in
+#                              to OpenSSL.
+#                      DONT_VERIFY_DOMAIN
+#                              Don't verify the peer certificate
+#                              matches the server name
+#
+#                   use ssldomain= to specify the peer name as advertised
+#                   in it's certificate. Used for verifying the correctness
+#                   of the received peer certificate. If not specified the
+#                   peer hostname will be used.
+#
+#                   use front-end-https to enable the "Front-End-Https: On"
+#                   header needed when using Squid as a SSL frontend in front
+#                   of Microsoft OWA. See MS KB document Q307347 for details
+#                   on this header. If set to auto the header will
+#                   only be added if the request is forwarded as a https://
+#                   URL.
+#
+#Default:
+# none
+
+#  TAG: cache_peer_domain
+#      Use to limit the domains for which a neighbor cache will be
+#      queried.  Usage:
+#
+#      cache_peer_domain cache-host domain [domain ...]
+#      cache_peer_domain cache-host !domain
+#
+#      For example, specifying
+#
+#              cache_peer_domain parent.foo.net        .edu
+#
+#      has the effect such that UDP query packets are sent to
+#      'bigserver' only when the requested object exists on a
+#      server in the .edu domain.  Prefixing the domainname
+#      with '!' means the cache will be queried for objects
+#      NOT in that domain.
+#
+#      NOTE:   * Any number of domains may be given for a cache-host,
+#                either on the same or separate lines.
+#              * When multiple domains are given for a particular
+#                cache-host, the first matched domain is applied.
+#              * Cache hosts with no domain restrictions are queried
+#                for all requests.
+#              * There are no defaults.
+#              * There is also a 'cache_peer_access' tag in the ACL
+#                section.
+#
+#Default:
+# none
+
+#  TAG: cache_peer_access
+#      Similar to 'cache_peer_domain' but provides more flexibility by
+#      using ACL elements.
+#
+#      cache_peer_access cache-host allow|deny [!]aclname ...
+#
+#      The syntax is identical to 'http_access' and the other lists of
+#      ACL elements.  See the comments for 'http_access' below, or
+#      the Squid FAQ (http://www.squid-cache.org/FAQ/FAQ-10.html).
+#
+#Default:
+# none
+
+#  TAG: neighbor_type_domain
+#      usage: neighbor_type_domain neighbor parent|sibling domain domain ...
+#
+#      Modifying the neighbor type for specific domains is now
+#      possible.  You can treat some domains differently than the the
+#      default neighbor type specified on the 'cache_peer' line.
+#      Normally it should only be necessary to list domains which
+#      should be treated differently because the default neighbor type
+#      applies for hostnames which do not match domains listed here.
+#
+#EXAMPLE:
+#      cache_peer cache.foo.org parent 3128 3130
+#      neighbor_type_domain cache.foo.org sibling .com .net
+#      neighbor_type_domain cache.foo.org sibling .au .de
+#
+#Default:
+# none
+
+#  TAG: dead_peer_timeout      (seconds)
+#      This controls how long Squid waits to declare a peer cache
+#      as "dead."  If there are no ICP replies received in this
+#      amount of time, Squid will declare the peer dead and not
+#      expect to receive any further ICP replies.  However, it
+#      continues to send ICP queries, and will mark the peer as
+#      alive upon receipt of the first subsequent ICP reply.
+#
+#      This timeout also affects when Squid expects to receive ICP
+#      replies from peers.  If more than 'dead_peer' seconds have
+#      passed since the last ICP reply was received, Squid will not
+#      expect to receive an ICP reply on the next query.  Thus, if
+#      your time between requests is greater than this timeout, you
+#      will see a lot of requests sent DIRECT to origin servers
+#      instead of to your parents.
+#
+#Default:
+# dead_peer_timeout 10 seconds
+
+#  TAG: hierarchy_stoplist
+#      A list of words which, if found in a URL, cause the object to
+#      be handled directly by this cache.  In other words, use this
+#      to not query neighbor caches for certain objects.  You may
+#      list this option multiple times.
+#      Note: never_direct overrides this option.
+#We recommend you to use at least the following line.
+hierarchy_stoplist cgi-bin ?
+
+
+# MEMORY CACHE OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: cache_mem      (bytes)
+#      NOTE: THIS PARAMETER DOES NOT SPECIFY THE MAXIMUM PROCESS SIZE.
+#      IT ONLY PLACES A LIMIT ON HOW MUCH ADDITIONAL MEMORY SQUID WILL
+#      USE AS A MEMORY CACHE OF OBJECTS. SQUID USES MEMORY FOR OTHER
+#      THINGS AS WELL. SEE THE SQUID FAQ SECTION 8 FOR DETAILS.
+#
+#      'cache_mem' specifies the ideal amount of memory to be used
+#      for:
+#              * In-Transit objects
+#              * Hot Objects
+#              * Negative-Cached objects
+#
+#      Data for these objects are stored in 4 KB blocks.  This
+#      parameter specifies the ideal upper limit on the total size of
+#      4 KB blocks allocated.  In-Transit objects take the highest
+#      priority.
+#
+#      In-transit objects have priority over the others.  When
+#      additional space is needed for incoming data, negative-cached
+#      and hot objects will be released.  In other words, the
+#      negative-cached and hot objects will fill up any unused space
+#      not needed for in-transit objects.
+#
+#      If circumstances require, this limit will be exceeded.
+#      Specifically, if your incoming request rate requires more than
+#      'cache_mem' of memory to hold in-transit objects, Squid will
+#      exceed this limit to satisfy the new requests.  When the load
+#      decreases, blocks will be freed until the high-water mark is
+#      reached.  Thereafter, blocks will be used to store hot
+#      objects.
+#
+#Default:
+# cache_mem 8 MB
+
+#  TAG: maximum_object_size_in_memory  (bytes)
+#      Objects greater than this size will not be attempted to kept in
+#      the memory cache. This should be set high enough to keep objects
+#      accessed frequently in memory to improve performance whilst low
+#      enough to keep larger objects from hoarding cache_mem.
+#
+#Default:
+# maximum_object_size_in_memory 8 KB
+
+#  TAG: memory_replacement_policy
+#      The memory replacement policy parameter determines which
+#      objects are purged from memory when memory space is needed.
+#
+#      See cache_replacement_policy for details.
+#
+#Default:
+# memory_replacement_policy lru
+
+
+# DISK CACHE OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: cache_replacement_policy
+#      The cache replacement policy parameter determines which
+#      objects are evicted (replaced) when disk space is needed.
+#
+#          lru       : Squid's original list based LRU policy
+#          heap GDSF : Greedy-Dual Size Frequency
+#          heap LFUDA: Least Frequently Used with Dynamic Aging
+#          heap LRU  : LRU policy implemented using a heap
+#
+#      Applies to any cache_dir lines listed below this.
+#
+#      The LRU policies keeps recently referenced objects.
+#
+#      The heap GDSF policy optimizes object hit rate by keeping smaller
+#      popular objects in cache so it has a better chance of getting a
+#      hit.  It achieves a lower byte hit rate than LFUDA though since
+#      it evicts larger (possibly popular) objects.
+#
+#      The heap LFUDA policy keeps popular objects in cache regardless of
+#      their size and thus optimizes byte hit rate at the expense of
+#      hit rate since one large, popular object will prevent many
+#      smaller, slightly less popular objects from being cached.
+#
+#      Both policies utilize a dynamic aging mechanism that prevents
+#      cache pollution that can otherwise occur with frequency-based
+#      replacement policies.
+#
+#      NOTE: if using the LFUDA replacement policy you should increase
+#      the value of maximum_object_size above its default of 4096 KB to
+#      to maximize the potential byte hit rate improvement of LFUDA.
+#
+#      For more information about the GDSF and LFUDA cache replacement
+#      policies see http://www.hpl.hp.com/techreports/1999/HPL-1999-69.html
+#      and http://fog.hpl.external.hp.com/techreports/98/HPL-98-173.html.
+#
+#Default:
+# cache_replacement_policy lru
+
+#  TAG: cache_dir
+#      Usage:
+#
+#      cache_dir Type Directory-Name Fs-specific-data [options]
+#
+#      You can specify multiple cache_dir lines to spread the
+#      cache among different disk partitions.
+#
+#      Type specifies the kind of storage system to use. Only "ufs"
+#      is built by default. To enable any of the other storage systems
+#      see the --enable-storeio configure option.
+#
+#      'Directory' is a top-level directory where cache swap
+#      files will be stored.  If you want to use an entire disk
+#      for caching, this can be the mount-point directory.
+#      The directory must exist and be writable by the Squid
+#      process.  Squid will NOT create this directory for you.
+#
+#      The ufs store type:
+#
+#      "ufs" is the old well-known Squid storage format that has always
+#      been there.
+#
+#      cache_dir ufs Directory-Name Mbytes L1 L2 [options]
+#
+#      'Mbytes' is the amount of disk space (MB) to use under this
+#      directory.  The default is 100 MB.  Change this to suit your
+#      configuration.  Do NOT put the size of your disk drive here.
+#      Instead, if you want Squid to use the entire disk drive,
+#      subtract 20% and use that value.
+#
+#      'Level-1' is the number of first-level subdirectories which
+#      will be created under the 'Directory'.  The default is 16.
+#
+#      'Level-2' is the number of second-level subdirectories which
+#      will be created under each first-level directory.  The default
+#      is 256.
+#
+#      The aufs store type:
+#
+#      "aufs" uses the same storage format as "ufs", utilizing
+#      POSIX-threads to avoid blocking the main Squid process on
+#      disk-I/O. This was formerly known in Squid as async-io.
+#
+#      cache_dir aufs Directory-Name Mbytes L1 L2 [options]
+#
+#      see argument descriptions under ufs above
+#
+#      The diskd store type:
+#
+#      "diskd" uses the same storage format as "ufs", utilizing a
+#      separate process to avoid blocking the main Squid process on
+#      disk-I/O.
+#
+#      cache_dir diskd Directory-Name Mbytes L1 L2 [options] [Q1=n] [Q2=n]
+#
+#      see argument descriptions under ufs above
+#
+#      Q1 specifies the number of unacknowledged I/O requests when Squid
+#      stops opening new files. If this many messages are in the queues,
+#      Squid won't open new files. Default is 64
+#
+#      Q2 specifies the number of unacknowledged messages when Squid
+#      starts blocking.  If this many messages are in the queues,
+#      Squid blocks until it receives some replies. Default is 72
+#
+#      When Q1 < Q2 (the default), the cache directory is optimized
+#      for lower response time at the expense of a decrease in hit
+#      ratio.  If Q1 > Q2, the cache directory is optimized for
+#      higher hit ratio at the expense of an increase in response
+#      time.
+#
+#      The coss store type:
+#
+#      NP: COSS filesystem in 3.0 has been deemed too unstable for
+#          production use and has thus been removed from this 3.0
+#          STABLE release. We hope that it can be made usable again
+#          in a future release.
+#
+#      block-size=n defines the "block size" for COSS cache_dir's.
+#      Squid uses file numbers as block numbers.  Since file numbers
+#      are limited to 24 bits, the block size determines the maximum
+#      size of the COSS partition.  The default is 512 bytes, which
+#      leads to a maximum cache_dir size of 512<<24, or 8 GB.  Note
+#      you should not change the coss block size after Squid
+#      has written some objects to the cache_dir.
+#
+#      The coss file store has changed from 2.5. Now it uses a file
+#      called 'stripe' in the directory names in the config - and
+#      this will be created by squid -z.
+#
+#      The null store type:
+#
+#      no options are allowed or required
+#
+#      Common options:
+#
+#      no-store, no new objects should be stored to this cache_dir
+#
+#      max-size=n, refers to the max object size this storedir supports.
+#      It is used to initially choose the storedir to dump the object.
+#      Note: To make optimal use of the max-size limits you should order
+#      the cache_dir lines with the smallest max-size value first and the
+#      ones with no max-size specification last.
+#
+#      Note for coss, max-size must be less than COSS_MEMBUF_SZ,
+#      which can be changed with the --with-coss-membuf-size=N configure
+#      option.
+#
+#Default:
+# cache_dir ufs /var/spool/squid 100 16 256
+
+#  TAG: store_dir_select_algorithm
+#      Set this to 'round-robin' as an alternative.
+#
+#Default:
+# store_dir_select_algorithm least-load
+
+#  TAG: max_open_disk_fds
+#      To avoid having disk as the I/O bottleneck Squid can optionally
+#      bypass the on-disk cache if more than this amount of disk file
+#      descriptors are open.
+#
+#      A value of 0 indicates no limit.
+#
+#Default:
+# max_open_disk_fds 0
+
+#  TAG: minimum_object_size    (bytes)
+#      Objects smaller than this size will NOT be saved on disk.  The
+#      value is specified in kilobytes, and the default is 0 KB, which
+#      means there is no minimum.
+#
+#Default:
+# minimum_object_size 0 KB
+
+#  TAG: maximum_object_size    (bytes)
+#      Objects larger than this size will NOT be saved on disk.  The
+#      value is specified in kilobytes, and the default is 4MB.  If
+#      you wish to get a high BYTES hit ratio, you should probably
+#      increase this (one 32 MB object hit counts for 3200 10KB
+#      hits).  If you wish to increase speed more than your want to
+#      save bandwidth you should leave this low.
+#
+#      NOTE: if using the LFUDA replacement policy you should increase
+#      this value to maximize the byte hit rate improvement of LFUDA!
+#      See replacement_policy below for a discussion of this policy.
+#
+#Default:
+# maximum_object_size 4096 KB
+
+#  TAG: cache_swap_low (percent, 0-100)
+#  TAG: cache_swap_high        (percent, 0-100)
+#
+#      The low- and high-water marks for cache object replacement.
+#      Replacement begins when the swap (disk) usage is above the
+#      low-water mark and attempts to maintain utilization near the
+#      low-water mark.  As swap utilization gets close to high-water
+#      mark object eviction becomes more aggressive.  If utilization is
+#      close to the low-water mark less replacement is done each time.
+#
+#      Defaults are 90% and 95%. If you have a large cache, 5% could be
+#      hundreds of MB. If this is the case you may wish to set these
+#      numbers closer together.
+#
+#Default:
+# cache_swap_low 90
+# cache_swap_high 95
+
+
+# LOGFILE OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: logformat
+#      Usage:
+#
+#      logformat <name> <format specification>
+#
+#      Defines an access log format.
+#
+#      The <format specification> is a string with embedded % format codes
+#
+#      % format codes all follow the same basic structure where all but
+#      the formatcode is optional. Output strings are automatically escaped
+#      as required according to their context and the output format
+#      modifiers are usually not needed, but can be specified if an explicit
+#      output format is desired.
+#
+#              % ["|[|'|#] [-] [[0]width] [{argument}] formatcode
+#
+#              "       output in quoted string format
+#              [       output in squid text log format as used by log_mime_hdrs
+#              #       output in URL quoted format
+#              '       output as-is
+#
+#              -       left aligned
+#              width   field width. If starting with 0 the
+#                      output is zero padded
+#              {arg}   argument such as header name etc
+#
+#      Format codes:
+#
+#              >a      Client source IP address
+#              >A      Client FQDN
+#              >p      Client source port
+#              <A      Server IP address or peer name
+#              la      Local IP address (http_port)
+#              lp      Local port number (http_port)
+#              ts      Seconds since epoch
+#              tu      subsecond time (milliseconds)
+#              tl      Local time. Optional strftime format argument
+#                      default %d/%b/%Y:%H:%M:%S %z
+#              tg      GMT time. Optional strftime format argument
+#                      default %d/%b/%Y:%H:%M:%S %z
+#              tr      Response time (milliseconds)
+#              >h      Request header. Optional header name argument
+#                      on the format header[:[separator]element]
+#              <h      Reply header. Optional header name argument
+#                      as for >h
+#              un      User name
+#              ul      User name from authentication
+#              ui      User name from ident
+#              us      User name from SSL
+#              ue      User name from external acl helper
+#              Hs      HTTP status code
+#              Ss      Squid request status (TCP_MISS etc)
+#              Sh      Squid hierarchy status (DEFAULT_PARENT etc)
+#              mt      MIME content type
+#              rm      Request method (GET/POST etc)
+#              ru      Request URL
+#              rp      Request URL-Path excluding hostname
+#              rv      Request protocol version
+#              et      Tag returned by external acl
+#              ea      Log string returned by external acl
+#              <st     Reply size including HTTP headers
+#              >st     Request size including HTTP headers
+#              st      Request+Reply size including HTTP headers
+#              <sH     Reply high offset sent
+#              <sS     Upstream object size
+#              %       a literal % character
+#
+#      The default formats available (which do not need re-defining) are:
+#
+#logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
+#logformat squidmime %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt [%>h] [%<h]
+#logformat common %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st %Ss:%Sh
+#logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
+#
+#Default:
+# none
+
+#  TAG: access_log
+#      These files log client request activities. Has a line every HTTP or
+#      ICP request. The format is:
+#      access_log <filepath> [<logformat name> [acl acl ...]]
+#      access_log none [acl acl ...]]
+#
+#      Will log to the specified file using the specified format (which
+#      must be defined in a logformat directive) those entries which match
+#      ALL the acl's specified (which must be defined in acl clauses).
+#      If no acl is specified, all requests will be logged to this file.
+#
+#      To disable logging of a request use the filepath "none", in which case
+#      a logformat name should not be specified.
+#
+#      To log the request via syslog specify a filepath of "syslog":
+#
+#      access_log syslog[:facility.priority] [format [acl1 [acl2 ....]]]
+#      where facility could be any of:
+#      authpriv, daemon, local0 .. local7 or user.
+#
+#      And priority could be any of:
+#      err, warning, notice, info, debug.
+access_log /var/log/squid/access.log squid
+
+#  TAG: log_access     allow|deny acl acl...
+#      This options allows you to control which requests gets logged
+#      to access.log (see access_log directive). Requests denied for
+#      logging will also not be accounted for in performance counters.
+#
+#Default:
+# none
+
+#  TAG: cache_log
+#      Cache logging file. This is where general information about
+#      your cache's behavior goes. You can increase the amount of data
+#      logged to this file with the "debug_options" tag below.
+#
+#Default:
+# cache_log /var/log/squid/cache.log
+
+#  TAG: cache_store_log
+#      Logs the activities of the storage manager.  Shows which
+#      objects are ejected from the cache, and which objects are
+#      saved and for how long.  To disable, enter "none". There are
+#      not really utilities to analyze this data, so you can safely
+#      disable it.
+#
+#Default:
+# cache_store_log /var/log/squid/store.log
+
+#  TAG: cache_swap_state
+#      Location for the cache "swap.state" file. This index file holds
+#      the metadata of objects saved on disk.  It is used to rebuild
+#      the cache during startup.  Normally this file resides in each
+#      'cache_dir' directory, but you may specify an alternate
+#      pathname here.  Note you must give a full filename, not just
+#      a directory. Since this is the index for the whole object
+#      list you CANNOT periodically rotate it!
+#
+#      If %s can be used in the file name it will be replaced with a
+#      a representation of the cache_dir name where each / is replaced
+#      with '.'. This is needed to allow adding/removing cache_dir
+#      lines when cache_swap_log is being used.
+#
+#      If have more than one 'cache_dir', and %s is not used in the name
+#      these swap logs will have names such as:
+#
+#              cache_swap_log.00
+#              cache_swap_log.01
+#              cache_swap_log.02
+#
+#      The numbered extension (which is added automatically)
+#      corresponds to the order of the 'cache_dir' lines in this
+#      configuration file.  If you change the order of the 'cache_dir'
+#      lines in this file, these index files will NOT correspond to
+#      the correct 'cache_dir' entry (unless you manually rename
+#      them).  We recommend you do NOT use this option.  It is
+#      better to keep these index files in each 'cache_dir' directory.
+#
+#Default:
+# none
+
+#  TAG: logfile_rotate
+#      Specifies the number of logfile rotations to make when you
+#      type 'squid -k rotate'. The default is 10, which will rotate
+#      with extensions 0 through 9. Setting logfile_rotate to 0 will
+#      disable the file name rotation, but the logfiles are still closed
+#      and re-opened. This will enable you to rename the logfiles
+#      yourself just before sending the rotate signal.
+#
+#      Note, the 'squid -k rotate' command normally sends a USR1
+#      signal to the running squid process.  In certain situations
+#      (e.g. on Linux with Async I/O), USR1 is used for other
+#      purposes, so -k rotate uses another signal.  It is best to get
+#      in the habit of using 'squid -k rotate' instead of 'kill -USR1
+#      <pid>'.
+#logfile_rotate 0
+#
+#Default:
+# logfile_rotate 0 
+
+#  TAG: emulate_httpd_log      on|off
+#      The Cache can emulate the log file format which many 'httpd'
+#      programs use.  To disable/enable this emulation, set
+#      emulate_httpd_log to 'off' or 'on'.  The default
+#      is to use the native log format since it includes useful
+#      information Squid-specific log analyzers use.
+#
+#Default:
+# emulate_httpd_log off
+
+#  TAG: log_ip_on_direct       on|off
+#      Log the destination IP address in the hierarchy log tag when going
+#      direct. Earlier Squid versions logged the hostname here. If you
+#      prefer the old way set this to off.
+#
+#Default:
+# log_ip_on_direct on
+
+#  TAG: mime_table
+#      Pathname to Squid's MIME table. You shouldn't need to change
+#      this, but the default file contains examples and formatting
+#      information if you do.
+#
+#Default:
+# mime_table /etc/squid/mime.conf
+
+#  TAG: log_mime_hdrs  on|off
+#      The Cache can record both the request and the response MIME
+#      headers for each HTTP transaction.  The headers are encoded
+#      safely and will appear as two bracketed fields at the end of
+#      the access log (for either the native or httpd-emulated log
+#      formats).  To enable this logging set log_mime_hdrs to 'on'.
+#
+#Default:
+# log_mime_hdrs off
+
+#  TAG: useragent_log
+#      Squid will write the User-Agent field from HTTP requests
+#      to the filename specified here.  By default useragent_log
+#      is disabled.
+#
+#Default:
+# none
+
+#  TAG: referer_log
+#      Squid will write the Referer field from HTTP requests to the
+#      filename specified here.  By default referer_log is disabled.
+#      Note that "referer" is actually a misspelling of "referrer"
+#      however the misspelt version has been accepted into the HTTP RFCs
+#      and we accept both.
+#
+#Default:
+# none
+
+#  TAG: pid_filename
+#      A filename to write the process-id to.  To disable, enter "none".
+#
+#Default:
+# pid_filename /var/run/squid.pid
+
+#  TAG: debug_options
+#      Logging options are set as section,level where each source file
+#      is assigned a unique section.  Lower levels result in less
+#      output,  Full debugging (level 9) can result in a very large
+#      log file, so be careful.  The magic word "ALL" sets debugging
+#      levels for all sections.  We recommend normally running with
+#      "ALL,1".
+#
+#Default:
+# debug_options ALL,1
+
+#  TAG: log_fqdn       on|off
+#      Turn this on if you wish to log fully qualified domain names
+#      in the access.log. To do this Squid does a DNS lookup of all
+#      IP's connecting to it. This can (in some situations) increase
+#      latency, which makes your cache seem slower for interactive
+#      browsing.
+#
+#Default:
+# log_fqdn off
+
+#  TAG: client_netmask
+#      A netmask for client addresses in logfiles and cachemgr output.
+#      Change this to protect the privacy of your cache clients.
+#      A netmask of 255.255.255.0 will log all IP's in that range with
+#      the last digit set to '0'.
+#
+#Default:
+# client_netmask 255.255.255.255
+
+#  TAG: forward_log
+# Note: This option is only available if Squid is rebuilt with the
+#       -DWIP_FWD_LOG define
+#
+#      Logs the server-side requests.
+#
+#      This is currently work in progress.
+#
+#Default:
+# none
+
+#  TAG: strip_query_terms
+#      By default, Squid strips query terms from requested URLs before
+#      logging.  This protects your user's privacy.
+#
+#Default:
+# strip_query_terms on
+
+#  TAG: buffered_logs  on|off
+#      cache.log log file is written with stdio functions, and as such
+#      it can be buffered or unbuffered. By default it will be unbuffered.
+#      Buffering it can speed up the writing slightly (though you are
+#      unlikely to need to worry unless you run with tons of debugging
+#      enabled in which case performance will suffer badly anyway..).
+#
+#Default:
+# buffered_logs off
+
+
+# OPTIONS FOR FTP GATEWAYING
+# -----------------------------------------------------------------------------
+
+#  TAG: ftp_user
+#      If you want the anonymous login password to be more informative
+#      (and enable the use of picky ftp servers), set this to something
+#      reasonable for your domain, like wwwuser@somewhere.net
+#
+#      The reason why this is domainless by default is the
+#      request can be made on the behalf of a user in any domain,
+#      depending on how the cache is used.
+#      Some ftp server also validate the email address is valid
+#      (for example perl.com).
+#
+#Default:
+# ftp_user Squid@
+
+#  TAG: ftp_list_width
+#      Sets the width of ftp listings. This should be set to fit in
+#      the width of a standard browser. Setting this too small
+#      can cut off long filenames when browsing ftp sites.
+#
+#Default:
+# ftp_list_width 32
+
+#  TAG: ftp_passive
+#      If your firewall does not allow Squid to use passive
+#      connections, turn off this option.
+#
+#Default:
+# ftp_passive on
+
+#  TAG: ftp_sanitycheck
+#      For security and data integrity reasons Squid by default performs
+#      sanity checks of the addresses of FTP data connections ensure the
+#      data connection is to the requested server. If you need to allow
+#      FTP connections to servers using another IP address for the data
+#      connection turn this off.
+#
+#Default:
+# ftp_sanitycheck on
+
+#  TAG: ftp_telnet_protocol
+#      The FTP protocol is officially defined to use the telnet protocol
+#      as transport channel for the control connection. However, many
+#      implementations are broken and does not respect this aspect of
+#      the FTP protocol.
+#
+#      If you have trouble accessing files with ASCII code 255 in the
+#      path or similar problems involving this ASCII code you can
+#      try setting this directive to off. If that helps, report to the
+#      operator of the FTP server in question that their FTP server
+#      is broken and does not follow the FTP standard.
+#
+#Default:
+# ftp_telnet_protocol on
+
+
+# OPTIONS FOR EXTERNAL SUPPORT PROGRAMS
+# -----------------------------------------------------------------------------
+
+#  TAG: diskd_program
+#      Specify the location of the diskd executable.
+#      Note this is only useful if you have compiled in
+#      diskd as one of the store io modules.
+#
+#Default:
+# diskd_program /usr/lib64/squid/diskd
+
+#  TAG: unlinkd_program
+#      Specify the location of the executable for file deletion process.
+#
+#Default:
+# unlinkd_program /usr/lib64/squid/unlinkd
+
+#  TAG: pinger_program
+# Note: This option is only available if Squid is rebuilt with the
+#       --enable-icmp option
+#
+#      Specify the location of the executable for the pinger process.
+#
+#Default:
+# pinger_program /usr/lib64/squid/pinger
+
+
+# OPTIONS FOR URL REWRITING
+# -----------------------------------------------------------------------------
+
+#  TAG: url_rewrite_program
+#      Specify the location of the executable for the URL rewriter.
+#      Since they can perform almost any function there isn't one included.
+#
+#      For each requested URL rewriter will receive on line with the format
+#
+#      URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kvpairs]<NL>
+#
+#      In the future, the rewriter interface will be extended with
+#      key=value pairs ("kvpairs" shown above).  Rewriter programs
+#      should be prepared to receive and possibly ignore additional
+#      whitespace-separated tokens on each input line.
+#
+#      And the rewriter may return a rewritten URL. The other components of
+#      the request line does not need to be returned (ignored if they are).
+#
+#      The rewriter can also indicate that a client-side redirect should
+#      be performed to the new URL. This is done by prefixing the returned
+#      URL with "301:" (moved permanently) or 302: (moved temporarily).
+#
+#      By default, a URL rewriter is not used.
+#
+#Default:
+# none
+
+#  TAG: url_rewrite_children
+#      The number of redirector processes to spawn. If you start
+#      too few Squid will have to wait for them to process a backlog of
+#      URLs, slowing it down. If you start too many they will use RAM
+#      and other system resources.
+#
+#Default:
+# url_rewrite_children 5
+
+#  TAG: url_rewrite_concurrency
+#      The number of requests each redirector helper can handle in
+#      parallel. Defaults to 0 which indicates the redirector
+#      is a old-style single threaded redirector.
+#
+#Default:
+# url_rewrite_concurrency 0
+
+#  TAG: url_rewrite_host_header
+#      By default Squid rewrites any Host: header in redirected
+#      requests.  If you are running an accelerator this may
+#      not be a wanted effect of a redirector.
+#
+#      WARNING: Entries are cached on the result of the URL rewriting
+#      process, so be careful if you have domain-virtual hosts.
+#
+#Default:
+# url_rewrite_host_header on
+
+#  TAG: url_rewrite_access
+#      If defined, this access list specifies which requests are
+#      sent to the redirector processes.  By default all requests
+#      are sent.
+#
+#Default:
+# none
+
+#  TAG: url_rewrite_bypass
+#      When this is 'on', a request will not go through the
+#      redirector if all redirectors are busy.  If this is 'off'
+#      and the redirector queue grows too large, Squid will exit
+#      with a FATAL error and ask you to increase the number of
+#      redirectors.  You should only enable this if the redirectors
+#      are not critical to your caching system.  If you use
+#      redirectors for access control, and you enable this option,
+#      users may have access to pages they should not
+#      be allowed to request.
+#
+#Default:
+# url_rewrite_bypass off
+
+
+# OPTIONS FOR TUNING THE CACHE
+# -----------------------------------------------------------------------------
+
+#  TAG: cache
+#      A list of ACL elements which, if matched and denied, cause the request to
+#      not be satisfied from the cache and the reply to not be cached.
+#      In other words, use this to force certain objects to never be cached.
+#
+#      You must use the words 'allow' or 'deny' to indicate whether items
+#      matching the ACL should be allowed or denied into the cache.
+#
+#      Default is to allow all to be cached
+#
+#Default:
+# none
+
+#  TAG: refresh_pattern
+#      usage: refresh_pattern [-i] regex min percent max [options]
+#
+#      By default, regular expressions are CASE-SENSITIVE.  To make
+#      them case-insensitive, use the -i option.
+#
+#      'Min' is the time (in minutes) an object without an explicit
+#      expiry time should be considered fresh. The recommended
+#      value is 0, any higher values may cause dynamic applications
+#      to be erroneously cached unless the application designer
+#      has taken the appropriate actions.
+#
+#      'Percent' is a percentage of the objects age (time since last
+#      modification age) an object without explicit expiry time
+#      will be considered fresh.
+#
+#      'Max' is an upper limit on how long objects without an explicit
+#      expiry time will be considered fresh.
+#
+#      options: override-expire
+#               override-lastmod
+#               reload-into-ims
+#               ignore-reload
+#               ignore-no-cache
+#               ignore-no-store
+#               ignore-private
+#               ignore-auth
+#               refresh-ims
+#
+#              override-expire enforces min age even if the server
+#              sent an explicit expiry time (e.g., with the
+#              Expires: header or Cache-Control: max-age). Doing this
+#              VIOLATES the HTTP standard.  Enabling this feature
+#              could make you liable for problems which it causes.
+#
+#              override-lastmod enforces min age even on objects
+#              that were modified recently.
+#
+#              reload-into-ims changes client no-cache or ``reload''
+#              to If-Modified-Since requests. Doing this VIOLATES the
+#              HTTP standard. Enabling this feature could make you
+#              liable for problems which it causes.
+#
+#              ignore-reload ignores a client no-cache or ``reload''
+#              header. Doing this VIOLATES the HTTP standard. Enabling
+#              this feature could make you liable for problems which
+#              it causes.
+#
+#              ignore-no-cache ignores any ``Pragma: no-cache'' and
+#              ``Cache-control: no-cache'' headers received from a server.
+#              The HTTP RFC never allows the use of this (Pragma) header
+#              from a server, only a client, though plenty of servers
+#              send it anyway.
+#
+#              ignore-no-store ignores any ``Cache-control: no-store''
+#              headers received from a server. Doing this VIOLATES
+#              the HTTP standard. Enabling this feature could make you
+#              liable for problems which it causes.
+#
+#              ignore-private ignores any ``Cache-control: private''
+#              headers received from a server. Doing this VIOLATES
+#              the HTTP standard. Enabling this feature could make you
+#              liable for problems which it causes.
+#
+#              ignore-auth caches responses to requests with authorization,
+#              as if the originserver had sent ``Cache-control: public''
+#              in the response header. Doing this VIOLATES the HTTP standard.
+#              Enabling this feature could make you liable for problems which
+#              it causes.
+#
+#              refresh-ims causes squid to contact the origin server
+#              when a client issues an If-Modified-Since request. This
+#              ensures that the client will receive an updated version
+#              if one is available.
+#
+#      Basically a cached object is:
+#
+#              FRESH if expires < now, else STALE
+#              STALE if age > max
+#              FRESH if lm-factor < percent, else STALE
+#              FRESH if age < min
+#              else STALE
+#
+#      The refresh_pattern lines are checked in the order listed here.
+#      The first entry which matches is used.  If none of the entries
+#      match the default will be used.
+#
+#      Note, you must uncomment all the default lines if you want
+#      to change one. The default setting is only active if none is
+#      used.
+#
+#Suggested default:
+refresh_pattern ^ftp:          1440    20%     10080
+refresh_pattern ^gopher:       1440    0%      1440
+refresh_pattern (cgi-bin|\?)   0       0%      0
+refresh_pattern .              0       20%     4320
+
+#  TAG: quick_abort_min        (KB)
+#  TAG: quick_abort_max        (KB)
+#  TAG: quick_abort_pct        (percent)
+#      The cache by default continues downloading aborted requests
+#      which are almost completed (less than 16 KB remaining). This
+#      may be undesirable on slow (e.g. SLIP) links and/or very busy
+#      caches.  Impatient users may tie up file descriptors and
+#      bandwidth by repeatedly requesting and immediately aborting
+#      downloads.
+#
+#      When the user aborts a request, Squid will check the
+#      quick_abort values to the amount of data transfered until
+#      then.
+#
+#      If the transfer has less than 'quick_abort_min' KB remaining,
+#      it will finish the retrieval.
+#
+#      If the transfer has more than 'quick_abort_max' KB remaining,
+#      it will abort the retrieval.
+#
+#      If more than 'quick_abort_pct' of the transfer has completed,
+#      it will finish the retrieval.
+#
+#      If you do not want any retrieval to continue after the client
+#      has aborted, set both 'quick_abort_min' and 'quick_abort_max'
+#      to '0 KB'.
+#
+#      If you want retrievals to always continue if they are being
+#      cached set 'quick_abort_min' to '-1 KB'.
+#
+#Default:
+# quick_abort_min 16 KB
+# quick_abort_max 16 KB
+# quick_abort_pct 95
+
+#  TAG: read_ahead_gap buffer-size
+#      The amount of data the cache will buffer ahead of what has been
+#      sent to the client when retrieving an object from another server.
+#
+#Default:
+# read_ahead_gap 16 KB
+
+#  TAG: negative_ttl   time-units
+#      Time-to-Live (TTL) for failed requests.  Certain types of
+#      failures (such as "connection refused" and "404 Not Found") are
+#      negatively-cached for a configurable amount of time.  The
+#      default is 5 minutes.  Note that this is different from
+#      negative caching of DNS lookups.
+#
+#      WARNING: This setting VIOLATES RFC 2616 when non-zero.
+#      If you have problems with eror pages caching, set to '0 seconds'
+#
+#Default:
+# negative_ttl 5 minutes
+
+#  TAG: positive_dns_ttl       time-units
+#      Upper limit on how long Squid will cache positive DNS responses.
+#      Default is 6 hours (360 minutes). This directive must be set
+#      larger than negative_dns_ttl.
+#
+#Default:
+# positive_dns_ttl 6 hours
+
+#  TAG: negative_dns_ttl       time-units
+#      Time-to-Live (TTL) for negative caching of failed DNS lookups.
+#      This also sets the lower cache limit on positive lookups.
+#      Minimum value is 1 second, and it is not recommendable to go
+#      much below 10 seconds.
+#
+#Default:
+# negative_dns_ttl 1 minutes
+
+#  TAG: range_offset_limit     (bytes)
+#      Sets a upper limit on how far into the the file a Range request
+#      may be to cause Squid to prefetch the whole file. If beyond this
+#      limit Squid forwards the Range request as it is and the result
+#      is NOT cached.
+#
+#      This is to stop a far ahead range request (lets say start at 17MB)
+#      from making Squid fetch the whole object up to that point before
+#      sending anything to the client.
+#
+#      A value of -1 causes Squid to always fetch the object from the
+#      beginning so it may cache the result. (2.0 style)
+#
+#      A value of 0 causes Squid to never fetch more than the
+#      client requested. (default)
+#
+#Default:
+# range_offset_limit 0 KB
+
+#  TAG: minimum_expiry_time    (seconds)
+#      The minimum caching time according to (Expires - Date)
+#      Headers Squid honors if the object can't be revalidated
+#      defaults to 60 seconds. In reverse proxy environments it
+#      might be desirable to honor shorter object lifetimes. It
+#      is most likely better to make your server return a
+#      meaningful Last-Modified header however. In ESI environments
+#      where page fragments often have short lifetimes, this will
+#      often be best set to 0.
+#
+#Default:
+# minimum_expiry_time 60 seconds
+
+#  TAG: store_avg_object_size  (kbytes)
+#      Average object size, used to estimate number of objects your
+#      cache can hold.  The default is 13 KB.
+#
+#Default:
+# store_avg_object_size 13 KB
+
+#  TAG: store_objects_per_bucket
+#      Target number of objects per bucket in the store hash table.
+#      Lowering this value increases the total number of buckets and
+#      also the storage maintenance rate.  The default is 20.
+#
+#Default:
+# store_objects_per_bucket 20
+
+
+# HTTP OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: request_header_max_size        (KB)
+#      This specifies the maximum size for HTTP headers in a request.
+#      Request headers are usually relatively small (about 512 bytes).
+#      Placing a limit on the request header size will catch certain
+#      bugs (for example with persistent connections) and possibly
+#      buffer-overflow or denial-of-service attacks.
+#
+#Default:
+# request_header_max_size 20 KB
+
+#  TAG: reply_header_max_size  (KB)
+#      This specifies the maximum size for HTTP headers in a reply.
+#      Reply headers are usually relatively small (about 512 bytes).
+#      Placing a limit on the reply header size will catch certain
+#      bugs (for example with persistent connections) and possibly
+#      buffer-overflow or denial-of-service attacks.
+#
+#Default:
+# reply_header_max_size 20 KB
+
+#  TAG: request_body_max_size  (bytes)
+#      This specifies the maximum size for an HTTP request body.
+#      In other words, the maximum size of a PUT/POST request.
+#      A user who attempts to send a request with a body larger
+#      than this limit receives an "Invalid Request" error message.
+#      If you set this parameter to a zero (the default), there will
+#      be no limit imposed.
+#
+#Default:
+# request_body_max_size 0 KB
+
+#  TAG: broken_posts
+#      A list of ACL elements which, if matched, causes Squid to send
+#      an extra CRLF pair after the body of a PUT/POST request.
+#
+#      Some HTTP servers has broken implementations of PUT/POST,
+#      and rely on an extra CRLF pair sent by some WWW clients.
+#
+#      Quote from RFC2616 section 4.1 on this matter:
+#
+#        Note: certain buggy HTTP/1.0 client implementations generate an
+#        extra CRLF's after a POST request. To restate what is explicitly
+#        forbidden by the BNF, an HTTP/1.1 client must not preface or follow
+#        a request with an extra CRLF.
+#
+#Example:
+# acl buggy_server url_regex ^http://....
+# broken_posts allow buggy_server
+#
+#Default:
+# none
+
+#  TAG: via    on|off
+#      If set (default), Squid will include a Via header in requests and
+#      replies as required by RFC2616.
+#
+#Default:
+# via on
+
+#  TAG: ie_refresh     on|off
+#      Microsoft Internet Explorer up until version 5.5 Service
+#      Pack 1 has an issue with transparent proxies, wherein it
+#      is impossible to force a refresh.  Turning this on provides
+#      a partial fix to the problem, by causing all IMS-REFRESH
+#      requests from older IE versions to check the origin server
+#      for fresh content.  This reduces hit ratio by some amount
+#      (~10% in my experience), but allows users to actually get
+#      fresh content when they want it.  Note because Squid
+#      cannot tell if the user is using 5.5 or 5.5SP1, the behavior
+#      of 5.5 is unchanged from old versions of Squid (i.e. a
+#      forced refresh is impossible).  Newer versions of IE will,
+#      hopefully, continue to have the new behavior and will be
+#      handled based on that assumption.  This option defaults to
+#      the old Squid behavior, which is better for hit ratios but
+#      worse for clients using IE, if they need to be able to
+#      force fresh content.
+#
+#Default:
+# ie_refresh off
+
+#  TAG: vary_ignore_expire     on|off
+#      Many HTTP servers supporting Vary gives such objects
+#      immediate expiry time with no cache-control header
+#      when requested by a HTTP/1.0 client. This option
+#      enables Squid to ignore such expiry times until
+#      HTTP/1.1 is fully implemented.
+#      WARNING: This may eventually cause some varying
+#      objects not intended for caching to get cached.
+#
+#Default:
+# vary_ignore_expire off
+
+#  TAG: extension_methods
+#      Squid only knows about standardized HTTP request methods.
+#      You can add up to 20 additional "extension" methods here.
+#
+#Default:
+# none
+
+#  TAG: request_entities
+#      Squid defaults to deny GET and HEAD requests with request entities,
+#      as the meaning of such requests are undefined in the HTTP standard
+#      even if not explicitly forbidden.
+#
+#      Set this directive to on if you have clients which insists
+#      on sending request entities in GET or HEAD requests. But be warned
+#      that there is server software (both proxies and web servers) which
+#      can fail to properly process this kind of request which may make you
+#      vulnerable to cache pollution attacks if enabled.
+#
+#Default:
+# request_entities off
+
+#  TAG: request_header_access
+#      Usage: request_header_access header_name allow|deny [!]aclname ...
+#
+#      WARNING: Doing this VIOLATES the HTTP standard.  Enabling
+#      this feature could make you liable for problems which it
+#      causes.
+#
+#      This option replaces the old 'anonymize_headers' and the
+#      older 'http_anonymizer' option with something that is much
+#      more configurable. This new method creates a list of ACLs
+#      for each header, allowing you very fine-tuned header
+#      mangling.
+#
+#      This option only applies to request headers, i.e., from the
+#      client to the server.
+#
+#      You can only specify known headers for the header name.
+#      Other headers are reclassified as 'Other'. You can also
+#      refer to all the headers with 'All'.
+#
+#      For example, to achieve the same behavior as the old
+#      'http_anonymizer standard' option, you should use:
+#
+#              request_header_access From deny all
+#              request_header_access Referer deny all
+#              request_header_access Server deny all
+#              request_header_access User-Agent deny all
+#              request_header_access WWW-Authenticate deny all
+#              request_header_access Link deny all
+#
+#      Or, to reproduce the old 'http_anonymizer paranoid' feature
+#      you should use:
+#
+#              request_header_access Allow allow all
+#              request_header_access Authorization allow all
+#              request_header_access WWW-Authenticate allow all
+#              request_header_access Proxy-Authorization allow all
+#              request_header_access Proxy-Authenticate allow all
+#              request_header_access Cache-Control allow all
+#              request_header_access Content-Encoding allow all
+#              request_header_access Content-Length allow all
+#              request_header_access Content-Type allow all
+#              request_header_access Date allow all
+#              request_header_access Expires allow all
+#              request_header_access Host allow all
+#              request_header_access If-Modified-Since allow all
+#              request_header_access Last-Modified allow all
+#              request_header_access Location allow all
+#              request_header_access Pragma allow all
+#              request_header_access Accept allow all
+#              request_header_access Accept-Charset allow all
+#              request_header_access Accept-Encoding allow all
+#              request_header_access Accept-Language allow all
+#              request_header_access Content-Language allow all
+#              request_header_access Mime-Version allow all
+#              request_header_access Retry-After allow all
+#              request_header_access Title allow all
+#              request_header_access Connection allow all
+#              request_header_access Proxy-Connection allow all
+#              request_header_access All deny all
+#
+#      although many of those are HTTP reply headers, and so should be
+#      controlled with the reply_header_access directive.
+#
+#      By default, all headers are allowed (no anonymizing is
+#      performed).
+#
+#Default:
+# none
+
+#  TAG: reply_header_access
+#      Usage: reply_header_access header_name allow|deny [!]aclname ...
+#
+#      WARNING: Doing this VIOLATES the HTTP standard.  Enabling
+#      this feature could make you liable for problems which it
+#      causes.
+#
+#      This option only applies to reply headers, i.e., from the
+#      server to the client.
+#
+#      This is the same as request_header_access, but in the other
+#      direction.
+#
+#      This option replaces the old 'anonymize_headers' and the
+#      older 'http_anonymizer' option with something that is much
+#      more configurable. This new method creates a list of ACLs
+#      for each header, allowing you very fine-tuned header
+#      mangling.
+#
+#      You can only specify known headers for the header name.
+#      Other headers are reclassified as 'Other'. You can also
+#      refer to all the headers with 'All'.
+#
+#      For example, to achieve the same behavior as the old
+#      'http_anonymizer standard' option, you should use:
+#
+#              reply_header_access From deny all
+#              reply_header_access Referer deny all
+#              reply_header_access Server deny all
+#              reply_header_access User-Agent deny all
+#              reply_header_access WWW-Authenticate deny all
+#              reply_header_access Link deny all
+#
+#      Or, to reproduce the old 'http_anonymizer paranoid' feature
+#      you should use:
+#
+#              reply_header_access Allow allow all
+#              reply_header_access Authorization allow all
+#              reply_header_access WWW-Authenticate allow all
+#              reply_header_access Proxy-Authorization allow all
+#              reply_header_access Proxy-Authenticate allow all
+#              reply_header_access Cache-Control allow all
+#              reply_header_access Content-Encoding allow all
+#              reply_header_access Content-Length allow all
+#              reply_header_access Content-Type allow all
+#              reply_header_access Date allow all
+#              reply_header_access Expires allow all
+#              reply_header_access Host allow all
+#              reply_header_access If-Modified-Since allow all
+#              reply_header_access Last-Modified allow all
+#              reply_header_access Location allow all
+#              reply_header_access Pragma allow all
+#              reply_header_access Accept allow all
+#              reply_header_access Accept-Charset allow all
+#              reply_header_access Accept-Encoding allow all
+#              reply_header_access Accept-Language allow all
+#              reply_header_access Content-Language allow all
+#              reply_header_access Mime-Version allow all
+#              reply_header_access Retry-After allow all
+#              reply_header_access Title allow all
+#              reply_header_access Connection allow all
+#              reply_header_access Proxy-Connection allow all
+#              reply_header_access All deny all
+#
+#      although the HTTP request headers won't be usefully controlled
+#      by this directive -- see request_header_access for details.
+#
+#      By default, all headers are allowed (no anonymizing is
+#      performed).
+#
+#Default:
+# none
+
+#  TAG: header_replace
+#      Usage:   header_replace header_name message
+#      Example: header_replace User-Agent Nutscrape/1.0 (CP/M; 8-bit)
+#
+#      This option allows you to change the contents of headers
+#      denied with header_access above, by replacing them with
+#      some fixed string. This replaces the old fake_user_agent
+#      option.
+#
+#      This only applies to request headers, not reply headers.
+#
+#      By default, headers are removed if denied.
+#
+#Default:
+# none
+
+#  TAG: relaxed_header_parser  on|off|warn
+#      In the default "on" setting Squid accepts certain forms
+#      of non-compliant HTTP messages where it is unambiguous
+#      what the sending application intended even if the message
+#      is not correctly formatted. The messages is then normalized
+#      to the correct form when forwarded by Squid.
+#
+#      If set to "warn" then a warning will be emitted in cache.log
+#      each time such HTTP error is encountered.
+#
+#      If set to "off" then such HTTP errors will cause the request
+#      or response to be rejected.
+#
+#Default:
+# relaxed_header_parser on
+
+
+# TIMEOUTS
+# -----------------------------------------------------------------------------
+
+#  TAG: forward_timeout        time-units
+#      This parameter specifies how long Squid should at most attempt in
+#      finding a forwarding path for the request before giving up.
+#
+#Default:
+# forward_timeout 4 minutes
+
+#  TAG: connect_timeout        time-units
+#      This parameter specifies how long to wait for the TCP connect to
+#      the requested server or peer to complete before Squid should
+#      attempt to find another path where to forward the request.
+#
+#Default:
+# connect_timeout 1 minute
+
+#  TAG: peer_connect_timeout   time-units
+#      This parameter specifies how long to wait for a pending TCP
+#      connection to a peer cache.  The default is 30 seconds.   You
+#      may also set different timeout values for individual neighbors
+#      with the 'connect-timeout' option on a 'cache_peer' line.
+#
+#Default:
+# peer_connect_timeout 30 seconds
+
+#  TAG: read_timeout   time-units
+#      The read_timeout is applied on server-side connections.  After
+#      each successful read(), the timeout will be extended by this
+#      amount.  If no data is read again after this amount of time,
+#      the request is aborted and logged with ERR_READ_TIMEOUT.  The
+#      default is 15 minutes.
+#
+#Default:
+# read_timeout 15 minutes
+
+#  TAG: request_timeout
+#      How long to wait for an HTTP request after initial
+#      connection establishment.
+#
+#Default:
+# request_timeout 5 minutes
+
+#  TAG: persistent_request_timeout
+#      How long to wait for the next HTTP request on a persistent
+#      connection after the previous request completes.
+#
+#Default:
+# persistent_request_timeout 2 minutes
+
+#  TAG: client_lifetime        time-units
+#      The maximum amount of time a client (browser) is allowed to
+#      remain connected to the cache process.  This protects the Cache
+#      from having a lot of sockets (and hence file descriptors) tied up
+#      in a CLOSE_WAIT state from remote clients that go away without
+#      properly shutting down (either because of a network failure or
+#      because of a poor client implementation).  The default is one
+#      day, 1440 minutes.
+#
+#      NOTE:  The default value is intended to be much larger than any
+#      client would ever need to be connected to your cache.  You
+#      should probably change client_lifetime only as a last resort.
+#      If you seem to have many client connections tying up
+#      filedescriptors, we recommend first tuning the read_timeout,
+#      request_timeout, persistent_request_timeout and quick_abort values.
+#
+#Default:
+# client_lifetime 1 day
+
+#  TAG: half_closed_clients
+#      Some clients may shutdown the sending side of their TCP
+#      connections, while leaving their receiving sides open.  Sometimes,
+#      Squid can not tell the difference between a half-closed and a
+#      fully-closed TCP connection.
+#
+#      By default, Squid will immediately close client connections when
+#      read(2) returns "no more data to read."
+#
+#      Change this option to 'on' and Squid will keep open connections
+#      until a read(2) or write(2) on the socket returns an error.
+#      This may show some benefits for reverse proxies. But if not
+#      it is recommended to leave OFF.
+#
+#Default:
+# half_closed_clients off
+
+#  TAG: pconn_timeout
+#      Timeout for idle persistent connections to servers and other
+#      proxies.
+#
+#Default:
+# pconn_timeout 1 minute
+
+#  TAG: ident_timeout
+#      Maximum time to wait for IDENT lookups to complete.
+#
+#      If this is too high, and you enabled IDENT lookups from untrusted
+#      users, you might be susceptible to denial-of-service by having
+#      many ident requests going at once.
+#
+#Default:
+# ident_timeout 10 seconds
+
+#  TAG: shutdown_lifetime      time-units
+#      When SIGTERM or SIGHUP is received, the cache is put into
+#      "shutdown pending" mode until all active sockets are closed.
+#      This value is the lifetime to set for all open descriptors
+#      during shutdown mode.  Any active clients after this many
+#      seconds will receive a 'timeout' message.
+#
+#Default:
+# shutdown_lifetime 30 seconds
+
+
+# ADMINISTRATIVE PARAMETERS
+# -----------------------------------------------------------------------------
+
+#  TAG: cache_mgr
+#      Email-address of local cache manager who will receive
+#      mail if the cache dies.  The default is "root."
+#
+#Default:
+# cache_mgr root 
+
+#  TAG: mail_from
+#      From: email-address for mail sent when the cache dies.
+#      The default is to use 'appname@unique_hostname'.
+#      Default appname value is "squid", can be changed into
+#      src/globals.h before building squid.
+#
+#Default:
+# none
+
+#  TAG: mail_program
+#      Email program used to send mail if the cache dies.
+#      The default is "mail". The specified program must comply
+#      with the standard Unix mail syntax:
+#        mail-program recipient < mailfile
+#
+#      Optional command line options can be specified.
+#
+#Default:
+# mail_program mail
+
+#  TAG: cache_effective_user
+#      If you start Squid as root, it will change its effective/real
+#      UID/GID to the user specified below.  The default is to change
+#      to UID of squid.
+#      see also; cache_effective_group
+#
+#Default:
+# cache_effective_user squid
+
+#  TAG: cache_effective_group
+#      Squid sets the GID to the effective user's default group ID
+#      (taken from the password file) and supplementary group list
+#      from the groups membership.
+#
+#      If you want Squid to run with a specific GID regardless of
+#      the group memberships of the effective user then set this
+#      to the group (or GID) you want Squid to run as. When set
+#      all other group privileges of the effective user are ignored
+#      and only this GID is effective. If Squid is not started as
+#      root the user starting Squid MUST be member of the specified
+#      group.
+#
+#      This option is not recommended by the Squid Team.
+#      Our preference is for administrators to configure a secure
+#      user account for squid with UID/GID matching system policies.
+#
+#Default:
+# none
+
+#  TAG: httpd_suppress_version_string  on|off
+#      Suppress Squid version string info in HTTP headers and HTML error pages.
+#
+#Default:
+# httpd_suppress_version_string off
+
+#  TAG: visible_hostname
+#      If you want to present a special hostname in error messages, etc,
+#      define this.  Otherwise, the return value of gethostname()
+#      will be used. If you have multiple caches in a cluster and
+#      get errors about IP-forwarding you must set them to have individual
+#      names with this setting.
+#
+#Default:
+# none
+
+#  TAG: unique_hostname
+#      If you want to have multiple machines with the same
+#      'visible_hostname' you must give each machine a different
+#      'unique_hostname' so forwarding loops can be detected.
+#
+#Default:
+# none
+
+#  TAG: hostname_aliases
+#      A list of other DNS names your cache has.
+#
+#Default:
+# none
+
+#  TAG: umask
+#      Minimum umask which should be enforced while the proxy
+#      is running, in addition to the umask set at startup.
+#
+#      For a traditional octal representation of umasks, start
+#        your value with 0.
+#
+#Default:
+# umask 027
+
+
+# OPTIONS FOR THE CACHE REGISTRATION SERVICE
+# -----------------------------------------------------------------------------
+#
+#      This section contains parameters for the (optional) cache
+#      announcement service.  This service is provided to help
+#      cache administrators locate one another in order to join or
+#      create cache hierarchies.
+#
+#      An 'announcement' message is sent (via UDP) to the registration
+#      service by Squid.  By default, the announcement message is NOT
+#      SENT unless you enable it with 'announce_period' below.
+#
+#      The announcement message includes your hostname, plus the
+#      following information from this configuration file:
+#
+#              http_port
+#              icp_port
+#              cache_mgr
+#
+#      All current information is processed regularly and made
+#      available on the Web at http://www.ircache.net/Cache/Tracker/.
+
+#  TAG: announce_period
+#      This is how frequently to send cache announcements.  The
+#      default is `0' which disables sending the announcement
+#      messages.
+#
+#      To enable announcing your cache, just uncomment the line
+#      below.
+#
+#Default:
+# announce_period 0
+#
+#To enable announcing your cache, just uncomment the line below.
+#announce_period 1 day
+
+#  TAG: announce_host
+#  TAG: announce_file
+#  TAG: announce_port
+#      announce_host and announce_port set the hostname and port
+#      number where the registration message will be sent.
+#
+#      Hostname will default to 'tracker.ircache.net' and port will
+#      default default to 3131.  If the 'filename' argument is given,
+#      the contents of that file will be included in the announce
+#      message.
+#
+#Default:
+# announce_host tracker.ircache.net
+# announce_port 3131
+
+
+# HTTPD-ACCELERATOR OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: httpd_accel_surrogate_id
+# Note: This option is only available if Squid is rebuilt with the
+#       -DUSE_SQUID_ESI define
+#
+#      Surrogates (http://www.esi.org/architecture_spec_1.0.html)
+#      need an identification token to allow control targeting. Because
+#      a farm of surrogates may all perform the same tasks, they may share
+#      an identification token.
+#
+#Default:
+# httpd_accel_surrogate_id unset-id
+
+#  TAG: http_accel_surrogate_remote    on|off
+# Note: This option is only available if Squid is rebuilt with the
+#       -DUSE_SQUID_ESI define
+#
+#      Remote surrogates (such as those in a CDN) honour Surrogate-Control: no-store-remote.
+#      Set this to on to have squid behave as a remote surrogate.
+#
+#Default:
+# http_accel_surrogate_remote off
+
+#  TAG: esi_parser     libxml2|expat|custom
+# Note: This option is only available if Squid is rebuilt with the
+#       -DUSE_SQUID_ESI define
+#
+#      ESI markup is not strictly XML compatible. The custom ESI parser
+#      will give higher performance, but cannot handle non ASCII character
+#      encodings.
+#
+#Default:
+# esi_parser custom
+
+
+# DELAY POOL PARAMETERS
+# -----------------------------------------------------------------------------
+
+#  TAG: delay_pools
+#      This represents the number of delay pools to be used.  For example,
+#      if you have one class 2 delay pool and one class 3 delays pool, you
+#      have a total of 2 delay pools.
+#
+#Default:
+# delay_pools 0
+
+#  TAG: delay_class
+#      This defines the class of each delay pool.  There must be exactly one
+#      delay_class line for each delay pool.  For example, to define two
+#      delay pools, one of class 2 and one of class 3, the settings above
+#      and here would be:
+#
+#Example:
+# delay_pools 4      # 4 delay pools
+# delay_class 1 2    # pool 1 is a class 2 pool
+# delay_class 2 3    # pool 2 is a class 3 pool
+# delay_class 3 4    # pool 3 is a class 4 pool
+# delay_class 4 5    # pool 4 is a class 5 pool
+#
+#      The delay pool classes are:
+#
+#              class 1         Everything is limited by a single aggregate
+#                              bucket.
+#
+#              class 2         Everything is limited by a single aggregate
+#                              bucket as well as an "individual" bucket chosen
+#                              from bits 25 through 32 of the IP address.
+#
+#              class 3         Everything is limited by a single aggregate
+#                              bucket as well as a "network" bucket chosen
+#                              from bits 17 through 24 of the IP address and a
+#                              "individual" bucket chosen from bits 17 through
+#                              32 of the IP address.
+#
+#              class 4         Everything in a class 3 delay pool, with an
+#                              additional limit on a per user basis. This
+#                              only takes effect if the username is established
+#                              in advance - by forcing authentication in your
+#                              http_access rules.
+#
+#              class 5         Requests are grouped according their tag (see
+#                              external_acl's tag= reply).
+#
+#      NOTE: If an IP address is a.b.c.d
+#              -> bits 25 through 32 are "d"
+#              -> bits 17 through 24 are "c"
+#              -> bits 17 through 32 are "c * 256 + d"
+#
+#Default:
+# none
+
+#  TAG: delay_access
+#      This is used to determine which delay pool a request falls into.
+#
+#      delay_access is sorted per pool and the matching starts with pool 1,
+#      then pool 2, ..., and finally pool N. The first delay pool where the
+#      request is allowed is selected for the request. If it does not allow
+#      the request to any pool then the request is not delayed (default).
+#
+#      For example, if you want some_big_clients in delay
+#      pool 1 and lotsa_little_clients in delay pool 2:
+#
+#Example:
+# delay_access 1 allow some_big_clients
+# delay_access 1 deny all
+# delay_access 2 allow lotsa_little_clients
+# delay_access 2 deny all
+# delay_access 3 allow authenticated_clients
+#
+#Default:
+# none
+
+#  TAG: delay_parameters
+#      This defines the parameters for a delay pool.  Each delay pool has
+#      a number of "buckets" associated with it, as explained in the
+#      description of delay_class.  For a class 1 delay pool, the syntax is:
+#
+#delay_parameters pool aggregate
+#
+#      For a class 2 delay pool:
+#
+#delay_parameters pool aggregate individual
+#
+#      For a class 3 delay pool:
+#
+#delay_parameters pool aggregate network individual
+#
+#      For a class 4 delay pool:
+#
+#delay_parameters pool aggregate network individual user
+#
+#      For a class 5 delay pool:
+#
+#delay_parameters pool tag
+#
+#      The variables here are:
+#
+#              pool            a pool number - ie, a number between 1 and the
+#                              number specified in delay_pools as used in
+#                              delay_class lines.
+#
+#              aggregate       the "delay parameters" for the aggregate bucket
+#                              (class 1, 2, 3).
+#
+#              individual      the "delay parameters" for the individual
+#                              buckets (class 2, 3).
+#
+#              network         the "delay parameters" for the network buckets
+#                              (class 3).
+#
+#              user            the delay parameters for the user buckets
+#                              (class 4).
+#
+#              tag             the delay parameters for the tag buckets
+#                              (class 5).
+#
+#      A pair of delay parameters is written restore/maximum, where restore is
+#      the number of bytes (not bits - modem and network speeds are usually
+#      quoted in bits) per second placed into the bucket, and maximum is the
+#      maximum number of bytes which can be in the bucket at any time.
+#
+#      For example, if delay pool number 1 is a class 2 delay pool as in the
+#      above example, and is being used to strictly limit each host to 64kbps
+#      (plus overheads), with no overall limit, the line is:
+#
+#delay_parameters 1 -1/-1 8000/8000
+#
+#      Note that the figure -1 is used to represent "unlimited".
+#
+#      And, if delay pool number 2 is a class 3 delay pool as in the above
+#      example, and you want to limit it to a total of 256kbps (strict limit)
+#      with each 8-bit network permitted 64kbps (strict limit) and each
+#      individual host permitted 4800bps with a bucket maximum size of 64kb
+#      to permit a decent web page to be downloaded at a decent speed
+#      (if the network is not being limited due to overuse) but slow down
+#      large downloads more significantly:
+#
+#delay_parameters 2 32000/32000 8000/8000 600/8000
+#
+#      There must be one delay_parameters line for each delay pool.
+#
+#      Finally, for a class 4 delay pool as in the example - each user will
+#      be limited to 128Kb no matter how many workstations they are logged into.:
+#
+#delay_parameters 4 32000/32000 8000/8000 600/64000 16000/16000
+#
+#Default:
+# none
+
+#  TAG: delay_initial_bucket_level     (percent, 0-100)
+#      The initial bucket percentage is used to determine how much is put
+#      in each bucket when squid starts, is reconfigured, or first notices
+#      a host accessing it (in class 2 and class 3, individual hosts and
+#      networks only have buckets associated with them once they have been
+#      "seen" by squid).
+#
+#Default:
+# delay_initial_bucket_level 50
+
+
+# WCCPv1 AND WCCPv2 CONFIGURATION OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: wccp_router
+#  TAG: wccp2_router
+#      Use this option to define your WCCP ``home'' router for
+#      Squid.
+#
+#      wccp_router supports a single WCCP(v1) router
+#
+#      wccp2_router supports multiple WCCPv2 routers
+#
+#      only one of the two may be used at the same time and defines
+#      which version of WCCP to use.
+#
+#Default:
+# wccp_router 0.0.0.0
+
+#  TAG: wccp_version
+#      This directive is only relevant if you need to set up WCCP(v1)
+#      to some very old and end-of-life Cisco routers. In all other
+#      setups it must be left unset or at the default setting.
+#      It defines an internal version in the WCCP(v1) protocol,
+#      with version 4 being the officially documented protocol.
+#
+#      According to some users, Cisco IOS 11.2 and earlier only
+#      support WCCP version 3.  If you're using that or an earlier
+#      version of IOS, you may need to change this value to 3, otherwise
+#      do not specify this parameter.
+#
+#Default:
+# wccp_version 4
+
+#  TAG: wccp2_rebuild_wait
+#      If this is enabled Squid will wait for the cache dir rebuild to finish
+#      before sending the first wccp2 HereIAm packet
+#
+#Default:
+# wccp2_rebuild_wait on
+
+#  TAG: wccp2_forwarding_method
+#      WCCP2 allows the setting of forwarding methods between the
+#      router/switch and the cache.  Valid values are as follows:
+#
+#      1 - GRE encapsulation (forward the packet in a GRE/WCCP tunnel)
+#      2 - L2 redirect (forward the packet using Layer 2/MAC rewriting)
+#
+#      Currently (as of IOS 12.4) cisco routers only support GRE.
+#      Cisco switches only support the L2 redirect assignment method.
+#
+#Default:
+# wccp2_forwarding_method 1
+
+#  TAG: wccp2_return_method
+#      WCCP2 allows the setting of return methods between the
+#      router/switch and the cache for packets that the cache
+#      decides not to handle.  Valid values are as follows:
+#
+#      1 - GRE encapsulation (forward the packet in a GRE/WCCP tunnel)
+#      2 - L2 redirect (forward the packet using Layer 2/MAC rewriting)
+#
+#      Currently (as of IOS 12.4) cisco routers only support GRE.
+#      Cisco switches only support the L2 redirect assignment.
+#
+#      If the "ip wccp redirect exclude in" command has been
+#      enabled on the cache interface, then it is still safe for
+#      the proxy server to use a l2 redirect method even if this
+#      option is set to GRE.
+#
+#Default:
+# wccp2_return_method 1
+
+#  TAG: wccp2_assignment_method
+#      WCCP2 allows the setting of methods to assign the WCCP hash
+#      Valid values are as follows:
+#
+#      1 - Hash assignment
+#      2 - Mask assignment
+#
+#      As a general rule, cisco routers support the hash assignment method
+#      and cisco switches support the mask assignment method.
+#
+#Default:
+# wccp2_assignment_method 1
+
+#  TAG: wccp2_service
+#      WCCP2 allows for multiple traffic services. There are two
+#      types: "standard" and "dynamic". The standard type defines
+#      one service id - http (id 0). The dynamic service ids can be from
+#      51 to 255 inclusive.  In order to use a dynamic service id
+#      one must define the type of traffic to be redirected; this is done
+#      using the wccp2_service_info option.
+#
+#      The "standard" type does not require a wccp2_service_info option,
+#      just specifying the service id will suffice.
+#
+#      MD5 service authentication can be enabled by adding
+#      "password=<password>" to the end of this service declaration.
+#
+#      Examples:
+#
+#      wccp2_service standard 0        # for the 'web-cache' standard service
+#      wccp2_service dynamic 80        # a dynamic service type which will be
+#                                      # fleshed out with subsequent options.
+#      wccp2_service standard 0 password=foo
+#
+#
+#Default:
+# wccp2_service standard 0
+
+#  TAG: wccp2_service_info
+#      Dynamic WCCPv2 services require further information to define the
+#      traffic you wish to have diverted.
+#
+#      The format is:
+#
+#      wccp2_service_info <id> protocol=<protocol> flags=<flag>,<flag>..
+#          priority=<priority> ports=<port>,<port>..
+#
+#      The relevant WCCPv2 flags:
+#      + src_ip_hash, dst_ip_hash
+#      + source_port_hash, dst_port_hash
+#      + src_ip_alt_hash, dst_ip_alt_hash
+#      + src_port_alt_hash, dst_port_alt_hash
+#      + ports_source
+#
+#      The port list can be one to eight entries.
+#
+#      Example:
+#
+#      wccp2_service_info 80 protocol=tcp flags=src_ip_hash,ports_source
+#          priority=240 ports=80
+#
+#      Note: the service id must have been defined by a previous
+#      'wccp2_service dynamic <id>' entry.
+#
+#Default:
+# none
+
+#  TAG: wccp2_weight
+#      Each cache server gets assigned a set of the destination
+#      hash proportional to their weight.
+#
+#Default:
+# wccp2_weight 10000
+
+#  TAG: wccp_address
+#  TAG: wccp2_address
+#      Use this option if you require WCCP to use a specific
+#      interface address.
+#
+#      The default behavior is to not bind to any specific address.
+#
+#Default:
+# wccp_address 0.0.0.0
+# wccp2_address 0.0.0.0
+
+
+# PERSISTENT CONNECTION HANDLING
+# -----------------------------------------------------------------------------
+#
+# Also see "pconn_timeout" in the TIMEOUTS section
+
+#  TAG: client_persistent_connections
+#  TAG: server_persistent_connections
+#      Persistent connection support for clients and servers.  By
+#      default, Squid uses persistent connections (when allowed)
+#      with its clients and servers.  You can use these options to
+#      disable persistent connections with clients and/or servers.
+#
+#Default:
+# client_persistent_connections on
+# server_persistent_connections on
+
+#  TAG: persistent_connection_after_error
+#      With this directive the use of persistent connections after
+#      HTTP errors can be disabled. Useful if you have clients
+#      who fail to handle errors on persistent connections proper.
+#
+#Default:
+# persistent_connection_after_error off
+
+#  TAG: detect_broken_pconn
+#      Some servers have been found to incorrectly signal the use
+#      of HTTP/1.0 persistent connections even on replies not
+#      compatible, causing significant delays. This server problem
+#      has mostly been seen on redirects.
+#
+#      By enabling this directive Squid attempts to detect such
+#      broken replies and automatically assume the reply is finished
+#      after 10 seconds timeout.
+#
+#Default:
+# detect_broken_pconn off
+
+
+# CACHE DIGEST OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: digest_generation
+#      This controls whether the server will generate a Cache Digest
+#      of its contents.  By default, Cache Digest generation is
+#      enabled if Squid is compiled with --enable-cache-digests defined.
+#
+#Default:
+# digest_generation on
+
+#  TAG: digest_bits_per_entry
+#      This is the number of bits of the server's Cache Digest which
+#      will be associated with the Digest entry for a given HTTP
+#      Method and URL (public key) combination.  The default is 5.
+#
+#Default:
+# digest_bits_per_entry 5
+
+#  TAG: digest_rebuild_period  (seconds)
+#      This is the wait time between Cache Digest rebuilds.
+#
+#Default:
+# digest_rebuild_period 1 hour
+
+#  TAG: digest_rewrite_period  (seconds)
+#      This is the wait time between Cache Digest writes to
+#      disk.
+#
+#Default:
+# digest_rewrite_period 1 hour
+
+#  TAG: digest_swapout_chunk_size      (bytes)
+#      This is the number of bytes of the Cache Digest to write to
+#      disk at a time.  It defaults to 4096 bytes (4KB), the Squid
+#      default swap page.
+#
+#Default:
+# digest_swapout_chunk_size 4096 bytes
+
+#  TAG: digest_rebuild_chunk_percentage        (percent, 0-100)
+#      This is the percentage of the Cache Digest to be scanned at a
+#      time.  By default it is set to 10% of the Cache Digest.
+#
+#Default:
+# digest_rebuild_chunk_percentage 10
+
+
+# SNMP OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: snmp_port
+#      The port number where Squid listens for SNMP requests. To enable
+#      SNMP support set this to a suitable port number. Port number
+#      3401 is often used for the Squid SNMP agent. By default it's
+#      set to "0" (disabled)
+#Default:
+# snmp_port 0
+#
+#snmp_port 3401
+
+#  TAG: snmp_access
+#      Allowing or denying access to the SNMP port.
+#
+#      All access to the agent is denied by default.
+#      usage:
+#
+#      snmp_access allow|deny [!]aclname ...
+#
+#Example:
+# snmp_access allow snmppublic localhost
+# snmp_access deny all
+#
+#Default:
+# snmp_access deny all
+
+#  TAG: snmp_incoming_address
+#  TAG: snmp_outgoing_address
+#      Just like 'udp_incoming_address' above, but for the SNMP port.
+#
+#      snmp_incoming_address   is used for the SNMP socket receiving
+#                              messages from SNMP agents.
+#      snmp_outgoing_address   is used for SNMP packets returned to SNMP
+#                              agents.
+#
+#      The default snmp_incoming_address (0.0.0.0) is to listen on all
+#      available network interfaces.
+#
+#      If snmp_outgoing_address is set to 255.255.255.255 (the default)
+#      it will use the same socket as snmp_incoming_address. Only
+#      change this if you want to have SNMP replies sent using another
+#      address than where this Squid listens for SNMP queries.
+#
+#      NOTE, snmp_incoming_address and snmp_outgoing_address can not have
+#      the same value since they both use port 3401.
+#
+#Default:
+# snmp_incoming_address 0.0.0.0
+# snmp_outgoing_address 255.255.255.255
+
+
+# ICP OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: icp_port
+#      The port number where Squid sends and receives ICP queries to
+#      and from neighbor caches.  The standard UDP port for ICP is 3130.
+#      Default is disabled (0).
+#Default:
+# icp_port 0
+#
+icp_port 3130
+
+#  TAG: htcp_port
+#      The port number where Squid sends and receives HTCP queries to
+#      and from neighbor caches.  To turn it on you want to set it to
+#      4827. By default it is set to "0" (disabled).
+#Default:
+# htcp_port 0
+#
+#htcp_port 4827
+
+#  TAG: log_icp_queries        on|off
+#      If set, ICP queries are logged to access.log. You may wish
+#      do disable this if your ICP load is VERY high to speed things
+#      up or to simplify log analysis.
+#
+#Default:
+# log_icp_queries on
+
+#  TAG: udp_incoming_address
+#      udp_incoming_address    is used for UDP packets received from other
+#                              caches.
+#
+#      The default behavior is to not bind to any specific address.
+#
+#      Only change this if you want to have all UDP queries received on
+#      a specific interface/address.
+#
+#      NOTE: udp_incoming_address is used by the ICP, HTCP, and DNS
+#      modules. Altering it will affect all of them in the same manner.
+#
+#      see also; udp_outgoing_address
+#
+#      NOTE, udp_incoming_address and udp_outgoing_address can not
+#      have the same value since they both use the same port.
+#
+#Default:
+# udp_incoming_address 0.0.0.0
+
+#  TAG: udp_outgoing_address
+#      udp_outgoing_address    is used for UDP packets sent out to other
+#                              caches.
+#
+#      The default behavior is to not bind to any specific address.
+#
+#      Instead it will use the same socket as udp_incoming_address.
+#      Only change this if you want to have UDP queries sent using another
+#      address than where this Squid listens for UDP queries from other
+#      caches.
+#
+#      NOTE: udp_outgoing_address is used by the ICP, HTCP, and DNS
+#      modules. Altering it will affect all of them in the same manner.
+#
+#      see also; udp_incoming_address
+#
+#      NOTE, udp_incoming_address and udp_outgoing_address can not
+#      have the same value since they both use the same port.
+#
+#Default:
+# udp_outgoing_address 255.255.255.255
+
+#  TAG: icp_hit_stale  on|off
+#      If you want to return ICP_HIT for stale cache objects, set this
+#      option to 'on'.  If you have sibling relationships with caches
+#      in other administrative domains, this should be 'off'.  If you only
+#      have sibling relationships with caches under your control,
+#      it is probably okay to set this to 'on'.
+#      If set to 'on', your siblings should use the option "allow-miss"
+#      on their cache_peer lines for connecting to you.
+#
+#Default:
+# icp_hit_stale off
+
+#  TAG: minimum_direct_hops
+#      If using the ICMP pinging stuff, do direct fetches for sites
+#      which are no more than this many hops away.
+#
+#Default:
+# minimum_direct_hops 4
+
+#  TAG: minimum_direct_rtt
+#      If using the ICMP pinging stuff, do direct fetches for sites
+#      which are no more than this many rtt milliseconds away.
+#
+#Default:
+# minimum_direct_rtt 400
+
+#  TAG: netdb_low
+#  TAG: netdb_high
+#      The low and high water marks for the ICMP measurement
+#      database.  These are counts, not percents.  The defaults are
+#      900 and 1000.  When the high water mark is reached, database
+#      entries will be deleted until the low mark is reached.
+#
+#Default:
+# netdb_low 900
+# netdb_high 1000
+
+#  TAG: netdb_ping_period
+#      The minimum period for measuring a site.  There will be at
+#      least this much delay between successive pings to the same
+#      network.  The default is five minutes.
+#
+#Default:
+# netdb_ping_period 5 minutes
+
+#  TAG: query_icmp     on|off
+#      If you want to ask your peers to include ICMP data in their ICP
+#      replies, enable this option.
+#
+#      If your peer has configured Squid (during compilation) with
+#      '--enable-icmp' that peer will send ICMP pings to origin server
+#      sites of the URLs it receives.  If you enable this option the
+#      ICP replies from that peer will include the ICMP data (if available).
+#      Then, when choosing a parent cache, Squid will choose the parent with
+#      the minimal RTT to the origin server.  When this happens, the
+#      hierarchy field of the access.log will be
+#      "CLOSEST_PARENT_MISS".  This option is off by default.
+#
+#Default:
+# query_icmp off
+
+#  TAG: test_reachability      on|off
+#      When this is 'on', ICP MISS replies will be ICP_MISS_NOFETCH
+#      instead of ICP_MISS if the target host is NOT in the ICMP
+#      database, or has a zero RTT.
+#
+#Default:
+# test_reachability off
+
+#  TAG: icp_query_timeout      (msec)
+#      Normally Squid will automatically determine an optimal ICP
+#      query timeout value based on the round-trip-time of recent ICP
+#      queries.  If you want to override the value determined by
+#      Squid, set this 'icp_query_timeout' to a non-zero value.  This
+#      value is specified in MILLISECONDS, so, to use a 2-second
+#      timeout (the old default), you would write:
+#
+#              icp_query_timeout 2000
+#
+#Default:
+# icp_query_timeout 0
+
+#  TAG: maximum_icp_query_timeout      (msec)
+#      Normally the ICP query timeout is determined dynamically.  But
+#      sometimes it can lead to very large values (say 5 seconds).
+#      Use this option to put an upper limit on the dynamic timeout
+#      value.  Do NOT use this option to always use a fixed (instead
+#      of a dynamic) timeout value. To set a fixed timeout see the
+#      'icp_query_timeout' directive.
+#
+#Default:
+# maximum_icp_query_timeout 2000
+
+#  TAG: minimum_icp_query_timeout      (msec)
+#      Normally the ICP query timeout is determined dynamically.  But
+#      sometimes it can lead to very small timeouts, even lower than
+#      the normal latency variance on your link due to traffic.
+#      Use this option to put an lower limit on the dynamic timeout
+#      value.  Do NOT use this option to always use a fixed (instead
+#      of a dynamic) timeout value. To set a fixed timeout see the
+#      'icp_query_timeout' directive.
+#
+#Default:
+# minimum_icp_query_timeout 5
+
+#  TAG: background_ping_rate   time-units
+#      Controls how often the ICP pings are sent to siblings that
+#      have background-ping set.
+#
+#Default:
+# background_ping_rate 10 seconds
+
+
+# MULTICAST ICP OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: mcast_groups
+#      This tag specifies a list of multicast groups which your server
+#      should join to receive multicasted ICP queries.
+#
+#      NOTE!  Be very careful what you put here!  Be sure you
+#      understand the difference between an ICP _query_ and an ICP
+#      _reply_.  This option is to be set only if you want to RECEIVE
+#      multicast queries.  Do NOT set this option to SEND multicast
+#      ICP (use cache_peer for that).  ICP replies are always sent via
+#      unicast, so this option does not affect whether or not you will
+#      receive replies from multicast group members.
+#
+#      You must be very careful to NOT use a multicast address which
+#      is already in use by another group of caches.
+#
+#      If you are unsure about multicast, please read the Multicast
+#      chapter in the Squid FAQ (http://www.squid-cache.org/FAQ/).
+#
+#      Usage: mcast_groups 239.128.16.128 224.0.1.20
+#
+#      By default, Squid doesn't listen on any multicast groups.
+#
+#Default:
+# none
+
+#  TAG: mcast_miss_addr
+# Note: This option is only available if Squid is rebuilt with the
+#       -DMULTICAST_MISS_STREAM define
+#
+#      If you enable this option, every "cache miss" URL will
+#      be sent out on the specified multicast address.
+#
+#      Do not enable this option unless you are are absolutely
+#      certain you understand what you are doing.
+#
+#Default:
+# mcast_miss_addr 255.255.255.255
+
+#  TAG: mcast_miss_ttl
+# Note: This option is only available if Squid is rebuilt with the
+#       -DMULTICAST_MISS_STREAM define
+#
+#      This is the time-to-live value for packets multicasted
+#      when multicasting off cache miss URLs is enabled.  By
+#      default this is set to 'site scope', i.e. 16.
+#
+#Default:
+# mcast_miss_ttl 16
+
+#  TAG: mcast_miss_port
+# Note: This option is only available if Squid is rebuilt with the
+#       -DMULTICAST_MISS_STREAM define
+#
+#      This is the port number to be used in conjunction with
+#      'mcast_miss_addr'.
+#
+#Default:
+# mcast_miss_port 3135
+
+#  TAG: mcast_miss_encode_key
+# Note: This option is only available if Squid is rebuilt with the
+#       -DMULTICAST_MISS_STREAM define
+#
+#      The URLs that are sent in the multicast miss stream are
+#      encrypted.  This is the encryption key.
+#
+#Default:
+# mcast_miss_encode_key XXXXXXXXXXXXXXXX
+
+#  TAG: mcast_icp_query_timeout        (msec)
+#      For multicast peers, Squid regularly sends out ICP "probes" to
+#      count how many other peers are listening on the given multicast
+#      address.  This value specifies how long Squid should wait to
+#      count all the replies.  The default is 2000 msec, or 2
+#      seconds.
+#
+#Default:
+# mcast_icp_query_timeout 2000
+
+
+# INTERNAL ICON OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: icon_directory
+#      Where the icons are stored. These are normally kept in
+#      /usr/share/squid/icons
+#
+#Default:
+# icon_directory /usr/share/squid/icons
+
+#  TAG: global_internal_static
+#      This directive controls is Squid should intercept all requests for
+#      /squid-internal-static/ no matter which host the URL is requesting
+#      (default on setting), or if nothing special should be done for
+#      such URLs (off setting). The purpose of this directive is to make
+#      icons etc work better in complex cache hierarchies where it may
+#      not always be possible for all corners in the cache mesh to reach
+#      the server generating a directory listing.
+#
+#Default:
+# global_internal_static on
+
+#  TAG: short_icon_urls
+#      If this is enabled Squid will use short URLs for icons.
+#      If disabled it will revert to the old behavior of including
+#      it's own name and port in the URL.
+#
+#      If you run a complex cache hierarchy with a mix of Squid and
+#      other proxies you may need to disable this directive.
+#
+#Default:
+# short_icon_urls on
+
+
+# ERROR PAGE OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: error_directory
+#      Directory where the error files are read from.
+#      /usr/lib/squid/errors contains sets of error files
+#      in different languages. The default error directory
+#      is /etc/squid/errors, which is a link to one of these
+#      error sets.
+# 
+#      If you wish to create your own versions of the error files,
+#      either to customize them to suit your language or company,
+#      copy the template English files to another directory and
+#      point this tag at them.
+#
+#      Current Language updates can be downloaded from:
+#              http://www.squid-cache.org/Versions/langpack/
+#
+#      The squid developers are interested in making squid available in
+#      a wide variety of languages. If you are making translations for a
+#      langauge that Squid does not currently provide please consider
+#      contributing your translation back to the project.
+#      see http://wiki.squid-cache.org/Translations
+#
+#Default:
+# error_directory /usr/share/squid/errors/templates
+
+#  TAG: err_html_text
+#      HTML text to include in error messages.  Make this a "mailto"
+#      URL to your admin address, or maybe just a link to your
+#      organizations Web page.
+#
+#      To include this in your error messages, you must rewrite
+#      the error template files (found in the "errors" directory).
+#      Wherever you want the 'err_html_text' line to appear,
+#      insert a %L tag in the error template file.
+#
+#Default:
+# none
+
+#  TAG: email_err_data on|off
+#      If enabled, information about the occurred error will be
+#      included in the mailto links of the ERR pages (if %W is set)
+#      so that the email body contains the data.
+#      Syntax is <A HREF="mailto:%w%W">%w</A>
+#
+#Default:
+# email_err_data on
+
+#  TAG: deny_info
+#      Usage:   deny_info err_page_name acl
+#      or       deny_info http://... acl
+#      Example: deny_info ERR_CUSTOM_ACCESS_DENIED bad_guys
+#
+#      This can be used to return a ERR_ page for requests which
+#      do not pass the 'http_access' rules.  Squid remembers the last
+#      acl it evaluated in http_access, and if a 'deny_info' line exists
+#      for that ACL Squid returns a corresponding error page.
+#
+#      The acl is typically the last acl on the http_access deny line which
+#      denied access. The exceptions to this rule are:
+#      - When Squid needs to request authentication credentials. It's then
+#        the first authentication related acl encountered
+#      - When none of the http_access lines matches. It's then the last
+#        acl processed on the last http_access line.
+#
+#      You may use ERR_ pages that come with Squid or create your own pages
+#      and put them into the configured errors/ directory.
+#
+#      Alternatively you can specify an error URL. The browsers will
+#      get redirected (302) to the specified URL. %s in the redirection
+#      URL will be replaced by the requested URL.
+#
+#      Alternatively you can tell Squid to reset the TCP connection
+#      by specifying TCP_RESET.
+#
+#Default:
+# none
+
+
+# OPTIONS INFLUENCING REQUEST FORWARDING 
+# -----------------------------------------------------------------------------
+
+#  TAG: nonhierarchical_direct
+#      By default, Squid will send any non-hierarchical requests
+#      (matching hierarchy_stoplist or not cacheable request type) direct
+#      to origin servers.
+#
+#      If you set this to off, Squid will prefer to send these
+#      requests to parents.
+#
+#      Note that in most configurations, by turning this off you will only
+#      add latency to these request without any improvement in global hit
+#      ratio.
+#
+#      If you are inside an firewall see never_direct instead of
+#      this directive.
+#
+#Default:
+# nonhierarchical_direct on
+
+#  TAG: prefer_direct
+#      Normally Squid tries to use parents for most requests. If you for some
+#      reason like it to first try going direct and only use a parent if
+#      going direct fails set this to on.
+#
+#      By combining nonhierarchical_direct off and prefer_direct on you
+#      can set up Squid to use a parent as a backup path if going direct
+#      fails.
+#
+#      Note: If you want Squid to use parents for all requests see
+#      the never_direct directive. prefer_direct only modifies how Squid
+#      acts on cacheable requests.
+#
+#Default:
+# prefer_direct off
+
+#  TAG: always_direct
+#      Usage: always_direct allow|deny [!]aclname ...
+#
+#      Here you can use ACL elements to specify requests which should
+#      ALWAYS be forwarded by Squid to the origin servers without using
+#      any peers.  For example, to always directly forward requests for
+#      local servers ignoring any parents or siblings you may have use
+#      something like:
+#
+#              acl local-servers dstdomain my.domain.net
+#              always_direct allow local-servers
+#
+#      To always forward FTP requests directly, use
+#
+#              acl FTP proto FTP
+#              always_direct allow FTP
+#
+#      NOTE: There is a similar, but opposite option named
+#      'never_direct'.  You need to be aware that "always_direct deny
+#      foo" is NOT the same thing as "never_direct allow foo".  You
+#      may need to use a deny rule to exclude a more-specific case of
+#      some other rule.  Example:
+#
+#              acl local-external dstdomain external.foo.net
+#              acl local-servers dstdomain  .foo.net
+#              always_direct deny local-external
+#              always_direct allow local-servers
+#
+#      NOTE: If your goal is to make the client forward the request
+#      directly to the origin server bypassing Squid then this needs
+#      to be done in the client configuration. Squid configuration
+#      can only tell Squid how Squid should fetch the object.
+#
+#      NOTE: This directive is not related to caching. The replies
+#      is cached as usual even if you use always_direct. To not cache
+#      the replies see no_cache.
+#
+#      This option replaces some v1.1 options such as local_domain
+#      and local_ip.
+#
+#Default:
+# none
+
+#  TAG: never_direct
+#      Usage: never_direct allow|deny [!]aclname ...
+#
+#      never_direct is the opposite of always_direct.  Please read
+#      the description for always_direct if you have not already.
+#
+#      With 'never_direct' you can use ACL elements to specify
+#      requests which should NEVER be forwarded directly to origin
+#      servers.  For example, to force the use of a proxy for all
+#      requests, except those in your local domain use something like:
+#
+#              acl local-servers dstdomain .foo.net
+#              never_direct deny local-servers
+#              never_direct allow all
+#
+#      or if Squid is inside a firewall and there are local intranet
+#      servers inside the firewall use something like:
+#
+#              acl local-intranet dstdomain .foo.net
+#              acl local-external dstdomain external.foo.net
+#              always_direct deny local-external
+#              always_direct allow local-intranet
+#              never_direct allow all
+#
+#      This option replaces some v1.1 options such as inside_firewall
+#      and firewall_ip.
+#
+#Default:
+# none
+
+
+# ADVANCED NETWORKING OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: incoming_icp_average
+#  TAG: incoming_http_average
+#  TAG: incoming_dns_average
+#  TAG: min_icp_poll_cnt
+#  TAG: min_dns_poll_cnt
+#  TAG: min_http_poll_cnt
+#      Heavy voodoo here.  I can't even believe you are reading this.
+#      Are you crazy?  Don't even think about adjusting these unless
+#      you understand the algorithms in comm_select.c first!
+#
+#Default:
+# incoming_icp_average 6
+# incoming_http_average 4
+# incoming_dns_average 4
+# min_icp_poll_cnt 8
+# min_dns_poll_cnt 8
+# min_http_poll_cnt 8
+
+#  TAG: accept_filter
+#      FreeBSD:
+#
+#      The name of an accept(2) filter to install on Squid's
+#      listen socket(s).  This feature is perhaps specific to
+#      FreeBSD and requires support in the kernel.
+#
+#      The 'httpready' filter delays delivering new connections
+#      to Squid until a full HTTP request has been received.
+#      See the accf_http(9) man page for details.
+#
+#      The 'dataready' filter delays delivering new connections
+#      to Squid until there is some data to process.
+#      See the accf_dataready(9) man page for details.
+#
+#      Linux:
+#      
+#      The 'data' filter delays delivering of new connections
+#      to Squid until there is some data to process by TCP_ACCEPT_DEFER.
+#      You may optionally specify a number of seconds to wait by
+#      'data=N' where N is the number of seconds. Defaults to 30
+#      if not specified.  See the tcp(7) man page for details.
+#EXAMPLE:
+## FreeBSD
+#accept_filter httpready
+## Linux
+#accept_filter data
+#
+#Default:
+# none
+
+#  TAG: tcp_recv_bufsize       (bytes)
+#      Size of receive buffer to set for TCP sockets.  Probably just
+#      as easy to change your kernel's default.  Set to zero to use
+#      the default buffer size.
+#
+#Default:
+# tcp_recv_bufsize 0 bytes
+
+
+# ICAP OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: icap_enable    on|off
+#      If you want to enable the ICAP module support, set this to on.
+#
+#Default:
+# icap_enable off
+
+#  TAG: icap_connect_timeout
+#      This parameter specifies how long to wait for the TCP connect to
+#      the requested ICAP server to complete before giving up and either
+#      terminating the HTTP transaction or bypassing the failure.
+#
+#      The default for optional services is peer_connect_timeout.
+#      The default for essential services is connect_timeout.
+#      If this option is explicitly set, its value applies to all services.
+#
+#Default:
+# none
+
+#  TAG: icap_io_timeout        time-units
+#      This parameter specifies how long to wait for an I/O activity on
+#      an established, active ICAP connection before giving up and
+#      either terminating the HTTP transaction or bypassing the
+#      failure.
+#
+#      The default is read_timeout.
+#
+#Default:
+# none
+
+#  TAG: icap_service_failure_limit
+#      The limit specifies the number of failures that Squid tolerates
+#      when establishing a new TCP connection with an ICAP service. If
+#      the number of failures exceeds the limit, the ICAP service is
+#      not used for new ICAP requests until it is time to refresh its
+#      OPTIONS. The per-service failure counter is reset to zero each
+#      time Squid fetches new service OPTIONS.
+#
+#      A negative value disables the limit. Without the limit, an ICAP
+#      service will not be considered down due to connectivity failures
+#      between ICAP OPTIONS requests.
+#
+#Default:
+# icap_service_failure_limit 10
+
+#  TAG: icap_service_revival_delay
+#      The delay specifies the number of seconds to wait after an ICAP
+#      OPTIONS request failure before requesting the options again. The
+#      failed ICAP service is considered "down" until fresh OPTIONS are
+#      fetched.
+#
+#      The actual delay cannot be smaller than the hardcoded minimum
+#      delay of 30 seconds.
+#
+#Default:
+# icap_service_revival_delay 180
+
+#  TAG: icap_preview_enable    on|off
+#      The ICAP Preview feature allows the ICAP server to handle the
+#      HTTP message by looking only at the beginning of the message body
+#      or even without receiving the body at all. In some environments, 
+#      previews greatly speedup ICAP processing.
+#
+#      During an ICAP OPTIONS transaction, the server may tell Squid what
+#      HTTP messages should be previewed and how big the preview should be.
+#      Squid will not use Preview if the server did not request one.
+#
+#      To disable ICAP Preview for all ICAP services, regardless of
+#      individual ICAP server OPTIONS responses, set this option to "off".
+#Example:
+#icap_preview_enable off
+#
+#Default:
+# icap_preview_enable on
+
+#  TAG: icap_preview_size
+#      The default size of preview data to be sent to the ICAP server.
+#      -1 means no preview. This value might be overwritten on a per server
+#      basis by OPTIONS requests.
+#
+#Default:
+# icap_preview_size -1
+
+#  TAG: icap_default_options_ttl
+#      The default TTL value for ICAP OPTIONS responses that don't have
+#      an Options-TTL header.
+#
+#Default:
+# icap_default_options_ttl 60
+
+#  TAG: icap_persistent_connections    on|off
+#      Whether or not Squid should use persistent connections to
+#      an ICAP server.
+#
+#Default:
+# icap_persistent_connections on
+
+#  TAG: icap_send_client_ip    on|off
+#      This adds the header "X-Client-IP" to ICAP requests.
+#
+#Default:
+# icap_send_client_ip off
+
+#  TAG: icap_send_client_username      on|off
+#      This sends authenticated HTTP client username (if available) to
+#      the ICAP service. The username value is encoded based on the
+#      icap_client_username_encode option and is sent using the header
+#      specified by the icap_client_username_header option.
+#
+#Default:
+# icap_send_client_username off
+
+#  TAG: icap_client_username_header
+#      ICAP request header name to use for send_client_username.
+#
+#Default:
+# icap_client_username_header X-Client-Username
+
+#  TAG: icap_client_username_encode    on|off
+#      Whether to base64 encode the authenticated client username.
+#
+#Default:
+# icap_client_username_encode off
+
+#  TAG: icap_service
+#      Defines a single ICAP service
+#
+#      icap_service servicename vectoring_point bypass service_url
+#
+#      vectoring_point = reqmod_precache|reqmod_postcache|respmod_precache|respmod_postcache
+#              This specifies at which point of transaction processing the
+#              ICAP service should be activated. *_postcache vectoring points
+#              are not yet supported.
+#      bypass = 1|0
+#              If set to 1, the ICAP service is treated as optional. If the
+#              service cannot be reached or malfunctions, Squid will try to
+#              ignore any errors and process the message as if the service
+#              was not enabled. No all ICAP errors can be bypassed.
+#              If set to 0, the ICAP service is treated as essential and all
+#              ICAP errors will result in an error page returned to the
+#              HTTP client.
+#      service_url = icap://servername:port/service
+#
+#Example:
+#icap_service service_1 reqmod_precache 0 icap://icap1.mydomain.net:1344/reqmod
+#icap_service service_2 respmod_precache 0 icap://icap2.mydomain.net:1344/respmod
+#
+#Default:
+# none
+
+#  TAG: icap_class
+#      Defines an ICAP service chain. Eventually, multiple services per
+#      vectoring point will be supported. For now, please specify a single
+#      service per class:
+#
+#      icap_class classname servicename
+#
+#Example:
+#icap_class class_1 service_1
+#icap class class_2 service_1
+#icap class class_3 service_3
+#
+#Default:
+# none
+
+#  TAG: icap_access
+#      Redirects a request through an ICAP service class, depending
+#      on given acls
+#
+#      icap_access classname allow|deny [!]aclname...
+#
+#      The icap_access statements are processed in the order they appear in
+#      this configuration file. If an access list matches, the processing stops.
+#      For an "allow" rule, the specified class is used for the request. A "deny"
+#      rule simply stops processing without using the class. You can also use the
+#      special classname "None".
+#
+#      For backward compatibility, it is also possible to use services
+#      directly here.
+#Example:
+#icap_access class_1 allow all
+#
+#Default:
+# none
+
+
+# DNS OPTIONS
+# -----------------------------------------------------------------------------
+
+#  TAG: check_hostnames
+#      For security and stability reasons Squid can check
+#      hostnames for Internet standard RFC compliance. If you want
+#      Squid to perform these checks turn this directive on.
+#
+#Default:
+# check_hostnames off
+
+#  TAG: allow_underscore
+#      Underscore characters is not strictly allowed in Internet hostnames
+#      but nevertheless used by many sites. Set this to off if you want
+#      Squid to be strict about the standard.
+#      This check is performed only when check_hostnames is set to on.
+#
+#Default:
+# allow_underscore on
+
+#  TAG: cache_dns_program
+# Note: This option is only available if Squid is rebuilt with the
+#       --disable-internal-dns option
+#
+#      Specify the location of the executable for dnslookup process.
+#
+#Default:
+# cache_dns_program /usr/lib64/squid/dnsserver
+
+#  TAG: dns_children
+# Note: This option is only available if Squid is rebuilt with the
+#       --disable-internal-dns option
+#
+#      The number of processes spawn to service DNS name lookups.
+#      For heavily loaded caches on large servers, you should
+#      probably increase this value to at least 10.  The maximum
+#      is 32.  The default is 5.
+#
+#      You must have at least one dnsserver process.
+#
+#Default:
+# dns_children 5
+
+#  TAG: dns_retransmit_interval
+#      Initial retransmit interval for DNS queries. The interval is
+#      doubled each time all configured DNS servers have been tried.
+#
+#
+#Default:
+# dns_retransmit_interval 5 seconds
+
+#  TAG: dns_timeout
+#      DNS Query timeout. If no response is received to a DNS query
+#      within this time all DNS servers for the queried domain
+#      are assumed to be unavailable.
+#
+#Default:
+# dns_timeout 2 minutes
+
+#  TAG: dns_defnames   on|off
+#      Normally the RES_DEFNAMES resolver option is disabled
+#      (see res_init(3)).  This prevents caches in a hierarchy
+#      from interpreting single-component hostnames locally.  To allow
+#      Squid to handle single-component names, enable this option.
+#
+#Default:
+# dns_defnames off
+
+#  TAG: dns_nameservers
+#      Use this if you want to specify a list of DNS name servers
+#      (IP addresses) to use instead of those given in your
+#      /etc/resolv.conf file.
+#      On Windows platforms, if no value is specified here or in
+#      the /etc/resolv.conf file, the list of DNS name servers are
+#      taken from the Windows registry, both static and dynamic DHCP
+#      configurations are supported.
+#
+#      Example: dns_nameservers 10.0.0.1 192.172.0.4
+#
+#Default:
+# none
+
+#  TAG: hosts_file
+#      Location of the host-local IP name-address associations
+#      database. Most Operating Systems have such a file on different
+#      default locations:
+#      - Un*X & Linux:    /etc/hosts
+#      - Windows NT/2000: %SystemRoot%\system32\drivers\etc\hosts
+#                         (%SystemRoot% value install default is c:\winnt)
+#      - Windows XP/2003: %SystemRoot%\system32\drivers\etc\hosts
+#                         (%SystemRoot% value install default is c:\windows)
+#      - Windows 9x/Me:   %windir%\hosts
+#                         (%windir% value is usually c:\windows)
+#      - Cygwin:          /etc/hosts
+#
+#      The file contains newline-separated definitions, in the
+#      form ip_address_in_dotted_form name [name ...] names are
+#      whitespace-separated. Lines beginning with an hash (#)
+#      character are comments.
+#
+#      The file is checked at startup and upon configuration.
+#      If set to 'none', it won't be checked.
+#      If append_domain is used, that domain will be added to
+#      domain-local (i.e. not containing any dot character) host
+#      definitions.
+#
+#Default:
+# hosts_file /etc/hosts
+
+#  TAG: dns_testnames
+#      The DNS tests exit as soon as the first site is successfully looked up
+#
+#      This test can be disabled with the -D command line option.
+#
+#Default:
+# dns_testnames netscape.com internic.net nlanr.net microsoft.com
+
+#  TAG: append_domain
+#      Appends local domain name to hostnames without any dots in
+#      them.  append_domain must begin with a period.
+#
+#      Be warned there are now Internet names with no dots in
+#      them using only top-domain names, so setting this may
+#      cause some Internet sites to become unavailable.
+#
+#Example:
+# append_domain .yourdomain.com
+#
+#Default:
+# none
+
+#  TAG: ignore_unknown_nameservers
+#      By default Squid checks that DNS responses are received
+#      from the same IP addresses they are sent to.  If they
+#      don't match, Squid ignores the response and writes a warning
+#      message to cache.log.  You can allow responses from unknown
+#      nameservers by setting this option to 'off'.
+#
+#Default:
+# ignore_unknown_nameservers on
+
+#  TAG: ipcache_size   (number of entries)
+#  TAG: ipcache_low    (percent)
+#  TAG: ipcache_high   (percent)
+#      The size, low-, and high-water marks for the IP cache.
+#
+#Default:
+# ipcache_size 1024
+# ipcache_low 90
+# ipcache_high 95
+
+#  TAG: fqdncache_size (number of entries)
+#      Maximum number of FQDN cache entries.
+#
+#Default:
+# fqdncache_size 1024
+
+
+# MISCELLANEOUS
+# -----------------------------------------------------------------------------
+
+#  TAG: memory_pools   on|off
+#      If set, Squid will keep pools of allocated (but unused) memory
+#      available for future use.  If memory is a premium on your
+#      system and you believe your malloc library outperforms Squid
+#      routines, disable this.
+#
+#Default:
+# memory_pools on
+
+#  TAG: memory_pools_limit     (bytes)
+#      Used only with memory_pools on:
+#      memory_pools_limit 50 MB
+#
+#      If set to a non-zero value, Squid will keep at most the specified
+#      limit of allocated (but unused) memory in memory pools. All free()
+#      requests that exceed this limit will be handled by your malloc
+#      library. Squid does not pre-allocate any memory, just safe-keeps
+#      objects that otherwise would be free()d. Thus, it is safe to set
+#      memory_pools_limit to a reasonably high value even if your
+#      configuration will use less memory.
+#
+#      If set to zero, Squid will keep all memory it can. That is, there
+#      will be no limit on the total amount of memory used for safe-keeping.
+#
+#      To disable memory allocation optimization, do not set
+#      memory_pools_limit to 0. Set memory_pools to "off" instead.
+#
+#      An overhead for maintaining memory pools is not taken into account
+#      when the limit is checked. This overhead is close to four bytes per
+#      object kept. However, pools may actually _save_ memory because of
+#      reduced memory thrashing in your malloc library.
+#
+#Default:
+# memory_pools_limit 5 MB
+
+#  TAG: forwarded_for  on|off
+#      If set, Squid will include your system's IP address or name
+#      in the HTTP requests it forwards.  By default it looks like
+#      this:
+#
+#              X-Forwarded-For: 192.1.2.3
+#
+#      If you disable this, it will appear as
+#
+#              X-Forwarded-For: unknown
+#
+#Default:
+# forwarded_for on
+
+#  TAG: cachemgr_passwd
+#      Specify passwords for cachemgr operations.
+#
+#      Usage: cachemgr_passwd password action action ...
+#
+#      Some valid actions are (see cache manager menu for a full list):
+#              5min
+#              60min
+#              asndb
+#              authenticator
+#              cbdata
+#              client_list
+#              comm_incoming
+#              config *
+#              counters
+#              delay
+#              digest_stats
+#              dns
+#              events
+#              filedescriptors
+#              fqdncache
+#              histograms
+#              http_headers
+#              info
+#              io
+#              ipcache
+#              mem
+#              menu
+#              netdb
+#              non_peers
+#              objects
+#              offline_toggle *
+#              pconn
+#              peer_select
+#              reconfigure *
+#              redirector
+#              refresh
+#              server_list
+#              shutdown *
+#              store_digest
+#              storedir
+#              utilization
+#              via_headers
+#              vm_objects
+#
+#      * Indicates actions which will not be performed without a
+#        valid password, others can be performed if not listed here.
+#
+#      To disable an action, set the password to "disable".
+#      To allow performing an action without a password, set the
+#      password to "none".
+#
+#      Use the keyword "all" to set the same password for all actions.
+#
+#Example:
+# cachemgr_passwd secret shutdown
+# cachemgr_passwd lesssssssecret info stats/objects
+# cachemgr_passwd disable all
+#
+#Default:
+# none
+
+#  TAG: client_db      on|off
+#      If you want to disable collecting per-client statistics,
+#      turn off client_db here.
+#
+#Default:
+# client_db on
+
+#  TAG: refresh_all_ims        on|off
+#      When you enable this option, squid will always check
+#      the origin server for an update when a client sends an
+#      If-Modified-Since request.  Many browsers use IMS
+#      requests when the user requests a reload, and this
+#      ensures those clients receive the latest version.
+#
+#      By default (off), squid may return a Not Modified response
+#      based on the age of the cached version.
+#
+#Default:
+# refresh_all_ims off
+
+#  TAG: reload_into_ims        on|off
+#      When you enable this option, client no-cache or ``reload''
+#      requests will be changed to If-Modified-Since requests.
+#      Doing this VIOLATES the HTTP standard.  Enabling this
+#      feature could make you liable for problems which it
+#      causes.
+#
+#      see also refresh_pattern for a more selective approach.
+#
+#Default:
+# reload_into_ims off
+
+#  TAG: maximum_single_addr_tries
+#      This sets the maximum number of connection attempts for a
+#      host that only has one address (for multiple-address hosts,
+#      each address is tried once).
+#
+#      The default value is one attempt, the (not recommended)
+#      maximum is 255 tries.  A warning message will be generated
+#      if it is set to a value greater than ten.
+#
+#      Note: This is in addition to the request re-forwarding which
+#      takes place if Squid fails to get a satisfying response.
+#
+#Default:
+# maximum_single_addr_tries 1
+
+#  TAG: retry_on_error
+#      If set to on Squid will automatically retry requests when
+#      receiving an error response. This is mainly useful if you
+#      are in a complex cache hierarchy to work around access
+#      control errors.
+#
+#Default:
+# retry_on_error off
+
+#  TAG: as_whois_server
+#      WHOIS server to query for AS numbers.  NOTE: AS numbers are
+#      queried only when Squid starts up, not for every request.
+#
+#Default:
+# as_whois_server whois.ra.net
+# as_whois_server whois.ra.net
+
+#  TAG: offline_mode
+#      Enable this option and Squid will never try to validate cached
+#      objects.
+#
+#Default:
+# offline_mode off
+
+#  TAG: uri_whitespace
+#      What to do with requests that have whitespace characters in the
+#      URI.  Options:
+#
+#      strip:  The whitespace characters are stripped out of the URL.
+#              This is the behavior recommended by RFC2396.
+#      deny:   The request is denied.  The user receives an "Invalid
+#              Request" message.
+#      allow:  The request is allowed and the URI is not changed.  The
+#              whitespace characters remain in the URI.  Note the
+#              whitespace is passed to redirector processes if they
+#              are in use.
+#      encode: The request is allowed and the whitespace characters are
+#              encoded according to RFC1738.  This could be considered
+#              a violation of the HTTP/1.1
+#              RFC because proxies are not allowed to rewrite URI's.
+#      chop:   The request is allowed and the URI is chopped at the
+#              first whitespace.  This might also be considered a
+#              violation.
+#
+#Default:
+# uri_whitespace strip
+
+#  TAG: coredump_dir
+#      By default Squid leaves core files in the directory from where
+#      it was started. If you set 'coredump_dir' to a directory
+#      that exists, Squid will chdir() to that directory at startup
+#      and coredump files will be left there.
+#
+#Default:
+# coredump_dir none
+#
+# Leave coredumps in the first cache dir
+coredump_dir /var/spool/squid
+
+#  TAG: chroot
+#      Use this to have Squid do a chroot() while initializing.  This
+#      also causes Squid to fully drop root privileges after
+#      initializing.  This means, for example, if you use a HTTP
+#      port less than 1024 and try to reconfigure, you will may get an
+#      error saying that Squid can not open the port.
+#
+#Default:
+# none
+
+#  TAG: balance_on_multiple_ip
+#      Some load balancing servers based on round robin DNS have been
+#      found not to preserve user session state across requests
+#      to different IP addresses.
+#
+#      By default Squid rotates IP's per request. By disabling
+#      this directive only connection failure triggers rotation.
+#
+#Default:
+# balance_on_multiple_ip on
+
+#  TAG: pipeline_prefetch
+#      To boost the performance of pipelined requests to closer
+#      match that of a non-proxied environment Squid can try to fetch
+#      up to two requests in parallel from a pipeline.
+#
+#      Defaults to off for bandwidth management and access logging
+#      reasons.
+#
+#Default:
+# pipeline_prefetch off
+
+#  TAG: high_response_time_warning     (msec)
+#      If the one-minute median response time exceeds this value,
+#      Squid prints a WARNING with debug level 0 to get the
+#      administrators attention.  The value is in milliseconds.
+#
+#Default:
+# high_response_time_warning 0
+
+#  TAG: high_page_fault_warning
+#      If the one-minute average page fault rate exceeds this
+#      value, Squid prints a WARNING with debug level 0 to get
+#      the administrators attention.  The value is in page faults
+#      per second.
+#
+#Default:
+# high_page_fault_warning 0
+
+#  TAG: high_memory_warning
+#      If the memory usage (as determined by mallinfo) exceeds
+#      this amount, Squid prints a WARNING with debug level 0 to get
+#      the administrators attention.
+#
+#Default:
+# high_memory_warning 0 KB
+
+#  TAG: sleep_after_fork       (microseconds)
+#      When this is set to a non-zero value, the main Squid process
+#      sleeps the specified number of microseconds after a fork()
+#      system call. This sleep may help the situation where your
+#      system reports fork() failures due to lack of (virtual)
+#      memory. Note, however, if you have a lot of child
+#      processes, these sleep delays will add up and your
+#      Squid will not service requests for some amount of time
+#      until all the child processes have been started.
+#      On Windows value less then 1000 (1 milliseconds) are
+#      rounded to 1000.
+#
+#Default:
+# sleep_after_fork 0
+
+#  TAG: windows_ipaddrchangemonitor    on|off
+#      On Windows Squid by default will monitor IP address changes and will 
+#      reconfigure itself after any detected event. This is very useful for
+#      proxies connected to internet with dial-up interfaces.
+#      In some cases (a Proxy server acting as VPN gateway is one) it could be
+#      desiderable to disable this behaviour setting this to 'off'.
+#      Note: after changing this, Squid service must be restarted.
+#
+#Default:
+# windows_ipaddrchangemonitor on
+
diff --git a/tests/root/etc/ssh/sshd_config b/tests/root/etc/ssh/sshd_config
new file mode 100644 (file)
index 0000000..b5e8160
--- /dev/null
@@ -0,0 +1,131 @@
+#      $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $
+
+# This is the sshd server system-wide configuration file.  See
+# sshd_config(5) for more information.
+
+# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
+
+# The strategy used for options in the default sshd_config shipped with
+# OpenSSH is to specify options with their default value where
+# possible, but leave them commented.  Uncommented options change a
+# default value.
+
+#Port 22
+#AddressFamily any
+#ListenAddress 0.0.0.0
+#ListenAddress ::
+
+# Disable legacy (protocol version 1) support in the server for new
+# installations. In future the default will change to require explicit
+# activation of protocol 1
+Protocol 2
+
+# HostKey for protocol version 1
+#HostKey /etc/ssh/ssh_host_key
+# HostKeys for protocol version 2
+#HostKey /etc/ssh/ssh_host_rsa_key
+#HostKey /etc/ssh/ssh_host_dsa_key
+
+# Lifetime and size of ephemeral version 1 server key
+#KeyRegenerationInterval 1h
+#ServerKeyBits 768
+
+# Logging
+# obsoletes QuietMode and FascistLogging
+#SyslogFacility AUTH
+SyslogFacility AUTHPRIV
+#LogLevel INFO
+
+# Authentication:
+
+#LoginGraceTime 2m
+#PermitRootLogin yes
+#StrictModes yes
+#MaxAuthTries 6
+
+#RSAAuthentication yes
+#PubkeyAuthentication yes
+#AuthorizedKeysFile    .ssh/authorized_keys
+
+# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
+#RhostsRSAAuthentication no
+# similar for protocol version 2
+#HostbasedAuthentication no
+# Change to yes if you don't trust ~/.ssh/known_hosts for
+# RhostsRSAAuthentication and HostbasedAuthentication
+#IgnoreUserKnownHosts no
+# Don't read the user's ~/.rhosts and ~/.shosts files
+#IgnoreRhosts yes
+
+# To disable tunneled clear text passwords, change to no here!
+#PasswordAuthentication yes
+#PermitEmptyPasswords no
+PasswordAuthentication yes
+
+# Change to no to disable s/key passwords
+#ChallengeResponseAuthentication yes
+ChallengeResponseAuthentication no
+
+# Kerberos options
+#KerberosAuthentication no
+#KerberosOrLocalPasswd yes
+#KerberosTicketCleanup yes
+#KerberosGetAFSToken no
+
+# GSSAPI options
+#GSSAPIAuthentication no
+GSSAPIAuthentication yes
+#GSSAPICleanupCredentials yes
+GSSAPICleanupCredentials yes
+
+# Set this to 'yes' to enable PAM authentication, account processing,
+# and session processing. If this is enabled, PAM authentication will
+# be allowed through the ChallengeResponseAuthentication and
+# PasswordAuthentication.  Depending on your PAM configuration,
+# PAM authentication via ChallengeResponseAuthentication may bypass
+# the setting of "PermitRootLogin without-password".
+# If you just want the PAM account and session checks to run without
+# PAM authentication, then enable this but set PasswordAuthentication
+# and ChallengeResponseAuthentication to 'no'.
+#UsePAM no
+UsePAM yes
+
+# Accept locale-related environment variables
+AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
+AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
+AcceptEnv LC_IDENTIFICATION LC_ALL
+#AllowTcpForwarding yes
+#GatewayPorts no
+#X11Forwarding no
+X11Forwarding yes
+#X11DisplayOffset 10
+#X11UseLocalhost yes
+#PrintMotd yes
+#PrintLastLog yes
+#TCPKeepAlive yes
+#UseLogin no
+#UsePrivilegeSeparation yes
+#PermitUserEnvironment no
+#Compression delayed
+#ClientAliveInterval 0
+#ClientAliveCountMax 3
+#ShowPatchLevel no
+#UseDNS yes
+#PidFile /var/run/sshd.pid
+#MaxStartups 10
+#PermitTunnel no
+
+# no default banner path
+#Banner /some/path
+
+# override default of no subsystems
+Subsystem      sftp    /usr/libexec/openssh/sftp-server
+
+# Example of overriding settings on a per-user basis
+Match User anoncvs
+      X11Forwarding no
+      AllowTcpForwarding no
+      ForceCommand cvs server
+
+Match Group restricted
+      ForceCommand /usr/local/bin/restricted_group_command
diff --git a/tests/root/etc/sudoers b/tests/root/etc/sudoers
new file mode 100644 (file)
index 0000000..78572b1
--- /dev/null
@@ -0,0 +1,95 @@
+## Sudoers allows particular users to run various commands as
+## the root user, without needing the root password.
+##
+## Examples are provided at the bottom of the file for collections
+## of related commands, which can then be delegated out to particular
+## users or groups.
+## 
+## This file must be edited with the 'visudo' command.
+
+## Host Aliases
+## Groups of machines. You may prefer to use hostnames (perhaps using 
+## wildcards for entire domains) or IP addresses instead.
+# Host_Alias     FILESERVERS = fs1, fs2
+# Host_Alias     MAILSERVERS = smtp, smtp2
+
+## User Aliases
+## These aren't often necessary, as you can use regular groups
+## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname 
+## rather than USERALIAS
+# User_Alias ADMINS = jsmith, mikem
+
+
+## Command Aliases
+## These are groups of related commands...
+
+## Networking
+Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
+
+## Installation and management of software
+Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
+
+## Services
+Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
+
+## Updating the locate database
+Cmnd_Alias LOCATE = /usr/bin/updatedb
+
+## Storage
+Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
+
+## Delegating permissions
+Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp 
+
+## Processes
+Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
+
+## Drivers
+Cmnd_Alias DRIVERS = /sbin/modprobe
+
+# Defaults specification
+
+#
+# Disable "ssh hostname sudo <cmd>", because it will show the password in clear. 
+#         You have to run "ssh -t hostname sudo <cmd>".
+#
+Defaults    requiretty
+
+Defaults    env_reset
+Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
+Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
+Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
+Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
+Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
+
+Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
+
+## Next comes the main part: which users can run what software on 
+## which machines (the sudoers file can be shared between multiple
+## systems).
+## Syntax:
+##
+##     user    MACHINE=COMMANDS
+##
+## The COMMANDS section may have other options added to it.
+##
+## Allow root to run any commands anywhere 
+root   ALL=(ALL)       ALL
+
+## Allows members of the 'sys' group to run networking, software, 
+## service management apps and more.
+# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
+
+## Allows people in group wheel to run all commands
+%wheel ALL=(ALL)       ALL
+
+## Same thing without a password
+# %wheel       ALL=(ALL)       NOPASSWD: ALL
+
+## Allows members of the users group to mount and unmount the 
+## cdrom as root
+# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
+
+## Allows members of the users group to shutdown this system
+# %users  localhost=/sbin/shutdown -h now
+
diff --git a/tests/root/etc/sysconfig/atd b/tests/root/etc/sysconfig/atd
new file mode 100644 (file)
index 0000000..056ce81
--- /dev/null
@@ -0,0 +1,9 @@
+# specify additional command line arguments for atd
+#
+# -l Specifies  a  limiting  load  factor,  over which batch jobs should not be run, instead of the compile-time
+#    choice of 0.8.  For an SMP system with n CPUs, you will probably want to set this higher than n-1.
+# 
+#  -b Specifiy the minimum interval in seconds between the start of two batch jobs (60 default).
+
+#example: 
+#OPTS="-l 4 -b 120"
diff --git a/tests/root/etc/sysconfig/authconfig b/tests/root/etc/sysconfig/authconfig
new file mode 100644 (file)
index 0000000..30e7c8c
--- /dev/null
@@ -0,0 +1,17 @@
+USEWINBINDAUTH=no
+USEHESIOD=no
+USESYSNETAUTH=no
+USEKERBEROS=no
+FORCESMARTCARD=no
+USESMBAUTH=no
+USESMARTCARD=no
+USELDAPAUTH=no
+USELOCAUTHORIZE=no
+USEWINBIND=no
+USESHADOW=yes
+USEDB=no
+USEPASSWDQC=no
+USEMD5=yes
+USELDAP=no
+USECRACKLIB=yes
+USENIS=no
diff --git a/tests/root/etc/sysconfig/autofs b/tests/root/etc/sysconfig/autofs
new file mode 100644 (file)
index 0000000..546fcd2
--- /dev/null
@@ -0,0 +1,91 @@
+#
+# Define default options for autofs.
+#
+# MASTER_MAP_NAME - default map name for the master map.
+#
+#MASTER_MAP_NAME="auto.master"
+#
+# TIMEOUT - set the default mount timeout (default 600).
+#
+TIMEOUT=3600
+#
+# NEGATIVE_TIMEOUT - set the default negative timeout for
+#                   failed mount attempts (default 60).
+#
+#NEGATIVE_TIMEOUT=60
+#
+# BROWSE_MODE - maps are browsable by default.
+#
+BROWSE_MODE="yes"
+#
+# APPEND_OPTIONS - append to global options instead of replace.
+#
+#APPEND_OPTIONS="yes"
+#
+# LOGGING - set default log level "none", "verbose" or "debug"
+#
+#LOGGING="none"
+#
+# Define base dn for map dn lookup.
+#
+# Define server URIs
+#
+# LDAP_URI - space seperated list of server uris of the form
+#           <proto>://<server>[/] where <proto> can be ldap
+#           or ldaps. The option can be given multiple times.
+#           Map entries that include a server name override
+#           this option.
+#
+#LDAP_URI=""
+#
+# LDAP__TIMEOUT - timeout value for the synchronous API  calls
+#                (default is LDAP library default).
+#
+#LDAP_TIMEOUT=-1
+#
+# LDAP_NETWORK_TIMEOUT - set the network response timeout (default 8).
+#
+#LDAP_NETWORK_TIMEOUT=8
+#
+# SEARCH_BASE - base dn to use for searching for map search dn.
+#              Multiple entries can be given and they are checked
+#              in the order they occur here.
+#
+#SEARCH_BASE=""
+#
+# Define the LDAP schema to used for lookups
+#
+# If no schema is set autofs will check each of the schemas
+# below in the order given to try and locate an appropriate
+# basdn for lookups. If you want to minimize the number of
+# queries to the server set the values here.
+#
+#MAP_OBJECT_CLASS="nisMap"
+#ENTRY_OBJECT_CLASS="nisObject"
+#MAP_ATTRIBUTE="nisMapName"
+#ENTRY_ATTRIBUTE="cn"
+#VALUE_ATTRIBUTE="nisMapEntry"
+#
+# Other common LDAP nameing
+#
+#MAP_OBJECT_CLASS="automountMap"
+#ENTRY_OBJECT_CLASS="automount"
+#MAP_ATTRIBUTE="ou"
+#ENTRY_ATTRIBUTE="cn"
+#VALUE_ATTRIBUTE="automountInformation"
+#
+#MAP_OBJECT_CLASS="automountMap"
+#ENTRY_OBJECT_CLASS="automount"
+#MAP_ATTRIBUTE="automountMapName"
+#ENTRY_ATTRIBUTE="automountKey"
+#VALUE_ATTRIBUTE="automountInformation"
+#
+# AUTH_CONF_FILE - set the default location for the SASL
+#                         authentication configuration file.
+#
+#AUTH_CONF_FILE="/etc/autofs_ldap_auth.conf"
+#
+# General global options
+#
+#OPTIONS=""
+#
diff --git a/tests/root/etc/sysconfig/clock b/tests/root/etc/sysconfig/clock
new file mode 100644 (file)
index 0000000..ed58def
--- /dev/null
@@ -0,0 +1,5 @@
+# The ZONE parameter is only evaluated by system-config-date.
+# The timezone of the system is defined by the contents of /etc/localtime.
+ZONE="America/Los Angeles"
+UTC=true
+ARC=false
diff --git a/tests/root/etc/sysconfig/cpuspeed b/tests/root/etc/sysconfig/cpuspeed
new file mode 100644 (file)
index 0000000..f06f89c
--- /dev/null
@@ -0,0 +1,72 @@
+# /etc/sysconfig/cpuspeed
+#
+# This configuration file controls the behavior of both the
+# cpuspeed daemon and various cpufreq modules.
+# For the vast majority of users, there shouldn't be any need to
+# alter the contents of this file at all. By and large, frequency
+# scaling should Just Work(tm) with the defaults.
+
+### DRIVER ###
+# Your CPUFreq driver module
+# Note that many drivers are now built-in, rather than built as modules,
+# so its usually best not to specify one. The most commonly-needed driver
+# module these days is 'p4-clockmod', however, in most cases, it is not
+# recommended for use. See: http://lkml.org/lkml/2006/2/25/84
+# default value: empty (try to auto-detect/use built-in)
+DRIVER=
+
+### GOVERNOR ###
+# Which scaling governor to use
+# Details on scaling governors for your cpu(s) can be found in
+# cpu-freq/governors.txt, part of the kernel-doc package
+# NOTES:
+# - The GOVERNOR parameter is only valid on centrino, powernow-k8 (amd64)
+#   and p4-clockmod platforms, other platforms that support frequency
+#   scaling always use the 'userspace' governor.
+# - Using the 'userspace' governor will trigger the cpuspeed daemon to run,
+#   which provides said user-space frequency scaling.
+# default value: empty (defaults to ondemand on centrino, powernow-k8,
+#                       and p4-clockmod systems, userspace on others)
+GOVERNOR=
+
+### FREQUENCIES ###
+# NOTE: valid max/min frequencies for your cpu(s) can be found in
+# /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
+# on systems that support frequency scaling (though only after the
+# appropriate drivers have been loaded via the cpuspeed initscript).
+# maximum speed to scale up to
+# default value: empty (use cpu reported maximum)
+MAX_SPEED=
+# minimum speed to scale down to
+# default value: empty (use cpu reported minimum)
+MIN_SPEED=
+
+### SCALING THRESHOLDS ###
+# Busy percentage threshold over which to scale up to max frequency
+# default value: empty (use governor default)
+UP_THRESHOLD=
+# Busy percentage threshold under which to scale frequency down
+# default value: empty (use governor default)
+DOWN_THRESHOLD=
+
+### NICE PROCESS HANDLING ###
+# Let background (nice) processes speed up the cpu
+# default value: 0 (background process usage can speed up cpu)
+# alternate value: 1 (background processes will be ignored)
+IGNORE_NICE=0
+
+
+#####################################################
+########## HISTORICAL CPUSPEED CONFIG BITS ##########
+#####################################################
+VMAJOR=1
+VMINOR=1
+
+# Add your favorite options here
+#OPTS="$OPTS -s 0 -i 10 -r"
+
+# uncomment and modify this to check the state of the AC adapter
+#OPTS="$OPTS -a /proc/acpi/ac_adapter/*/state"
+
+# uncomment and modify this to check the system temperature
+#OPTS="$OPTS -t /proc/acpi/thermal_zone/*/temperature 75"
diff --git a/tests/root/etc/sysconfig/crond b/tests/root/etc/sysconfig/crond
new file mode 100644 (file)
index 0000000..9e5819d
--- /dev/null
@@ -0,0 +1,9 @@
+# Settings for the CRON daemon.
+# CRONDARGS= :  any extra command-line startup arguments for crond
+# CRON_VALIDATE_MAILRCPTS=1:a non-empty value of this variable will
+#                           enable vixie-cron-4.1's validation of 
+#                           mail recipient names, which would then be
+#                           restricted to contain only the chars
+#                           from this tr(1) set : [@!:%-_.,:alnum:]
+#                           otherwise mailing is not attempted.
+CRONDARGS=
diff --git a/tests/root/etc/sysconfig/crontab b/tests/root/etc/sysconfig/crontab
new file mode 100644 (file)
index 0000000..8341aa9
--- /dev/null
@@ -0,0 +1,6 @@
+# Possible values are 1, 2, ... or nothing
+# Delay is determined using the hostname and the variable (Delay) from this configuration file.
+# Bigger value means shorter delay.
+# This delay could be switched off, but then you can have problems with network overload 
+# (for example yum updates in cron.daily run on all your computers etc.)
+DELAY=1
diff --git a/tests/root/etc/sysconfig/firstboot b/tests/root/etc/sysconfig/firstboot
new file mode 100644 (file)
index 0000000..78ef6a0
--- /dev/null
@@ -0,0 +1 @@
+RUN_FIRSTBOOT=NO
diff --git a/tests/root/etc/sysconfig/grub b/tests/root/etc/sysconfig/grub
new file mode 100644 (file)
index 0000000..c112ffc
--- /dev/null
@@ -0,0 +1,2 @@
+boot=/dev/sda
+forcelba=0
diff --git a/tests/root/etc/sysconfig/hsqldb b/tests/root/etc/sysconfig/hsqldb
new file mode 100644 (file)
index 0000000..5e1d587
--- /dev/null
@@ -0,0 +1,128 @@
+# $Id: hsqldb-1.73.0-standard.cfg,v 1.1 2004/12/23 22:21:08 fnasser Exp $
+
+# Sample configuration file for HSQLDB database server.
+# See the "UNIX Quick Start" chapter of the Hsqldb User Guide.
+
+# N.b.!!!!  You must place this in the right location for your type of UNIX.
+# See the init script "hsqldb" to see where this must be placed and
+# what it should be renamed to.
+
+# This file is "sourced" by a Bourne shell, so use Bourne shell syntax.
+
+# This file WILL NOT WORK until you set (at least) the non-commented
+# variables to the appropriate values for your system.
+# Life will be easier if you avoid all filepaths with spaces or any other
+# funny characters.  Don't ask for support if you ignore this advice.
+
+# Thanks to Meikel Bisping for his contributions.  -- Blaine
+
+# JPackage hsqldb home is /var/lib/hsqldb
+
+HSQLDB_HOME=/var/lib/hsqldb
+
+# JPackage source Java config
+
+. /etc/java/java.conf
+
+JAVA_EXECUTABLE=${JAVA_HOME}/bin/java
+
+# Unless you copied a hsqldb.jar file from another system, this typically
+# resides at $HSQLDB_HOME/lib/hsqldb.jar, where $HSQLDB_HOME is your HSQLDB
+# software base directory.
+HSQLDB_JAR_PATH=${HSQLDB_HOME}/lib/hsqldb.jar
+
+# Where the file "server.properties" (or "webserver.properties") resides.
+SERVER_HOME=${HSQLDB_HOME}
+
+# What UNIX user the Server/WebServer process will run as.
+# (The shutdown client is always run as root or the invoker of the init script).
+# Runs as root by default, but you should take the time to set database file
+# ownerships to another user and set that user name here.
+# You do need to run as root if your Server/WebServer will run on a privileged
+# (< 1024) port.
+# If you really do want to run as root, comment out the HSQLDB_OWNER setting
+# completely.  I.e., do not set it to root.  This will run Server/Webserver
+# without any "su" at all.
+HSQLDB_OWNER=hsqldb
+
+# We require all Server/WebServer instances to be accessible within 
+# $MAX_START_SECS from when the Server/WebServer is started.
+# Defaults to 60.
+# Raise this is you are running lots of DB instances or have a slow server.
+#MAX_START_SECS=200
+# Ditto for this one
+#SU_ECHO_SECS=1
+
+# Time to allow for JVM to die after all HSQLDB instances stopped.
+# Defaults to 1.
+#MAX_TERMINATE_SECS=0
+
+# These are "urlid" values from a SqlTool authentication file
+# ** IN ADDITION TO THOSE IN YOUR server.properties OR webserver.properties **
+# file.  All server.urlid.X values from your properties file will automatically
+# be started/stopped/tested.  $SHUTDOWN_URLIDS is for additional urlids which
+# will stopped.  (Therefore, most users will not set this at all).
+# Separate multiple values with white space.  NO OTHER SPECIAL CHARACTERS!
+# Make sure to quote the entire value if it contains white space separator(s).
+# Defaults to none (i.e., only urlids set in properties file will be stopped).
+#SHUTDOWN_URLIDS='sa mygms'
+
+# SqlTool authentication file used only for shutdown.
+# The default value will be sqltool.rc in root's home directory, since it is 
+# root who runs the init script.
+# (See the SqlTool chapter of the HSQLDB User Guide if you don't understand 
+# this).
+AUTH_FILE=${HSQLDB_HOME}/sqltool.rc
+
+# Set to 'WebServer' to start a HSQLDB WebServer instead of a Server.
+# Defaults to 'Server'.
+#TARGET_CLASS=WebServer
+
+# Server-side classpath IN ADDITION TO the HSQLDB_JAR_PATH set above.
+# The classpath here is *earlier* than HSQLDB_JAR_PATH, to allow you 
+# override classes in the HSQLDB_JAR_PATH jar file.
+# In particular, you will want to add classpath elements to give access of
+# all of your store procedures (store procedures are documented in the 
+# HSQLDB User Guide in the SQL Syntax chapter.
+#
+# N.B.!
+# If you're adding files to the classpath in order to be able to call them
+# from SQL queries, you will be unable to access them unless you adjust the
+# value of the system property hsqldb.method_class_names. Please see the
+# comments on SERVER_JVMARGS, at the end of this file.
+# SERVER_ADDL_CLASSPATH=/home/blaine/storedprocs.jar:/usr/dev/dbutil/classes
+
+# For TLS encryption for your Server, set these two variables.
+# N.b.:  If you set these, then make this file unreadable to non-root users!!!!
+# See the TLS chapter of the HSQLDB User Guide, paying attention to the 
+# security warning(s).
+# If you are running with a private server cert, then you will also need to 
+# set "truststore" in the your SqlTool config file (location is set by the
+# AUTH_FILE variable in this file, or it must be at the default location for 
+# HSQLDB_OWNER).
+#TLS_KEYSTORE=/path/to/jks/server.store
+#TLS_PASSWORD=password
+
+# Any JVM args for the invocation of the JDBC client used to verify DB
+# instances and to shut them down (SqlToolSprayer).
+# For multiple args, put quotes around entire value.
+#CLIENT_JVMARGS=-Djavax.net.debug=ssl
+
+# Any JVM args for the server.
+# For multiple args, put quotes around entire value.
+#
+# N.B.!
+# The default value of SERVER_JVMARGS sets the system property 
+# hsqldb.method_class_names to be empty. This is in order to lessen the
+# security risk posed by HSQLDB allowing Java method calls in SQL statements.
+# The implications of changing this value (as explained by the authors of
+# HSQLDB) are as follows:
+#     If [it] is not set, then static methods of all available Java classes
+#     can be accessed as functions in HSQLDB. If the property is set, then
+#     only the list of semicolon seperated method names becomes accessible.
+#     An empty property value means no class is accessible.
+# Regardless of the value of hsqldb.method_class_names, methods in
+# org.hsqldb.Library will be accessible.
+# Before making changes to the value below, please be advised of the possible
+# dangers involved in allowing SQL queries to contain Java method calls.
+SERVER_JVMARGS=-Dhsqldb.method_class_names=\"\"
diff --git a/tests/root/etc/sysconfig/httpd b/tests/root/etc/sysconfig/httpd
new file mode 100644 (file)
index 0000000..7102c61
--- /dev/null
@@ -0,0 +1,22 @@
+# Configuration file for the httpd service.
+
+#
+# The default processing model (MPM) is the process-based
+# 'prefork' model.  A thread-based model, 'worker', is also
+# available, but does not work with some modules (such as PHP).
+# The service must be stopped before changing this variable.
+#
+#HTTPD=/usr/sbin/httpd.worker
+
+#
+# To pass additional options (for instance, -D definitions) to the
+# httpd binary at startup, set OPTIONS here.
+#
+#OPTIONS=
+
+#
+# By default, the httpd process is started in the C locale; to 
+# change the locale in which the server runs, the HTTPD_LANG
+# variable can be set.
+#
+#HTTPD_LANG=C
diff --git a/tests/root/etc/sysconfig/hw-uuid b/tests/root/etc/sysconfig/hw-uuid
new file mode 100644 (file)
index 0000000..d60c740
--- /dev/null
@@ -0,0 +1 @@
+9a1c565e-3b93-4e74-9611-2b71b9b84a05
diff --git a/tests/root/etc/sysconfig/hwconf b/tests/root/etc/sysconfig/hwconf
new file mode 100644 (file)
index 0000000..1e9f79f
--- /dev/null
@@ -0,0 +1,672 @@
+-
+class: OTHER
+bus: PCI
+detached: 0
+desc: "Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub"
+vendorId: 8086
+deviceId: 27a0
+subVendorId: 17aa
+subDeviceId: 2017
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev:  0
+pcifn:  0
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: shpchp
+desc: "Intel Corporation 82801G (ICH7 Family) PCI Express Port 1"
+vendorId: 8086
+deviceId: 27d0
+subVendorId: 0000
+subDeviceId: 0000
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1c
+pcifn:  0
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: shpchp
+desc: "Intel Corporation 82801G (ICH7 Family) PCI Express Port 2"
+vendorId: 8086
+deviceId: 27d2
+subVendorId: 0000
+subDeviceId: 0000
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1c
+pcifn:  1
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: shpchp
+desc: "Intel Corporation 82801G (ICH7 Family) PCI Express Port 3"
+vendorId: 8086
+deviceId: 27d4
+subVendorId: 0000
+subDeviceId: 0000
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1c
+pcifn:  2
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: shpchp
+desc: "Intel Corporation 82801G (ICH7 Family) PCI Express Port 4"
+vendorId: 8086
+deviceId: 27d6
+subVendorId: 0000
+subDeviceId: 0000
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1c
+pcifn:  3
+-
+class: OTHER
+bus: PCI
+detached: 0
+desc: "Intel Corporation 82801 Mobile PCI Bridge"
+vendorId: 8086
+deviceId: 2448
+subVendorId: 0000
+subDeviceId: 0000
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1e
+pcifn:  0
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: intel-rng
+desc: "Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge"
+vendorId: 8086
+deviceId: 27b9
+subVendorId: 17aa
+subDeviceId: 2009
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1f
+pcifn:  0
+-
+class: OTHER
+bus: PCI
+detached: 0
+driver: i2c-i801
+desc: "Intel Corporation 82801G (ICH7 Family) SMBus Controller"
+vendorId: 8086
+deviceId: 27da
+subVendorId: 17aa
+subDeviceId: 200f
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1f
+pcifn:  3
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "ATM1200"
+deviceId: ATM1200
+compat: PNP0c31
+-
+class: OTHER
+bus: USB
+detached: 0
+driver: hci_usb
+desc: "Broadcom Corp BCM2045B"
+usbclass: 254
+usbsubclass: 1
+usbprotocol: 0
+usbbus: 5
+usblevel: 1
+usbport: 0
+usbdev: 2
+vendorId: 0a5c
+deviceId: 2110
+usbmfr: Broadcom Corp
+usbprod: BCM2045B
+-
+class: OTHER
+bus: USB
+detached: 0
+driver: hci_usb
+desc: "Broadcom Corp BCM2045B"
+usbclass: 255
+usbsubclass: 255
+usbprotocol: 255
+usbbus: 5
+usblevel: 1
+usbport: 0
+usbdev: 2
+vendorId: 0a5c
+deviceId: 2110
+usbmfr: Broadcom Corp
+usbprod: BCM2045B
+-
+class: OTHER
+bus: USB
+detached: 0
+driver: hci_usb
+desc: "Broadcom Corp BCM2045B"
+usbclass: 224
+usbsubclass: 1
+usbprotocol: 1
+usbbus: 5
+usblevel: 1
+usbport: 0
+usbdev: 2
+vendorId: 0a5c
+deviceId: 2110
+usbmfr: Broadcom Corp
+usbprod: BCM2045B
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "IBM0057"
+deviceId: IBM0057
+compat: PNP0f13
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+driver: nsc-ircc
+desc: "IBM0071"
+deviceId: IBM0071
+compat: PNP0511
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "Lid Switch"
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Linux 2.6.24.4-64.fc8 ehci_hcd EHCI Host Controller"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 1
+usblevel: 0
+usbport: 0
+usbdev: 1
+vendorId: 0000
+deviceId: 0000
+usbmfr: Linux 2.6.24.4-64.fc8 ehci_hcd
+usbprod: EHCI Host Controller
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Linux 2.6.24.4-64.fc8 uhci_hcd UHCI Host Controller"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 5
+usblevel: 0
+usbport: 0
+usbdev: 1
+vendorId: 0000
+deviceId: 0000
+usbmfr: Linux 2.6.24.4-64.fc8 uhci_hcd
+usbprod: UHCI Host Controller
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Linux 2.6.24.4-64.fc8 uhci_hcd UHCI Host Controller"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 4
+usblevel: 0
+usbport: 0
+usbdev: 1
+vendorId: 0000
+deviceId: 0000
+usbmfr: Linux 2.6.24.4-64.fc8 uhci_hcd
+usbprod: UHCI Host Controller
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Linux 2.6.24.4-64.fc8 uhci_hcd UHCI Host Controller"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 3
+usblevel: 0
+usbport: 0
+usbdev: 1
+vendorId: 0000
+deviceId: 0000
+usbmfr: Linux 2.6.24.4-64.fc8 uhci_hcd
+usbprod: UHCI Host Controller
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Linux 2.6.24.4-64.fc8 uhci_hcd UHCI Host Controller"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 2
+usblevel: 0
+usbport: 0
+usbdev: 1
+vendorId: 0000
+deviceId: 0000
+usbmfr: Linux 2.6.24.4-64.fc8 uhci_hcd
+usbprod: UHCI Host Controller
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+driver: pcspkr
+desc: "PC Speaker"
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0103"
+deviceId: PNP0103
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0200"
+deviceId: PNP0200
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0303"
+deviceId: PNP0303
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0800"
+deviceId: PNP0800
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0a08"
+deviceId: PNP0a08
+compat: PNP0a03
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0b00"
+deviceId: PNP0b00
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0c01"
+deviceId: PNP0c01
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0c02"
+deviceId: PNP0c02
+-
+class: OTHER
+bus: ISAPNP
+detached: 0
+desc: "PNP0c04"
+deviceId: PNP0c04
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "Power Button (FF)"
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "STMicroelectronics Biometric Coprocessor"
+usbclass: 255
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 5
+usblevel: 1
+usbport: 1
+usbdev: 3
+vendorId: 0483
+deviceId: 2016
+usbmfr: STMicroelectronics
+usbprod: Biometric Coprocessor
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "Sleep Button (CM)"
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "TPPS/2 IBM TrackPoint"
+-
+class: OTHER
+bus: USB
+detached: 0
+desc: "Unknown USB device 0x451:0x2046"
+usbclass: 9
+usbsubclass: 0
+usbprotocol: 0
+usbbus: 1
+usblevel: 2
+usbport: 0
+usbdev: 5
+vendorId: 0451
+deviceId: 2046
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "Video Bus"
+-
+class: OTHER
+bus: PSAUX
+detached: 0
+desc: "Video Bus"
+-
+class: NETWORK
+bus: PCI
+detached: 0
+device: eth0
+driver: e1000
+desc: "Intel Corporation 82573L Gigabit Ethernet Controller"
+network.hwaddr: 00:15:58:81:5b:0e
+vendorId: 8086
+deviceId: 109a
+subVendorId: 17aa
+subDeviceId: 2001
+pciType: 1
+pcidom:    0
+pcibus:  2
+pcidev:  0
+pcifn:  0
+-
+class: NETWORK
+bus: PCI
+detached: 0
+device: wlan0
+driver: iwl3945
+desc: "Intel Corporation PRO/Wireless 3945ABG Network Connection"
+network.hwaddr: 00:19:d2:9f:88:96
+vendorId: 8086
+deviceId: 4227
+subVendorId: 8086
+subDeviceId: 1010
+pciType: 1
+pcidom:    0
+pcibus:  3
+pcidev:  0
+pcifn:  0
+-
+class: MOUSE
+bus: USB
+detached: 0
+device: input/mice
+driver: genericwheelusb
+desc: "ATEN 4 Port USB KVM B V1.80"
+usbclass: 3
+usbsubclass: 1
+usbprotocol: 2
+usbbus: 1
+usblevel: 3
+usbport: 0
+usbdev: 6
+vendorId: 0557
+deviceId: 2205
+usbmfr: ATEN
+usbprod: 4 Port USB KVM B V1.80
+-
+class: MOUSE
+bus: PSAUX
+detached: 0
+device: input/mice
+driver: generic3ps/2
+desc: "Macintosh mouse button emulation"
+-
+class: MOUSE
+bus: PSAUX
+detached: 0
+device: input/mice
+driver: synaptics
+desc: "SynPS/2 Synaptics TouchPad"
+-
+class: MOUSE
+bus: PSAUX
+detached: 0
+device: input/mice
+driver: generic3ps/2
+desc: "ThinkPad Extra Buttons"
+-
+class: AUDIO
+bus: PCI
+detached: 0
+driver: snd-hda-intel
+desc: "Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller"
+vendorId: 8086
+deviceId: 27d8
+subVendorId: 17aa
+subDeviceId: 2010
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1b
+pcifn:  0
+-
+class: CDROM
+bus: SCSI
+detached: 0
+device: scd0
+desc: "MATSHITA DVD-RAM UJ-842"
+host: 4
+id: 0
+channel: 0
+lun: 0
+-
+class: VIDEO
+bus: PCI
+detached: 0
+driver: intelfb
+desc: "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
+video.xdriver: intel
+vendorId: 8086
+deviceId: 27a2
+subVendorId: 17aa
+subDeviceId: 201a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev:  2
+pcifn:  0
+-
+class: VIDEO
+bus: PCI
+detached: 0
+desc: "Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller"
+vendorId: 8086
+deviceId: 27a6
+subVendorId: 17aa
+subDeviceId: 201a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev:  2
+pcifn:  1
+-
+class: HD
+bus: SCSI
+detached: 0
+device: sda
+desc: "ATA HTS721010G9SA00"
+host: 0
+id: 0
+channel: 0
+lun: 0
+-
+class: KEYBOARD
+bus: PSAUX
+detached: 0
+desc: "AT Translated Set 2 keyboard"
+-
+class: KEYBOARD
+bus: USB
+detached: 0
+driver: keybdev
+desc: "ATEN 4 Port USB KVM B V1.80"
+usbclass: 3
+usbsubclass: 1
+usbprotocol: 1
+usbbus: 1
+usblevel: 3
+usbport: 0
+usbdev: 6
+vendorId: 0557
+deviceId: 2205
+usbmfr: ATEN
+usbprod: 4 Port USB KVM B V1.80
+-
+class: USB
+bus: PCI
+detached: 0
+driver: uhci-hcd
+desc: "Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1"
+vendorId: 8086
+deviceId: 27c8
+subVendorId: 17aa
+subDeviceId: 200a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1d
+pcifn:  0
+-
+class: USB
+bus: PCI
+detached: 0
+driver: uhci-hcd
+desc: "Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2"
+vendorId: 8086
+deviceId: 27c9
+subVendorId: 17aa
+subDeviceId: 200a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1d
+pcifn:  1
+-
+class: USB
+bus: PCI
+detached: 0
+driver: uhci-hcd
+desc: "Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3"
+vendorId: 8086
+deviceId: 27ca
+subVendorId: 17aa
+subDeviceId: 200a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1d
+pcifn:  2
+-
+class: USB
+bus: PCI
+detached: 0
+driver: uhci-hcd
+desc: "Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4"
+vendorId: 8086
+deviceId: 27cb
+subVendorId: 17aa
+subDeviceId: 200a
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1d
+pcifn:  3
+-
+class: USB
+bus: PCI
+detached: 0
+driver: ehci-hcd
+desc: "Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller"
+vendorId: 8086
+deviceId: 27cc
+subVendorId: 17aa
+subDeviceId: 200b
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1d
+pcifn:  7
+-
+class: SOCKET
+bus: PCI
+detached: 0
+driver: yenta_socket
+desc: "Texas Instruments PCI1510 PC card Cardbus Controller"
+vendorId: 104c
+deviceId: ac56
+subVendorId: 17aa
+subDeviceId: 2012
+pciType: 1
+pcidom:    0
+pcibus: 15
+pcidev:  0
+pcifn:  0
+-
+class: IDE
+bus: PCI
+detached: 0
+driver: ata_piix
+desc: "Intel Corporation 82801G (ICH7 Family) IDE Controller"
+vendorId: 8086
+deviceId: 27df
+subVendorId: 17aa
+subDeviceId: 200c
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1f
+pcifn:  1
+-
+class: SATA
+bus: PCI
+detached: 0
+driver: ahci
+desc: "Intel Corporation 82801GBM/GHM (ICH7 Family) SATA AHCI Controller"
+vendorId: 8086
+deviceId: 27c5
+subVendorId: 17aa
+subDeviceId: 200d
+pciType: 1
+pcidom:    0
+pcibus:  0
+pcidev: 1f
+pcifn:  2
diff --git a/tests/root/etc/sysconfig/i18n b/tests/root/etc/sysconfig/i18n
new file mode 100644 (file)
index 0000000..9dcb0b1
--- /dev/null
@@ -0,0 +1,2 @@
+LANG="en_US.UTF-8"
+SYSFONT="latarcyrheb-sun16"
diff --git a/tests/root/etc/sysconfig/init b/tests/root/etc/sysconfig/init
new file mode 100644 (file)
index 0000000..117b6bc
--- /dev/null
@@ -0,0 +1,25 @@
+# color => new RH6.0 bootup
+# verbose => old-style bootup
+# anything else => new style bootup without ANSI colors or positioning
+BOOTUP=color
+# Turn on graphical boot
+GRAPHICAL=yes
+# column to start "[  OK  ]" label in 
+RES_COL=60
+# terminal sequence to move to that column. You could change this
+# to something like "tput hpa ${RES_COL}" if your terminal supports it
+MOVE_TO_COL="echo -en \\033[${RES_COL}G"
+# terminal sequence to set color to a 'success' color (currently: green)
+SETCOLOR_SUCCESS="echo -en \\033[0;32m"
+# terminal sequence to set color to a 'failure' color (currently: red)
+SETCOLOR_FAILURE="echo -en \\033[0;31m"
+# terminal sequence to set color to a 'warning' color (currently: yellow)
+SETCOLOR_WARNING="echo -en \\033[0;33m"
+# terminal sequence to reset to the default color.
+SETCOLOR_NORMAL="echo -en \\033[0;39m"
+# default kernel loglevel on boot (syslog will reset this)
+LOGLEVEL=3
+# Set to anything other than 'no' to allow hotkey interactive startup...
+PROMPT=yes
+# Set to 'yes' to allow probing for devices with swap signatures
+AUTOSWAP=no
diff --git a/tests/root/etc/sysconfig/iptables b/tests/root/etc/sysconfig/iptables
new file mode 100644 (file)
index 0000000..3c39d45
--- /dev/null
@@ -0,0 +1,48 @@
+# Firewall configuration written by system-config-firewall
+# Manual customization of this file is not recommended.
+*filter
+:INPUT ACCEPT [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+:RH-Firewall-1-INPUT - [0:0]
+-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
+-A INPUT -p icmp -j ACCEPT
+-A INPUT -i lo -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
+-A INPUT -p ah -j ACCEPT
+-A INPUT -p esp -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 631 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 631 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 2020 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 32769 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 5900 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 5901 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
+-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
+-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
+-A INPUT --tcp-flags SYN,RST,ACK,FIN SYN -j ACCEPT
+-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
+-A INPUT -j REJECT --reject-with icmp-host-prohibited
+-A FORWARD -j REJECT --reject-with icmp-host-prohibited
+-A INPUT -j RH-Firewall-1-INPUT
+-A FORWARD -j RH-Firewall-1-INPUT
+-A RH-Firewall-1-INPUT -i lo -j ACCEPT
+-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
+-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
+-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
+-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
+-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
+-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
+COMMIT
diff --git a/tests/root/etc/sysconfig/iptables-config b/tests/root/etc/sysconfig/iptables-config
new file mode 100644 (file)
index 0000000..6402740
--- /dev/null
@@ -0,0 +1,48 @@
+# Load additional iptables modules (nat helpers)
+#   Default: -none-
+# Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which
+# are loaded after the firewall rules are applied. Options for the helpers are
+# stored in /etc/modprobe.conf.
+IPTABLES_MODULES="ip_conntrack_netbios_ns"
+
+# Unload modules on restart and stop
+#   Value: yes|no,  default: yes
+# This option has to be 'yes' to get to a sane state for a firewall
+# restart or stop. Only set to 'no' if there are problems unloading netfilter
+# modules.
+IPTABLES_MODULES_UNLOAD="yes"
+
+# Save current firewall rules on stop.
+#   Value: yes|no,  default: no
+# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets stopped
+# (e.g. on system shutdown).
+IPTABLES_SAVE_ON_STOP="no"
+
+# Save current firewall rules on restart.
+#   Value: yes|no,  default: no
+# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets
+# restarted.
+IPTABLES_SAVE_ON_RESTART="no"
+
+# Save (and restore) rule and chain counter.
+#   Value: yes|no,  default: no
+# Save counters for rules and chains to /etc/sysconfig/iptables if
+# 'service iptables save' is called or on stop or restart if SAVE_ON_STOP or
+# SAVE_ON_RESTART is enabled.
+IPTABLES_SAVE_COUNTER="no"
+
+# Numeric status output
+#   Value: yes|no,  default: yes
+# Print IP addresses and port numbers in numeric format in the status output.
+IPTABLES_STATUS_NUMERIC="yes"
+
+# Verbose status output
+#   Value: yes|no,  default: yes
+# Print info about the number of packets and bytes plus the "input-" and
+# "outputdevice" in the status output.
+IPTABLES_STATUS_VERBOSE="no"
+
+# Status output with numbered lines
+#   Value: yes|no,  default: yes
+# Print a counter/number for every rule in the status output.
+IPTABLES_STATUS_LINENUMBERS="yes"
diff --git a/tests/root/etc/sysconfig/irda b/tests/root/etc/sysconfig/irda
new file mode 100644 (file)
index 0000000..7776c3b
--- /dev/null
@@ -0,0 +1,4 @@
+IRDA=yes
+DEVICE=/dev/ttyS2
+#DONGLE=actisys+
+DISCOVERY=yes
diff --git a/tests/root/etc/sysconfig/irqbalance b/tests/root/etc/sysconfig/irqbalance
new file mode 100644 (file)
index 0000000..0ff3939
--- /dev/null
@@ -0,0 +1,18 @@
+# irqbalance is a daemon process that distributes interrupts across
+# CPUS on SMP systems.  The default is to rebalance once every 10
+# seconds.  There is one configuration option:
+#
+# ONESHOT=yes
+#    after starting, wait for a minute, then look at the interrupt
+#    load and balance it once; after balancing exit and do not change
+#    it again.
+ONESHOT=
+
+#
+# IRQ_AFFINITY_MASK
+#    64 bit bitmask which allows you to indicate which cpu's should
+#    be skipped when reblancing irqs.  Cpu numbers which have their 
+#    corresponding bits set to zero in this mask will not have any
+#    irq's assigned to them on rebalance
+#
+#IRQ_AFFINITY_MASK=
diff --git a/tests/root/etc/sysconfig/kdump b/tests/root/etc/sysconfig/kdump
new file mode 100644 (file)
index 0000000..34b5f16
--- /dev/null
@@ -0,0 +1,32 @@
+# Kernel Version string for the -kdump kernel, such as 2.6.13-1544.FC5kdump
+# If no version is specified, then the init script will try to find a
+# kdump kernel with the same version number as the running kernel.
+KDUMP_KERNELVER=""
+
+# The kdump commandline is the command line that needs to be passed off to
+# the kdump kernel.  This will likely match the contents of the grub kernel
+# line.  For example:
+#   KDUMP_COMMANDLINE="ro root=LABEL=/"
+# If a command line is not specified, the default will be taken from
+# /proc/cmdline
+KDUMP_COMMANDLINE=""
+
+# This variable lets us append arguments to the current kdump commandline
+# As taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
+KDUMP_COMMANDLINE_APPEND="irqpoll maxcpus=1"
+
+# Any additional kexec arguments required.  In most situations, this should
+# be left empty
+#
+# Example:
+#   KEXEC_ARGS="--elf32-core-headers"
+KEXEC_ARGS=" --args-linux"
+
+#Where to find the boot image
+KDUMP_BOOTDIR="/boot"
+
+#What is the image type used for kdump
+KDUMP_IMG="vmlinuz"
+
+#What is the images extension.  Relocatable kernels don't have one
+KDUMP_IMG_EXT=""
diff --git a/tests/root/etc/sysconfig/kernel b/tests/root/etc/sysconfig/kernel
new file mode 100644 (file)
index 0000000..77448aa
--- /dev/null
@@ -0,0 +1,6 @@
+# UPDATEDEFAULT specifies if new-kernel-pkg should make
+# new kernels the default
+UPDATEDEFAULT=yes
+
+# DEFAULTKERNEL specifies the default kernel package type
+DEFAULTKERNEL=kernel-xen
diff --git a/tests/root/etc/sysconfig/keyboard b/tests/root/etc/sysconfig/keyboard
new file mode 100644 (file)
index 0000000..970189b
--- /dev/null
@@ -0,0 +1,2 @@
+KEYBOARDTYPE="pc"
+KEYTABLE="us"
diff --git a/tests/root/etc/sysconfig/kudzu b/tests/root/etc/sysconfig/kudzu
new file mode 100644 (file)
index 0000000..6156022
--- /dev/null
@@ -0,0 +1,6 @@
+# Set to anything other than 'no' to force a 'safe' probe on startup.
+# 'safe' probe disables:
+# - serial port probing
+# - DDC monitor probing
+# - PS/2 probing
+SAFE=no
diff --git a/tests/root/etc/sysconfig/libvirtd b/tests/root/etc/sysconfig/libvirtd
new file mode 100644 (file)
index 0000000..fe4596a
--- /dev/null
@@ -0,0 +1,9 @@
+# Override the default config file
+#LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
+
+# Listen for TCP/IP connections
+# NB. must setup TLS/SSL keys prior to using this
+#LIBVIRTD_ARGS="--listen"
+
+# Override Kerberos service keytab for SASL/GSSAPI
+#KRB5_KTNAME=/etc/libvirt/krb5.tab
diff --git a/tests/root/etc/sysconfig/lircd b/tests/root/etc/sysconfig/lircd
new file mode 100644 (file)
index 0000000..749be17
--- /dev/null
@@ -0,0 +1,2 @@
+# Options to lircd
+LIRCD_OPTIONS=
diff --git a/tests/root/etc/sysconfig/lm_sensors b/tests/root/etc/sysconfig/lm_sensors
new file mode 100644 (file)
index 0000000..c1b5809
--- /dev/null
@@ -0,0 +1,2 @@
+#    /etc/sysconfig/sensors - Defines modules loaded by /etc/rc.d/init.d/lm_sensors
+# Run sensors-detect to generate this config file
diff --git a/tests/root/etc/sysconfig/nasd b/tests/root/etc/sysconfig/nasd
new file mode 100644 (file)
index 0000000..240fab1
--- /dev/null
@@ -0,0 +1,10 @@
+# Options to nasd
+# See nasd(1) for more details
+# -aa          allow any client to connect
+# -local       allow local clients only
+# -b           detach and run in background
+# -v           enable verbose messages
+# -d           <num>   enable debug messages at level <num>
+# -pn          partial networking enabled
+# -nopn                partial networking disabled [default]
+NASD_OPTIONS="-b -local"
diff --git a/tests/root/etc/sysconfig/netconsole b/tests/root/etc/sysconfig/netconsole
new file mode 100644 (file)
index 0000000..7b9d96e
--- /dev/null
@@ -0,0 +1,20 @@
+# This is the configuration file for the netconsole service.  By starting
+# this service you allow a remote syslog daemon to record console output
+# from this system.
+
+# The local port number that the netconsole module will use
+# LOCALPORT=6666
+
+# The ethernet device to send console messages out of (only set this if it
+# can't be automatically determined)
+# DEV=
+
+# The IP address of the remote syslog server to send messages to
+# SYSLOGADDR=
+
+# The listening port of the remote syslog daemon
+# SYSLOGPORT=514
+
+# The MAC address of the remote syslog server (only set this if it can't
+# be automatically determined)
+# SYSLOGMACADDR=
diff --git a/tests/root/etc/sysconfig/netdump_id_dsa.pub b/tests/root/etc/sysconfig/netdump_id_dsa.pub
new file mode 100644 (file)
index 0000000..70ec26b
--- /dev/null
@@ -0,0 +1 @@
+ssh-dss AAAAB3NzaC1kc3MAAACBAN4hXeRHrCzo+hdWYlXNK17bVODegv1x4HxDbrCZK92tRxHBsYFng1+oWTZs607LQ/dfcLxFRfPREuKLXiWFY6bDdJDfB5V5HzCBFCH+o5NQ48y8IcIpGic/5+cqWyY6pcxnwfzEQHtdLEeo93lRMzpMsFsbkST3qpBe8QJM3/gtAAAAFQDWWFFtL9NeP0zjhJv6FNDNfZ75CwAAAIAJansjnrRm3FKDxeFf6FuiBvioa4UJszeaSfoGpd6ugScfOyM/u1r08xPgn9ud5/kwRPxV56HWkqgxJQ0dChIMij3HiraZmyg5AY9i85ZW1ZUOEgMRDmWRTOMHK++u9Dmh1d1FtugrUeP6e4wP9nC2y/r+3qhsPTrqBUTXZikkFgAAAIA8Oue6cIFNZSzQRB4UM6hLwxfXAgWBHzoa7UxF7Zh6H65xnKswpIIcQHX77RFK0oF5Y4ks0Fjy5GLTlAGbSy2IcH9ecugRK6+bnEzO09NNO+yXzh/xahCX3ubOmdoFNm4dwdlQy7n3NgFqI99tHIvY/B1MCs7XkMKV4s6yzLVS4Q== root@localhost.localdomain
diff --git a/tests/root/etc/sysconfig/network b/tests/root/etc/sysconfig/network
new file mode 100644 (file)
index 0000000..9ae0d72
--- /dev/null
@@ -0,0 +1,3 @@
+NETWORKING=yes
+NETWORKING_IPV6=no
+HOSTNAME=galia.watzmann.net
diff --git a/tests/root/etc/sysconfig/network-scripts/ifcfg-br0 b/tests/root/etc/sysconfig/network-scripts/ifcfg-br0
new file mode 100644 (file)
index 0000000..f609e1d
--- /dev/null
@@ -0,0 +1,5 @@
+# Intel Corporation 82573L Gigabit Ethernet Controller
+DEVICE=br0
+ONBOOT=yes
+BOOTPROTO=dhcp
+TYPE=Bridge
diff --git a/tests/root/etc/sysconfig/network-scripts/ifcfg-eth0 b/tests/root/etc/sysconfig/network-scripts/ifcfg-eth0
new file mode 100644 (file)
index 0000000..fddec4d
--- /dev/null
@@ -0,0 +1,7 @@
+# Intel Corporation 82573L Gigabit Ethernet Controller
+DEVICE=eth0
+#BOOTPROTO=dhcp
+HWADDR=XX:YY:ZZ:81:5B:0E
+ONBOOT=yes
+#DHCP_HOSTNAME=dhcp.example.com
+BRIDGE=br0
diff --git a/tests/root/etc/sysconfig/network-scripts/ifcfg-lo b/tests/root/etc/sysconfig/network-scripts/ifcfg-lo
new file mode 100644 (file)
index 0000000..cb4f3f9
--- /dev/null
@@ -0,0 +1,9 @@
+DEVICE=lo
+IPADDR=127.0.0.1
+NETMASK=255.0.0.0
+NETWORK=127.0.0.0
+# If you're having problems with gated making 127.0.0.0/8 a martian,
+# you can change this to something else (255.255.255.255, for example)
+BROADCAST=127.255.255.255
+ONBOOT=yes
+NAME=loopback
diff --git a/tests/root/etc/sysconfig/network-scripts/ifcfg-wlan0 b/tests/root/etc/sysconfig/network-scripts/ifcfg-wlan0
new file mode 100644 (file)
index 0000000..e20c26b
--- /dev/null
@@ -0,0 +1,5 @@
+# Intel Corporation PRO/Wireless 3945ABG Network Connection
+DEVICE=wlan0
+BOOTPROTO=dhcp
+ONBOOT=no
+HWADDR=XX:XX:XX:9f:88:96
diff --git a/tests/root/etc/sysconfig/nfs b/tests/root/etc/sysconfig/nfs
new file mode 100644 (file)
index 0000000..5e99161
--- /dev/null
@@ -0,0 +1,69 @@
+## Firewalling
+STATD_PORT=662
+STATD_OUTGOING_PORT=2020
+LOCKD_TCPPORT=32803
+LOCKD_UDPPORT=32769
+MOUNTD_PORT=892
+##
+#
+# Define which protocol versions mountd 
+# will advertise. The values are "no" or "yes"
+# with yes being the default
+#MOUNTD_NFS_V1="no"
+#MOUNTD_NFS_V2="no"
+#MOUNTD_NFS_V3="no"
+#
+#
+# Path to remote quota server. See rquotad(8)
+#RQUOTAD="/usr/sbin/rpc.rquotad"
+# Port rquotad should listen on.
+#RQUOTAD_PORT=875
+# Optinal options passed to rquotad
+#RPCRQUOTADOPTS=""
+#
+#
+# TCP port rpc.lockd should listen on.
+#LOCKD_TCPPORT=32803
+# UDP port rpc.lockd should listen on.
+#LOCKD_UDPPORT=32769
+#
+#
+# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
+#RPCNFSDARGS
+# Number of nfs server processes to be started.
+# The default is 8. 
+#RPCNFSDCOUNT=8
+#
+#
+# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
+#RPCMOUNTDOPTS=""
+# Port rpc.mountd should listen on.
+#MOUNTD_PORT=892
+#
+#
+# Optional arguments passed to rpc.statd. See rpc.statd(8)
+#STATDARG=""
+# Port rpc.statd should listen on.
+#STATD_PORT=662
+# Outgoing port statd should used. The default is port
+# is random
+#STATD_OUTGOING_PORT=2020
+# Specify callout program 
+#STATD_HA_CALLOUT="/usr/local/bin/foo"
+#
+#
+# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
+#RPCIDMAPDARGS=""
+#
+# Set to turn on Secure NFS mounts. 
+#SECURE_NFS="yes"
+# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
+#RPCGSSDARGS="-vvv"
+# Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)
+#RPCSVCGSSDARGS="-vvv"
+# Don't load security modules in to the kernel
+#SECURE_NFS_MODS="noload"
+#
+# Don't load sunrpc module.
+#RPCMTAB="noload"
+#
diff --git a/tests/root/etc/sysconfig/ntpd b/tests/root/etc/sysconfig/ntpd
new file mode 100644 (file)
index 0000000..b9fd41f
--- /dev/null
@@ -0,0 +1,8 @@
+# Drop root to id 'ntp:ntp' by default.
+OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid"
+
+# Set to 'yes' to sync hw clock after successful ntpdate
+SYNC_HWCLOCK=no
+
+# Additional options for ntpdate
+NTPDATE_OPTIONS=""
diff --git a/tests/root/etc/sysconfig/prelink b/tests/root/etc/sysconfig/prelink
new file mode 100644 (file)
index 0000000..db8c22f
--- /dev/null
@@ -0,0 +1,37 @@
+# Set this to no to disable prelinking altogether
+# (if you change this from yes to no prelink -ua
+# will be run next night to undo prelinking)
+PRELINKING=yes
+
+# Options to pass to prelink
+# -m   Try to conserve virtual memory by allowing overlapping
+#      assigned virtual memory slots for libraries which
+#      never appear together in one binary
+# -R   Randomize virtual memory slot assignments for libraries.
+#      This makes it slightly harder for various buffer overflow
+#      attacks, since library addresses will be different on each
+#      host using -R.
+PRELINK_OPTS=-mR
+
+# How often should full prelink be run (in days)
+# Normally, prelink will be run in quick mode, every
+# $PRELINK_FULL_TIME_INTERVAL days it will be run
+# in normal mode.  Comment it out if it should be run
+# in normal mode always.
+PRELINK_FULL_TIME_INTERVAL=14
+
+# How often should prelink run (in days) even if
+# no packages have been upgraded via rpm.
+# If $PRELINK_FULL_TIME_INTERVAL days have not elapsed
+# yet since last normal mode prelinking, last
+# quick mode prelinking happened less than
+# $PRELINK_NONRPM_CHECK_INTERVAL days ago
+# and no packages have been upgraded by rpm
+# since last quick mode prelinking, prelink
+# will not do anything.
+# Change to
+# PRELINK_NONRPM_CHECK_INTERVAL=0
+# if you want to disable the rpm database timestamp
+# check (especially if you don't use rpm/up2date/yum/apt-rpm
+# exclusively to upgrade system libraries and/or binaries).
+PRELINK_NONRPM_CHECK_INTERVAL=7
diff --git a/tests/root/etc/sysconfig/puppet b/tests/root/etc/sysconfig/puppet
new file mode 100644 (file)
index 0000000..3befdd4
--- /dev/null
@@ -0,0 +1,11 @@
+# The puppetmaster server
+#PUPPET_SERVER=puppet
+
+# If you wish to specify the port to connect to do so here
+#PUPPET_PORT=8140
+
+# Where to log to. Specify syslog to send log messages to the system log.
+#PUPPET_LOG=/var/log/puppet/puppet.log
+
+# You may specify other parameters to the puppet client here
+#PUPPET_EXTRA_OPTS=--waitforcert=500
diff --git a/tests/root/etc/sysconfig/readonly-root b/tests/root/etc/sysconfig/readonly-root
new file mode 100644 (file)
index 0000000..dbf1829
--- /dev/null
@@ -0,0 +1,17 @@
+# Set to 'yes' to mount the system filesystems read-only.
+READONLY=no
+# Set to 'yes' to mount various temporary state as either tmpfs
+# or on the block device labelled RW_LABEL. Implied by READONLY
+TEMPORARY_STATE=no
+# Place to put a tmpfs for temporary scratch writable space
+RW_MOUNT=/var/lib/stateless/writable
+# Label on local filesystem which can be used for temporary scratch space
+RW_LABEL=stateless-rw
+# Options to use for temporary mount
+RW_OPTIONS=
+# Label for partition with persistent data
+STATE_LABEL=stateless-state
+# Where to mount to the persistent data
+STATE_MOUNT=/var/lib/stateless/state
+# Options to use for peristent mount
+STATE_OPTIONS=
diff --git a/tests/root/etc/sysconfig/rsyslog b/tests/root/etc/sysconfig/rsyslog
new file mode 100644 (file)
index 0000000..7fa4b78
--- /dev/null
@@ -0,0 +1,16 @@
+# Options to syslogd
+# -m 0 disables 'MARK' messages.
+# -r enables logging from remote machines
+# -x disables DNS lookups on messages recieved with -r
+# See syslogd(8) for more details
+SYSLOGD_OPTIONS="-m 0"
+# Options to klogd
+# -2 prints all kernel oops messages twice; once for klogd to decode, and
+#    once for processing with 'ksymoops'
+# -x disables all klogd processing of oops messages entirely
+# See klogd(8) for more details
+KLOGD_OPTIONS="-x"
+#
+SYSLOG_UMASK=077
+# set this to a umask value to use for all log files as in umask(1).
+# By default, all permissions are removed for "group" and "other". 
diff --git a/tests/root/etc/sysconfig/samba b/tests/root/etc/sysconfig/samba
new file mode 100644 (file)
index 0000000..944b72f
--- /dev/null
@@ -0,0 +1,6 @@
+# Options to smbd
+SMBDOPTIONS="-D"
+# Options to nmbd
+NMBDOPTIONS="-D"
+# Options for winbindd
+WINBINDOPTIONS=""
diff --git a/tests/root/etc/sysconfig/saslauthd b/tests/root/etc/sysconfig/saslauthd
new file mode 100644 (file)
index 0000000..08e4373
--- /dev/null
@@ -0,0 +1,11 @@
+# Directory in which to place saslauthd's listening socket, pid file, and so
+# on.  This directory must already exist.
+SOCKETDIR=/var/run/saslauthd
+
+# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list
+# of which mechanism your installation was compiled with the ablity to use.
+MECH=pam
+
+# Additional flags to pass to saslauthd on the command line.  See saslauthd(8)
+# for the list of accepted flags.
+FLAGS=
diff --git a/tests/root/etc/sysconfig/smartmontools b/tests/root/etc/sysconfig/smartmontools
new file mode 100644 (file)
index 0000000..75d591c
--- /dev/null
@@ -0,0 +1,4 @@
+# command line options for smartd
+smartd_opts="-q never"
+# autogenerated config file options
+# smartd_conf_opts="-H -m root"
diff --git a/tests/root/etc/sysconfig/spamassassin b/tests/root/etc/sysconfig/spamassassin
new file mode 100644 (file)
index 0000000..70b21ed
--- /dev/null
@@ -0,0 +1,2 @@
+# Options to spamd
+SPAMDOPTIONS="-d -c -m5 -H"
diff --git a/tests/root/etc/sysconfig/sysstat b/tests/root/etc/sysconfig/sysstat
new file mode 100644 (file)
index 0000000..5aeb175
--- /dev/null
@@ -0,0 +1,2 @@
+# How long to keep log files (days), maximum is a month
+HISTORY=7
diff --git a/tests/root/etc/sysconfig/sysstat.ioconf b/tests/root/etc/sysconfig/sysstat.ioconf
new file mode 100644 (file)
index 0000000..cf3840e
--- /dev/null
@@ -0,0 +1,240 @@
+#
+# sysstat.ioconf
+#
+#  Copyright (C) 2004, Red Hat, Inc.
+#
+#  This file gives iostat and sadc a clue about how to find whole
+#   disk devices in /proc/partitions and /proc/diskstats
+#
+# line format, general record:
+#   major:name:ctrlpre:ctrlno:devfmt:devcnt:partpre:partcnt:description
+#
+#  major:              major # for device
+#  name:               base of device name
+#  ctrlpre:            string to use in generating controller designators
+#                       eg: the c in c0d2p6, decimal formatting implied
+#                        '*' means none or irrelevant
+#  ctrlno:             which controller of this type is this
+#  devfmt:             type of device naming convention
+#      a:              alpha: xxa, xxb, ... xxaa, xxab, ... xxzz
+#       x:             exception... record contains a specific name
+#                        for a specific minor #, stored in the devcnt field
+#      %string:        string to use in generating drive designators,
+#                       eg: the 'd' in c0d2p6 , decimal formatting implied
+#      d:              no special translations (decimal formatting)
+#  devcnt:             how many whole devs per major number
+#  partpre:            appended to whole dev before part designator
+#                        eg. the p in c0d2p6, decimal formatting implied
+#                       '*' means none
+#  partcnt:            number of partitions per volume
+#                       or minor # for exception records
+#  description:                informative text
+#
+# line format, indirect record:
+#   major:base_major:ctrlno[:[desc]]
+#
+#  major:              major number of the device
+#  base_major:         major number of the template for this type,
+#                       0 for not supported
+#  ctrlno:             controller number of this type
+#  desc:               controller-specific description
+#                      if absent the desc from base_major will be
+#                       used in sprintf( buf, desc, ctrlno )
+
+
+1:ram:*:0:d:256:*:1:RAM disks (ram0..ram255)
+1:initrd:x:250:d:256:*:1:Initial RAM Disk (initrd)
+
+#2:0:0:Floppy Devices
+2:fd:*:0:d:4:*:1:Floppy Devices fd0,fd1,fd2,fd3
+
+3:hd:*:0:a:2:*:64:IDE - Controller %d
+22:3:1:
+33:3:2:
+34:3:3:
+56:3:4:
+57:3:5:
+88:3:6:
+89:3:7:
+90:3:8:
+91:3:9:
+
+#4:0:0:NODEV
+#5:0:0:NODEV
+#6:0:0:NODEV
+7:loop:*:0:d:256:*:1:Loop Devices 
+
+8:sd:*:0:a:16:*:16:SCSI - Controller %d
+65:8:1:
+66:8:2:
+67:8:3:
+68:8:4:
+69:8:5:
+70:8:6:
+71:8:7:
+
+9:md:*:0:d:256:*:1:Metadisk (Software RAID) devices  (md0..md255)
+
+#10:0:0:NODEV
+
+11:sr:*:0:d:256:*:1:CDROM - CDROM (sr0..sr255)
+
+#12:0:0:MSCDEX CD-ROM Callback
+
+13:xd:*:0:a:2:*:64:8-bit MFM/RLL/IDE controller (xda, xdb)
+
+#14:0:0:BIOS Hard Drive Callback
+#15:0:0:CDROM - Sony CDU-31A/CDU-33A
+#16:0:0:CDROM - Goldstar
+#17:0:0:CDROM - Optics Storage
+#18:0:0:CDROM - Sanyo
+
+19:double:*:0:d:256:*:1:Compressed Disk (double0..double255)
+
+#20:0:0:CDROM - Hitachi
+
+21:mfm:*:0:a:2:*:64:Acorn MFM Hard Drive (mfma, mfmb)
+
+# 22: see IDE, dev 3
+
+#23:0:0:CDROM - Mistumi Proprietary
+#24:0:0:CDROM - Sony CDU-535
+#25:0:0:CDROM - Matsushita (Panasonic/Soundblaster) #1
+#26:0:1:CDROM - Matsushita (Panasonic/Soundblaster) #2
+#27:0:2:CDROM - Matsushita (Panasonic/Soundblaster) #3
+#28:0:3:CDROM - Matsushita (Panasonic/Soundblaster) #4
+# 28:0:0:! ACSI (Atari) Disk Not Supported
+#29:0:0:CDROM - Aztech/Orchid/Okano/Wearnes
+#30:0:0:CDROM - Philips LMS CM-205
+#31:0:0:ROM/flash Memory Card
+#32:0:0:CDROM -  Phillips LMS CM-206
+
+# 33: See IDE, dev 3
+# 34: See IDE, dev 3
+
+#35:0:0:Slow Memory RAM Disk
+
+36:ed:*:0:a:2:*:64:MCA ESDI Hard Disk (eda, edb)
+
+#37:0:0:Zorro II Ram Disk
+#38:0:0:Reserved For Linux/AP+
+#39:0:0:Reserved For Linux/AP+
+#40:0:0:Syquest EZ135 Parallel Port Drive
+#41:0:0:CDROM -  MicroSolutions Parallel Port BackPack
+#42:0:0:For DEMO Use Only
+
+43:nb:*:0:d:256:*:1:Network Block devices (nb0..nb255)
+44:ftl:*:0:a:16:*:16:Flash Translation Layer (ftla..ftlp)
+45:pd:*:0:a:4:*:16:Parallel Port IDE (pda..pdd)
+
+#46:0:0:CDROM - Parallel Port ATAPI
+
+47:pf:*:0:d:256:*:1:Parallel Port ATAPI Disk Devices (pf0..pf255)
+
+48:rd:/c:0:%d:32:p:8:Mylex DAC960 RAID, Controller %d
+49:48:1:
+50:48:2:
+51:48:3:
+52:48:4:
+53:48:5:
+54:48:6:
+55:48:7:
+
+# 56, 57: see IDE, dev 3:
+
+58:lvm:*:0:d:256:*:1:Logical Volume Manager (lvm0..lvm255)
+
+#59:0:0:PDA Filesystem Device
+#60:0:0:Local/Experimental Use
+#61:0:0:Local/Experimental Use
+#62:0:0:Local/Experimental Use
+#63:0:0:Local/Experimental Use
+#64:0:0:NODEV
+
+# 65..71: See SCSI, dev 8:
+
+72:ida/:c:0:%d:16:p:16:Compaq Intelligent Drive Array - Controller %d
+73:72:1:
+74:72:2:
+75:72:3:
+76:72:4:
+77:72:5:
+78:72:6:
+79:72:7:
+
+80:i2o/hd:*:0:a:16:*:16:I2O Disk - Controller %d
+81:80:1:
+82:80:2:
+83:80:3:
+84:80:4:
+85:80:5:
+86:80:6:
+87:80:7:
+
+# 88..91: see IDE, dev 3:
+
+#92:0:0:PPDD Encrypted Disk
+#93:0:0:NAND Flash Translation Layer not supported
+
+94:dasd:*:0:a:64:*:4:IBM S/390 DASD Block Storage (dasda, dasdb, ...)
+
+#95:0:0:IBM S/390 VM/ESA Minidisk
+#96:0:0:NODEV
+#97:0:0:CD/DVD packed writing devices not supported
+
+98:ubd:*:0:d:256:*:1:User-mode Virtual Block Devices (ubd0..ubd256)
+
+#99:0:0:JavaStation Flash Disk
+#100:0:0:NODEV
+
+101:amiraid/ar:*:0:d:16:p:16:AMI HyperDisk RAID (amiraid/ar0 - amiraid/ar15)
+
+#102:0:0:Compressed Block Device
+#103:0:0:Audit Block Device
+
+104:cciss:/c:0:%d:16:p:16:HP SA 5xxx/6xxx (cciss) Controller %d
+105:104:1:
+106:104:2:
+107:104:3:
+108:104:4:
+109:104:5:
+110:104:6:
+111:104:7:
+
+112:iseries/vd:*:0:a:32:*:8:IBM iSeries Virtual Disk (.../vda - .../vdaf)
+
+#113:0:0:CDROM - IBM iSeries Virtual
+
+# 114..159 NODEV
+
+160:sx8/:*:0:d:8:p:32:Promise SATA SX8 Unit %d
+161:160:1:
+
+# 162..198 UNUSED
+
+#199:0:0:Veritas Volume Manager (VxVM) Volumes
+#200:0:0:NODEV
+#201:0:0:Veritas VxVM Dynamic Multipathing Driver
+
+# 202..230: UNUSED
+
+232:emcpower:*:0:a:16:*:16:EMC PowerPath Unit %d
+233:232:1:
+234:232:2:
+235:232:3:
+236:232:4:
+237:232:5:
+238:232:6:
+239:232:7:
+240:232:8:
+241:232:9:
+242:232:10:
+243:232:11:
+244:232:12:
+245:232:13:
+246:232:14:
+247:232:15:
+
+# 240..254: LOCAL/Experimental
+# 255: reserved for big dev_t expansion
+
diff --git a/tests/root/etc/sysconfig/system-config-firewall b/tests/root/etc/sysconfig/system-config-firewall
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/root/etc/sysconfig/system-config-securitylevel b/tests/root/etc/sysconfig/system-config-securitylevel
new file mode 100644 (file)
index 0000000..765169c
--- /dev/null
@@ -0,0 +1,5 @@
+# Configuration file for system-config-securitylevel
+
+--enabled
+--port=22:tcp
+--port=2049:tcp
diff --git a/tests/root/etc/sysconfig/system-config-users b/tests/root/etc/sysconfig/system-config-users
new file mode 100644 (file)
index 0000000..a7d75b6
--- /dev/null
@@ -0,0 +1,10 @@
+# Configuration file for system-config-users
+
+# Filter out system users
+FILTER=true
+# Automatically assign highest UID for new users
+ASSIGN_HIGHEST_UID=true
+# Automatically assign highest GID for new groups
+ASSIGN_HIGHEST_GID=true
+# Prefer to have same UID and GID for new users
+PREFER_SAME_UID_GID=true
diff --git a/tests/root/etc/sysconfig/vncservers b/tests/root/etc/sysconfig/vncservers
new file mode 100644 (file)
index 0000000..31536f6
--- /dev/null
@@ -0,0 +1,21 @@
+# The VNCSERVERS variable is a list of display:user pairs.
+#
+# Uncomment the lines below to start a VNC server on display :2
+# as my 'myusername' (adjust this to your own).  You will also
+# need to set a VNC password; run 'man vncpasswd' to see how
+# to do that.  
+#
+# DO NOT RUN THIS SERVICE if your local area network is
+# untrusted!  For a secure way of using VNC, see
+# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
+
+# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
+
+# Use "-nohttpd" to prevent web-based VNC clients connecting.
+
+# Use "-localhost" to prevent remote VNC clients connecting except when
+# doing so through a secure tunnel.  See the "-via" option in the
+# `man vncviewer' manual page.
+
+# VNCSERVERS="2:myusername"
+# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
diff --git a/tests/root/etc/sysconfig/wpa_supplicant b/tests/root/etc/sysconfig/wpa_supplicant
new file mode 100644 (file)
index 0000000..402bac1
--- /dev/null
@@ -0,0 +1,6 @@
+# wlan0 and wifi0
+# INTERFACES="-iwlan0 -iwifi0"
+INTERFACES="-iwlan0"
+# ndiswrapper and prism
+# DRIVERS="-Dndiswrapper -Dprism"
+DRIVERS="-Dwext"
diff --git a/tests/root/etc/sysconfig/xend b/tests/root/etc/sysconfig/xend
new file mode 100644 (file)
index 0000000..19b82df
--- /dev/null
@@ -0,0 +1,16 @@
+
+#XENSTORED_PID="/var/run/xenstore.pid"
+#XENSTORED_ARGS=
+
+# Log all hypervisor messages (cf xm dmesg)
+#XENCONSOLED_LOG_HYPERVISOR=no
+
+# Log all guest console output (cf xm console)
+#XENCONSOLED_LOG_GUESTS=no
+
+# Location to store guest & hypervisor logs
+#XENCONSOLED_LOG_DIR=/var/log/xen/console
+
+#XENCONSOLED_ARGS=
+
+#BLKTAPCTRL_ARGS=
diff --git a/tests/root/etc/sysconfig/xendomains b/tests/root/etc/sysconfig/xendomains
new file mode 100644 (file)
index 0000000..e93b1a4
--- /dev/null
@@ -0,0 +1,137 @@
+## Path: System/xen
+## Description: xen domain start/stop on boot
+## Type: string
+## Default: 
+#
+# The xendomains script can send SysRq requests to domains on shutdown.
+# If you don't want to MIGRATE, SAVE, or SHUTDOWN, this may be a possibility
+# to do a quick and dirty shutdown ("s e i u o") or at least sync the disks
+# of the domains ("s").
+#
+XENDOMAINS_SYSRQ=""
+
+## Type: integer 
+## Default: 100000
+#
+# If XENDOMAINS_SYSRQ is set, this variable determines how long to wait
+# (in microseconds) after each SysRq, so the domain has a chance to react.
+# If you want to a quick'n'dirty shutdown via SysRq, you may want to set
+# it to a relatively high value (1200000).
+#
+XENDOMAINS_USLEEP=100000
+
+## Type: integer
+## Default: 5000000
+#
+# When creating a guest domain, it is sensible to allow a little time for it
+# to get started before creating another domain or proceeding through the
+# boot process.  Without this, the booting guests will thrash the disk as they
+# start up.  This timeout (in microseconds) specifies the delay after guest
+# domain creation.
+#
+XENDOMAINS_CREATE_USLEEP=5000000
+
+## Type: string
+## Default: ""
+#
+# Set this to a non-empty string if you want to migrate virtual machines
+# on shutdown. The string will be passed to the xm migrate DOMID command
+# as is: It should contain the target IP address of the physical machine
+# to migrate to and optionally parameters like --live. Leave empty if
+# you don't want to try virtual machine relocation on shutdown.
+# If migration succeeds, neither SAVE nor SHUTDOWN will be executed for
+# that domain.
+#
+XENDOMAINS_MIGRATE=""
+
+## Type: string
+## Default: /var/lib/xen/save
+#
+# Directory to save running domains to when the system (dom0) is
+# shut down. Will also be used to restore domains from if # XENDOMAINS_RESTORE
+# is set (see below). Leave empty to disable domain saving on shutdown 
+# (e.g. because you rather shut domains down).
+# If domain saving does succeed, SHUTDOWN will not be executed.
+#
+XENDOMAINS_SAVE=/var/lib/xen/save
+
+## Type: string
+## Default: "--halt --wait"
+#
+# If neither MIGRATE nor SAVE were enabled or if they failed, you can
+# try to shut down a domain by sending it a shutdown request. To do this,
+# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting
+# for the domain to be really down. Leave empty to skip domain shutdown.
+#
+XENDOMAINS_SHUTDOWN="--halt --wait"
+
+## Type: string
+## Default: "--all --halt --wait"
+#
+# After we have gone over all virtual machines (resp. all automatically
+# started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq,
+# migrated, saved and/or shutdown according to the settings above, we
+# might want to shutdown the virtual machines that are still running
+# for some reason or another. To do this, set this variable to
+# "--all --halt --wait", it will be passed to xm shutdown.
+# Leave it empty not to do anything special here.
+# (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY
+# is set.)
+# 
+XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait"
+
+## Type: boolean
+## Default: true
+#
+# This variable determines whether saved domains from XENDOMAINS_SAVE
+# will be restored on system startup. 
+#
+XENDOMAINS_RESTORE=true
+
+## Type: string
+## Default: /etc/xen/auto
+#
+# This variable sets the directory where domains configurations
+# are stored that should be started on system startup automatically.
+# Leave empty if you don't want to start domains automatically
+# (or just don't place any xen domain config files in that dir).
+# Note that the script tries to be clever if both RESTORE and AUTO are 
+# set: It will first restore saved domains and then only start domains
+# in AUTO which are not running yet. 
+# Note that the name matching is somewhat fuzzy.
+#
+XENDOMAINS_AUTO=/etc/xen/auto
+
+## Type: boolean
+## Default: false
+# 
+# If this variable is set to "true", only the domains started via config 
+# files in XENDOMAINS_AUTO will be treated according to XENDOMAINS_SYSRQ,
+# XENDOMAINS_MIGRATE, XENDOMAINS_SAVE, XENDMAINS_SHUTDOWN; otherwise
+# all running domains will be. 
+# Note that the name matching is somewhat fuzzy.
+# 
+XENDOMAINS_AUTO_ONLY=false
+
+## Type: integer
+## Default: 300
+#
+# On xendomains stop, a number of xm commands (xm migrate, save, shutdown,
+# shutdown --all) may be executed. In the worst case, these commands may
+# stall forever, which will prevent a successful shutdown of the machine.
+# If this variable is non-zero, the script will set up a watchdog timer
+# for every of these xm commands and time it out after the number of seconds
+# specified by this variable.
+# Note that SHUTDOWN_ALL will not be called if no virtual machines or only
+# zombies are still running, so you don't need to enable this timeout just
+# for the zombie case.
+# The setting should be large enough to make sure that migrate/save/shutdown
+# can succeed. If you do live migrations, keep in mind that live migration
+# of a 1GB machine over Gigabit ethernet may actually take something like
+# 100s (assuming that live migration uses 10% of the network # bandwidth).
+# Depending on the virtual machine, a shutdown may also require a significant
+# amount of time. So better setup this variable to a huge number and hope the
+# watchdog never fires.
+#
+XENDOMAINS_STOP_MAXWAIT=300
+
diff --git a/tests/root/etc/sysctl.conf b/tests/root/etc/sysctl.conf
new file mode 100644 (file)
index 0000000..db98922
--- /dev/null
@@ -0,0 +1,20 @@
+# Kernel sysctl configuration file for Red Hat Linux
+#
+# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
+# sysctl.conf(5) for more details.
+
+# Controls IP packet forwarding
+net.ipv4.ip_forward = 0
+
+# Controls source route verification
+net.ipv4.conf.default.rp_filter = 1
+
+# Do not accept source routing
+net.ipv4.conf.default.accept_source_route = 0
+
+# Controls the System Request debugging functionality of the kernel
+kernel.sysrq = 0
+
+# Controls whether core dumps will append the PID to the core filename.
+# Useful for debugging multi-threaded applications.
+kernel.core_uses_pid = 1
diff --git a/tests/root/etc/vsftpd.conf b/tests/root/etc/vsftpd.conf
new file mode 100644 (file)
index 0000000..5470b6e
--- /dev/null
@@ -0,0 +1,29 @@
+# Standalone mode
+listen=YES
+max_clients=200
+max_per_ip=4
+# Access rights
+anonymous_enable=YES
+local_enable=NO
+write_enable=NO
+anon_upload_enable=NO
+anon_mkdir_write_enable=NO
+anon_other_write_enable=NO
+# Security
+anon_world_readable_only=YES
+connect_from_port_20=YES
+hide_ids=YES
+pasv_min_port=50000
+pasv_max_port=60000
+# Features
+xferlog_enable=YES
+ls_recurse_enable=NO
+ascii_download_enable=NO
+async_abor_enable=YES
+# Performance
+one_process_model=YES
+idle_session_timeout=120
+data_connection_timeout=300
+accept_timeout=60
+connect_timeout=60
+anon_max_rate=50000
diff --git a/tests/root/etc/xinetd.conf b/tests/root/etc/xinetd.conf
new file mode 100644 (file)
index 0000000..41904e0
--- /dev/null
@@ -0,0 +1,50 @@
+#
+# This is the master xinetd configuration file. Settings in the
+# default section will be inherited by all service configurations
+# unless explicitly overridden in the service configuration. See
+# xinetd.conf in the man pages for a more detailed explanation of
+# these attributes.
+
+defaults
+{
+# The next two items are intended to be a quick access place to
+# temporarily enable or disable services.
+#
+#      enabled         =
+#      disabled        =
+
+# Define general logging characteristics.
+       log_type        = SYSLOG daemon info 
+       log_on_failure  = HOST
+       log_on_success  = PID HOST DURATION EXIT
+
+# Define access restriction defaults
+#
+#      no_access       =
+#      only_from       =
+#      max_load        = 0
+       cps             = 50 10
+       instances       = 50
+       per_source      = 10
+
+# Address and networking defaults
+#
+#      bind            =
+#      mdns            = yes
+       v6only          = no
+
+# setup environmental attributes
+#
+#      passenv         =
+       groups          = yes
+       umask           = 002
+
+# Generally, banners are not used. This sets up their global defaults
+#
+#      banner          =
+#      banner_fail     =
+#      banner_success  =
+}
+
+includedir /etc/xinetd.d
diff --git a/tests/root/etc/xinetd.d/cvs b/tests/root/etc/xinetd.d/cvs
new file mode 100644 (file)
index 0000000..6c4984f
--- /dev/null
@@ -0,0 +1,19 @@
+# default: off
+# description: The CVS service can record the history of your source \
+#              files. CVS stores all the versions of a file in a single \
+#              file in a clever way that only stores the differences \
+#              between versions.
+service cvspserver
+{
+       disable                 = yes
+       port                    = 2401
+       socket_type             = stream
+       protocol                = tcp
+       wait                    = no
+       user                    = root
+       passenv                 = PATH
+       server                  = /usr/bin/cvs
+       env                     = HOME=/var/cvs
+       server_args             = -f --allow-root=/var/cvs pserver
+#      bind                    = 127.0.0.1
+}
diff --git a/tests/root/etc/xinetd.d/rsync b/tests/root/etc/xinetd.d/rsync
new file mode 100644 (file)
index 0000000..d4b591e
--- /dev/null
@@ -0,0 +1,14 @@
+# default: off
+# description: The rsync server is a good addition to an ftp server, as it \
+#      allows crc checksumming etc.
+service rsync
+{
+       disable = yes
+       flags           = IPv6
+       socket_type     = stream
+       wait            = no
+       user            = root
+       server          = /usr/bin/rsync
+       server_args     = --daemon
+       log_on_failure  += USERID
+}
diff --git a/tests/root/etc/yum.conf b/tests/root/etc/yum.conf
new file mode 100644 (file)
index 0000000..9660673
--- /dev/null
@@ -0,0 +1,15 @@
+[main]
+cachedir=/var/cache/yum
+keepcache=0
+debuglevel=2
+logfile=/var/log/yum.log
+exactarch=1
+obsoletes=1
+gpgcheck=1
+plugins=1
+metadata_expire=1800
+
+installonly_limit=100
+
+# PUT YOUR REPOS HERE OR IN separate files named file.repo
+# in /etc/yum.repos.d
diff --git a/tests/root/etc/yum.repos.d/fedora-updates.repo b/tests/root/etc/yum.repos.d/fedora-updates.repo
new file mode 100644 (file)
index 0000000..f451ba7
--- /dev/null
@@ -0,0 +1,26 @@
+[updates]
+name=Fedora $releasever - $basearch - Updates
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/$releasever/$basearch/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
+
+[updates-debuginfo]
+name=Fedora $releasever - $basearch - Updates - Debug
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/$releasever/$basearch/debug/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-debug-f$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
+
+[updates-source]
+name=Fedora $releasever - Updates Source
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/$releasever/SRPMS/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-source-f$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
diff --git a/tests/root/etc/yum.repos.d/fedora.repo b/tests/root/etc/yum.repos.d/fedora.repo
new file mode 100644 (file)
index 0000000..a8ce2c0
--- /dev/null
@@ -0,0 +1,26 @@
+[fedora]
+name=Fedora $releasever - $basearch
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+[fedora-debuginfo]
+name=Fedora $releasever - $basearch - Debug
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+[fedora-source]
+name=Fedora $releasever - Source
+failovermethod=priority
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
diff --git a/tests/root/etc/yum.repos.d/remi.repo b/tests/root/etc/yum.repos.d/remi.repo
new file mode 100644 (file)
index 0000000..ea0eeee
--- /dev/null
@@ -0,0 +1,16 @@
+[remi]
+name=Les RPM de remi pour FC$releasever - $basearch
+baseurl=http://remi.collet.free.fr/rpms/fc$releasever.$basearch/
+       http://iut-info.ens.univ-reims.fr/remirpms/fc$releasever.$basearch/
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
+
+[remi-test]
+name=Les RPM de remi en test pour FC$releasever - $basearch
+baseurl=http://remi.collet.free.fr/rpms/test-fc$releasever.$basearch/
+       http://iut-info.ens.univ-reims.fr/remirpms/test-fc$releasever.$basearch/
+enabled=0
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
+
diff --git a/tests/root/pairs.txt b/tests/root/pairs.txt
new file mode 100644 (file)
index 0000000..c00b6cb
--- /dev/null
@@ -0,0 +1,3 @@
+key1=value1
+key2 = value2
+key3= value3
diff --git a/tests/test-api.c b/tests/test-api.c
new file mode 100644 (file)
index 0000000..54b4c7d
--- /dev/null
@@ -0,0 +1,376 @@
+/*
+ * test-api.c: test public API functions for conformance
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "augeas.h"
+
+#include "cutest.h"
+#include "internal.h"
+
+#include <unistd.h>
+
+static const char *abs_top_srcdir;
+static char *root;
+static char *loadpath;
+
+#define die(msg)                                                    \
+    do {                                                            \
+        fprintf(stderr, "%d: Fatal error: %s\n", __LINE__, msg);    \
+        exit(EXIT_FAILURE);                                         \
+    } while(0)
+
+static void testGet(CuTest *tc) {
+    int r;
+    const char *value;
+    struct augeas *aug;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    /* Make sure we're looking at the right thing */
+    r = aug_match(aug, "/augeas/version/save/*", NULL);
+    CuAssertTrue(tc, r > 1);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    /* aug_get returns 1 and the value if exactly one node matches */
+    r = aug_get(aug, "/augeas/version/save/*[1]", &value);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertPtrNotNull(tc, value);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    /* aug_get returns 0 and no value when no node matches */
+    r = aug_get(aug, "/augeas/version/save/*[ last() + 1 ]", &value);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertPtrEquals(tc, NULL, value);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    /* aug_get should return an error when multiple nodes match */
+    r = aug_get(aug, "/augeas/version/save/*", &value);
+    CuAssertIntEquals(tc, -1, r);
+    CuAssertPtrEquals(tc, NULL, value);
+    CuAssertIntEquals(tc, AUG_EMMATCH, aug_error(aug));
+
+    aug_close(aug);
+}
+
+static void testSetM(CuTest *tc) {
+    int r;
+    struct augeas *aug;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    /* Change base nodes when SUB is NULL */
+    r = aug_setm(aug, "/augeas/version/save/*", NULL, "changed");
+    CuAssertIntEquals(tc, 4, r);
+
+    r = aug_match(aug, "/augeas/version/save/*[. = 'changed']", NULL);
+    CuAssertIntEquals(tc, 4, r);
+
+    /* Only change existing nodes */
+    r = aug_setm(aug, "/augeas/version/save", "mode", "again");
+    CuAssertIntEquals(tc, 4, r);
+
+    r = aug_match(aug, "/augeas/version/save/*", NULL);
+    CuAssertIntEquals(tc, 4, r);
+
+    r = aug_match(aug, "/augeas/version/save/*[. = 'again']", NULL);
+    CuAssertIntEquals(tc, 4, r);
+
+    /* Create a new node */
+    r = aug_setm(aug, "/augeas/version/save", "mode[last() + 1]", "newmode");
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_match(aug, "/augeas/version/save/*", NULL);
+    CuAssertIntEquals(tc, 5, r);
+
+    r = aug_match(aug, "/augeas/version/save/*[. = 'again']", NULL);
+    CuAssertIntEquals(tc, 4, r);
+
+    r = aug_match(aug, "/augeas/version/save/*[last()][. = 'newmode']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    /* Noexistent base */
+    r = aug_setm(aug, "/augeas/version/save[last()+1]", "mode", "newmode");
+    CuAssertIntEquals(tc, 0, r);
+
+    /* Invalid path expressions */
+    r = aug_setm(aug, "/augeas/version/save[]", "mode", "invalid");
+    CuAssertIntEquals(tc, -1, r);
+
+    r = aug_setm(aug, "/augeas/version/save/*", "mode[]", "invalid");
+    CuAssertIntEquals(tc, -1, r);
+
+    aug_close(aug);
+}
+
+/* Check that defining a variable leads to a corresponding entry in
+ * /augeas/variables and that that entry disappears when the variable is
+ * undefined */
+static void testDefVarMeta(CuTest *tc) {
+    int r;
+    struct augeas *aug;
+    static const char *const expr = "/augeas/version/save/mode";
+    const char *value;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    r = aug_defvar(aug, "var", expr);
+    CuAssertIntEquals(tc, 4, r);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_get(aug, "/augeas/variables/var", &value);
+    CuAssertStrEquals(tc, expr, value);
+
+    r = aug_defvar(aug, "var", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    aug_close(aug);
+}
+
+/* Check that defining a variable with defnode leads to a corresponding
+ * entry in /augeas/variables and that that entry disappears when the
+ * variable is undefined
+ */
+static void testDefNodeExistingMeta(CuTest *tc) {
+    int r, created;
+    struct augeas *aug;
+    static const char *const expr = "/augeas/version/save/mode";
+    const char *value;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    r = aug_defnode(aug, "var", expr, "other", &created);
+    CuAssertIntEquals(tc, 4, r);
+    CuAssertIntEquals(tc, 0, created);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_get(aug, "/augeas/variables/var", &value);
+    CuAssertStrEquals(tc, expr, value);
+
+    r = aug_defvar(aug, "var", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    aug_close(aug);
+}
+
+/* Check that defining a variable with defnode leads to a corresponding
+ * entry in /augeas/variables and that that entry disappears when the
+ * variable is undefined
+ */
+static void testDefNodeCreateMeta(CuTest *tc) {
+    int r, created;
+    struct augeas *aug;
+    static const char *const expr = "/augeas/version/save/mode[last()+1]";
+    static const char *const expr_can = "/augeas/version/save/mode[5]";
+    const char *value;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+    CuAssertIntEquals(tc, AUG_NOERROR, aug_error(aug));
+
+    r = aug_defnode(aug, "var", expr, "other", &created);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertIntEquals(tc, 1, created);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_get(aug, "/augeas/variables/var", &value);
+    CuAssertStrEquals(tc, expr_can, value);
+
+    r = aug_defvar(aug, "var", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_match(aug, "/augeas/variables/*", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    aug_close(aug);
+}
+
+static void reset_indexes(uint *a, uint *b, uint *c, uint *d, uint *e, uint *f) {
+    *a = 0; *b = 0; *c = 0; *d = 0; *e = 0; *f = 0;
+}
+
+#define SPAN_TEST_DEF_LAST { .expr = NULL, .ls = 0, .le = 0, \
+        .vs = 0, .ve = 0, .ss = 0, .se = 0 }
+
+struct span_test_def {
+    const char *expr;
+    const char *f;
+    int ret;
+    int ls;
+    int le;
+    int vs;
+    int ve;
+    int ss;
+    int se;
+};
+
+static const struct span_test_def span_test[] = {
+    { .expr = "/files/etc/hosts/1/ipaddr", .f = "hosts", .ret = 0, .ls = 0, .le = 0, .vs = 104, .ve = 113, .ss = 104, .se = 113 },
+    { .expr = "/files/etc/hosts/1", .f = "hosts", .ret = 0, .ls = 0, .le = 0, .vs = 0, .ve = 0, .ss = 104, .se = 171 },
+    { .expr = "/files/etc/hosts/*[last()]", .f = "hosts", .ret = 0, .ls = 0, .le = 0, .vs = 0, .ve = 0, .ss = 266, .se = 309 },
+    { .expr = "/files/etc/hosts/#comment[2]", .f = "hosts", .ret = 0, .ls = 0, .le = 0, .vs = 58, .ve = 103, .ss = 56, .se = 104 },
+    { .expr = "/files/etc/hosts", .f = "hosts", .ret = 0, .ls = 0, .le = 0, .vs = 0, .ve = 0, .ss = 0, .se = 309 },
+    { .expr = "/files", .f = NULL, .ret = -1, .ls = 0, .le = 0, .vs = 0, .ve = 0, .ss = 0, .se = 0 },
+    { .expr = "/random", .f = NULL, .ret = -1, .ls = 0, .le = 0, .vs = 0, .ve = 0, .ss = 0, .se = 0 },
+    SPAN_TEST_DEF_LAST
+};
+
+static void testNodeInfo(CuTest *tc) {
+    int ret;
+    int i = 0;
+    struct augeas *aug;
+    struct span_test_def test;
+    char *fbase;
+    char msg[1024];
+    static const char *const expr = "/files/etc/hosts/1/ipaddr";
+
+    char *filename_ac;
+    uint label_start, label_end, value_start, value_end, span_start, span_end;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD|AUG_ENABLE_SPAN);
+    ret = aug_load(aug);
+    CuAssertRetSuccess(tc, ret);
+
+    while(span_test[i].expr != NULL) {
+        test = span_test[i];
+        i++;
+        ret = aug_span(aug, test.expr, &filename_ac, &label_start, &label_end,
+                     &value_start, &value_end, &span_start, &span_end);
+        sprintf(msg, "span_test %d ret\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.ret, ret);
+        sprintf(msg, "span_test %d label_start\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.ls, label_start);
+        sprintf(msg, "span_test %d label_end\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.le, label_end);
+        sprintf(msg, "span_test %d value_start\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.vs, value_start);
+        sprintf(msg, "span_test %d value_end\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.ve, value_end);
+        sprintf(msg, "span_test %d span_start\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.ss, span_start);
+        sprintf(msg, "span_test %d span_end\n", i);
+        CuAssertIntEquals_Msg(tc, msg, test.se, span_end);
+        if (filename_ac != NULL) {
+            fbase = basename(filename_ac);
+        } else {
+            fbase = NULL;
+        }
+        sprintf(msg, "span_test %d filename\n", i);
+        CuAssertStrEquals_Msg(tc, msg, test.f, fbase);
+        free(filename_ac);
+        filename_ac = NULL;
+        reset_indexes(&label_start, &label_end, &value_start, &value_end,
+                      &span_start, &span_end);
+    }
+
+    /* aug_span returns -1 and when no node matches */
+    ret = aug_span(aug, "/files/etc/hosts/*[ last() + 1 ]", &filename_ac,
+            &label_start, &label_end, &value_start, &value_end,
+            &span_start, &span_end);
+    CuAssertIntEquals(tc, -1, ret);
+    CuAssertPtrEquals(tc, NULL, filename_ac);
+    CuAssertIntEquals(tc, AUG_ENOMATCH, aug_error(aug));
+
+    /* aug_span should return an error when multiple nodes match */
+    ret = aug_span(aug, "/files/etc/hosts/*", &filename_ac,
+            &label_start, &label_end, &value_start, &value_end,
+            &span_start, &span_end);
+    CuAssertIntEquals(tc, -1, ret);
+    CuAssertPtrEquals(tc, NULL, filename_ac);
+    CuAssertIntEquals(tc, AUG_EMMATCH, aug_error(aug));
+
+    /* aug_span returns -1 if nodes span are not loaded */
+    aug_close(aug);
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    ret = aug_load(aug);
+    CuAssertRetSuccess(tc, ret);
+    ret = aug_span(aug, expr, &filename_ac, &label_start, &label_end,
+                 &value_start, &value_end, &span_start, &span_end);
+    CuAssertIntEquals(tc, -1, ret);
+    CuAssertPtrEquals(tc, NULL, filename_ac);
+    CuAssertIntEquals(tc, AUG_ENOSPAN, aug_error(aug));
+    reset_indexes(&label_start, &label_end, &value_start, &value_end,
+                  &span_start, &span_end);
+
+    aug_close(aug);
+}
+
+int main(void) {
+    char *output = NULL;
+    CuSuite* suite = CuSuiteNew();
+    CuSuiteSetup(suite, NULL, NULL);
+
+    SUITE_ADD_TEST(suite, testGet);
+    SUITE_ADD_TEST(suite, testSetM);
+    SUITE_ADD_TEST(suite, testDefVarMeta);
+    SUITE_ADD_TEST(suite, testDefNodeExistingMeta);
+    SUITE_ADD_TEST(suite, testDefNodeCreateMeta);
+    SUITE_ADD_TEST(suite, testNodeInfo);
+
+    abs_top_srcdir = getenv("abs_top_srcdir");
+    if (abs_top_srcdir == NULL)
+        die("env var abs_top_srcdir must be set");
+
+    if (asprintf(&root, "%s/tests/root", abs_top_srcdir) < 0) {
+        die("failed to set root");
+    }
+
+    if (asprintf(&loadpath, "%s/lenses", abs_top_srcdir) < 0) {
+        die("failed to set loadpath");
+    }
+
+    CuSuiteRun(suite);
+    CuSuiteSummary(suite, &output);
+    CuSuiteDetails(suite, &output);
+    printf("%s\n", output);
+    free(output);
+    return suite->failCount;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/test-augtool-empty-line.sh b/tests/test-augtool-empty-line.sh
new file mode 100755 (executable)
index 0000000..270ce21
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/bash
+
+# Test for BZ 566844. Make sure we don't spew nonsense when the input
+# contains empty lines
+out=$(augtool --nostdinc 2>&1 <<EOF
+
+quit
+EOF
+)
+result=$?
+
+if [ $result -ne 0 ]; then
+    echo "augtool failed"
+    exit 1
+fi
+
+if [ -n "$out" ]; then
+    echo "augtool produced output:"
+    echo "$out"
+    exit 1
+fi
diff --git a/tests/test-augtool-modify-root.sh b/tests/test-augtool-modify-root.sh
new file mode 100755 (executable)
index 0000000..b102965
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Make sure changing the value of root works
+
+exp="/ = root"
+
+act=$(augtool --noautoload 2>&1 <<EOF
+set / root
+get /
+quit
+EOF
+)
+result=$?
+
+if [ $result -ne 0 ]; then
+    echo "augtool failed"
+    exit 1
+fi
+
+if [ "$act" != "$exp" ]; then
+    echo "augtool produced unexpected output:"
+    echo "Expected:"
+    echo "$exp"
+    echo "Actual:"
+    echo "$act"
+    exit 1
+fi
diff --git a/tests/test-augtool.sh b/tests/test-augtool.sh
new file mode 100755 (executable)
index 0000000..a0d11f3
--- /dev/null
@@ -0,0 +1,81 @@
+#! /bin/sh
+
+TOP_DIR=$(cd $(dirname $0)/.. && pwd)
+TOP_BUILDDIR="$abs_top_builddir"
+[ -z "$TOP_BUILDDIR" ] && TOP_BUILDDIR="$TOP_DIR"
+TOP_SRCDIR="$abs_top_srcdir"
+[ -z "$TOP_SRCDIR" ] && TOP_SRCDIR="$TOP_DIR"
+
+TEST_DIR="$TOP_SRCDIR/tests"
+
+export PATH="$TOP_BUILDDIR/src:${PATH}"
+
+export AUGEAS_ROOT="$TOP_BUILDDIR/build/test-augtool"
+export AUGEAS_LENS_LIB="$TOP_SRCDIR/lenses"
+
+fail() {
+    [ -z "$failed" ] && echo FAIL
+    failed=yes
+    echo "$@"
+    result=1
+}
+
+# Without args, run all tests
+if [ $# -eq 0 ] ; then
+    args="$TEST_DIR/test-augtool/*.sh"
+else
+    args="$@"
+fi
+
+result=0
+
+for tst in $args; do
+    unset failed
+
+    printf "%-40s ... " $(basename $tst .sh)
+
+    # Read in test variables. The variables we understand are
+    # echo              - echo augtool commands if set to some value
+    # commands          - the commands to send to augtool
+    # lens              - the lens to use
+    # file              - the file that should be changed
+    # diff              - the expected diff
+    # refresh           - print diff in a form suitable for cut and paste
+    #                     into the test file if set to some value
+
+    unset echo commands lens file diff refresh
+    . $tst
+
+    # Setup test root from root/
+    [ -d "$AUGEAS_ROOT" ] && rm -rf "$AUGEAS_ROOT"
+    dest_dir="$AUGEAS_ROOT"$(dirname $file)
+    mkdir -p $dest_dir
+    cp -p "$TEST_DIR"/root/$file $dest_dir
+
+    [ -n "$echo" ] && echo="-e"
+
+    commands="set /augeas/load/Test/lens $lens
+set /augeas/load/Test/incl $file
+load
+$commands
+save
+quit"
+    echo "$commands" | augtool $echo --nostdinc --noautoload -n || fail "augtool failed"
+
+    abs_file="$AUGEAS_ROOT$file"
+    if [ ! -f "${abs_file}.augnew" ]; then
+        fail "Expected file $file.augnew"
+    else
+        act=$(diff -u "$abs_file" "${abs_file}.augnew" \
+            | sed -r -e "s/^ $//;s!^(---|\+\+\+) ${AUGEAS_ROOT}($file(\.augnew)?)(.*)\$!\1 \2!;s/\\t/\\\\t/g")
+
+        if [ "$act" != "$diff" ] ; then
+            fail "$act"
+        fi
+    fi
+    other_files=$(find "$AUGEAS_ROOT" -name \*.augnew -not -path "$abs_file.augnew")
+    [ -n "$other_files" ] && fail "Unexpected file(s) $other_files"
+    [ -z "$failed" ] && echo OK
+done
+
+exit $result
diff --git a/tests/test-augtool/aliases-add-value.sh b/tests/test-augtool/aliases-add-value.sh
new file mode 100644 (file)
index 0000000..24c2f9a
--- /dev/null
@@ -0,0 +1,19 @@
+commands="
+ins value after /files/etc/aliases/1/value[last()]
+set /files/etc/aliases/1/value[last()] barbar
+"
+
+lens=Aliases.lns
+file="/etc/aliases"
+
+diff='--- /etc/aliases
++++ /etc/aliases.augnew
+@@ -8,7 +8,7 @@
+ #
+
+ # Basic system aliases -- these MUST be present.
+-mailer-daemon:\tpostmaster
++mailer-daemon:\tpostmaster, barbar
+ postmaster:\troot
+
+ # General redirections for pseudo accounts.'
diff --git a/tests/test-augtool/aliases-change-value.sh b/tests/test-augtool/aliases-change-value.sh
new file mode 100644 (file)
index 0000000..909f61f
--- /dev/null
@@ -0,0 +1,17 @@
+commands="
+set /files/etc/aliases/3/value[2] ruth
+"
+
+lens=Aliases.lns
+file="/etc/aliases"
+
+diff='--- /etc/aliases
++++ /etc/aliases.augnew
+@@ -12,7 +12,7 @@
+ postmaster:\troot
+
+ # General redirections for pseudo accounts.
+-bin:\t\troot, adm
++bin:\t\troot, ruth
+ daemon:\t\troot
+ adm:\t\troot'
diff --git a/tests/test-augtool/grub-change-default.sh b/tests/test-augtool/grub-change-default.sh
new file mode 100644 (file)
index 0000000..a0a2e37
--- /dev/null
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/grub.conf/default 2
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -7,7 +7,7 @@
+ #          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+ #          initrd /initrd-version.img
+ #boot=/dev/sda
+-default=0
++default=2
+ timeout=5
+ splashimage=(hd0,0)/grub/splash.xpm.gz
+ hiddenmenu'
diff --git a/tests/test-augtool/grub-rm-entry.sh b/tests/test-augtool/grub-rm-entry.sh
new file mode 100644 (file)
index 0000000..5ea0aa3
--- /dev/null
@@ -0,0 +1,26 @@
+commands="
+rm /files/etc/grub.conf/title[2]
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -15,10 +15,6 @@
+ \troot (hd0,0)
+ \tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
+ \tinitrd /initrd-2.6.24.4-64.fc8.img
+-title Fedora (2.6.24.3-50.fc8)
+-\troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+-\tinitrd /initrd-2.6.24.3-50.fc8.img
+ title Fedora (2.6.21.7-3.fc8xen)
+ \troot (hd0,0)
+ \tkernel /xen.gz-2.6.21.7-3.fc8
+@@ -28,4 +24,4 @@
+ \troot (hd0,0)
+ \tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+ \tinitrd /initrd-2.6.24.3-34.fc8.img
+-        savedefault
++\tsavedefault'
diff --git a/tests/test-augtool/grub-setm-newvalues.sh b/tests/test-augtool/grub-setm-newvalues.sh
new file mode 100644 (file)
index 0000000..a6d13c0
--- /dev/null
@@ -0,0 +1,33 @@
+# add console values to multiple kernel entries
+commands="
+setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] tty0
+setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] ttyS0,9600n8
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -13,11 +13,11 @@
+ hiddenmenu
+ title Fedora (2.6.24.4-64.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.4-64.fc8.img
+ title Fedora (2.6.24.3-50.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.3-50.fc8.img
+ title Fedora (2.6.21.7-3.fc8xen)
+ \troot (hd0,0)
+@@ -26,6 +26,6 @@
+ \tmodule /initrd-2.6.21.7-3.fc8xen.img
+ title Fedora (2.6.24.3-34.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.3-34.fc8.img
+         savedefault'
diff --git a/tests/test-augtool/ini-yum-change.sh b/tests/test-augtool/ini-yum-change.sh
new file mode 100644 (file)
index 0000000..67075b3
--- /dev/null
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/yum.conf/main/debuglevel 99
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -1,7 +1,7 @@
+ [main]
+ cachedir=/var/cache/yum
+ keepcache=0
+-debuglevel=2
++debuglevel=99
+ logfile=/var/log/yum.log
+ exactarch=1
+ obsoletes=1'
diff --git a/tests/test-augtool/ini-yum-newkey.sh b/tests/test-augtool/ini-yum-newkey.sh
new file mode 100644 (file)
index 0000000..ee9c432
--- /dev/null
@@ -0,0 +1,14 @@
+commands="
+set /files/etc/yum.conf/main/newparam newval
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -13,3 +13,4 @@
+
+ # PUT YOUR REPOS HERE OR IN separate files named file.repo
+ # in /etc/yum.repos.d
++newparam=newval'
diff --git a/tests/test-augtool/ini-yum-newsec.sh b/tests/test-augtool/ini-yum-newsec.sh
new file mode 100644 (file)
index 0000000..8060dac
--- /dev/null
@@ -0,0 +1,15 @@
+commands="
+set /files/etc/yum.conf/other/newparam newval
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -13,3 +13,5 @@
+
+ # PUT YOUR REPOS HERE OR IN separate files named file.repo
+ # in /etc/yum.repos.d
++[other]
++newparam=newval'
diff --git a/tests/test-augtool/ini-yum-rmkey.sh b/tests/test-augtool/ini-yum-rmkey.sh
new file mode 100644 (file)
index 0000000..3c24026
--- /dev/null
@@ -0,0 +1,16 @@
+commands="
+rm /files/etc/yum.conf/main/keepcache
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -1,6 +1,5 @@
+ [main]
+ cachedir=/var/cache/yum
+-keepcache=0
+ debuglevel=2
+ logfile=/var/log/yum.log
+ exactarch=1'
diff --git a/tests/test-augtool/rec-append-record.sh b/tests/test-augtool/rec-append-record.sh
new file mode 100644 (file)
index 0000000..976cc66
--- /dev/null
@@ -0,0 +1,18 @@
+commands='
+ins 01 after /files/etc/pam.d/newrole/*[last()]
+defvar new /files/etc/pam.d/newrole/*[last()]
+set $new/type auth
+set $new/control include
+set $new/module system-auth
+'
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -3,3 +3,4 @@
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++auth\tinclude\tsystem-auth'
diff --git a/tests/test-augtool/rec-hosts-add.sh b/tests/test-augtool/rec-hosts-add.sh
new file mode 100644 (file)
index 0000000..09b6f29
--- /dev/null
@@ -0,0 +1,17 @@
+commands='
+ins 10000 before /files/etc/hosts/2
+set /files/etc/hosts/10000/ipaddr 192.168.0.1
+set /files/etc/hosts/10000/canonical pigiron.example.com
+'
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -3,4 +3,5 @@
+ 127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
++192.168.0.1\tpigiron.example.com
+ 172.31.122.14   orange.watzmann.net orange'
diff --git a/tests/test-augtool/rec-hosts-reorder-new.sh b/tests/test-augtool/rec-hosts-reorder-new.sh
new file mode 100644 (file)
index 0000000..d917a06
--- /dev/null
@@ -0,0 +1,31 @@
+# Delete the first hosts entry and then add it back into the tree as
+# a new entry.
+#
+# Since we add the same entry, but under a new key (01 instead of 1), all
+# the separators are set to their defaults. That is why the separator
+# between localhost.localdomain and localhost changes from a '\t' to a ' '
+# If we used the old key '0' to insert back in, we'd have an exact move of
+# the line. That is checked by rec-hosts-reorder
+
+commands="
+rm /files/etc/hosts/1
+set /files/etc/hosts/01/ipaddr 127.0.0.1
+set /files/etc/hosts/01/canonical localhost.localdomain
+set /files/etc/hosts/01/alias[1] localhost
+set /files/etc/hosts/01/alias[2] galia.watzmann.net
+set /files/etc/hosts/01/alias[3] galia
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,6 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+ 172.31.122.14   orange.watzmann.net orange
++127.0.0.1\tlocalhost.localdomain localhost galia.watzmann.net galia'
diff --git a/tests/test-augtool/rec-hosts-reorder.sh b/tests/test-augtool/rec-hosts-reorder.sh
new file mode 100644 (file)
index 0000000..d763e87
--- /dev/null
@@ -0,0 +1,25 @@
+# Delete the first hosts entry and then add it back into the tree
+# Because of how nodes are ordered, this should be equivalent to
+# moving the corresponding line to the end of the file
+commands="
+rm /files/etc/hosts/1
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+set /files/etc/hosts/1/canonical localhost.localdomain
+set /files/etc/hosts/1/alias[1] localhost
+set /files/etc/hosts/1/alias[2] galia.watzmann.net
+set /files/etc/hosts/1/alias[3] galia
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,6 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+ 172.31.122.14   orange.watzmann.net orange
++127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia'
diff --git a/tests/test-augtool/rec-hosts-rm-hosts.sh b/tests/test-augtool/rec-hosts-rm-hosts.sh
new file mode 100644 (file)
index 0000000..e4b2c2c
--- /dev/null
@@ -0,0 +1,18 @@
+# This will leave /etc/hosts with nothing but comments and whitespace
+commands="
+rm /files/etc/hosts/1
+rm /files/etc/hosts/2
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,4 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+-172.31.122.14   orange.watzmann.net orange'
diff --git a/tests/test-augtool/rec-initdefault.sh b/tests/test-augtool/rec-initdefault.sh
new file mode 100644 (file)
index 0000000..190a271
--- /dev/null
@@ -0,0 +1,20 @@
+# Change the initdefault
+
+commands="
+set /files/etc/inittab/*[action = 'initdefault']/runlevels 3
+"
+
+lens=Inittab.lns
+file="/etc/inittab"
+
+diff='--- /etc/inittab
++++ /etc/inittab.augnew
+@@ -15,7 +15,7 @@
+ #   5 - X11
+ #   6 - reboot (Do NOT set initdefault to this)
+ #
+-id:5:initdefault:
++id:3:initdefault:
+
+ # System initialization.
+ si::sysinit:/etc/rc.d/rc.sysinit'
diff --git a/tests/test-augtool/rec-ins-record.sh b/tests/test-augtool/rec-ins-record.sh
new file mode 100644 (file)
index 0000000..7caf7ef
--- /dev/null
@@ -0,0 +1,19 @@
+commands="
+ins 10000 before /files/etc/pam.d/newrole/3
+set /files/etc/pam.d/newrole/10000/type session
+set /files/etc/pam.d/newrole/10000/control include
+set /files/etc/pam.d/newrole/10000/module system-auth
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,6 @@
+ #%PAM-1.0
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
++session\tinclude\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-mod-field.sh b/tests/test-augtool/rec-mod-field.sh
new file mode 100644 (file)
index 0000000..47624db
--- /dev/null
@@ -0,0 +1,17 @@
+commands="
+set /files/etc/pam.d/newrole/3/module other_module
+set /files/etc/pam.d/newrole/3/argument other_module_opts
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,5 @@
+ #%PAM-1.0
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+-password   include\tsystem-auth
++password   include\tother_module\tother_module_opts
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-rm-inner-field.sh b/tests/test-augtool/rec-rm-inner-field.sh
new file mode 100644 (file)
index 0000000..bdfa6d7
--- /dev/null
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/4/argument
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -2,4 +2,4 @@
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+-session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++session    required\tpam_namespace.so'
diff --git a/tests/test-augtool/rec-rm-record.sh b/tests/test-augtool/rec-rm-record.sh
new file mode 100644 (file)
index 0000000..16721b4
--- /dev/null
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/1
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,4 @@
+ #%PAM-1.0
+-auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-rm-tail-field.sh b/tests/test-augtool/rec-rm-tail-field.sh
new file mode 100644 (file)
index 0000000..bdfa6d7
--- /dev/null
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/4/argument
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -2,4 +2,4 @@
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+-session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++session    required\tpam_namespace.so'
diff --git a/tests/test-augtool/sshd-add-acceptenv.sh b/tests/test-augtool/sshd-add-acceptenv.sh
new file mode 100644 (file)
index 0000000..7b44476
--- /dev/null
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/ssh/sshd_config/AcceptEnv[3]/01 FOO
+"
+
+lens=Sshd.lns
+file="/etc/ssh/sshd_config"
+
+diff='--- /etc/ssh/sshd_config
++++ /etc/ssh/sshd_config.augnew
+@@ -93,7 +93,7 @@
+ # Accept locale-related environment variables
+ AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
+ AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
+-AcceptEnv LC_IDENTIFICATION LC_ALL
++AcceptEnv LC_IDENTIFICATION LC_ALL FOO
+ #AllowTcpForwarding yes
+ #GatewayPorts no
+ #X11Forwarding no'
diff --git a/tests/test-augtool/yum.repos-setm-enabled.sh b/tests/test-augtool/yum.repos-setm-enabled.sh
new file mode 100644 (file)
index 0000000..efc32de
--- /dev/null
@@ -0,0 +1,27 @@
+# set all existing repos to enabled
+commands="
+setm /files/etc/yum.repos.d/fedora.repo/* enabled 1
+"
+
+lens=Yum.lns
+file="/etc/yum.repos.d/fedora.repo"
+
+diff='--- /etc/yum.repos.d/fedora.repo
++++ /etc/yum.repos.d/fedora.repo.augnew
+@@ -12,7 +12,7 @@
+ failovermethod=priority
+ #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
+ mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
+-enabled=0
++enabled=1
+ gpgcheck=1
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+@@ -21,6 +21,6 @@
+ failovermethod=priority
+ #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
+ mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
+-enabled=0
++enabled=1
+ gpgcheck=1
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY'
diff --git a/tests/test-bug-1.sh b/tests/test-bug-1.sh
new file mode 100755 (executable)
index 0000000..80198cd
--- /dev/null
@@ -0,0 +1,36 @@
+#! /bin/bash
+
+# Test for bug https://fedorahosted.org/augeas/ticket/1
+#
+# Check that putting an invalid node into the tree and saving
+# leads to failure, and therefore the original file being preserved
+
+root=$abs_top_builddir/build/test-bug-1
+file=$root/etc/logrotate.d/test
+
+rm -rf $root
+mkdir -p $(dirname $file)
+
+cat > $file <<EOF
+myfile {
+  weekly
+}
+EOF
+ln $file $file.orig
+
+augtool --nostdinc -I $abs_top_srcdir/lenses -r $root > /dev/null <<EOF
+ins invalid before /files/etc/logrotate.d/test/rule
+save
+EOF
+
+result=$?
+
+if [ $result -eq 0 ] ; then
+    echo "augtool succeeded, but should have failed"
+    exit 1
+fi
+
+if [ ! $file -ef $file.orig ] ; then
+    echo "File was changed, but should not have been"
+    exit 1
+fi
diff --git a/tests/test-events-saved.sh b/tests/test-events-saved.sh
new file mode 100755 (executable)
index 0000000..ebddf10
--- /dev/null
@@ -0,0 +1,41 @@
+#! /bin/bash
+
+# Check that saving preserves mode and ownership; for this test to make
+# much sense (if any) the user running it should have at least one
+# supplementary group
+
+run_augtool() {
+augtool --nostdinc -r $root -I $abs_top_srcdir/lenses <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.1.1
+set /files/etc/grub.conf/default 3
+set /files/etc/inittab/1/action fake
+rm /files/etc/puppet/puppet.conf
+set /files/etc/yum.repos.d/fedora.repo/fedora/enabled 0
+save
+match /augeas/events/saved
+EOF
+}
+
+root=$abs_top_builddir/build/test-events-saved
+
+rm -rf $root
+mkdir -p $root
+cp -pr $abs_top_srcdir/tests/root/* $root
+chmod -R u+w $root
+
+saved=$(run_augtool | grep ^/augeas/events/saved | cut -d ' ' -f 3 | sort | tr '\n' ' ')
+exp="/files/etc/grub.conf /files/etc/hosts /files/etc/inittab /files/etc/puppet/puppet.conf /files/etc/yum.repos.d/fedora.repo "
+
+if [ -f "$root/etc/puppet/puppet.conf" ]
+then
+  echo "File /etc/puppet/puppet.conf should have been deleted"
+  exit 1
+fi
+
+if [ "$saved" != "$exp" ]
+then
+    echo "Unexpected entries in /augeas/events/saved:"
+    echo "Expected: \"$exp\""
+    echo "Actual:   \"$saved\""
+    exit 1
+fi
diff --git a/tests/test-get.sh b/tests/test-get.sh
new file mode 100755 (executable)
index 0000000..9fc077a
--- /dev/null
@@ -0,0 +1,17 @@
+#! /bin/bash
+
+# Check that reading the files in tests/root/ with augtool does not lead to
+# any errors
+
+TOPDIR=$(cd $(dirname $0)/.. && pwd)
+[ -n "$abs_top_srcdir" ] || abs_top_srcdir=$TOPDIR
+
+export AUGEAS_LENS_LIB=$abs_top_srcdir/lenses
+export AUGEAS_ROOT=$abs_top_srcdir/tests/root
+
+errors=$(augtool --nostdinc match '/augeas//error/descendant-or-self::*')
+
+if [ "x$errors" != "x  (no matches)" ] ; then
+    printf "get /augeas//error reported errors:\n%s\n" "$errors"
+    exit 1
+fi
diff --git a/tests/test-idempotent.sh b/tests/test-idempotent.sh
new file mode 100755 (executable)
index 0000000..03080ab
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/bash
+
+# Test that saving changes that don't really change the underlying file
+# leave the original file intact
+
+root=$abs_top_builddir/build/test-idempotent
+hosts=$root/etc/hosts
+
+rm -rf $root
+mkdir -p $(dirname $hosts)
+
+cat <<EOF > $hosts
+127.0.0.1 localhost
+EOF
+touch -r $0 $hosts
+cp -p $hosts $hosts.stamp
+
+augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.1.1
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+save
+EOF
+
+[ $hosts -nt $hosts.stamp ] && exit 1
+
+augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.1.1
+save
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+save
+EOF
+
+[ $hosts -nt $hosts.stamp ] || exit 1
diff --git a/tests/test-interpreter.sh b/tests/test-interpreter.sh
new file mode 100755 (executable)
index 0000000..78beca6
--- /dev/null
@@ -0,0 +1,67 @@
+#! /bin/bash
+
+# Run test modules that make sure the interpreter fails/succeeds in
+# various hairy situations.
+#
+# If run with option '-v', error output from each augparse run is printed
+
+TOPDIR=$(cd $(dirname $0)/.. && pwd)
+DATADIR=${abs_top_srcdir-${TOPDIR}}/tests
+MODULES=${DATADIR}/modules
+AUGPARSE=${abs_top_builddir-${DATADIR}/..}/src/augparse
+
+set -e
+
+VERBOSE=n
+if [ "x$1" = "x-v" ]; then
+    VERBOSE=y
+fi
+
+run_tests ()
+{
+    ret_succ=$1
+    ret_fail=$(( 1 - $ret_succ ))
+    action=$2
+    shift
+    shift
+
+    for g in $*; do
+        if [ ! -r "$g" ]; then
+            echo "Grammar file $g is not readable"
+            exit 19
+        fi
+        printf "$action %-30s ... " $(basename $g .aug)
+        set +e
+        errs=$(augparse --nostdinc -I ${MODULES} $g 2>&1 > /dev/null)
+        ret=$?
+        set -e
+        if [ $ret -eq $ret_fail ]; then
+            echo FAIL
+            result=1
+        elif [ $ret -eq $ret_succ ]; then
+            echo PASS
+        else
+            echo ERROR
+            result=19
+        fi
+        if [ "$VERBOSE" = "y" ] ; then
+            echo $errs
+        fi
+    done
+}
+
+if [ ! -x $AUGPARSE ] ; then
+    echo "Failed to find executable augparse"
+    echo "  looked for $AUGPARSE"
+    exit 127
+fi
+
+echo "--------------------------------"
+echo "Running interpreter tests"
+echo
+
+result=0
+run_tests 1 reject $MODULES/fail_*.aug
+run_tests 0 accept $MODULES/pass_*.aug
+
+exit $result
diff --git a/tests/test-load.c b/tests/test-load.c
new file mode 100644 (file)
index 0000000..d025900
--- /dev/null
@@ -0,0 +1,532 @@
+/*
+ * test-load.c: test the aug_load functionality
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include "augeas.h"
+
+#include "cutest.h"
+#include "internal.h"
+
+static const char *abs_top_srcdir;
+static const char *abs_top_builddir;
+static char *root = NULL;
+static char *loadpath;
+
+#define die(msg)                                                    \
+    do {                                                            \
+        fprintf(stderr, "%d: Fatal error: %s\n", __LINE__, msg);    \
+        exit(EXIT_FAILURE);                                         \
+    } while(0)
+
+static struct augeas *setup_writable_hosts(CuTest *tc) {
+    char *etcdir, *build_root;
+    struct augeas *aug = NULL;
+    int r;
+
+    if (asprintf(&build_root, "%s/build/test-load/%s",
+                 abs_top_builddir, tc->name) < 0) {
+        CuFail(tc, "failed to set build_root");
+    }
+
+    if (asprintf(&etcdir, "%s/etc", build_root) < 0)
+        CuFail(tc, "asprintf etcdir failed");
+
+    run(tc, "test -d %s && chmod -R u+w %s || :", build_root, build_root);
+    run(tc, "rm -rf %s", build_root);
+    run(tc, "mkdir -p %s", etcdir);
+    run(tc, "cp -pr %s/etc/hosts %s", root, etcdir);
+    run(tc, "chmod -R u+w %s", build_root);
+
+    aug = aug_init(build_root, loadpath, AUG_NO_MODL_AUTOLOAD);
+    CuAssertPtrNotNull(tc, aug);
+
+    r = aug_set(aug, "/augeas/load/Hosts/lens", "Hosts.lns");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_set(aug, "/augeas/load/Hosts/incl", "/etc/hosts");
+    CuAssertRetSuccess(tc, r);
+
+    free(build_root);
+    free(etcdir);
+    return aug;
+}
+
+static void testDefault(CuTest *tc) {
+    augeas *aug = NULL;
+    int nmatches, r;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC);
+    CuAssertPtrNotNull(tc, aug);
+
+    nmatches = aug_match(aug, "/augeas/load/*", NULL);
+    CuAssertPositive(tc, nmatches);
+
+    nmatches = aug_match(aug, "/files/etc/hosts/1", NULL);
+    CuAssertIntEquals(tc, 1, nmatches);
+
+    r = aug_rm(aug, "/augeas/load/*");
+    CuAssertTrue(tc, r >= 0);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/files/*", NULL);
+    CuAssertZero(tc, nmatches);
+
+    aug_close(aug);
+}
+
+static void testNoLoad(CuTest *tc) {
+    augeas *aug = NULL;
+    int nmatches, r;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+
+    nmatches = aug_match(aug, "/augeas/load/*", NULL);
+    CuAssertPositive(tc, nmatches);
+
+    nmatches = aug_match(aug, "/files/*", NULL);
+    CuAssertZero(tc, nmatches);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/files/*", NULL);
+    CuAssertPositive(tc, nmatches);
+
+    /* Now load /etc/hosts only */
+    r = aug_rm(aug, "/augeas/load/*[label() != 'Hosts']");
+    CuAssertTrue(tc, r >= 0);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/files/etc/*", NULL);
+    CuAssertIntEquals(tc, 1, nmatches);
+
+    aug_close(aug);
+}
+
+static void testNoAutoload(CuTest *tc) {
+    augeas *aug = NULL;
+    int nmatches, r;
+
+    aug = aug_init(root, loadpath, AUG_NO_MODL_AUTOLOAD);
+    CuAssertPtrNotNull(tc, aug);
+
+    nmatches = aug_match(aug, "/augeas/load/*", NULL);
+    CuAssertZero(tc, nmatches);
+
+    r = aug_set(aug, "/augeas/load/Hosts/lens", "Hosts.lns");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_set(aug, "/augeas/load/Hosts/incl", "/etc/hosts");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/files/etc/hosts/*[ipaddr]", NULL);
+    CuAssertIntEquals(tc, 2, nmatches);
+
+    aug_close(aug);
+}
+
+static void invalidLens(CuTest *tc, augeas *aug, const char *lens) {
+    int r, nmatches;
+
+    r = aug_set(aug, "/augeas/load/Junk/lens", lens);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_set(aug, "/augeas/load/Junk/incl", "/dev/null");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/augeas/load/Junk/error", NULL);
+    CuAssertIntEquals(tc, 1, nmatches);
+}
+
+static void testInvalidLens(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC|AUG_NO_LOAD);
+    CuAssertPtrNotNull(tc, aug);
+
+    r = aug_rm(aug, "/augeas/load/*");
+    CuAssertTrue(tc, r >= 0);
+
+    invalidLens(tc, aug, NULL);
+    invalidLens(tc, aug, "@Nomodule");
+    invalidLens(tc, aug, "@Util");
+    invalidLens(tc, aug, "Nomodule.noelns");
+
+    aug_close(aug);
+}
+
+static void testLoadSave(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_save(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/augeas/events/saved", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    aug_close(aug);
+}
+
+/* Tests bug #79 */
+static void testLoadDefined(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC);
+    CuAssertPtrNotNull(tc, aug);
+
+    r = aug_defvar(aug, "v", "/files/etc/hosts/*/ipaddr");
+    CuAssertIntEquals(tc, 2, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "$v", NULL);
+    CuAssertIntEquals(tc, 2, r);
+
+    aug_close(aug);
+}
+
+static void testDefvarExpr(CuTest *tc) {
+    static const char *const expr = "/files/etc/hosts/*/ipaddr";
+    static const char *const expr2 = "/files/etc/hosts/*/canonical";
+
+    augeas *aug = NULL;
+    const char *v;
+    int r;
+
+    aug = aug_init(root, loadpath, AUG_NO_STDINC);
+    CuAssertPtrNotNull(tc, aug);
+
+    r = aug_defvar(aug, "v", expr);
+    CuAssertIntEquals(tc, 2, r);
+
+    r = aug_get(aug, "/augeas/variables/v", &v);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertStrEquals(tc, expr, v);
+
+    r = aug_defvar(aug, "v", expr2);
+    CuAssertIntEquals(tc, 2, r);
+
+    r = aug_get(aug, "/augeas/variables/v", &v);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertStrEquals(tc, expr2, v);
+
+    r = aug_defvar(aug, "v", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_get(aug, "/augeas/variables/v", &v);
+    CuAssertIntEquals(tc, 0, r);
+    CuAssertStrEquals(tc, NULL, v);
+
+    aug_close(aug);
+}
+
+static void testReloadChanged(CuTest *tc) {
+    FILE *fp;
+    augeas *aug = NULL;
+    const char *build_root, *mtime2, *s;
+    char *mtime1;
+    char *hosts = NULL;
+    int r;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_get(aug, "/augeas/root", &build_root);
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &s);
+    CuAssertIntEquals(tc, 1, r);
+    mtime1 = strdup(s);
+    CuAssertPtrNotNull(tc, mtime1);
+
+    /* Tickle /etc/hosts behind augeas' back */
+    r = asprintf(&hosts, "%setc/hosts", build_root);
+    CuAssertPositive(tc, r);
+
+    fp = fopen(hosts, "a");
+    CuAssertPtrNotNull(tc, fp);
+
+    r = fprintf(fp, "192.168.0.1 other.example.com\n");
+    CuAssertTrue(tc, r > 0);
+
+    r = fclose(fp);
+    CuAssertRetSuccess(tc, r);
+
+    /* Unsaved changes are discarded */
+    r = aug_set(aug, "/files/etc/hosts/1/ipaddr", "127.0.0.2");
+    CuAssertRetSuccess(tc, r);
+
+    /* Check that we really did load the right file*/
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &mtime2);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertStrNotEqual(tc, mtime1, mtime2);
+
+    r = aug_match(aug, "/files/etc/hosts/*[ipaddr = '192.168.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    r = aug_match(aug, "/files/etc/hosts/1[ipaddr = '127.0.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    free(mtime1);
+    free(hosts);
+    aug_close(aug);
+}
+
+static void testReloadDirty(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    /* Unsaved changes are discarded */
+    r = aug_set(aug, "/files/etc/hosts/1/ipaddr", "127.0.0.2");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/files/etc/hosts/1[ipaddr = '127.0.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    aug_close(aug);
+}
+
+static void testReloadDeleted(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    /* A missing file causes a reload */
+    r = aug_rm(aug, "/files/etc/hosts");
+    CuAssertPositive(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/files/etc/hosts/1[ipaddr = '127.0.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    /* A missing entry in a file causes a reload */
+    r = aug_rm(aug, "/files/etc/hosts/1/ipaddr");
+    CuAssertPositive(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/files/etc/hosts/1[ipaddr = '127.0.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    aug_close(aug);
+}
+
+static void testReloadDeletedMeta(CuTest *tc) {
+    augeas *aug = NULL;
+    int r;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    /* Unsaved changes are discarded */
+    r = aug_rm(aug, "/augeas/files/etc/hosts");
+    CuAssertPositive(tc, r);
+
+    r = aug_set(aug, "/files/etc/hosts/1/ipaddr", "127.0.0.2");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/files/etc/hosts/1[ipaddr = '127.0.0.1']", NULL);
+    CuAssertIntEquals(tc, 1, r);
+
+    aug_close(aug);
+}
+
+/* BZ 613967 - segfault when reloading a file that has been externally
+ * modified, and we have a variable pointing into the old tree
+ */
+static void testReloadExternalMod(CuTest *tc) {
+    augeas *aug = NULL;
+    int r, created;
+    const char *aug_root, *s;
+    char *mtime;
+
+    aug = setup_writable_hosts(tc);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &s);
+    CuAssertIntEquals(tc, 1, r);
+    mtime = strdup(s);
+    CuAssertPtrNotNull(tc, mtime);
+
+    /* Set up a new entry and save */
+    r = aug_defnode(aug, "new", "/files/etc/hosts/3", NULL, &created);
+    CuAssertIntEquals(tc, 1, r);
+    CuAssertIntEquals(tc, 1, created);
+
+    r = aug_set(aug, "$new/ipaddr", "172.31.42.1");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_set(aug, "$new/canonical", "new.example.com");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_save(aug);
+    CuAssertRetSuccess(tc, r);
+
+    /* Fake the mtime to be old */
+    r = aug_set(aug, "/augeas/files/etc/hosts/mtime", mtime);
+    CuAssertRetSuccess(tc, r);
+
+    /* Now modify the file outside of Augeas */
+    r = aug_get(aug, "/augeas/root", &aug_root);
+    CuAssertIntEquals(tc, 1, r);
+
+    run(tc, "sed -i -e '1,2d' %setc/hosts", aug_root);
+
+    /* Reload and save again */
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_save(aug);
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_match(aug, "/files/etc/hosts/#comment", NULL);
+    CuAssertIntEquals(tc, 2, r);
+
+    r = aug_match(aug, "/files/etc/hosts/*", NULL);
+    CuAssertIntEquals(tc, 5, r);
+}
+
+/* Make sure parse errors from applying a lens to a file that does not
+ * match get reported under /augeas//error
+ *
+ * Tests bug #138
+ */
+static void testParseErrorReported(CuTest *tc) {
+    augeas *aug = NULL;
+    int nmatches, r;
+
+    aug = aug_init(root, loadpath, AUG_NO_MODL_AUTOLOAD);
+    CuAssertPtrNotNull(tc, aug);
+
+    r = aug_set(aug, "/augeas/load/Bad/lens", "Yum.lns");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_set(aug, "/augeas/load/Bad/incl", "/etc/fstab");
+    CuAssertRetSuccess(tc, r);
+
+    r = aug_load(aug);
+    CuAssertRetSuccess(tc, r);
+
+    nmatches = aug_match(aug, "/augeas/files/etc/fstab/error", NULL);
+    CuAssertIntEquals(tc, 1, nmatches);
+
+    aug_close(aug);
+}
+
+int main(void) {
+    char *output = NULL;
+    CuSuite* suite = CuSuiteNew();
+    CuSuiteSetup(suite, NULL, NULL);
+    SUITE_ADD_TEST(suite, testDefault);
+    SUITE_ADD_TEST(suite, testNoLoad);
+    SUITE_ADD_TEST(suite, testNoAutoload);
+    SUITE_ADD_TEST(suite, testInvalidLens);
+    SUITE_ADD_TEST(suite, testLoadSave);
+    SUITE_ADD_TEST(suite, testLoadDefined);
+    SUITE_ADD_TEST(suite, testDefvarExpr);
+    SUITE_ADD_TEST(suite, testReloadChanged);
+    SUITE_ADD_TEST(suite, testReloadDirty);
+    SUITE_ADD_TEST(suite, testReloadDeleted);
+    SUITE_ADD_TEST(suite, testReloadDeletedMeta);
+    SUITE_ADD_TEST(suite, testReloadExternalMod);
+    SUITE_ADD_TEST(suite, testParseErrorReported);
+
+    abs_top_srcdir = getenv("abs_top_srcdir");
+    if (abs_top_srcdir == NULL)
+        die("env var abs_top_srcdir must be set");
+
+    abs_top_builddir = getenv("abs_top_builddir");
+    if (abs_top_builddir == NULL)
+        die("env var abs_top_builddir must be set");
+
+    if (asprintf(&root, "%s/tests/root", abs_top_srcdir) < 0) {
+        die("failed to set root");
+    }
+
+    if (asprintf(&loadpath, "%s/lenses", abs_top_srcdir) < 0) {
+        die("failed to set loadpath");
+    }
+
+    CuSuiteRun(suite);
+    CuSuiteSummary(suite, &output);
+    CuSuiteDetails(suite, &output);
+    printf("%s\n", output);
+    free(output);
+    return suite->failCount;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/test-mv.sh b/tests/test-mv.sh
new file mode 100755 (executable)
index 0000000..e7832e5
--- /dev/null
@@ -0,0 +1,46 @@
+#! /bin/bash
+
+aug_mv() {
+opts='--nostdinc -r /dev/null'
+(augtool $opts | grep -v '/augeas\|/files\|augtool' | tr '\n' ' ') <<EOF
+set /a/b/c value
+mv $1 $2
+print
+EOF
+}
+
+assert_eq() {
+    msg=$1
+    if [ "$ACT" != "$EXP" ] ; then
+        echo "Failed: aug_mv $msg"
+        echo "Expected: <$EXP>"
+        echo "Actual  : <$ACT>"
+        exit 1
+    fi
+
+}
+
+ACT=$(aug_mv /a/b/c /x)
+EXP='/a /a/b /x = "value" '
+assert_eq /x
+
+ACT=$(aug_mv /a/b/c /x/y)
+EXP='/a /a/b /x /x/y = "value" '
+assert_eq /x/y
+
+ACT=$(aug_mv /a/b/c /a/x)
+EXP='/a /a/b /a/x = "value" '
+assert_eq /a/x
+
+# Check that we don't move into a descendant
+ACT=$(aug_mv /a/b/c /a/b/c/d)
+EXP='Failed /a /a/b /a/b/c = "value" /a/b/c/d '
+assert_eq /a/b/c/d
+
+ACT=$(aug_mv /a/b/c /a/b/d)
+EXP='/a /a/b /a/b/d = "value" '
+assert_eq /a/b/d
+
+ACT=$(aug_mv /a /x/y)
+EXP='/x /x/y /x/y/b /x/y/b/c = "value" '
+assert_eq "/a to /x/y"
diff --git a/tests/test-preserve.sh b/tests/test-preserve.sh
new file mode 100755 (executable)
index 0000000..daafea3
--- /dev/null
@@ -0,0 +1,113 @@
+#! /bin/bash
+
+# Check that saving preserves mode and ownership; for this test to make
+# much sense (if any) the user running it should have at least one
+# supplementary group
+
+root=$abs_top_builddir/build/preserve
+hosts=$root/etc/hosts
+
+init_dirs() {
+rm -rf $root
+mkdir -p $(dirname $hosts)
+}
+
+stat_inode() {
+ls -il $1 | cut -d ' ' -f 1
+}
+
+AUGTOOL="augtool --nostdinc -r $root -I $abs_top_srcdir/lenses"
+init_dirs
+
+printf '127.0.0.1\tlocalhost\n' > $hosts
+
+chmod 0600 $hosts
+group=$(groups | tr ' ' '\n' | tail -1)
+chgrp $group $hosts
+
+[ -x /usr/bin/chcon ] && selinux=yes || selinux=no
+if [ $selinux = yes ] ; then
+  /usr/bin/chcon -t etc_t $hosts > /dev/null 2>/dev/null || selinux=no
+fi
+
+$AUGTOOL >/dev/null <<EOF
+set /files/etc/hosts/1/alias alias.example.com
+save
+EOF
+if [ $? != 0 ] ; then
+    echo "augtool failed on existing file"
+    exit 1
+fi
+
+act_group=$(ls -l $hosts | sed -e 's/  */ /g' | cut -d ' ' -f 4)
+act_mode=$(ls -l $hosts | cut -b 1-10)
+if [ $selinux = yes ] ; then
+  act_con=$(stat --format=%C $hosts | cut -d ':' -f 3)
+fi
+if [ "x$group" != "x$act_group" ] ; then
+    echo "Expected group $group but got $act_group"
+    exit 1
+fi
+
+if [ x-rw------- != "x$act_mode" ] ; then
+    echo "Expected mode 0600 but got $act_mode"
+    exit 1
+fi
+
+if [ $selinux = yes -a xetc_t != "x$act_con" ] ; then
+    echo "Expected SELinux type etc_t but got $act_con"
+    exit 1
+fi
+
+# Check that we create new files without error
+init_dirs
+
+$AUGTOOL > /dev/null <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+set /files/etc/hosts/1/canonical host.example.com
+save
+EOF
+if [ $? != 0 ] ; then
+    echo "augtool failed on new file"
+    exit 1
+fi
+
+# Check that we create new files without error when backups are requested
+init_dirs
+
+$AUGTOOL -b > /dev/null <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+set /files/etc/hosts/1/canonical host.example.com
+save
+EOF
+if [ $? != 0 ] ; then
+    echo "augtool -b failed on new file"
+    exit 1
+fi
+
+# Check that we preserve a backup file on request
+printf '127.0.0.1\tlocalhost\n' > $hosts
+exp_inode=$(stat_inode $hosts)
+
+$AUGTOOL -b > /dev/null <<EOF
+set /files/etc/hosts/1/alias alias.example.com
+print /augeas/save
+save
+EOF
+
+if [ ! -f $hosts.augsave ] ; then
+  echo "Backup file was not created"
+  exit 1
+fi
+
+act_inode=$(stat_inode $hosts.augsave)
+if [ "x$act_inode" != "x$exp_inode" ] ; then
+  echo "Backup file's inode changed"
+  exit 1
+fi
+
+act_inode=$(stat_inode $hosts)
+if [ "x$act_inode" = "x$exp_inode" ] ; then
+  echo "Same inode for backup file and main file"
+  exit 1
+fi
diff --git a/tests/test-put-symlink.sh b/tests/test-put-symlink.sh
new file mode 100755 (executable)
index 0000000..6996b23
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/bash
+
+# Test that we correctly preserve symlinks when saving a file
+
+ROOT=$abs_top_builddir/build/test-put-symlink
+LENSES=$abs_top_srcdir/lenses
+HOSTS=$ROOT/etc/hosts
+REAL_HOSTS=$ROOT/other/hosts
+
+rm -rf $ROOT
+mkdir -p $(dirname $HOSTS)
+mkdir -p $(dirname $REAL_HOSTS)
+
+cat <<EOF > $REAL_HOSTS
+127.0.0.1 localhost
+EOF
+
+(cd $(dirname $HOSTS) && ln -s ../other/hosts $(basename $HOSTS))
+
+augtool --nostdinc -I $LENSES -b -r $ROOT > /dev/null <<EOF
+set /files/etc/hosts/1/alias myhost
+save
+EOF
+
+HOSTS_AUGSAVE=${HOSTS}.augsave
+if [ ! -f $HOSTS_AUGSAVE ] ; then
+    echo "Missing /etc/hosts.augsave"
+    exit 1
+fi
+if [ -h $HOSTS_AUGSAVE ] ; then
+    echo "The file /etc/hosts.augsave is a symlink"
+    exit 1
+fi
+if [ ! -h $HOSTS ] ; then
+    echo "/etc/hosts is not a symbolic link"
+    exit 1
+fi
+
+LINK=$(readlink $HOSTS)
+if [ "x$LINK" != "x../other/hosts" ] ; then
+    echo "/etc/hosts does not link to ../other/hosts"
+    exit 1
+fi
diff --git a/tests/test-save-empty.sh b/tests/test-save-empty.sh
new file mode 100755 (executable)
index 0000000..00741da
--- /dev/null
@@ -0,0 +1,55 @@
+#! /bin/bash
+
+# Test that we report an error when writing to nonexistant dirs
+# but that we do create new files correctly
+
+save_hosts() {
+opts="--nostdinc -r $ROOT -I $abs_top_srcdir/lenses"
+(augtool $opts | grep ^/augeas) <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+set /files/etc/hosts/1/canonical localhost
+save
+print /augeas/files/etc/hosts/error
+EOF
+}
+
+expected_errors() {
+cat <<EOF
+/augeas/files/etc/hosts/error = "open_augnew"
+/augeas/files/etc/hosts/error/message = "No such file or directory"
+EOF
+}
+
+ROOT=$abs_top_builddir/build/test-save-empty
+HOSTS=$ROOT/etc/hosts
+
+rm -rf $ROOT
+mkdir -p $ROOT
+ACTUAL=$(save_hosts)
+EXPECTED=$(expected_errors)
+
+if [ "$ACTUAL" != "$EXPECTED" ]
+then
+    echo "No error on missing /etc directory"
+    exit 1
+fi
+
+mkdir -p $ROOT/etc
+ACTUAL=$(save_hosts)
+if [ -n "$ACTUAL" ] ; then
+    echo "Error creating file:"
+    echo $ACTUAL
+    exit 1
+fi
+
+if [ ! -f $HOSTS ] ; then
+    echo "File ${HOSTS} was not created"
+    exit 1
+fi
+
+printf '127.0.0.1\tlocalhost\n' > $HOSTS.expected
+
+if ! cmp $HOSTS $HOSTS.expected > /dev/null 2>&1 ; then
+    echo "Contents of $HOSTS are incorrect"
+    exit 1
+fi
diff --git a/tests/test-save-mode.sh b/tests/test-save-mode.sh
new file mode 100755 (executable)
index 0000000..d34f5bc
--- /dev/null
@@ -0,0 +1,122 @@
+#! /bin/bash
+
+# Test manipulating the save flags in /augeas/save
+
+root=$abs_top_builddir/build/test-save-mode
+hosts=$root/etc/hosts
+augopts="--nostdinc -r $root -I $abs_top_srcdir/lenses"
+
+run_augtool() {
+    exp=$1
+    shift
+    augtool $augopts "$@" > /dev/null
+    status=$?
+    if [ "x$exp" = ok -a $status -ne 0 ] ; then
+        echo "augtool failed"
+        exit 1
+    elif [ "x$exp" = fail -a $status -eq 0 ] ; then
+        echo "augtool succeeded but should have failed"
+        exit 1
+    fi
+}
+
+assert_ipaddr() {
+    exp="/files/etc/hosts/1/ipaddr = $1"
+    act=$(augtool $augopts get /files/etc/hosts/1/ipaddr)
+
+    if [ "$act" != "$exp" ] ; then
+        printf "Expected: %s\n" "$exp"
+        printf "Actual  : %s\n" "$act"
+        exit 1
+    fi
+}
+
+assert_file_exists() {
+    if [ ! -f "$1" ] ; then
+        echo "File $1 does not exist, but should"
+        exit 1
+    fi
+}
+
+assert_file_exists_not() {
+    if [ -f "$1" ] ; then
+        echo "File $1 exists, but should not"
+        exit 1
+    fi
+}
+
+setup() {
+#    echo $*
+    rm -rf $root
+    mkdir -p $(dirname $hosts)
+    cat > $hosts <<EOF
+127.0.0.1 localhost
+EOF
+}
+
+setup "No /augeas/save"
+run_augtool fail <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+rm /augeas/save
+save
+EOF
+assert_ipaddr 127.0.0.1
+
+setup "Invalid /augeas/save"
+run_augtool fail <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+set /augeas/save "not a valid flag"
+save
+EOF
+assert_ipaddr 127.0.0.1
+
+setup "noop"
+run_augtool fail <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+set /augeas/save noop
+save
+EOF
+assert_ipaddr 127.0.0.1
+assert_file_exists_not $hosts.augnew
+assert_file_exists_not $hosts.augsave
+
+setup "newfile"
+run_augtool ok <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+set /augeas/save newfile
+save
+EOF
+assert_ipaddr 127.0.0.1
+assert_file_exists $hosts.augnew
+assert_file_exists_not $hosts.augsave
+
+setup "overwrite"
+run_augtool ok <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+set /augeas/save overwrite
+save
+EOF
+assert_ipaddr 127.0.0.2
+assert_file_exists_not $hosts.augnew
+assert_file_exists_not $hosts.augsave
+
+setup "backup"
+run_augtool ok <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+set /augeas/save backup
+save
+EOF
+assert_ipaddr 127.0.0.2
+assert_file_exists_not $hosts.augnew
+assert_file_exists $hosts.augsave
+
+
+augopts="${augopts} --autosave"
+
+setup "autosave"
+run_augtool ok <<EOF
+set /files/etc/hosts/1/ipaddr 127.0.0.2
+EOF
+assert_ipaddr 127.0.0.2
+assert_file_exists_not $hosts.augnew
+assert_file_exists_not $hosts.augsave
diff --git a/tests/test-save.c b/tests/test-save.c
new file mode 100644 (file)
index 0000000..68b7736
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * test-save.c: test various aspects of saving
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <lutter@redhat.com>
+ */
+
+#include <config.h>
+#include "augeas.h"
+#include "internal.h"
+#include "cutest.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+const char *abs_top_srcdir;
+const char *abs_top_builddir;
+char *root = NULL, *src_root = NULL;
+struct augeas *aug = NULL;
+
+#define die(msg)                                                    \
+    do {                                                            \
+        fprintf(stderr, "%s:%d: Fatal error: %s\n", __FILE__, __LINE__, msg); \
+        exit(EXIT_FAILURE);                                         \
+    } while(0)
+
+static void setup(CuTest *tc) {
+    char *lensdir;
+
+    if (asprintf(&root, "%s/build/test-save/%s",
+                 abs_top_builddir, tc->name) < 0) {
+        CuFail(tc, "failed to set root");
+    }
+
+    if (asprintf(&lensdir, "%s/lenses", abs_top_srcdir) < 0)
+        CuFail(tc, "asprintf lensdir failed");
+
+    run(tc, "test -d %s && chmod -R u+w %s || :", root, root);
+    run(tc, "rm -rf %s", root);
+    run(tc, "mkdir -p %s", root);
+    run(tc, "cp -pr %s/* %s", src_root, root);
+    run(tc, "chmod -R u+w %s", root);
+
+    aug = aug_init(root, lensdir, AUG_NO_STDINC);
+    CuAssertPtrNotNull(tc, aug);
+}
+
+static void teardown(ATTRIBUTE_UNUSED CuTest *tc) {
+    aug_close(aug);
+    aug = NULL;
+    free(root);
+    root = NULL;
+}
+
+static void testSaveNewFile(CuTest *tc) {
+    int r;
+
+    r = aug_match(aug, "/augeas/files/etc/yum.repos.d/new.repo/path", NULL);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_set(aug, "/files/etc/yum.repos.d/new.repo/newrepo/baseurl",
+                "http://foo.com/");
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_save(aug);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_match(aug, "/augeas/files/etc/yum.repos.d/new.repo/path", NULL);
+    CuAssertIntEquals(tc, 1, r);
+}
+
+static void testNonExistentLens(CuTest *tc) {
+    int r;
+
+    r = aug_rm(aug, "/augeas/load/*");
+    CuAssertTrue(tc, r >= 0);
+
+    r = aug_set(aug, "/augeas/load/Fake/lens", "Fake.lns");
+    CuAssertIntEquals(tc, 0, r);
+    r = aug_set(aug, "/augeas/load/Fake/incl", "/fake");
+    CuAssertIntEquals(tc, 0, r);
+    r = aug_set(aug, "/files/fake/entry", "value");
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_save(aug);
+    CuAssertIntEquals(tc, -1, r);
+    r = aug_error(aug);
+    CuAssertIntEquals(tc, AUG_ENOLENS, r);
+}
+
+static void testMultipleXfm(CuTest *tc) {
+    int r;
+
+    r = aug_set(aug, "/augeas/load/Yum2/lens", "Yum.lns");
+    CuAssertIntEquals(tc, 0, r);
+    r = aug_set(aug, "/augeas/load/Yum2/incl", "/etc/yum.repos.d/*");
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_set(aug, "/files/etc/yum.repos.d/fedora.repo/fedora/enabled", "0");
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_save(aug);
+    CuAssertIntEquals(tc, -1, r);
+    r = aug_error(aug);
+    CuAssertIntEquals(tc, AUG_EMXFM, r);
+}
+
+static void testMtime(CuTest *tc) {
+    const char *s, *mtime2;
+    char *mtime1;
+    int r;
+
+    r = aug_set(aug, "/files/etc/hosts/1/alias[last() + 1]", "new");
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &s);
+    CuAssertIntEquals(tc, 1, r);
+    mtime1 = strdup(s);
+    CuAssertPtrNotNull(tc, mtime1);
+
+
+    r = aug_save(aug);
+    CuAssertIntEquals(tc, 0, r);
+
+    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &mtime2);
+    CuAssertIntEquals(tc, 1, r);
+
+    CuAssertStrNotEqual(tc, mtime1, mtime2);
+    CuAssertStrNotEqual(tc, "0", mtime2);
+}
+
+int main(void) {
+    char *output = NULL;
+    CuSuite* suite = CuSuiteNew();
+
+    abs_top_srcdir = getenv("abs_top_srcdir");
+    if (abs_top_srcdir == NULL)
+        die("env var abs_top_srcdir must be set");
+
+    abs_top_builddir = getenv("abs_top_builddir");
+    if (abs_top_builddir == NULL)
+        die("env var abs_top_builddir must be set");
+
+    if (asprintf(&src_root, "%s/tests/root", abs_top_srcdir) < 0) {
+        die("failed to set src_root");
+    }
+
+    CuSuiteSetup(suite, setup, teardown);
+
+    SUITE_ADD_TEST(suite, testSaveNewFile);
+    SUITE_ADD_TEST(suite, testNonExistentLens);
+    SUITE_ADD_TEST(suite, testMultipleXfm);
+    SUITE_ADD_TEST(suite, testMtime);
+
+    CuSuiteRun(suite);
+    CuSuiteSummary(suite, &output);
+    CuSuiteDetails(suite, &output);
+    printf("%s\n", output);
+    free(output);
+    return suite->failCount;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/test-unlink-error.sh b/tests/test-unlink-error.sh
new file mode 100755 (executable)
index 0000000..350e7ca
--- /dev/null
@@ -0,0 +1,24 @@
+#! /bin/bash
+
+# Make sure we don't delete files simply because there was an error reading
+# them in
+
+root=$abs_top_builddir/build/test-unlink-error
+xinetd=$root/etc/xinetd.conf
+
+rm -rf $root
+mkdir -p $(dirname $xinetd)
+
+cat > $xinetd <<EOF
+intentional garbage
+EOF
+
+augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF
+clear /files
+save
+EOF
+
+if [ ! -f $xinetd ] ; then
+  echo "Deleted xinetd.conf"
+  exit 1
+fi
diff --git a/tests/test-xpath.c b/tests/test-xpath.c
new file mode 100644 (file)
index 0000000..3a3d241
--- /dev/null
@@ -0,0 +1,378 @@
+/*
+ * test-xpath.c: check that XPath expressions yield the expected result
+ *
+ * Copyright (C) 2007 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David Lutterkort <dlutter@redhat.com>
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include <augeas.h>
+#include <internal.h>
+#include <memory.h>
+
+static const char *abs_top_srcdir;
+static char *root;
+
+#define KW_TEST "test"
+
+struct entry {
+    struct entry *next;
+    char *path;
+    char *value;
+};
+
+struct test {
+    struct test *next;
+    char *name;
+    char *match;
+    struct entry *entries;
+};
+
+#define die(msg)                                                    \
+    do {                                                            \
+        fprintf(stderr, "%d: Fatal error: %s\n", __LINE__, msg);    \
+        exit(EXIT_FAILURE);                                         \
+    } while(0)
+
+static char *skipws(char *s) {
+    while (isspace(*s)) s++;
+    return s;
+}
+
+static char *findws(char *s) {
+    while (*s && ! isspace(*s)) s++;
+    return s;
+}
+
+static char *token(char *s, char **tok) {
+    char *t = skipws(s);
+    s = findws(t);
+    *tok = strndup(t, s - t);
+    return s;
+}
+
+static char *token_to_eol(char *s, char **tok) {
+    char *t = skipws(s);
+    while (*s && *s != '\n') s++;
+    *tok = strndup(t, s - t);
+    return s;
+}
+
+static struct test *read_tests(void) {
+    char *fname;
+    FILE *fp;
+    char line[BUFSIZ];
+    struct test *result = NULL, *t = NULL;
+    int lc = 0;
+
+    if (asprintf(&fname, "%s/tests/xpath.tests", abs_top_srcdir) < 0)
+        die("asprintf fname");
+
+    if ((fp = fopen(fname, "r")) == NULL)
+        die("fopen xpath.tests");
+
+    while (fgets(line, BUFSIZ, fp) != NULL) {
+        lc += 1;
+        char *s = skipws(line);
+        if (*s == '#' || *s == '\0')
+            continue;
+        if (STREQLEN(s, KW_TEST, strlen(KW_TEST))) {
+            if (ALLOC(t) < 0)
+                die("out of memory");
+            list_append(result, t);
+            s = token(s + strlen(KW_TEST), &(t->name));
+            s = token_to_eol(s, &(t->match));
+        } else {
+            struct entry *e = NULL;
+            if (ALLOC(e) < 0)
+                die("out of memory");
+            list_append(t->entries, e);
+            s = token(s, &(e->path));
+            s = skipws(s);
+            if (*s) {
+                if (*s != '=') {
+                    fprintf(stderr,
+                     "line %d: either list only a path or path = value\n", lc);
+                    die("xpath.tests has incorrect format");
+                }
+                s = token_to_eol(s + 1, &(e->value));
+            }
+        }
+        s = skipws(s);
+        if (*s != '\0') {
+            fprintf(stderr, "line %d: junk at end of line\n", lc);
+            die("xpath.tests has incorrect format");
+        }
+    }
+    return result;
+}
+
+static void print_pv(const char *path, const char *value) {
+    if (value)
+        printf("    %s = %s\n", path, value);
+    else
+        printf("    %s\n", path);
+}
+
+static int has_match(const char *path, char **matches, int nmatches) {
+    int found = 0;
+    for (int i=0; i < nmatches; i++) {
+        if (matches[i] != NULL && STREQ(path, matches[i])) {
+            found = 1;
+            break;
+        }
+    }
+    return found;
+}
+
+static int run_one_test(struct augeas *aug, struct test *t) {
+    int nexp = 0, nact;
+    char **matches;
+    int result = 0;
+
+    printf("%-30s ... ", t->name);
+    list_for_each(e, t->entries)
+        nexp++;
+    nact = aug_match(aug, t->match, &matches);
+    if (nact != nexp) {
+        result = -1;
+    } else {
+        struct entry *e;
+        const char *val;
+
+        for (e = t->entries; e != NULL; e = e->next) {
+            if (! has_match(e->path, matches, nact))
+                result = -1;
+            if (! streqv(e->value, "...")) {
+                aug_get(aug, e->path, &val);
+                if (!streqv(e->value, val))
+                    result = -1;
+            }
+        }
+    }
+    if (result == 0) {
+        printf("PASS\n");
+    } else {
+        printf("FAIL\n");
+
+        printf("  Match: %s\n", t->match);
+        printf("  Expected: %d entries\n", nexp);
+        list_for_each(e, t->entries) {
+            print_pv(e->path, e->value);
+        }
+        if (nact < 0) {
+            printf("  Actual: aug_match failed\n");
+            } else {
+            printf("  Actual: %d entries\n", nact);
+        }
+        for (int i=0; i < nact; i++) {
+            const char *val;
+            aug_get(aug, matches[i], &val);
+            print_pv(matches[i], val);
+        }
+    }
+    return result;
+}
+
+static int test_rm_var(struct augeas *aug) {
+    int r;
+
+    printf("%-30s ... ", "rm_var");
+    r = aug_defvar(aug, "h", "/files/etc/hosts/2/ipaddr");
+    if (r < 0)
+        die("aug_defvar failed");
+
+    r = aug_match(aug, "$h", NULL);
+    if (r != 1) {
+        fprintf(stderr, "expected 1 match, got %d\n", r);
+        goto fail;
+    }
+
+    r = aug_rm(aug, "/files/etc/hosts/2");
+    if (r != 4) {
+        fprintf(stderr, "expected 4 nodes removed, got %d\n", r);
+        goto fail;
+    }
+
+    r = aug_match(aug, "$h", NULL);
+    if (r != 0) {
+        fprintf(stderr, "expected no match, got %d\n", r);
+        goto fail;
+    }
+    printf("PASS\n");
+    return 0;
+ fail:
+    printf("FAIL\n");
+    return -1;
+}
+
+static int test_defvar_nonexistent(struct augeas *aug) {
+    int r;
+
+    printf("%-30s ... ", "defvar_nonexistent");
+    r = aug_defvar(aug, "x", "/foo/bar");
+    if (r < 0)
+        die("aug_defvar failed");
+
+    r = aug_set(aug, "$x", "baz");
+    if (r != -1)
+        goto fail;
+    printf("PASS\n");
+    return 0;
+ fail:
+    printf("FAIL\n");
+    return -1;
+}
+
+static int test_defnode_nonexistent(struct augeas *aug) {
+    int r, created;
+
+    printf("%-30s ... ", "defnode_nonexistent");
+    r = aug_defnode(aug, "x", "/defnode/bar[0 = 1]", "foo", &created);
+    if (r != 1)
+        die("aug_defnode failed");
+    if (created != 1) {
+        fprintf(stderr, "defnode did not create a node\n");
+        goto fail;
+    }
+    r = aug_match(aug, "$x", NULL);
+    if (r != 1) {
+        fprintf(stderr, "$x must have exactly one entry, but has %d\n", r);
+        goto fail;
+    }
+
+    r = aug_defnode(aug, "x", "/defnode/bar", NULL, &created);
+    if (r != 1)
+        die("aug_defnode failed");
+    if (created != 0) {
+        fprintf(stderr, "defnode created node again\n");
+        goto fail;
+    }
+
+    // FIXME: get values and compare them, too
+
+    r = aug_set(aug, "$x", "baz");
+    if (r != 0)
+        goto fail;
+
+    r = aug_match(aug, "$x", NULL);
+    if (r != 1)
+        goto fail;
+
+    printf("PASS\n");
+    return 0;
+ fail:
+    printf("FAIL\n");
+    return -1;
+}
+
+static int test_invalid_regexp(struct augeas *aug) {
+    int r;
+
+    printf("%-30s ... ", "invalid_regexp");
+    r = aug_match(aug, "/files/*[ * =~ regexp('.*[aeiou')]", NULL);
+    if (r >= 0)
+        goto fail;
+
+    printf("PASS\n");
+    return 0;
+ fail:
+    printf("FAIL\n");
+    return -1;
+}
+
+static int run_tests(struct test *tests) {
+    char *lensdir;
+    struct augeas *aug = NULL;
+    int r, result = EXIT_SUCCESS;
+
+    if (asprintf(&lensdir, "%s/lenses", abs_top_srcdir) < 0)
+        die("asprintf lensdir failed");
+
+    aug = aug_init(root, lensdir, AUG_NO_STDINC|AUG_SAVE_NEWFILE);
+    if (aug == NULL)
+        die("aug_init");
+    r = aug_defvar(aug, "hosts", "/files/etc/hosts/*");
+    if (r != 6)
+        die("aug_defvar $hosts");
+    r = aug_defvar(aug, "localhost", "'127.0.0.1'");
+    if (r != 0)
+        die("aug_defvar $localhost");
+
+    list_for_each(t, tests) {
+        if (run_one_test(aug, t) < 0)
+            result = EXIT_FAILURE;
+    }
+
+    if (test_rm_var(aug) < 0)
+        result = EXIT_FAILURE;
+
+    if (test_defvar_nonexistent(aug) < 0)
+        result = EXIT_FAILURE;
+
+    if (test_defnode_nonexistent(aug) < 0)
+        result = EXIT_FAILURE;
+
+    if (test_invalid_regexp(aug) < 0)
+        result = EXIT_FAILURE;
+
+    aug_close(aug);
+
+    return result;
+}
+
+int main(void) {
+    struct test *tests;
+
+    abs_top_srcdir = getenv("abs_top_srcdir");
+    if (abs_top_srcdir == NULL)
+        die("env var abs_top_srcdir must be set");
+
+    if (asprintf(&root, "%s/tests/root", abs_top_srcdir) < 0) {
+        die("failed to set root");
+    }
+
+    tests = read_tests();
+    return run_tests(tests);
+    /*
+    list_for_each(t, tests) {
+        printf("Test %s\n", t->name);
+        printf("match %s\n", t->match);
+        list_for_each(e, t->entries) {
+            if (e->value)
+                printf("    %s = %s\n", e->path, e->value);
+            else
+                printf("    %s\n", e->path);
+        }
+    }
+    */
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/xpath.tests b/tests/xpath.tests
new file mode 100644 (file)
index 0000000..b16792a
--- /dev/null
@@ -0,0 +1,237 @@
+# Tests of the XPath matching
+
+# Blank lines and lines starting with '#' are ignored
+#
+# Each test consists of one line declaring the test followed by a complete
+# list of the expected result of the match.
+#
+# The test is declared with a line 'test NAME MATCH'. A result is either
+# just a path (meaning that the value associated with that node must be
+# NULL) or of the form PATH = VALUE, meaning that the value for the node at
+# PATH must be VALUE. If VALUE is '...', the test does not check the value
+# associated with PATH in the tree.
+#
+# The MATCH XPath expression is matched against a fixed tree (the one from the
+# root/ subdirectory) and the result of the aug_match is compared with the
+# results listed in the test
+#
+# The test framework sets up variables:
+#   hosts   /files/etc/hosts/*
+
+# Very simple to warm up
+test wildcard /files/etc/hosts/*/ipaddr
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+     /files/etc/hosts/2/ipaddr = 172.31.122.14
+
+test wildcard-var $hosts/ipaddr
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+     /files/etc/hosts/2/ipaddr = 172.31.122.14
+
+# Compare the value of the current node with a constant
+test self-value /files/etc/hosts/*/ipaddr[ . = '127.0.0.1' ]
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+
+test self-value-var $hosts/ipaddr[ . = $localhost ]
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+
+# Find nodes that have a child named 'ipaddr' with a fixed value
+test child-value /files/etc/hosts/*[ipaddr = '127.0.0.1']
+     /files/etc/hosts/1
+
+test child-value-var $hosts[ipaddr = $localhost]
+     /files/etc/hosts/1
+
+# Find nodes that have a child 'ipaddr' that has no value
+test child-nil-value /files/etc/hosts/*[ipaddr = '']
+
+test child-nil-value-var $hosts[ipaddr = '']
+
+# Find nodes that have no value
+test self-nil-value /files/etc/hosts/*[. = '']
+     /files/etc/hosts/1
+     /files/etc/hosts/2
+
+test self-nil-value-var $hosts[. = '']
+     /files/etc/hosts/1
+     /files/etc/hosts/2
+
+# Match over two levels of the tree
+test two-wildcards /files/etc/*/*[ipaddr='127.0.0.1']
+     /files/etc/hosts/1
+
+test pam-system-auth /files/etc/pam.d/*/*[module = 'system-auth']
+     /files/etc/pam.d/login/2
+     /files/etc/pam.d/login/4
+     /files/etc/pam.d/login/5
+     /files/etc/pam.d/login/8
+     /files/etc/pam.d/postgresql/1
+     /files/etc/pam.d/postgresql/2
+     /files/etc/pam.d/newrole/1
+     /files/etc/pam.d/newrole/2
+     /files/etc/pam.d/newrole/3
+
+# Multiple predicates are treated with 'and'
+test pam-two-preds /files/etc/pam.d/*/*[module = 'system-auth'][type = 'account']
+     /files/etc/pam.d/login/4
+     /files/etc/pam.d/postgresql/2
+     /files/etc/pam.d/newrole/2
+
+# Find nodes that have siblings with a given value
+test pam-two-preds-control /files/etc/pam.d/*/*[module = 'system-auth'][type = 'account']/control
+     /files/etc/pam.d/login/4/control = include
+     /files/etc/pam.d/postgresql/2/control = include
+     /files/etc/pam.d/newrole/2/control = include
+
+# last() gives the last node with a certain name
+test last /files/etc/hosts/*[ipaddr = "127.0.0.1"]/alias[last()]
+     /files/etc/hosts/1/alias[3] = galia
+
+test last-var $hosts[ipaddr = $localhost]/alias[last()]
+     /files/etc/hosts/1/alias[3] = galia
+
+# We can get nodes counting from the right with 'last()-N'
+test last-minus-one /files/etc/hosts/*[ipaddr = "127.0.0.1"]/alias[ last() - 1 ]
+     /files/etc/hosts/1/alias[2] = galia.watzmann.net
+
+# Make sure we look at all nodes with a given label (ticket #23)
+test transparent-multi-node /files/etc/ssh/sshd_config/AcceptEnv/10
+     /files/etc/ssh/sshd_config/AcceptEnv[2]/10 = LC_ADDRESS
+
+test abbrev-descendants /files/etc/pam.d//1
+     /files/etc/pam.d/login/1
+     /files/etc/pam.d/postgresql/1
+     /files/etc/pam.d/newrole/1
+
+test descendant-or-self /files/descendant-or-self :: 4
+     /files/etc/ssh/sshd_config/AcceptEnv[1]/4 = LC_TIME
+     /files/etc/aliases/4
+     /files/etc/fstab/4
+     /files/etc/pam.d/login/4
+     /files/etc/pam.d/newrole/4
+     /files/etc/inittab/4
+
+test descendant /files/etc/aliases/4/descendant::4
+
+test descendant-or-self-2 /files/etc/aliases/4/descendant-or-self::4
+     /files/etc/aliases/4
+
+# No matches because the predicate asks if there is a toplevel node
+# 'ipaddr' with the given value
+test abs-locpath /files/etc/hosts/*[/ipaddr = '127.0.0.1']/canonical
+
+test rel-pred /files/etc/hosts/*/canonical[../ipaddr = '127.0.0.1']
+     /files/etc/hosts/1/canonical = localhost.localdomain
+
+# Not the best way to write this, but entirely acceptable
+test path-with-parent /files/etc/hosts/*/canonical[../ipaddr = '127.0.0.1']/../alias
+     /files/etc/hosts/1/alias[1] = localhost
+     /files/etc/hosts/1/alias[2] = galia.watzmann.net
+     /files/etc/hosts/1/alias[3] = galia
+
+test node-exists-pred /files/etc/hosts/*/canonical[../alias]
+     /files/etc/hosts/1/canonical = localhost.localdomain
+     /files/etc/hosts/2/canonical = orange.watzmann.net
+
+test ipaddr-child //*[ipaddr]
+     /files/etc/hosts/1
+     /files/etc/hosts/2
+
+test ipaddr-sibling //*[../ipaddr]
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+     /files/etc/hosts/1/canonical = localhost.localdomain
+     /files/etc/hosts/1/alias[1] = localhost
+     /files/etc/hosts/1/alias[2] = galia.watzmann.net
+     /files/etc/hosts/1/alias[3] = galia
+     /files/etc/hosts/2/ipaddr = 172.31.122.14
+     /files/etc/hosts/2/canonical = orange.watzmann.net
+     /files/etc/hosts/2/alias = orange
+
+test lircd-ancestor //*[ancestor::kudzu][label() != '#comment']
+     /augeas/files/etc/sysconfig/kudzu/path = /files/etc/sysconfig/kudzu
+     /augeas/files/etc/sysconfig/kudzu/mtime = ...
+     /augeas/files/etc/sysconfig/kudzu/lens = @Shellvars
+     /augeas/files/etc/sysconfig/kudzu/lens/info = ...
+     /files/etc/sysconfig/kudzu/SAFE = no
+
+test wildcard-last /files/etc/hosts/*[position() = last()]
+     /files/etc/hosts/2
+
+test wildcard-not-last /files/etc/hosts/*[position() != last()][ipaddr]
+     /files/etc/hosts/1
+
+test nodeset-nodeset-eq /files/etc/sysconfig/network-scripts/*[BRIDGE = /files/etc/sysconfig/network-scripts/ifcfg-br0/DEVICE]
+     /files/etc/sysconfig/network-scripts/ifcfg-eth0
+
+test last-ssh-service /files/etc/services/service-name[port = '22'][last()]
+     /files/etc/services/service-name[24] = ssh
+
+test count-one-alias /files/etc/hosts/*[count(alias) = 1]
+     /files/etc/hosts/2
+
+test number-gt /files/etc/hosts/*[count(alias) > 1]
+     /files/etc/hosts/1
+
+test pred-or /files/etc/hosts/*[canonical = 'localhost' or alias = 'localhost']
+     /files/etc/hosts/1
+
+test pred-and-or /files/etc/hosts/*[(canonical = 'localhost' or alias = 'localhost') and ipaddr = '127.0.0.1']
+     /files/etc/hosts/1
+
+# We used to parse this as '/files/etc/.' followed by garbage, that
+# was silently ignored. This path must not match anything, instead of
+# every child of /files/etc
+test path-with-dot /files/etc/.notthere
+
+test str-neq /files/etc/*['foo' != 'foo']
+
+# label() returns the label of the context node as a string
+test label-neq /files/etc/hosts/*[label() != '#comment']
+     /files/etc/hosts/1
+     /files/etc/hosts/2
+
+# 'and' and 'or' need to coerce types to boolean
+test coerce-or /files[/files/etc/hosts/*[ipaddr = '127.0.0.1'] or /files/etc/aliases/*[name = 'root'] ]
+     /files
+
+test coerce-and-true /files['foo' and count(/files/etc/hosts/*) ]
+     /files
+
+test coerce-and-false /files['' and count(/none) and /none]
+
+test preceding-sibling /files/etc/hosts/*/preceding-sibling::*[alias = 'localhost']
+     /files/etc/hosts/1
+
+test preceding-sibling-pred /files/etc/grub.conf/*[preceding-sibling::*[1] = ../default]
+     /files/etc/grub.conf/timeout = 5
+
+test preceding-sibling-pred2 /files/etc/grub.conf/*[preceding-sibling::*[1][self::default]]
+     /files/etc/grub.conf/timeout = 5
+
+test following-sibling /files/etc/hosts/1/*/following-sibling::alias
+     /files/etc/hosts/1/alias[1] = localhost
+     /files/etc/hosts/1/alias[2] = galia.watzmann.net
+     /files/etc/hosts/1/alias[3] = galia
+
+test following-sibling-pred /files/etc/hosts/1/*[following-sibling::alias]
+     /files/etc/hosts/1/ipaddr = 127.0.0.1
+     /files/etc/hosts/1/canonical = localhost.localdomain
+     /files/etc/hosts/1/alias[1] = localhost
+     /files/etc/hosts/1/alias[2] = galia.watzmann.net
+
+test regexp1 /files/etc/sysconfig/network-scripts/*[label() =~ regexp('.*-eth0')]
+     /files/etc/sysconfig/network-scripts/ifcfg-eth0
+
+test regexp2 /files/etc/hosts/*[* =~ regexp('127\..*')]
+     /files/etc/hosts/1
+
+# Union of nodesets
+test union (/files/etc/yum.conf | /files/etc/yum.repos.d/*)/*/gpgcheck
+     /files/etc/yum.conf/main/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora-updates.repo/updates/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora-updates.repo/updates-debuginfo/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora-updates.repo/updates-source/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora.repo/fedora/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora.repo/fedora-debuginfo/gpgcheck = 1
+     /files/etc/yum.repos.d/fedora.repo/fedora-source/gpgcheck = 1
+     /files/etc/yum.repos.d/remi.repo/remi/gpgcheck = 1
+     /files/etc/yum.repos.d/remi.repo/remi-test/gpgcheck = 1